babylon.module.d.ts 6.6 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929150930150931150932150933150934150935150936150937150938150939150940150941150942150943150944150945150946150947150948150949150950150951150952150953150954150955150956150957150958150959150960150961150962150963150964150965150966150967150968150969150970150971150972150973150974150975150976150977150978150979150980150981150982150983150984150985150986150987150988150989150990150991150992150993150994150995150996150997150998150999151000151001151002151003151004151005151006151007151008151009151010151011151012151013151014151015151016151017151018151019151020151021151022151023151024151025151026151027151028151029151030151031151032151033151034151035151036151037151038151039151040151041151042151043151044151045151046151047151048151049151050151051151052151053151054151055151056151057151058151059151060151061151062151063151064151065151066151067151068151069151070151071151072151073151074151075151076151077151078151079151080151081151082151083151084151085151086151087151088151089151090151091151092151093151094151095151096151097151098151099151100151101151102151103151104151105151106151107151108151109151110151111151112151113151114151115151116151117151118151119151120151121151122151123151124151125151126151127151128151129151130151131151132151133151134151135151136151137151138151139151140151141151142151143151144151145151146151147151148151149151150151151151152151153151154151155151156151157151158151159151160151161151162151163151164151165151166151167151168151169151170151171151172151173151174151175151176151177151178151179151180151181151182151183151184151185151186151187151188151189151190151191151192151193151194151195151196151197151198151199151200151201151202151203151204151205151206151207151208151209151210151211151212151213151214151215151216151217151218151219151220151221151222151223151224151225151226151227151228151229151230151231151232151233151234151235151236151237151238151239151240151241151242151243151244151245151246151247151248151249151250151251151252151253151254151255151256151257151258151259151260151261151262151263151264151265151266151267151268151269151270151271151272151273151274151275151276151277151278151279151280151281151282151283151284151285151286151287151288151289151290151291151292151293151294151295151296151297151298151299151300151301151302151303151304151305151306151307151308151309151310151311151312151313151314151315151316151317151318151319151320151321151322151323151324151325151326151327151328151329151330151331151332151333151334151335151336151337151338151339151340151341151342151343151344151345151346151347151348151349151350151351151352151353151354151355151356151357151358151359151360151361151362151363151364151365151366151367151368151369151370151371151372151373151374151375151376151377151378151379151380151381151382151383151384151385151386151387151388151389151390151391151392151393151394151395151396151397151398151399151400151401151402151403151404151405151406151407151408151409151410151411151412151413151414151415151416151417151418151419151420151421151422151423151424151425151426151427151428151429151430151431151432151433151434151435151436151437151438151439151440151441151442151443151444151445151446151447151448151449151450151451151452151453151454151455151456151457151458151459151460151461151462151463151464151465151466151467151468151469151470151471151472151473151474151475151476151477151478151479151480151481151482151483151484151485151486151487151488151489151490151491151492151493151494151495151496151497151498151499151500151501151502151503151504151505151506151507151508151509151510151511151512151513151514151515151516151517151518151519151520151521151522151523151524151525151526151527151528151529151530151531151532151533151534151535151536151537151538151539151540151541151542151543151544151545151546151547151548151549151550151551151552151553151554151555151556151557151558151559151560151561151562151563151564151565151566151567151568151569151570151571151572151573151574151575151576151577151578151579151580151581151582151583151584151585151586151587151588151589151590151591151592151593151594151595151596151597151598151599151600151601151602151603151604151605151606151607151608151609151610151611151612151613151614151615151616151617151618151619151620151621151622151623151624151625151626151627151628151629151630151631151632151633151634151635151636151637151638151639151640151641151642151643151644151645151646151647151648151649151650151651151652151653151654151655151656151657151658151659151660151661151662151663151664151665151666151667151668151669151670151671151672151673151674151675151676151677151678151679151680151681151682151683151684151685151686151687151688151689151690151691151692151693151694151695151696151697151698151699151700151701151702151703151704151705151706151707151708151709151710151711151712151713151714151715151716151717151718151719151720151721151722151723151724151725151726151727151728151729151730151731151732151733151734151735151736151737151738151739151740151741151742151743151744151745151746151747151748151749151750151751151752151753151754151755151756151757151758151759151760151761151762151763151764151765151766151767151768151769151770151771151772151773151774151775151776151777151778151779151780151781151782151783151784151785151786151787151788151789151790151791151792151793151794151795151796151797151798151799151800151801151802151803151804151805151806151807151808151809151810151811151812151813151814151815151816151817151818151819151820151821151822151823151824151825151826151827151828151829151830151831151832151833151834151835151836151837151838151839151840151841151842151843151844151845151846151847151848151849151850151851151852151853151854151855151856151857151858151859151860151861151862151863151864151865151866151867151868151869151870151871151872151873151874151875151876151877151878151879151880151881151882151883151884151885151886151887151888151889151890151891151892151893151894151895151896151897151898151899151900151901151902151903151904151905151906151907151908151909151910151911151912151913151914151915151916151917151918151919151920151921151922151923151924151925151926151927151928151929151930151931151932151933151934151935151936151937151938151939151940151941151942151943151944151945151946151947151948151949151950151951151952151953151954151955151956151957151958151959151960151961151962151963151964151965151966151967151968151969151970151971151972151973151974151975151976151977151978151979151980151981151982151983151984151985151986151987151988151989151990151991151992151993151994151995151996151997151998151999152000152001152002152003152004152005152006152007152008152009152010152011152012152013152014152015152016152017152018152019152020152021152022152023152024152025152026152027152028152029152030152031152032152033152034152035152036152037152038152039152040152041152042152043152044152045152046152047152048152049152050152051152052152053152054152055152056152057152058152059152060152061152062152063152064152065152066152067152068152069152070152071152072152073152074152075152076152077152078152079152080152081152082152083152084152085152086152087152088152089152090152091152092152093152094152095152096152097152098152099152100152101152102152103152104152105152106152107152108152109152110152111152112152113152114152115152116152117152118152119152120152121152122152123152124152125152126152127152128152129152130152131152132152133152134152135152136152137152138152139152140152141152142152143152144152145152146152147152148152149152150152151152152152153152154152155152156152157152158152159152160152161152162152163152164152165152166152167152168152169152170152171152172152173152174152175152176152177152178152179152180152181152182152183152184152185152186152187152188152189152190152191152192152193152194152195152196152197152198152199152200152201152202152203152204152205152206152207152208152209152210152211152212152213152214152215152216152217152218152219152220152221152222152223152224152225152226152227152228152229152230152231152232152233152234152235152236152237152238152239152240152241152242152243152244152245152246152247152248152249152250152251152252152253152254152255152256152257152258152259152260152261152262152263152264152265152266152267152268152269152270152271152272152273152274152275152276152277152278152279152280152281152282152283152284152285152286152287152288152289152290152291152292152293152294152295152296152297152298152299152300152301152302152303152304152305152306152307152308152309152310152311152312152313152314152315152316152317152318152319152320152321152322152323152324152325152326152327152328152329152330152331152332152333152334152335152336152337152338152339152340152341152342152343152344152345152346152347152348152349152350152351152352152353152354152355152356152357152358152359152360152361152362152363152364152365152366152367152368152369152370152371152372152373152374152375152376152377152378152379152380152381152382152383152384152385152386152387152388152389152390152391152392152393152394152395152396152397152398152399152400152401152402152403152404152405152406152407152408152409152410152411152412152413152414152415152416152417152418152419152420152421152422152423152424152425152426152427152428152429152430152431152432152433152434152435152436152437152438152439152440152441152442152443152444152445152446152447152448152449152450152451152452152453152454152455152456152457152458152459152460152461152462152463152464152465152466152467152468152469152470152471152472152473152474152475152476152477152478152479152480152481152482152483152484152485152486152487152488152489152490152491152492152493152494152495152496152497152498152499152500152501152502152503152504152505152506152507152508152509152510152511152512152513152514152515152516152517152518152519152520152521152522152523152524152525152526152527152528152529152530152531152532152533152534152535152536152537152538152539152540152541152542152543152544152545152546152547152548152549152550152551152552152553152554152555152556152557152558152559152560152561152562152563152564152565152566152567152568152569152570152571152572152573152574152575152576152577152578152579152580152581152582152583152584152585152586152587152588152589152590152591152592152593152594152595152596152597152598152599152600152601152602152603152604152605152606152607152608152609152610152611152612152613152614152615152616152617152618152619152620152621152622152623152624152625152626152627152628152629152630152631152632152633152634152635152636152637152638152639152640152641152642152643152644152645152646152647152648152649152650152651152652152653152654152655152656152657152658152659152660152661152662152663152664152665152666152667152668152669152670152671152672152673152674152675152676152677152678152679152680152681152682152683152684152685152686152687152688152689152690152691152692152693152694152695152696152697152698152699152700152701152702152703152704152705152706152707152708152709152710152711152712152713152714152715152716152717152718152719152720152721152722152723152724152725152726152727152728152729152730152731152732152733152734152735152736152737152738152739152740152741152742152743152744152745152746152747152748152749152750152751152752152753152754152755152756152757152758152759152760152761152762152763152764152765152766152767152768152769152770152771152772152773152774152775152776152777152778152779152780152781152782152783152784152785152786152787152788152789152790152791152792152793152794152795152796152797152798152799152800152801152802152803152804152805152806152807152808152809152810152811152812152813152814152815152816152817152818152819152820152821152822152823152824152825152826152827152828152829152830152831152832152833152834152835152836152837152838152839152840152841152842152843152844152845152846152847152848152849152850152851152852152853152854152855152856152857152858152859152860152861152862152863152864152865152866152867152868152869152870152871152872152873152874152875152876152877152878152879152880152881152882152883152884152885152886152887152888152889152890152891152892152893152894152895152896152897152898152899152900152901152902152903152904152905152906152907152908152909152910152911152912152913152914152915152916152917152918152919152920152921152922152923152924152925152926152927152928152929152930152931152932152933152934152935152936152937152938152939152940152941152942152943152944152945152946152947152948152949152950152951152952152953152954152955152956152957152958152959152960152961152962152963152964152965152966152967152968152969152970152971152972152973152974152975152976152977152978152979152980152981152982152983152984152985152986152987152988152989152990152991152992152993152994152995152996152997152998152999153000153001153002153003153004153005153006153007153008153009153010153011153012153013153014153015153016153017153018153019153020153021153022153023153024153025153026153027153028153029153030153031153032153033153034153035153036153037153038153039153040153041153042153043153044153045153046153047153048153049153050153051153052153053153054153055153056153057153058153059153060153061153062153063153064153065153066153067153068153069153070153071153072153073153074153075153076153077153078153079153080153081153082153083153084153085153086153087153088153089153090153091153092153093153094153095153096153097153098153099153100153101153102153103153104153105153106153107153108153109153110153111153112153113153114153115153116153117153118153119153120153121153122153123153124153125153126153127153128153129153130153131153132153133153134153135153136153137153138153139153140153141153142153143153144153145153146153147153148153149153150153151153152153153153154153155153156153157153158153159153160153161153162153163153164153165153166153167153168153169153170153171153172153173153174153175153176153177153178153179153180153181153182153183153184153185153186153187153188153189153190153191153192153193153194153195153196153197153198153199153200153201153202153203153204153205153206153207153208153209153210153211153212153213153214153215153216153217153218153219153220153221153222153223153224153225153226153227153228153229153230153231153232153233153234153235153236153237153238153239153240153241153242153243153244153245153246153247153248153249153250153251153252153253153254153255153256153257153258153259153260153261153262153263153264153265153266153267153268153269153270153271153272153273153274153275153276153277153278153279153280153281153282153283153284153285153286153287153288153289153290153291153292153293153294153295153296153297153298153299153300153301153302153303153304153305153306153307153308153309153310153311153312153313153314153315153316153317153318153319153320153321153322153323153324153325153326153327153328153329153330153331153332153333153334153335153336153337153338153339153340153341153342153343153344153345153346153347153348153349153350153351153352153353153354153355153356153357153358153359153360153361153362153363153364153365153366153367153368153369153370153371153372153373153374153375153376153377153378153379153380153381153382153383153384153385153386153387153388153389153390153391153392153393153394153395153396153397153398153399153400153401153402153403153404153405153406153407153408153409153410153411153412153413153414153415153416153417153418153419153420153421153422153423153424153425153426153427153428153429153430153431153432153433153434153435153436153437153438153439153440153441153442153443153444153445153446153447153448153449153450153451153452153453153454153455153456153457153458153459153460153461153462153463153464153465153466153467153468153469153470153471153472153473153474153475153476153477153478153479153480153481153482153483153484153485153486153487153488153489153490153491153492153493153494153495153496153497153498153499153500153501153502153503153504153505153506153507153508153509153510153511153512153513153514153515153516153517153518153519153520153521153522153523153524153525153526153527153528153529153530153531153532153533153534153535153536153537153538153539153540153541153542153543153544153545153546153547153548153549153550153551153552153553153554153555153556153557153558153559153560153561153562153563153564153565153566153567153568153569153570153571153572153573153574153575153576153577153578153579153580153581153582153583153584153585153586153587153588153589153590153591153592153593153594153595153596153597153598153599153600153601153602153603153604153605153606153607153608153609153610153611153612153613153614153615153616153617153618153619153620153621153622153623153624153625153626153627153628153629153630153631153632153633153634153635153636153637153638153639153640153641153642153643153644153645153646153647153648153649153650153651153652153653153654153655153656153657153658153659153660153661153662153663153664153665153666153667153668153669153670153671153672153673153674153675153676153677153678153679153680153681153682153683153684153685153686153687153688153689153690153691153692153693153694153695153696153697153698153699153700153701153702153703153704153705153706153707153708153709153710153711153712153713153714153715153716153717153718153719153720153721153722153723153724153725153726153727153728153729153730153731153732153733153734153735153736153737153738153739153740153741153742153743153744153745153746153747153748153749153750153751153752153753153754153755153756153757153758153759153760153761153762153763153764153765153766153767153768153769153770153771153772153773153774153775153776153777153778153779153780153781153782153783153784153785153786153787153788153789153790153791153792153793153794153795153796153797153798153799153800153801153802153803153804153805153806153807153808153809153810153811153812153813153814153815153816153817153818153819153820153821153822153823153824153825153826153827153828153829153830153831153832153833153834153835153836153837153838153839153840153841153842153843153844153845153846153847153848153849153850153851153852153853153854153855153856153857153858153859153860153861153862153863153864153865153866153867153868153869153870153871153872153873153874153875153876153877153878153879153880153881153882153883153884153885153886153887153888153889153890153891153892153893153894153895153896153897153898153899153900153901153902153903153904153905153906153907153908153909153910153911153912153913153914153915153916153917153918153919153920153921153922153923153924153925153926153927153928153929153930153931153932153933153934153935153936153937153938153939153940153941153942153943153944153945153946153947153948153949153950153951153952153953153954153955153956153957153958153959153960153961153962153963153964153965153966153967153968153969153970153971153972153973153974153975153976153977153978153979153980153981153982153983153984153985153986153987153988153989153990153991153992153993153994153995153996153997153998153999154000154001154002154003154004154005154006154007154008154009154010154011154012154013154014154015154016154017154018154019154020154021154022154023154024154025154026154027154028154029154030154031154032154033154034154035154036154037154038154039154040154041154042154043154044154045154046154047154048154049154050154051154052154053154054154055154056154057154058154059154060154061154062154063154064154065154066154067154068154069154070154071154072154073154074154075154076154077154078154079154080154081154082154083154084154085154086154087154088154089154090154091154092154093154094154095154096154097154098154099154100154101154102154103154104154105154106154107154108154109154110154111154112154113154114154115154116154117154118154119154120154121154122154123154124154125154126154127154128154129154130154131154132154133154134154135154136154137154138154139154140154141154142154143154144154145154146154147154148154149154150154151154152154153154154154155154156154157154158154159154160154161154162154163154164154165154166154167154168154169154170154171154172154173154174154175154176154177154178154179154180154181154182154183154184154185154186154187154188154189154190154191154192154193154194154195154196154197154198154199154200154201154202154203154204154205154206154207154208154209154210154211154212154213154214154215154216154217154218154219154220154221154222154223154224154225154226154227154228154229154230154231154232154233154234154235154236154237154238154239154240154241154242154243154244154245154246154247154248154249154250154251154252154253154254154255154256154257154258154259154260154261154262154263154264154265154266154267154268154269154270154271154272154273154274154275154276154277154278154279154280154281154282154283154284154285154286154287154288154289154290154291154292154293154294154295154296154297154298154299154300154301154302154303154304154305154306154307154308154309154310154311154312154313154314154315154316154317154318154319154320154321154322154323154324154325154326154327154328154329154330154331154332154333154334154335154336154337154338154339154340154341154342154343154344154345154346154347154348154349154350154351154352154353154354154355154356154357154358154359154360154361154362154363154364154365154366154367154368154369154370154371154372154373154374154375154376154377154378154379154380154381154382154383154384154385154386154387154388154389154390154391154392154393154394154395154396154397154398154399154400154401154402154403154404154405154406154407154408154409154410154411154412154413154414154415154416154417154418154419154420154421154422154423154424154425154426154427154428154429154430154431154432154433154434154435154436154437154438154439154440154441154442154443154444154445154446154447154448154449154450154451154452154453154454154455154456154457154458154459154460154461154462154463154464154465154466154467154468154469154470154471154472154473154474154475154476154477154478154479154480154481154482154483154484154485154486154487154488154489154490154491154492154493154494154495154496154497154498154499154500154501154502154503154504154505154506154507154508154509154510154511154512154513154514154515154516154517154518154519154520154521154522154523154524154525154526154527154528154529154530154531154532154533154534154535154536154537154538154539154540154541154542154543154544154545154546154547154548154549154550154551154552154553154554154555154556154557154558154559154560154561154562154563154564154565154566154567154568154569154570154571154572154573154574154575154576154577154578154579154580154581154582154583154584154585154586154587154588154589154590154591154592154593154594154595154596154597154598154599154600154601154602154603154604154605154606154607154608154609154610154611154612154613154614154615154616154617154618154619154620154621154622154623154624154625154626154627154628154629154630154631154632154633154634154635154636154637154638154639154640154641154642154643154644154645154646154647154648154649154650154651154652154653154654154655154656154657154658154659154660154661154662154663154664154665154666154667154668154669154670154671154672154673154674154675154676154677154678154679154680154681154682154683154684154685154686154687154688154689154690154691154692154693154694154695154696154697154698154699154700154701154702154703154704154705154706154707154708154709154710154711154712154713154714154715154716154717154718154719154720154721154722154723154724154725154726154727154728154729154730154731154732154733154734154735154736154737154738154739154740154741154742154743154744154745154746154747154748154749154750154751154752154753154754154755154756154757154758154759154760154761154762154763154764154765154766154767154768154769154770154771154772154773154774154775154776154777154778154779154780154781154782154783154784154785154786154787154788154789154790154791154792154793154794154795154796154797154798154799154800154801154802154803154804154805154806154807154808154809154810154811154812154813154814154815154816154817154818154819154820154821154822154823154824154825154826154827154828154829154830154831154832154833154834154835154836154837154838154839154840154841154842154843154844154845154846154847154848154849154850154851154852154853154854154855154856154857154858154859154860154861154862154863154864154865154866154867154868154869154870154871154872154873154874154875154876154877154878154879154880154881154882154883154884154885154886154887154888154889154890154891154892154893154894154895154896154897154898154899154900154901154902154903154904154905154906154907154908154909154910154911154912154913154914154915154916154917154918154919154920154921154922154923154924154925154926154927154928154929154930154931154932154933154934154935154936154937154938154939154940154941154942154943154944154945154946154947154948154949154950154951154952154953154954154955154956154957154958154959154960154961154962154963154964154965154966154967154968154969154970154971154972154973154974154975154976154977154978154979154980154981154982154983154984154985154986154987154988154989154990154991154992154993154994154995154996
  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. * Prepass texture index for color
  1058. */
  1059. static readonly PREPASS_COLOR_INDEX: number;
  1060. /**
  1061. * Prepass texture index for irradiance
  1062. */
  1063. static readonly PREPASS_IRRADIANCE_INDEX: number;
  1064. /**
  1065. * Prepass texture index for depth + normal
  1066. */
  1067. static readonly PREPASS_DEPTHNORMAL_INDEX: number;
  1068. /**
  1069. * Prepass texture index for albedo
  1070. */
  1071. static readonly PREPASS_ALBEDO_INDEX: number;
  1072. }
  1073. }
  1074. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1075. import { Nullable } from "babylonjs/types";
  1076. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1077. /**
  1078. * This represents the required contract to create a new type of texture loader.
  1079. */
  1080. export interface IInternalTextureLoader {
  1081. /**
  1082. * Defines wether the loader supports cascade loading the different faces.
  1083. */
  1084. supportCascades: boolean;
  1085. /**
  1086. * This returns if the loader support the current file information.
  1087. * @param extension defines the file extension of the file being loaded
  1088. * @param mimeType defines the optional mime type of the file being loaded
  1089. * @returns true if the loader can load the specified file
  1090. */
  1091. canLoad(extension: string, mimeType?: string): boolean;
  1092. /**
  1093. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1094. * @param data contains the texture data
  1095. * @param texture defines the BabylonJS internal texture
  1096. * @param createPolynomials will be true if polynomials have been requested
  1097. * @param onLoad defines the callback to trigger once the texture is ready
  1098. * @param onError defines the callback to trigger in case of error
  1099. */
  1100. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1101. /**
  1102. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1103. * @param data contains the texture data
  1104. * @param texture defines the BabylonJS internal texture
  1105. * @param callback defines the method to call once ready to upload
  1106. */
  1107. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1108. }
  1109. }
  1110. declare module "babylonjs/Engines/IPipelineContext" {
  1111. /**
  1112. * Class used to store and describe the pipeline context associated with an effect
  1113. */
  1114. export interface IPipelineContext {
  1115. /**
  1116. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1117. */
  1118. isAsync: boolean;
  1119. /**
  1120. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1121. */
  1122. isReady: boolean;
  1123. /** @hidden */
  1124. _getVertexShaderCode(): string | null;
  1125. /** @hidden */
  1126. _getFragmentShaderCode(): string | null;
  1127. /** @hidden */
  1128. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1129. }
  1130. }
  1131. declare module "babylonjs/Meshes/dataBuffer" {
  1132. /**
  1133. * Class used to store gfx data (like WebGLBuffer)
  1134. */
  1135. export class DataBuffer {
  1136. /**
  1137. * Gets or sets the number of objects referencing this buffer
  1138. */
  1139. references: number;
  1140. /** Gets or sets the size of the underlying buffer */
  1141. capacity: number;
  1142. /**
  1143. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1144. */
  1145. is32Bits: boolean;
  1146. /**
  1147. * Gets the underlying buffer
  1148. */
  1149. get underlyingResource(): any;
  1150. }
  1151. }
  1152. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1153. /** @hidden */
  1154. export interface IShaderProcessor {
  1155. attributeProcessor?: (attribute: string) => string;
  1156. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1157. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1158. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1159. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1160. lineProcessor?: (line: string, isFragment: boolean) => string;
  1161. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1162. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1163. }
  1164. }
  1165. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1166. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1167. /** @hidden */
  1168. export interface ProcessingOptions {
  1169. defines: string[];
  1170. indexParameters: any;
  1171. isFragment: boolean;
  1172. shouldUseHighPrecisionShader: boolean;
  1173. supportsUniformBuffers: boolean;
  1174. shadersRepository: string;
  1175. includesShadersStore: {
  1176. [key: string]: string;
  1177. };
  1178. processor?: IShaderProcessor;
  1179. version: string;
  1180. platformName: string;
  1181. lookForClosingBracketForUniformBuffer?: boolean;
  1182. }
  1183. }
  1184. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1185. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1186. /** @hidden */
  1187. export class ShaderCodeNode {
  1188. line: string;
  1189. children: ShaderCodeNode[];
  1190. additionalDefineKey?: string;
  1191. additionalDefineValue?: string;
  1192. isValid(preprocessors: {
  1193. [key: string]: string;
  1194. }): boolean;
  1195. process(preprocessors: {
  1196. [key: string]: string;
  1197. }, options: ProcessingOptions): string;
  1198. }
  1199. }
  1200. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1201. /** @hidden */
  1202. export class ShaderCodeCursor {
  1203. private _lines;
  1204. lineIndex: number;
  1205. get currentLine(): string;
  1206. get canRead(): boolean;
  1207. set lines(value: string[]);
  1208. }
  1209. }
  1210. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1211. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1212. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1213. /** @hidden */
  1214. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1215. process(preprocessors: {
  1216. [key: string]: string;
  1217. }, options: ProcessingOptions): string;
  1218. }
  1219. }
  1220. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1221. /** @hidden */
  1222. export class ShaderDefineExpression {
  1223. isTrue(preprocessors: {
  1224. [key: string]: string;
  1225. }): boolean;
  1226. private static _OperatorPriority;
  1227. private static _Stack;
  1228. static postfixToInfix(postfix: string[]): string;
  1229. static infixToPostfix(infix: string): string[];
  1230. }
  1231. }
  1232. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1233. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1234. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1235. /** @hidden */
  1236. export class ShaderCodeTestNode extends ShaderCodeNode {
  1237. testExpression: ShaderDefineExpression;
  1238. isValid(preprocessors: {
  1239. [key: string]: string;
  1240. }): boolean;
  1241. }
  1242. }
  1243. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1244. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1245. /** @hidden */
  1246. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1247. define: string;
  1248. not: boolean;
  1249. constructor(define: string, not?: boolean);
  1250. isTrue(preprocessors: {
  1251. [key: string]: string;
  1252. }): boolean;
  1253. }
  1254. }
  1255. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1256. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1257. /** @hidden */
  1258. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1259. leftOperand: ShaderDefineExpression;
  1260. rightOperand: ShaderDefineExpression;
  1261. isTrue(preprocessors: {
  1262. [key: string]: string;
  1263. }): boolean;
  1264. }
  1265. }
  1266. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1267. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1268. /** @hidden */
  1269. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1270. leftOperand: ShaderDefineExpression;
  1271. rightOperand: ShaderDefineExpression;
  1272. isTrue(preprocessors: {
  1273. [key: string]: string;
  1274. }): boolean;
  1275. }
  1276. }
  1277. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1278. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1279. /** @hidden */
  1280. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1281. define: string;
  1282. operand: string;
  1283. testValue: string;
  1284. constructor(define: string, operand: string, testValue: string);
  1285. isTrue(preprocessors: {
  1286. [key: string]: string;
  1287. }): boolean;
  1288. }
  1289. }
  1290. declare module "babylonjs/Offline/IOfflineProvider" {
  1291. /**
  1292. * Class used to enable access to offline support
  1293. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1294. */
  1295. export interface IOfflineProvider {
  1296. /**
  1297. * Gets a boolean indicating if scene must be saved in the database
  1298. */
  1299. enableSceneOffline: boolean;
  1300. /**
  1301. * Gets a boolean indicating if textures must be saved in the database
  1302. */
  1303. enableTexturesOffline: boolean;
  1304. /**
  1305. * Open the offline support and make it available
  1306. * @param successCallback defines the callback to call on success
  1307. * @param errorCallback defines the callback to call on error
  1308. */
  1309. open(successCallback: () => void, errorCallback: () => void): void;
  1310. /**
  1311. * Loads an image from the offline support
  1312. * @param url defines the url to load from
  1313. * @param image defines the target DOM image
  1314. */
  1315. loadImage(url: string, image: HTMLImageElement): void;
  1316. /**
  1317. * Loads a file from offline support
  1318. * @param url defines the URL to load from
  1319. * @param sceneLoaded defines a callback to call on success
  1320. * @param progressCallBack defines a callback to call when progress changed
  1321. * @param errorCallback defines a callback to call on error
  1322. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1323. */
  1324. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1325. }
  1326. }
  1327. declare module "babylonjs/Misc/filesInputStore" {
  1328. /**
  1329. * Class used to help managing file picking and drag'n'drop
  1330. * File Storage
  1331. */
  1332. export class FilesInputStore {
  1333. /**
  1334. * List of files ready to be loaded
  1335. */
  1336. static FilesToLoad: {
  1337. [key: string]: File;
  1338. };
  1339. }
  1340. }
  1341. declare module "babylonjs/Misc/retryStrategy" {
  1342. import { WebRequest } from "babylonjs/Misc/webRequest";
  1343. /**
  1344. * Class used to define a retry strategy when error happens while loading assets
  1345. */
  1346. export class RetryStrategy {
  1347. /**
  1348. * Function used to defines an exponential back off strategy
  1349. * @param maxRetries defines the maximum number of retries (3 by default)
  1350. * @param baseInterval defines the interval between retries
  1351. * @returns the strategy function to use
  1352. */
  1353. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1354. }
  1355. }
  1356. declare module "babylonjs/Misc/baseError" {
  1357. /**
  1358. * @ignore
  1359. * Application error to support additional information when loading a file
  1360. */
  1361. export abstract class BaseError extends Error {
  1362. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1363. }
  1364. }
  1365. declare module "babylonjs/Misc/fileTools" {
  1366. import { WebRequest } from "babylonjs/Misc/webRequest";
  1367. import { Nullable } from "babylonjs/types";
  1368. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1369. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1370. import { BaseError } from "babylonjs/Misc/baseError";
  1371. /** @ignore */
  1372. export class LoadFileError extends BaseError {
  1373. request?: WebRequest;
  1374. file?: File;
  1375. /**
  1376. * Creates a new LoadFileError
  1377. * @param message defines the message of the error
  1378. * @param request defines the optional web request
  1379. * @param file defines the optional file
  1380. */
  1381. constructor(message: string, object?: WebRequest | File);
  1382. }
  1383. /** @ignore */
  1384. export class RequestFileError extends BaseError {
  1385. request: WebRequest;
  1386. /**
  1387. * Creates a new LoadFileError
  1388. * @param message defines the message of the error
  1389. * @param request defines the optional web request
  1390. */
  1391. constructor(message: string, request: WebRequest);
  1392. }
  1393. /** @ignore */
  1394. export class ReadFileError extends BaseError {
  1395. file: File;
  1396. /**
  1397. * Creates a new ReadFileError
  1398. * @param message defines the message of the error
  1399. * @param file defines the optional file
  1400. */
  1401. constructor(message: string, file: File);
  1402. }
  1403. /**
  1404. * @hidden
  1405. */
  1406. export class FileTools {
  1407. /**
  1408. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1409. */
  1410. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1411. /**
  1412. * Gets or sets the base URL to use to load assets
  1413. */
  1414. static BaseUrl: string;
  1415. /**
  1416. * Default behaviour for cors in the application.
  1417. * It can be a string if the expected behavior is identical in the entire app.
  1418. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1419. */
  1420. static CorsBehavior: string | ((url: string | string[]) => string);
  1421. /**
  1422. * Gets or sets a function used to pre-process url before using them to load assets
  1423. */
  1424. static PreprocessUrl: (url: string) => string;
  1425. /**
  1426. * Removes unwanted characters from an url
  1427. * @param url defines the url to clean
  1428. * @returns the cleaned url
  1429. */
  1430. private static _CleanUrl;
  1431. /**
  1432. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1433. * @param url define the url we are trying
  1434. * @param element define the dom element where to configure the cors policy
  1435. */
  1436. static SetCorsBehavior(url: string | string[], element: {
  1437. crossOrigin: string | null;
  1438. }): void;
  1439. /**
  1440. * Loads an image as an HTMLImageElement.
  1441. * @param input url string, ArrayBuffer, or Blob to load
  1442. * @param onLoad callback called when the image successfully loads
  1443. * @param onError callback called when the image fails to load
  1444. * @param offlineProvider offline provider for caching
  1445. * @param mimeType optional mime type
  1446. * @returns the HTMLImageElement of the loaded image
  1447. */
  1448. 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>;
  1449. /**
  1450. * Reads a file from a File object
  1451. * @param file defines the file to load
  1452. * @param onSuccess defines the callback to call when data is loaded
  1453. * @param onProgress defines the callback to call during loading process
  1454. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1455. * @param onError defines the callback to call when an error occurs
  1456. * @returns a file request object
  1457. */
  1458. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1459. /**
  1460. * Loads a file from a url
  1461. * @param url url to load
  1462. * @param onSuccess callback called when the file successfully loads
  1463. * @param onProgress callback called while file is loading (if the server supports this mode)
  1464. * @param offlineProvider defines the offline provider for caching
  1465. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1466. * @param onError callback called when the file fails to load
  1467. * @returns a file request object
  1468. */
  1469. 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;
  1470. /**
  1471. * Loads a file
  1472. * @param url url to load
  1473. * @param onSuccess callback called when the file successfully loads
  1474. * @param onProgress callback called while file is loading (if the server supports this mode)
  1475. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1476. * @param onError callback called when the file fails to load
  1477. * @param onOpened callback called when the web request is opened
  1478. * @returns a file request object
  1479. */
  1480. 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;
  1481. /**
  1482. * Checks if the loaded document was accessed via `file:`-Protocol.
  1483. * @returns boolean
  1484. */
  1485. static IsFileURL(): boolean;
  1486. }
  1487. }
  1488. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1489. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1490. import { WebRequest } from "babylonjs/Misc/webRequest";
  1491. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1492. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1493. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1494. /** @hidden */
  1495. export class ShaderProcessor {
  1496. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1497. private static _ProcessPrecision;
  1498. private static _ExtractOperation;
  1499. private static _BuildSubExpression;
  1500. private static _BuildExpression;
  1501. private static _MoveCursorWithinIf;
  1502. private static _MoveCursor;
  1503. private static _EvaluatePreProcessors;
  1504. private static _PreparePreProcessors;
  1505. private static _ProcessShaderConversion;
  1506. private static _ProcessIncludes;
  1507. /**
  1508. * Loads a file from a url
  1509. * @param url url to load
  1510. * @param onSuccess callback called when the file successfully loads
  1511. * @param onProgress callback called while file is loading (if the server supports this mode)
  1512. * @param offlineProvider defines the offline provider for caching
  1513. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1514. * @param onError callback called when the file fails to load
  1515. * @returns a file request object
  1516. * @hidden
  1517. */
  1518. 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;
  1519. }
  1520. }
  1521. declare module "babylonjs/Maths/math.like" {
  1522. import { float, int, DeepImmutable } from "babylonjs/types";
  1523. /**
  1524. * @hidden
  1525. */
  1526. export interface IColor4Like {
  1527. r: float;
  1528. g: float;
  1529. b: float;
  1530. a: float;
  1531. }
  1532. /**
  1533. * @hidden
  1534. */
  1535. export interface IColor3Like {
  1536. r: float;
  1537. g: float;
  1538. b: float;
  1539. }
  1540. /**
  1541. * @hidden
  1542. */
  1543. export interface IVector4Like {
  1544. x: float;
  1545. y: float;
  1546. z: float;
  1547. w: float;
  1548. }
  1549. /**
  1550. * @hidden
  1551. */
  1552. export interface IVector3Like {
  1553. x: float;
  1554. y: float;
  1555. z: float;
  1556. }
  1557. /**
  1558. * @hidden
  1559. */
  1560. export interface IVector2Like {
  1561. x: float;
  1562. y: float;
  1563. }
  1564. /**
  1565. * @hidden
  1566. */
  1567. export interface IMatrixLike {
  1568. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1569. updateFlag: int;
  1570. }
  1571. /**
  1572. * @hidden
  1573. */
  1574. export interface IViewportLike {
  1575. x: float;
  1576. y: float;
  1577. width: float;
  1578. height: float;
  1579. }
  1580. /**
  1581. * @hidden
  1582. */
  1583. export interface IPlaneLike {
  1584. normal: IVector3Like;
  1585. d: float;
  1586. normalize(): void;
  1587. }
  1588. }
  1589. declare module "babylonjs/Materials/iEffectFallbacks" {
  1590. import { Effect } from "babylonjs/Materials/effect";
  1591. /**
  1592. * Interface used to define common properties for effect fallbacks
  1593. */
  1594. export interface IEffectFallbacks {
  1595. /**
  1596. * Removes the defines that should be removed when falling back.
  1597. * @param currentDefines defines the current define statements for the shader.
  1598. * @param effect defines the current effect we try to compile
  1599. * @returns The resulting defines with defines of the current rank removed.
  1600. */
  1601. reduce(currentDefines: string, effect: Effect): string;
  1602. /**
  1603. * Removes the fallback from the bound mesh.
  1604. */
  1605. unBindMesh(): void;
  1606. /**
  1607. * Checks to see if more fallbacks are still availible.
  1608. */
  1609. hasMoreFallbacks: boolean;
  1610. }
  1611. }
  1612. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1613. /**
  1614. * Class used to evalaute queries containing `and` and `or` operators
  1615. */
  1616. export class AndOrNotEvaluator {
  1617. /**
  1618. * Evaluate a query
  1619. * @param query defines the query to evaluate
  1620. * @param evaluateCallback defines the callback used to filter result
  1621. * @returns true if the query matches
  1622. */
  1623. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1624. private static _HandleParenthesisContent;
  1625. private static _SimplifyNegation;
  1626. }
  1627. }
  1628. declare module "babylonjs/Misc/tags" {
  1629. /**
  1630. * Class used to store custom tags
  1631. */
  1632. export class Tags {
  1633. /**
  1634. * Adds support for tags on the given object
  1635. * @param obj defines the object to use
  1636. */
  1637. static EnableFor(obj: any): void;
  1638. /**
  1639. * Removes tags support
  1640. * @param obj defines the object to use
  1641. */
  1642. static DisableFor(obj: any): void;
  1643. /**
  1644. * Gets a boolean indicating if the given object has tags
  1645. * @param obj defines the object to use
  1646. * @returns a boolean
  1647. */
  1648. static HasTags(obj: any): boolean;
  1649. /**
  1650. * Gets the tags available on a given object
  1651. * @param obj defines the object to use
  1652. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1653. * @returns the tags
  1654. */
  1655. static GetTags(obj: any, asString?: boolean): any;
  1656. /**
  1657. * Adds tags to an object
  1658. * @param obj defines the object to use
  1659. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1660. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1661. */
  1662. static AddTagsTo(obj: any, tagsString: string): void;
  1663. /**
  1664. * @hidden
  1665. */
  1666. static _AddTagTo(obj: any, tag: string): void;
  1667. /**
  1668. * Removes specific tags from a specific object
  1669. * @param obj defines the object to use
  1670. * @param tagsString defines the tags to remove
  1671. */
  1672. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1673. /**
  1674. * @hidden
  1675. */
  1676. static _RemoveTagFrom(obj: any, tag: string): void;
  1677. /**
  1678. * Defines if tags hosted on an object match a given query
  1679. * @param obj defines the object to use
  1680. * @param tagsQuery defines the tag query
  1681. * @returns a boolean
  1682. */
  1683. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1684. }
  1685. }
  1686. declare module "babylonjs/Maths/math.scalar" {
  1687. /**
  1688. * Scalar computation library
  1689. */
  1690. export class Scalar {
  1691. /**
  1692. * Two pi constants convenient for computation.
  1693. */
  1694. static TwoPi: number;
  1695. /**
  1696. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1697. * @param a number
  1698. * @param b number
  1699. * @param epsilon (default = 1.401298E-45)
  1700. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1701. */
  1702. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1703. /**
  1704. * Returns a string : the upper case translation of the number i to hexadecimal.
  1705. * @param i number
  1706. * @returns the upper case translation of the number i to hexadecimal.
  1707. */
  1708. static ToHex(i: number): string;
  1709. /**
  1710. * Returns -1 if value is negative and +1 is value is positive.
  1711. * @param value the value
  1712. * @returns the value itself if it's equal to zero.
  1713. */
  1714. static Sign(value: number): number;
  1715. /**
  1716. * Returns the value itself if it's between min and max.
  1717. * Returns min if the value is lower than min.
  1718. * Returns max if the value is greater than max.
  1719. * @param value the value to clmap
  1720. * @param min the min value to clamp to (default: 0)
  1721. * @param max the max value to clamp to (default: 1)
  1722. * @returns the clamped value
  1723. */
  1724. static Clamp(value: number, min?: number, max?: number): number;
  1725. /**
  1726. * the log2 of value.
  1727. * @param value the value to compute log2 of
  1728. * @returns the log2 of value.
  1729. */
  1730. static Log2(value: number): number;
  1731. /**
  1732. * Loops the value, so that it is never larger than length and never smaller than 0.
  1733. *
  1734. * This is similar to the modulo operator but it works with floating point numbers.
  1735. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1736. * With t = 5 and length = 2.5, the result would be 0.0.
  1737. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1738. * @param value the value
  1739. * @param length the length
  1740. * @returns the looped value
  1741. */
  1742. static Repeat(value: number, length: number): number;
  1743. /**
  1744. * Normalize the value between 0.0 and 1.0 using min and max values
  1745. * @param value value to normalize
  1746. * @param min max to normalize between
  1747. * @param max min to normalize between
  1748. * @returns the normalized value
  1749. */
  1750. static Normalize(value: number, min: number, max: number): number;
  1751. /**
  1752. * Denormalize the value from 0.0 and 1.0 using min and max values
  1753. * @param normalized value to denormalize
  1754. * @param min max to denormalize between
  1755. * @param max min to denormalize between
  1756. * @returns the denormalized value
  1757. */
  1758. static Denormalize(normalized: number, min: number, max: number): number;
  1759. /**
  1760. * Calculates the shortest difference between two given angles given in degrees.
  1761. * @param current current angle in degrees
  1762. * @param target target angle in degrees
  1763. * @returns the delta
  1764. */
  1765. static DeltaAngle(current: number, target: number): number;
  1766. /**
  1767. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1768. * @param tx value
  1769. * @param length length
  1770. * @returns The returned value will move back and forth between 0 and length
  1771. */
  1772. static PingPong(tx: number, length: number): number;
  1773. /**
  1774. * Interpolates between min and max with smoothing at the limits.
  1775. *
  1776. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1777. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1778. * @param from from
  1779. * @param to to
  1780. * @param tx value
  1781. * @returns the smooth stepped value
  1782. */
  1783. static SmoothStep(from: number, to: number, tx: number): number;
  1784. /**
  1785. * Moves a value current towards target.
  1786. *
  1787. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1788. * Negative values of maxDelta pushes the value away from target.
  1789. * @param current current value
  1790. * @param target target value
  1791. * @param maxDelta max distance to move
  1792. * @returns resulting value
  1793. */
  1794. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1795. /**
  1796. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1797. *
  1798. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1799. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1800. * @param current current value
  1801. * @param target target value
  1802. * @param maxDelta max distance to move
  1803. * @returns resulting angle
  1804. */
  1805. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1806. /**
  1807. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1808. * @param start start value
  1809. * @param end target value
  1810. * @param amount amount to lerp between
  1811. * @returns the lerped value
  1812. */
  1813. static Lerp(start: number, end: number, amount: number): number;
  1814. /**
  1815. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1816. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1817. * @param start start value
  1818. * @param end target value
  1819. * @param amount amount to lerp between
  1820. * @returns the lerped value
  1821. */
  1822. static LerpAngle(start: number, end: number, amount: number): number;
  1823. /**
  1824. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1825. * @param a start value
  1826. * @param b target value
  1827. * @param value value between a and b
  1828. * @returns the inverseLerp value
  1829. */
  1830. static InverseLerp(a: number, b: number, value: number): number;
  1831. /**
  1832. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1833. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1834. * @param value1 spline value
  1835. * @param tangent1 spline value
  1836. * @param value2 spline value
  1837. * @param tangent2 spline value
  1838. * @param amount input value
  1839. * @returns hermite result
  1840. */
  1841. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1842. /**
  1843. * Returns a random float number between and min and max values
  1844. * @param min min value of random
  1845. * @param max max value of random
  1846. * @returns random value
  1847. */
  1848. static RandomRange(min: number, max: number): number;
  1849. /**
  1850. * This function returns percentage of a number in a given range.
  1851. *
  1852. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1853. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1854. * @param number to convert to percentage
  1855. * @param min min range
  1856. * @param max max range
  1857. * @returns the percentage
  1858. */
  1859. static RangeToPercent(number: number, min: number, max: number): number;
  1860. /**
  1861. * This function returns number that corresponds to the percentage in a given range.
  1862. *
  1863. * PercentToRange(0.34,0,100) will return 34.
  1864. * @param percent to convert to number
  1865. * @param min min range
  1866. * @param max max range
  1867. * @returns the number
  1868. */
  1869. static PercentToRange(percent: number, min: number, max: number): number;
  1870. /**
  1871. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1872. * @param angle The angle to normalize in radian.
  1873. * @return The converted angle.
  1874. */
  1875. static NormalizeRadians(angle: number): number;
  1876. }
  1877. }
  1878. declare module "babylonjs/Maths/math.constants" {
  1879. /**
  1880. * Constant used to convert a value to gamma space
  1881. * @ignorenaming
  1882. */
  1883. export const ToGammaSpace: number;
  1884. /**
  1885. * Constant used to convert a value to linear space
  1886. * @ignorenaming
  1887. */
  1888. export const ToLinearSpace = 2.2;
  1889. /**
  1890. * Constant used to define the minimal number value in Babylon.js
  1891. * @ignorenaming
  1892. */
  1893. let Epsilon: number;
  1894. export { Epsilon };
  1895. }
  1896. declare module "babylonjs/Maths/math.viewport" {
  1897. /**
  1898. * Class used to represent a viewport on screen
  1899. */
  1900. export class Viewport {
  1901. /** viewport left coordinate */
  1902. x: number;
  1903. /** viewport top coordinate */
  1904. y: number;
  1905. /**viewport width */
  1906. width: number;
  1907. /** viewport height */
  1908. height: number;
  1909. /**
  1910. * Creates a Viewport object located at (x, y) and sized (width, height)
  1911. * @param x defines viewport left coordinate
  1912. * @param y defines viewport top coordinate
  1913. * @param width defines the viewport width
  1914. * @param height defines the viewport height
  1915. */
  1916. constructor(
  1917. /** viewport left coordinate */
  1918. x: number,
  1919. /** viewport top coordinate */
  1920. y: number,
  1921. /**viewport width */
  1922. width: number,
  1923. /** viewport height */
  1924. height: number);
  1925. /**
  1926. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1927. * @param renderWidth defines the rendering width
  1928. * @param renderHeight defines the rendering height
  1929. * @returns a new Viewport
  1930. */
  1931. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1932. /**
  1933. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1934. * @param renderWidth defines the rendering width
  1935. * @param renderHeight defines the rendering height
  1936. * @param ref defines the target viewport
  1937. * @returns the current viewport
  1938. */
  1939. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1940. /**
  1941. * Returns a new Viewport copied from the current one
  1942. * @returns a new Viewport
  1943. */
  1944. clone(): Viewport;
  1945. }
  1946. }
  1947. declare module "babylonjs/Misc/arrayTools" {
  1948. /**
  1949. * Class containing a set of static utilities functions for arrays.
  1950. */
  1951. export class ArrayTools {
  1952. /**
  1953. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1954. * @param size the number of element to construct and put in the array
  1955. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1956. * @returns a new array filled with new objects
  1957. */
  1958. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1959. }
  1960. }
  1961. declare module "babylonjs/Maths/math.plane" {
  1962. import { DeepImmutable } from "babylonjs/types";
  1963. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  1964. /**
  1965. * Represents a plane by the equation ax + by + cz + d = 0
  1966. */
  1967. export class Plane {
  1968. private static _TmpMatrix;
  1969. /**
  1970. * Normal of the plane (a,b,c)
  1971. */
  1972. normal: Vector3;
  1973. /**
  1974. * d component of the plane
  1975. */
  1976. d: number;
  1977. /**
  1978. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1979. * @param a a component of the plane
  1980. * @param b b component of the plane
  1981. * @param c c component of the plane
  1982. * @param d d component of the plane
  1983. */
  1984. constructor(a: number, b: number, c: number, d: number);
  1985. /**
  1986. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1987. */
  1988. asArray(): number[];
  1989. /**
  1990. * @returns a new plane copied from the current Plane.
  1991. */
  1992. clone(): Plane;
  1993. /**
  1994. * @returns the string "Plane".
  1995. */
  1996. getClassName(): string;
  1997. /**
  1998. * @returns the Plane hash code.
  1999. */
  2000. getHashCode(): number;
  2001. /**
  2002. * Normalize the current Plane in place.
  2003. * @returns the updated Plane.
  2004. */
  2005. normalize(): Plane;
  2006. /**
  2007. * Applies a transformation the plane and returns the result
  2008. * @param transformation the transformation matrix to be applied to the plane
  2009. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2010. */
  2011. transform(transformation: DeepImmutable<Matrix>): Plane;
  2012. /**
  2013. * Compute the dot product between the point and the plane normal
  2014. * @param point point to calculate the dot product with
  2015. * @returns the dot product (float) of the point coordinates and the plane normal.
  2016. */
  2017. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2018. /**
  2019. * Updates the current Plane from the plane defined by the three given points.
  2020. * @param point1 one of the points used to contruct the plane
  2021. * @param point2 one of the points used to contruct the plane
  2022. * @param point3 one of the points used to contruct the plane
  2023. * @returns the updated Plane.
  2024. */
  2025. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2026. /**
  2027. * Checks if the plane is facing a given direction
  2028. * @param direction the direction to check if the plane is facing
  2029. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2030. * @returns True is the vector "direction" is the same side than the plane normal.
  2031. */
  2032. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2033. /**
  2034. * Calculates the distance to a point
  2035. * @param point point to calculate distance to
  2036. * @returns the signed distance (float) from the given point to the Plane.
  2037. */
  2038. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2039. /**
  2040. * Creates a plane from an array
  2041. * @param array the array to create a plane from
  2042. * @returns a new Plane from the given array.
  2043. */
  2044. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2045. /**
  2046. * Creates a plane from three points
  2047. * @param point1 point used to create the plane
  2048. * @param point2 point used to create the plane
  2049. * @param point3 point used to create the plane
  2050. * @returns a new Plane defined by the three given points.
  2051. */
  2052. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2053. /**
  2054. * Creates a plane from an origin point and a normal
  2055. * @param origin origin of the plane to be constructed
  2056. * @param normal normal of the plane to be constructed
  2057. * @returns a new Plane the normal vector to this plane at the given origin point.
  2058. * Note : the vector "normal" is updated because normalized.
  2059. */
  2060. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2061. /**
  2062. * Calculates the distance from a plane and a point
  2063. * @param origin origin of the plane to be constructed
  2064. * @param normal normal of the plane to be constructed
  2065. * @param point point to calculate distance to
  2066. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2067. */
  2068. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2069. }
  2070. }
  2071. declare module "babylonjs/Engines/performanceConfigurator" {
  2072. /** @hidden */
  2073. export class PerformanceConfigurator {
  2074. /** @hidden */
  2075. static MatrixUse64Bits: boolean;
  2076. /** @hidden */
  2077. static MatrixTrackPrecisionChange: boolean;
  2078. /** @hidden */
  2079. static MatrixCurrentType: any;
  2080. /** @hidden */
  2081. static MatrixTrackedMatrices: Array<any> | null;
  2082. /** @hidden */
  2083. static SetMatrixPrecision(use64bits: boolean): void;
  2084. }
  2085. }
  2086. declare module "babylonjs/Maths/math.vector" {
  2087. import { Viewport } from "babylonjs/Maths/math.viewport";
  2088. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  2089. import { IPlaneLike } from "babylonjs/Maths/math.like";
  2090. import { Plane } from "babylonjs/Maths/math.plane";
  2091. /**
  2092. * Class representing a vector containing 2 coordinates
  2093. */
  2094. export class Vector2 {
  2095. /** defines the first coordinate */
  2096. x: number;
  2097. /** defines the second coordinate */
  2098. y: number;
  2099. /**
  2100. * Creates a new Vector2 from the given x and y coordinates
  2101. * @param x defines the first coordinate
  2102. * @param y defines the second coordinate
  2103. */
  2104. constructor(
  2105. /** defines the first coordinate */
  2106. x?: number,
  2107. /** defines the second coordinate */
  2108. y?: number);
  2109. /**
  2110. * Gets a string with the Vector2 coordinates
  2111. * @returns a string with the Vector2 coordinates
  2112. */
  2113. toString(): string;
  2114. /**
  2115. * Gets class name
  2116. * @returns the string "Vector2"
  2117. */
  2118. getClassName(): string;
  2119. /**
  2120. * Gets current vector hash code
  2121. * @returns the Vector2 hash code as a number
  2122. */
  2123. getHashCode(): number;
  2124. /**
  2125. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2126. * @param array defines the source array
  2127. * @param index defines the offset in source array
  2128. * @returns the current Vector2
  2129. */
  2130. toArray(array: FloatArray, index?: number): Vector2;
  2131. /**
  2132. * Update the current vector from an array
  2133. * @param array defines the destination array
  2134. * @param index defines the offset in the destination array
  2135. * @returns the current Vector3
  2136. */
  2137. fromArray(array: FloatArray, index?: number): Vector2;
  2138. /**
  2139. * Copy the current vector to an array
  2140. * @returns a new array with 2 elements: the Vector2 coordinates.
  2141. */
  2142. asArray(): number[];
  2143. /**
  2144. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2145. * @param source defines the source Vector2
  2146. * @returns the current updated Vector2
  2147. */
  2148. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2149. /**
  2150. * Sets the Vector2 coordinates with the given floats
  2151. * @param x defines the first coordinate
  2152. * @param y defines the second coordinate
  2153. * @returns the current updated Vector2
  2154. */
  2155. copyFromFloats(x: number, y: number): Vector2;
  2156. /**
  2157. * Sets the Vector2 coordinates with the given floats
  2158. * @param x defines the first coordinate
  2159. * @param y defines the second coordinate
  2160. * @returns the current updated Vector2
  2161. */
  2162. set(x: number, y: number): Vector2;
  2163. /**
  2164. * Add another vector with the current one
  2165. * @param otherVector defines the other vector
  2166. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2167. */
  2168. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2169. /**
  2170. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2171. * @param otherVector defines the other vector
  2172. * @param result defines the target vector
  2173. * @returns the unmodified current Vector2
  2174. */
  2175. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2176. /**
  2177. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2178. * @param otherVector defines the other vector
  2179. * @returns the current updated Vector2
  2180. */
  2181. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2182. /**
  2183. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2184. * @param otherVector defines the other vector
  2185. * @returns a new Vector2
  2186. */
  2187. addVector3(otherVector: Vector3): Vector2;
  2188. /**
  2189. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2190. * @param otherVector defines the other vector
  2191. * @returns a new Vector2
  2192. */
  2193. subtract(otherVector: Vector2): Vector2;
  2194. /**
  2195. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2196. * @param otherVector defines the other vector
  2197. * @param result defines the target vector
  2198. * @returns the unmodified current Vector2
  2199. */
  2200. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2201. /**
  2202. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2203. * @param otherVector defines the other vector
  2204. * @returns the current updated Vector2
  2205. */
  2206. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2207. /**
  2208. * Multiplies in place the current Vector2 coordinates by the given ones
  2209. * @param otherVector defines the other vector
  2210. * @returns the current updated Vector2
  2211. */
  2212. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2213. /**
  2214. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2215. * @param otherVector defines the other vector
  2216. * @returns a new Vector2
  2217. */
  2218. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2219. /**
  2220. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2221. * @param otherVector defines the other vector
  2222. * @param result defines the target vector
  2223. * @returns the unmodified current Vector2
  2224. */
  2225. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2226. /**
  2227. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2228. * @param x defines the first coordinate
  2229. * @param y defines the second coordinate
  2230. * @returns a new Vector2
  2231. */
  2232. multiplyByFloats(x: number, y: number): Vector2;
  2233. /**
  2234. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2235. * @param otherVector defines the other vector
  2236. * @returns a new Vector2
  2237. */
  2238. divide(otherVector: Vector2): Vector2;
  2239. /**
  2240. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2241. * @param otherVector defines the other vector
  2242. * @param result defines the target vector
  2243. * @returns the unmodified current Vector2
  2244. */
  2245. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2246. /**
  2247. * Divides the current Vector2 coordinates by the given ones
  2248. * @param otherVector defines the other vector
  2249. * @returns the current updated Vector2
  2250. */
  2251. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2252. /**
  2253. * Gets a new Vector2 with current Vector2 negated coordinates
  2254. * @returns a new Vector2
  2255. */
  2256. negate(): Vector2;
  2257. /**
  2258. * Negate this vector in place
  2259. * @returns this
  2260. */
  2261. negateInPlace(): Vector2;
  2262. /**
  2263. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2264. * @param result defines the Vector3 object where to store the result
  2265. * @returns the current Vector2
  2266. */
  2267. negateToRef(result: Vector2): Vector2;
  2268. /**
  2269. * Multiply the Vector2 coordinates by scale
  2270. * @param scale defines the scaling factor
  2271. * @returns the current updated Vector2
  2272. */
  2273. scaleInPlace(scale: number): Vector2;
  2274. /**
  2275. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2276. * @param scale defines the scaling factor
  2277. * @returns a new Vector2
  2278. */
  2279. scale(scale: number): Vector2;
  2280. /**
  2281. * Scale the current Vector2 values by a factor to a given Vector2
  2282. * @param scale defines the scale factor
  2283. * @param result defines the Vector2 object where to store the result
  2284. * @returns the unmodified current Vector2
  2285. */
  2286. scaleToRef(scale: number, result: Vector2): Vector2;
  2287. /**
  2288. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2289. * @param scale defines the scale factor
  2290. * @param result defines the Vector2 object where to store the result
  2291. * @returns the unmodified current Vector2
  2292. */
  2293. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2294. /**
  2295. * Gets a boolean if two vectors are equals
  2296. * @param otherVector defines the other vector
  2297. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2298. */
  2299. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2300. /**
  2301. * Gets a boolean if two vectors are equals (using an epsilon value)
  2302. * @param otherVector defines the other vector
  2303. * @param epsilon defines the minimal distance to consider equality
  2304. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2305. */
  2306. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2307. /**
  2308. * Gets a new Vector2 from current Vector2 floored values
  2309. * @returns a new Vector2
  2310. */
  2311. floor(): Vector2;
  2312. /**
  2313. * Gets a new Vector2 from current Vector2 floored values
  2314. * @returns a new Vector2
  2315. */
  2316. fract(): Vector2;
  2317. /**
  2318. * Gets the length of the vector
  2319. * @returns the vector length (float)
  2320. */
  2321. length(): number;
  2322. /**
  2323. * Gets the vector squared length
  2324. * @returns the vector squared length (float)
  2325. */
  2326. lengthSquared(): number;
  2327. /**
  2328. * Normalize the vector
  2329. * @returns the current updated Vector2
  2330. */
  2331. normalize(): Vector2;
  2332. /**
  2333. * Gets a new Vector2 copied from the Vector2
  2334. * @returns a new Vector2
  2335. */
  2336. clone(): Vector2;
  2337. /**
  2338. * Gets a new Vector2(0, 0)
  2339. * @returns a new Vector2
  2340. */
  2341. static Zero(): Vector2;
  2342. /**
  2343. * Gets a new Vector2(1, 1)
  2344. * @returns a new Vector2
  2345. */
  2346. static One(): Vector2;
  2347. /**
  2348. * Gets a new Vector2 set from the given index element of the given array
  2349. * @param array defines the data source
  2350. * @param offset defines the offset in the data source
  2351. * @returns a new Vector2
  2352. */
  2353. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2354. /**
  2355. * Sets "result" from the given index element of the given array
  2356. * @param array defines the data source
  2357. * @param offset defines the offset in the data source
  2358. * @param result defines the target vector
  2359. */
  2360. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2361. /**
  2362. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2363. * @param value1 defines 1st point of control
  2364. * @param value2 defines 2nd point of control
  2365. * @param value3 defines 3rd point of control
  2366. * @param value4 defines 4th point of control
  2367. * @param amount defines the interpolation factor
  2368. * @returns a new Vector2
  2369. */
  2370. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2371. /**
  2372. * 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".
  2373. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2374. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2375. * @param value defines the value to clamp
  2376. * @param min defines the lower limit
  2377. * @param max defines the upper limit
  2378. * @returns a new Vector2
  2379. */
  2380. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2381. /**
  2382. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2383. * @param value1 defines the 1st control point
  2384. * @param tangent1 defines the outgoing tangent
  2385. * @param value2 defines the 2nd control point
  2386. * @param tangent2 defines the incoming tangent
  2387. * @param amount defines the interpolation factor
  2388. * @returns a new Vector2
  2389. */
  2390. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2391. /**
  2392. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2393. * @param start defines the start vector
  2394. * @param end defines the end vector
  2395. * @param amount defines the interpolation factor
  2396. * @returns a new Vector2
  2397. */
  2398. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2399. /**
  2400. * Gets the dot product of the vector "left" and the vector "right"
  2401. * @param left defines first vector
  2402. * @param right defines second vector
  2403. * @returns the dot product (float)
  2404. */
  2405. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2406. /**
  2407. * Returns a new Vector2 equal to the normalized given vector
  2408. * @param vector defines the vector to normalize
  2409. * @returns a new Vector2
  2410. */
  2411. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2412. /**
  2413. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2414. * @param left defines 1st vector
  2415. * @param right defines 2nd vector
  2416. * @returns a new Vector2
  2417. */
  2418. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2419. /**
  2420. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2421. * @param left defines 1st vector
  2422. * @param right defines 2nd vector
  2423. * @returns a new Vector2
  2424. */
  2425. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2426. /**
  2427. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2428. * @param vector defines the vector to transform
  2429. * @param transformation defines the matrix to apply
  2430. * @returns a new Vector2
  2431. */
  2432. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2433. /**
  2434. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2435. * @param vector defines the vector to transform
  2436. * @param transformation defines the matrix to apply
  2437. * @param result defines the target vector
  2438. */
  2439. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2440. /**
  2441. * Determines if a given vector is included in a triangle
  2442. * @param p defines the vector to test
  2443. * @param p0 defines 1st triangle point
  2444. * @param p1 defines 2nd triangle point
  2445. * @param p2 defines 3rd triangle point
  2446. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2447. */
  2448. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2449. /**
  2450. * Gets the distance between the vectors "value1" and "value2"
  2451. * @param value1 defines first vector
  2452. * @param value2 defines second vector
  2453. * @returns the distance between vectors
  2454. */
  2455. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2456. /**
  2457. * Returns the squared distance between the vectors "value1" and "value2"
  2458. * @param value1 defines first vector
  2459. * @param value2 defines second vector
  2460. * @returns the squared distance between vectors
  2461. */
  2462. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2463. /**
  2464. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2465. * @param value1 defines first vector
  2466. * @param value2 defines second vector
  2467. * @returns a new Vector2
  2468. */
  2469. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2470. /**
  2471. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2472. * @param p defines the middle point
  2473. * @param segA defines one point of the segment
  2474. * @param segB defines the other point of the segment
  2475. * @returns the shortest distance
  2476. */
  2477. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2478. }
  2479. /**
  2480. * Class used to store (x,y,z) vector representation
  2481. * A Vector3 is the main object used in 3D geometry
  2482. * It can represent etiher the coordinates of a point the space, either a direction
  2483. * Reminder: js uses a left handed forward facing system
  2484. */
  2485. export class Vector3 {
  2486. private static _UpReadOnly;
  2487. private static _ZeroReadOnly;
  2488. /** @hidden */
  2489. _x: number;
  2490. /** @hidden */
  2491. _y: number;
  2492. /** @hidden */
  2493. _z: number;
  2494. /** @hidden */
  2495. _isDirty: boolean;
  2496. /** Gets or sets the x coordinate */
  2497. get x(): number;
  2498. set x(value: number);
  2499. /** Gets or sets the y coordinate */
  2500. get y(): number;
  2501. set y(value: number);
  2502. /** Gets or sets the z coordinate */
  2503. get z(): number;
  2504. set z(value: number);
  2505. /**
  2506. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2507. * @param x defines the first coordinates (on X axis)
  2508. * @param y defines the second coordinates (on Y axis)
  2509. * @param z defines the third coordinates (on Z axis)
  2510. */
  2511. constructor(x?: number, y?: number, z?: number);
  2512. /**
  2513. * Creates a string representation of the Vector3
  2514. * @returns a string with the Vector3 coordinates.
  2515. */
  2516. toString(): string;
  2517. /**
  2518. * Gets the class name
  2519. * @returns the string "Vector3"
  2520. */
  2521. getClassName(): string;
  2522. /**
  2523. * Creates the Vector3 hash code
  2524. * @returns a number which tends to be unique between Vector3 instances
  2525. */
  2526. getHashCode(): number;
  2527. /**
  2528. * Creates an array containing three elements : the coordinates of the Vector3
  2529. * @returns a new array of numbers
  2530. */
  2531. asArray(): number[];
  2532. /**
  2533. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2534. * @param array defines the destination array
  2535. * @param index defines the offset in the destination array
  2536. * @returns the current Vector3
  2537. */
  2538. toArray(array: FloatArray, index?: number): Vector3;
  2539. /**
  2540. * Update the current vector from an array
  2541. * @param array defines the destination array
  2542. * @param index defines the offset in the destination array
  2543. * @returns the current Vector3
  2544. */
  2545. fromArray(array: FloatArray, index?: number): Vector3;
  2546. /**
  2547. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2548. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2549. */
  2550. toQuaternion(): Quaternion;
  2551. /**
  2552. * Adds the given vector to the current Vector3
  2553. * @param otherVector defines the second operand
  2554. * @returns the current updated Vector3
  2555. */
  2556. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2557. /**
  2558. * Adds the given coordinates to the current Vector3
  2559. * @param x defines the x coordinate of the operand
  2560. * @param y defines the y coordinate of the operand
  2561. * @param z defines the z coordinate of the operand
  2562. * @returns the current updated Vector3
  2563. */
  2564. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2565. /**
  2566. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2567. * @param otherVector defines the second operand
  2568. * @returns the resulting Vector3
  2569. */
  2570. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2571. /**
  2572. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2573. * @param otherVector defines the second operand
  2574. * @param result defines the Vector3 object where to store the result
  2575. * @returns the current Vector3
  2576. */
  2577. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2578. /**
  2579. * Subtract the given vector from the current Vector3
  2580. * @param otherVector defines the second operand
  2581. * @returns the current updated Vector3
  2582. */
  2583. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2584. /**
  2585. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2586. * @param otherVector defines the second operand
  2587. * @returns the resulting Vector3
  2588. */
  2589. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2590. /**
  2591. * Subtracts the given vector from the current Vector3 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. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2597. /**
  2598. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2599. * @param x defines the x coordinate of the operand
  2600. * @param y defines the y coordinate of the operand
  2601. * @param z defines the z coordinate of the operand
  2602. * @returns the resulting Vector3
  2603. */
  2604. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2605. /**
  2606. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2607. * @param x defines the x coordinate of the operand
  2608. * @param y defines the y coordinate of the operand
  2609. * @param z defines the z coordinate of the operand
  2610. * @param result defines the Vector3 object where to store the result
  2611. * @returns the current Vector3
  2612. */
  2613. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2614. /**
  2615. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2616. * @returns a new Vector3
  2617. */
  2618. negate(): Vector3;
  2619. /**
  2620. * Negate this vector in place
  2621. * @returns this
  2622. */
  2623. negateInPlace(): Vector3;
  2624. /**
  2625. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2626. * @param result defines the Vector3 object where to store the result
  2627. * @returns the current Vector3
  2628. */
  2629. negateToRef(result: Vector3): Vector3;
  2630. /**
  2631. * Multiplies the Vector3 coordinates by the float "scale"
  2632. * @param scale defines the multiplier factor
  2633. * @returns the current updated Vector3
  2634. */
  2635. scaleInPlace(scale: number): Vector3;
  2636. /**
  2637. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2638. * @param scale defines the multiplier factor
  2639. * @returns a new Vector3
  2640. */
  2641. scale(scale: number): Vector3;
  2642. /**
  2643. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2644. * @param scale defines the multiplier factor
  2645. * @param result defines the Vector3 object where to store the result
  2646. * @returns the current Vector3
  2647. */
  2648. scaleToRef(scale: number, result: Vector3): Vector3;
  2649. /**
  2650. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2651. * @param scale defines the scale factor
  2652. * @param result defines the Vector3 object where to store the result
  2653. * @returns the unmodified current Vector3
  2654. */
  2655. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2656. /**
  2657. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2658. * @param origin defines the origin of the projection ray
  2659. * @param plane defines the plane to project to
  2660. * @returns the projected vector3
  2661. */
  2662. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2663. /**
  2664. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2665. * @param origin defines the origin of the projection ray
  2666. * @param plane defines the plane to project to
  2667. * @param result defines the Vector3 where to store the result
  2668. */
  2669. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2670. /**
  2671. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2672. * @param otherVector defines the second operand
  2673. * @returns true if both vectors are equals
  2674. */
  2675. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2676. /**
  2677. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2678. * @param otherVector defines the second operand
  2679. * @param epsilon defines the minimal distance to define values as equals
  2680. * @returns true if both vectors are distant less than epsilon
  2681. */
  2682. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2683. /**
  2684. * Returns true if the current Vector3 coordinates equals the given floats
  2685. * @param x defines the x coordinate of the operand
  2686. * @param y defines the y coordinate of the operand
  2687. * @param z defines the z coordinate of the operand
  2688. * @returns true if both vectors are equals
  2689. */
  2690. equalsToFloats(x: number, y: number, z: number): boolean;
  2691. /**
  2692. * Multiplies the current Vector3 coordinates by the given ones
  2693. * @param otherVector defines the second operand
  2694. * @returns the current updated Vector3
  2695. */
  2696. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2697. /**
  2698. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2699. * @param otherVector defines the second operand
  2700. * @returns the new Vector3
  2701. */
  2702. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2703. /**
  2704. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2705. * @param otherVector defines the second operand
  2706. * @param result defines the Vector3 object where to store the result
  2707. * @returns the current Vector3
  2708. */
  2709. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2710. /**
  2711. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2712. * @param x defines the x coordinate of the operand
  2713. * @param y defines the y coordinate of the operand
  2714. * @param z defines the z coordinate of the operand
  2715. * @returns the new Vector3
  2716. */
  2717. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2718. /**
  2719. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2720. * @param otherVector defines the second operand
  2721. * @returns the new Vector3
  2722. */
  2723. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2724. /**
  2725. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2726. * @param otherVector defines the second operand
  2727. * @param result defines the Vector3 object where to store the result
  2728. * @returns the current Vector3
  2729. */
  2730. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2731. /**
  2732. * Divides the current Vector3 coordinates by the given ones.
  2733. * @param otherVector defines the second operand
  2734. * @returns the current updated Vector3
  2735. */
  2736. divideInPlace(otherVector: Vector3): Vector3;
  2737. /**
  2738. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2739. * @param other defines the second operand
  2740. * @returns the current updated Vector3
  2741. */
  2742. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2743. /**
  2744. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2745. * @param other defines the second operand
  2746. * @returns the current updated Vector3
  2747. */
  2748. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2749. /**
  2750. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2751. * @param x defines the x coordinate of the operand
  2752. * @param y defines the y coordinate of the operand
  2753. * @param z defines the z coordinate of the operand
  2754. * @returns the current updated Vector3
  2755. */
  2756. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2757. /**
  2758. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2759. * @param x defines the x coordinate of the operand
  2760. * @param y defines the y coordinate of the operand
  2761. * @param z defines the z coordinate of the operand
  2762. * @returns the current updated Vector3
  2763. */
  2764. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2765. /**
  2766. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2767. * Check if is non uniform within a certain amount of decimal places to account for this
  2768. * @param epsilon the amount the values can differ
  2769. * @returns if the the vector is non uniform to a certain number of decimal places
  2770. */
  2771. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2772. /**
  2773. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2774. */
  2775. get isNonUniform(): boolean;
  2776. /**
  2777. * Gets a new Vector3 from current Vector3 floored values
  2778. * @returns a new Vector3
  2779. */
  2780. floor(): Vector3;
  2781. /**
  2782. * Gets a new Vector3 from current Vector3 floored values
  2783. * @returns a new Vector3
  2784. */
  2785. fract(): Vector3;
  2786. /**
  2787. * Gets the length of the Vector3
  2788. * @returns the length of the Vector3
  2789. */
  2790. length(): number;
  2791. /**
  2792. * Gets the squared length of the Vector3
  2793. * @returns squared length of the Vector3
  2794. */
  2795. lengthSquared(): number;
  2796. /**
  2797. * Normalize the current Vector3.
  2798. * Please note that this is an in place operation.
  2799. * @returns the current updated Vector3
  2800. */
  2801. normalize(): Vector3;
  2802. /**
  2803. * Reorders the x y z properties of the vector in place
  2804. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2805. * @returns the current updated vector
  2806. */
  2807. reorderInPlace(order: string): this;
  2808. /**
  2809. * Rotates the vector around 0,0,0 by a quaternion
  2810. * @param quaternion the rotation quaternion
  2811. * @param result vector to store the result
  2812. * @returns the resulting vector
  2813. */
  2814. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2815. /**
  2816. * Rotates a vector around a given point
  2817. * @param quaternion the rotation quaternion
  2818. * @param point the point to rotate around
  2819. * @param result vector to store the result
  2820. * @returns the resulting vector
  2821. */
  2822. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2823. /**
  2824. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2825. * The cross product is then orthogonal to both current and "other"
  2826. * @param other defines the right operand
  2827. * @returns the cross product
  2828. */
  2829. cross(other: Vector3): Vector3;
  2830. /**
  2831. * Normalize the current Vector3 with the given input length.
  2832. * Please note that this is an in place operation.
  2833. * @param len the length of the vector
  2834. * @returns the current updated Vector3
  2835. */
  2836. normalizeFromLength(len: number): Vector3;
  2837. /**
  2838. * Normalize the current Vector3 to a new vector
  2839. * @returns the new Vector3
  2840. */
  2841. normalizeToNew(): Vector3;
  2842. /**
  2843. * Normalize the current Vector3 to the reference
  2844. * @param reference define the Vector3 to update
  2845. * @returns the updated Vector3
  2846. */
  2847. normalizeToRef(reference: Vector3): Vector3;
  2848. /**
  2849. * Creates a new Vector3 copied from the current Vector3
  2850. * @returns the new Vector3
  2851. */
  2852. clone(): Vector3;
  2853. /**
  2854. * Copies the given vector coordinates to the current Vector3 ones
  2855. * @param source defines the source Vector3
  2856. * @returns the current updated Vector3
  2857. */
  2858. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2859. /**
  2860. * Copies the given floats to the current Vector3 coordinates
  2861. * @param x defines the x coordinate of the operand
  2862. * @param y defines the y coordinate of the operand
  2863. * @param z defines the z coordinate of the operand
  2864. * @returns the current updated Vector3
  2865. */
  2866. copyFromFloats(x: number, y: number, z: number): Vector3;
  2867. /**
  2868. * Copies the given floats to the current Vector3 coordinates
  2869. * @param x defines the x coordinate of the operand
  2870. * @param y defines the y coordinate of the operand
  2871. * @param z defines the z coordinate of the operand
  2872. * @returns the current updated Vector3
  2873. */
  2874. set(x: number, y: number, z: number): Vector3;
  2875. /**
  2876. * Copies the given float to the current Vector3 coordinates
  2877. * @param v defines the x, y and z coordinates of the operand
  2878. * @returns the current updated Vector3
  2879. */
  2880. setAll(v: number): Vector3;
  2881. /**
  2882. * Get the clip factor between two vectors
  2883. * @param vector0 defines the first operand
  2884. * @param vector1 defines the second operand
  2885. * @param axis defines the axis to use
  2886. * @param size defines the size along the axis
  2887. * @returns the clip factor
  2888. */
  2889. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2890. /**
  2891. * Get angle between two vectors
  2892. * @param vector0 angle between vector0 and vector1
  2893. * @param vector1 angle between vector0 and vector1
  2894. * @param normal direction of the normal
  2895. * @return the angle between vector0 and vector1
  2896. */
  2897. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2898. /**
  2899. * Returns a new Vector3 set from the index "offset" of the given array
  2900. * @param array defines the source array
  2901. * @param offset defines the offset in the source array
  2902. * @returns the new Vector3
  2903. */
  2904. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2905. /**
  2906. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2907. * @param array defines the source array
  2908. * @param offset defines the offset in the source array
  2909. * @returns the new Vector3
  2910. * @deprecated Please use FromArray instead.
  2911. */
  2912. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2913. /**
  2914. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2915. * @param array defines the source array
  2916. * @param offset defines the offset in the source array
  2917. * @param result defines the Vector3 where to store the result
  2918. */
  2919. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2920. /**
  2921. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2922. * @param array defines the source array
  2923. * @param offset defines the offset in the source array
  2924. * @param result defines the Vector3 where to store the result
  2925. * @deprecated Please use FromArrayToRef instead.
  2926. */
  2927. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2928. /**
  2929. * Sets the given vector "result" with the given floats.
  2930. * @param x defines the x coordinate of the source
  2931. * @param y defines the y coordinate of the source
  2932. * @param z defines the z coordinate of the source
  2933. * @param result defines the Vector3 where to store the result
  2934. */
  2935. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2936. /**
  2937. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2938. * @returns a new empty Vector3
  2939. */
  2940. static Zero(): Vector3;
  2941. /**
  2942. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2943. * @returns a new unit Vector3
  2944. */
  2945. static One(): Vector3;
  2946. /**
  2947. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2948. * @returns a new up Vector3
  2949. */
  2950. static Up(): Vector3;
  2951. /**
  2952. * Gets a up Vector3 that must not be updated
  2953. */
  2954. static get UpReadOnly(): DeepImmutable<Vector3>;
  2955. /**
  2956. * Gets a zero Vector3 that must not be updated
  2957. */
  2958. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2959. /**
  2960. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2961. * @returns a new down Vector3
  2962. */
  2963. static Down(): Vector3;
  2964. /**
  2965. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2966. * @param rightHandedSystem is the scene right-handed (negative z)
  2967. * @returns a new forward Vector3
  2968. */
  2969. static Forward(rightHandedSystem?: boolean): Vector3;
  2970. /**
  2971. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2972. * @param rightHandedSystem is the scene right-handed (negative-z)
  2973. * @returns a new forward Vector3
  2974. */
  2975. static Backward(rightHandedSystem?: boolean): Vector3;
  2976. /**
  2977. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2978. * @returns a new right Vector3
  2979. */
  2980. static Right(): Vector3;
  2981. /**
  2982. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2983. * @returns a new left Vector3
  2984. */
  2985. static Left(): Vector3;
  2986. /**
  2987. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2988. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2989. * @param vector defines the Vector3 to transform
  2990. * @param transformation defines the transformation matrix
  2991. * @returns the transformed Vector3
  2992. */
  2993. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2994. /**
  2995. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2996. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2997. * @param vector defines the Vector3 to transform
  2998. * @param transformation defines the transformation matrix
  2999. * @param result defines the Vector3 where to store the result
  3000. */
  3001. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3002. /**
  3003. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  3004. * This method computes tranformed coordinates only, not transformed direction vectors
  3005. * @param x define the x coordinate of the source vector
  3006. * @param y define the y coordinate of the source vector
  3007. * @param z define the z coordinate of the source vector
  3008. * @param transformation defines the transformation matrix
  3009. * @param result defines the Vector3 where to store the result
  3010. */
  3011. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3012. /**
  3013. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3014. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3015. * @param vector defines the Vector3 to transform
  3016. * @param transformation defines the transformation matrix
  3017. * @returns the new Vector3
  3018. */
  3019. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3020. /**
  3021. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3022. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3023. * @param vector defines the Vector3 to transform
  3024. * @param transformation defines the transformation matrix
  3025. * @param result defines the Vector3 where to store the result
  3026. */
  3027. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3028. /**
  3029. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3030. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3031. * @param x define the x coordinate of the source vector
  3032. * @param y define the y coordinate of the source vector
  3033. * @param z define the z coordinate of the source vector
  3034. * @param transformation defines the transformation matrix
  3035. * @param result defines the Vector3 where to store the result
  3036. */
  3037. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3038. /**
  3039. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3040. * @param value1 defines the first control point
  3041. * @param value2 defines the second control point
  3042. * @param value3 defines the third control point
  3043. * @param value4 defines the fourth control point
  3044. * @param amount defines the amount on the spline to use
  3045. * @returns the new Vector3
  3046. */
  3047. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3048. /**
  3049. * 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"
  3050. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3051. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3052. * @param value defines the current value
  3053. * @param min defines the lower range value
  3054. * @param max defines the upper range value
  3055. * @returns the new Vector3
  3056. */
  3057. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3058. /**
  3059. * 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"
  3060. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3061. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3062. * @param value defines the current value
  3063. * @param min defines the lower range value
  3064. * @param max defines the upper range value
  3065. * @param result defines the Vector3 where to store the result
  3066. */
  3067. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3068. /**
  3069. * Checks if a given vector is inside a specific range
  3070. * @param v defines the vector to test
  3071. * @param min defines the minimum range
  3072. * @param max defines the maximum range
  3073. */
  3074. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3075. /**
  3076. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3077. * @param value1 defines the first control point
  3078. * @param tangent1 defines the first tangent vector
  3079. * @param value2 defines the second control point
  3080. * @param tangent2 defines the second tangent vector
  3081. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3082. * @returns the new Vector3
  3083. */
  3084. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3085. /**
  3086. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3087. * @param start defines the start value
  3088. * @param end defines the end value
  3089. * @param amount max defines amount between both (between 0 and 1)
  3090. * @returns the new Vector3
  3091. */
  3092. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3093. /**
  3094. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3095. * @param start defines the start value
  3096. * @param end defines the end value
  3097. * @param amount max defines amount between both (between 0 and 1)
  3098. * @param result defines the Vector3 where to store the result
  3099. */
  3100. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3101. /**
  3102. * Returns the dot product (float) between the vectors "left" and "right"
  3103. * @param left defines the left operand
  3104. * @param right defines the right operand
  3105. * @returns the dot product
  3106. */
  3107. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3108. /**
  3109. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3110. * The cross product is then orthogonal to both "left" and "right"
  3111. * @param left defines the left operand
  3112. * @param right defines the right operand
  3113. * @returns the cross product
  3114. */
  3115. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3116. /**
  3117. * Sets the given vector "result" with the cross product of "left" and "right"
  3118. * The cross product is then orthogonal to both "left" and "right"
  3119. * @param left defines the left operand
  3120. * @param right defines the right operand
  3121. * @param result defines the Vector3 where to store the result
  3122. */
  3123. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3124. /**
  3125. * Returns a new Vector3 as the normalization of the given vector
  3126. * @param vector defines the Vector3 to normalize
  3127. * @returns the new Vector3
  3128. */
  3129. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3130. /**
  3131. * Sets the given vector "result" with the normalization of the given first vector
  3132. * @param vector defines the Vector3 to normalize
  3133. * @param result defines the Vector3 where to store the result
  3134. */
  3135. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3136. /**
  3137. * Project a Vector3 onto screen space
  3138. * @param vector defines the Vector3 to project
  3139. * @param world defines the world matrix to use
  3140. * @param transform defines the transform (view x projection) matrix to use
  3141. * @param viewport defines the screen viewport to use
  3142. * @returns the new Vector3
  3143. */
  3144. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3145. /** @hidden */
  3146. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3147. /**
  3148. * Unproject from screen space to object space
  3149. * @param source defines the screen space Vector3 to use
  3150. * @param viewportWidth defines the current width of the viewport
  3151. * @param viewportHeight defines the current height of the viewport
  3152. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3153. * @param transform defines the transform (view x projection) matrix to use
  3154. * @returns the new Vector3
  3155. */
  3156. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3157. /**
  3158. * Unproject from screen space to object space
  3159. * @param source defines the screen space Vector3 to use
  3160. * @param viewportWidth defines the current width of the viewport
  3161. * @param viewportHeight defines the current height of the viewport
  3162. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3163. * @param view defines the view matrix to use
  3164. * @param projection defines the projection matrix to use
  3165. * @returns the new Vector3
  3166. */
  3167. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3168. /**
  3169. * Unproject from screen space to object space
  3170. * @param source defines the screen space Vector3 to use
  3171. * @param viewportWidth defines the current width of the viewport
  3172. * @param viewportHeight defines the current height of the viewport
  3173. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3174. * @param view defines the view matrix to use
  3175. * @param projection defines the projection matrix to use
  3176. * @param result defines the Vector3 where to store the result
  3177. */
  3178. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3179. /**
  3180. * Unproject from screen space to object space
  3181. * @param sourceX defines the screen space x coordinate to use
  3182. * @param sourceY defines the screen space y coordinate to use
  3183. * @param sourceZ defines the screen space z coordinate to use
  3184. * @param viewportWidth defines the current width of the viewport
  3185. * @param viewportHeight defines the current height of the viewport
  3186. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3187. * @param view defines the view matrix to use
  3188. * @param projection defines the projection matrix to use
  3189. * @param result defines the Vector3 where to store the result
  3190. */
  3191. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3192. /**
  3193. * Gets the minimal coordinate values between two Vector3
  3194. * @param left defines the first operand
  3195. * @param right defines the second operand
  3196. * @returns the new Vector3
  3197. */
  3198. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3199. /**
  3200. * Gets the maximal coordinate values between two Vector3
  3201. * @param left defines the first operand
  3202. * @param right defines the second operand
  3203. * @returns the new Vector3
  3204. */
  3205. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3206. /**
  3207. * Returns the distance between the vectors "value1" and "value2"
  3208. * @param value1 defines the first operand
  3209. * @param value2 defines the second operand
  3210. * @returns the distance
  3211. */
  3212. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3213. /**
  3214. * Returns the squared distance between the vectors "value1" and "value2"
  3215. * @param value1 defines the first operand
  3216. * @param value2 defines the second operand
  3217. * @returns the squared distance
  3218. */
  3219. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3220. /**
  3221. * Returns a new Vector3 located at the center between "value1" and "value2"
  3222. * @param value1 defines the first operand
  3223. * @param value2 defines the second operand
  3224. * @returns the new Vector3
  3225. */
  3226. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3227. /**
  3228. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3229. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3230. * to something in order to rotate it from its local system to the given target system
  3231. * Note: axis1, axis2 and axis3 are normalized during this operation
  3232. * @param axis1 defines the first axis
  3233. * @param axis2 defines the second axis
  3234. * @param axis3 defines the third axis
  3235. * @returns a new Vector3
  3236. */
  3237. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3238. /**
  3239. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3240. * @param axis1 defines the first axis
  3241. * @param axis2 defines the second axis
  3242. * @param axis3 defines the third axis
  3243. * @param ref defines the Vector3 where to store the result
  3244. */
  3245. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3246. }
  3247. /**
  3248. * Vector4 class created for EulerAngle class conversion to Quaternion
  3249. */
  3250. export class Vector4 {
  3251. /** x value of the vector */
  3252. x: number;
  3253. /** y value of the vector */
  3254. y: number;
  3255. /** z value of the vector */
  3256. z: number;
  3257. /** w value of the vector */
  3258. w: number;
  3259. /**
  3260. * Creates a Vector4 object from the given floats.
  3261. * @param x x value of the vector
  3262. * @param y y value of the vector
  3263. * @param z z value of the vector
  3264. * @param w w value of the vector
  3265. */
  3266. constructor(
  3267. /** x value of the vector */
  3268. x: number,
  3269. /** y value of the vector */
  3270. y: number,
  3271. /** z value of the vector */
  3272. z: number,
  3273. /** w value of the vector */
  3274. w: number);
  3275. /**
  3276. * Returns the string with the Vector4 coordinates.
  3277. * @returns a string containing all the vector values
  3278. */
  3279. toString(): string;
  3280. /**
  3281. * Returns the string "Vector4".
  3282. * @returns "Vector4"
  3283. */
  3284. getClassName(): string;
  3285. /**
  3286. * Returns the Vector4 hash code.
  3287. * @returns a unique hash code
  3288. */
  3289. getHashCode(): number;
  3290. /**
  3291. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3292. * @returns the resulting array
  3293. */
  3294. asArray(): number[];
  3295. /**
  3296. * Populates the given array from the given index with the Vector4 coordinates.
  3297. * @param array array to populate
  3298. * @param index index of the array to start at (default: 0)
  3299. * @returns the Vector4.
  3300. */
  3301. toArray(array: FloatArray, index?: number): Vector4;
  3302. /**
  3303. * Update the current vector from an array
  3304. * @param array defines the destination array
  3305. * @param index defines the offset in the destination array
  3306. * @returns the current Vector3
  3307. */
  3308. fromArray(array: FloatArray, index?: number): Vector4;
  3309. /**
  3310. * Adds the given vector to the current Vector4.
  3311. * @param otherVector the vector to add
  3312. * @returns the updated Vector4.
  3313. */
  3314. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3315. /**
  3316. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3317. * @param otherVector the vector to add
  3318. * @returns the resulting vector
  3319. */
  3320. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3321. /**
  3322. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3323. * @param otherVector the vector to add
  3324. * @param result the vector to store the result
  3325. * @returns the current Vector4.
  3326. */
  3327. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3328. /**
  3329. * Subtract in place the given vector from the current Vector4.
  3330. * @param otherVector the vector to subtract
  3331. * @returns the updated Vector4.
  3332. */
  3333. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3334. /**
  3335. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3336. * @param otherVector the vector to add
  3337. * @returns the new vector with the result
  3338. */
  3339. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3340. /**
  3341. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3342. * @param otherVector the vector to subtract
  3343. * @param result the vector to store the result
  3344. * @returns the current Vector4.
  3345. */
  3346. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3347. /**
  3348. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3349. */
  3350. /**
  3351. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3352. * @param x value to subtract
  3353. * @param y value to subtract
  3354. * @param z value to subtract
  3355. * @param w value to subtract
  3356. * @returns new vector containing the result
  3357. */
  3358. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3359. /**
  3360. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3361. * @param x value to subtract
  3362. * @param y value to subtract
  3363. * @param z value to subtract
  3364. * @param w value to subtract
  3365. * @param result the vector to store the result in
  3366. * @returns the current Vector4.
  3367. */
  3368. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3369. /**
  3370. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3371. * @returns a new vector with the negated values
  3372. */
  3373. negate(): Vector4;
  3374. /**
  3375. * Negate this vector in place
  3376. * @returns this
  3377. */
  3378. negateInPlace(): Vector4;
  3379. /**
  3380. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3381. * @param result defines the Vector3 object where to store the result
  3382. * @returns the current Vector4
  3383. */
  3384. negateToRef(result: Vector4): Vector4;
  3385. /**
  3386. * Multiplies the current Vector4 coordinates by scale (float).
  3387. * @param scale the number to scale with
  3388. * @returns the updated Vector4.
  3389. */
  3390. scaleInPlace(scale: number): Vector4;
  3391. /**
  3392. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3393. * @param scale the number to scale with
  3394. * @returns a new vector with the result
  3395. */
  3396. scale(scale: number): Vector4;
  3397. /**
  3398. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3399. * @param scale the number to scale with
  3400. * @param result a vector to store the result in
  3401. * @returns the current Vector4.
  3402. */
  3403. scaleToRef(scale: number, result: Vector4): Vector4;
  3404. /**
  3405. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3406. * @param scale defines the scale factor
  3407. * @param result defines the Vector4 object where to store the result
  3408. * @returns the unmodified current Vector4
  3409. */
  3410. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3411. /**
  3412. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3413. * @param otherVector the vector to compare against
  3414. * @returns true if they are equal
  3415. */
  3416. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3417. /**
  3418. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3419. * @param otherVector vector to compare against
  3420. * @param epsilon (Default: very small number)
  3421. * @returns true if they are equal
  3422. */
  3423. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3424. /**
  3425. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3426. * @param x x value to compare against
  3427. * @param y y value to compare against
  3428. * @param z z value to compare against
  3429. * @param w w value to compare against
  3430. * @returns true if equal
  3431. */
  3432. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3433. /**
  3434. * Multiplies in place the current Vector4 by the given one.
  3435. * @param otherVector vector to multiple with
  3436. * @returns the updated Vector4.
  3437. */
  3438. multiplyInPlace(otherVector: Vector4): Vector4;
  3439. /**
  3440. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3441. * @param otherVector vector to multiple with
  3442. * @returns resulting new vector
  3443. */
  3444. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3445. /**
  3446. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3447. * @param otherVector vector to multiple with
  3448. * @param result vector to store the result
  3449. * @returns the current Vector4.
  3450. */
  3451. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3452. /**
  3453. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3454. * @param x x value multiply with
  3455. * @param y y value multiply with
  3456. * @param z z value multiply with
  3457. * @param w w value multiply with
  3458. * @returns resulting new vector
  3459. */
  3460. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3461. /**
  3462. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3463. * @param otherVector vector to devide with
  3464. * @returns resulting new vector
  3465. */
  3466. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3467. /**
  3468. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3469. * @param otherVector vector to devide with
  3470. * @param result vector to store the result
  3471. * @returns the current Vector4.
  3472. */
  3473. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3474. /**
  3475. * Divides the current Vector3 coordinates by the given ones.
  3476. * @param otherVector vector to devide with
  3477. * @returns the updated Vector3.
  3478. */
  3479. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3480. /**
  3481. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3482. * @param other defines the second operand
  3483. * @returns the current updated Vector4
  3484. */
  3485. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3486. /**
  3487. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3488. * @param other defines the second operand
  3489. * @returns the current updated Vector4
  3490. */
  3491. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3492. /**
  3493. * Gets a new Vector4 from current Vector4 floored values
  3494. * @returns a new Vector4
  3495. */
  3496. floor(): Vector4;
  3497. /**
  3498. * Gets a new Vector4 from current Vector3 floored values
  3499. * @returns a new Vector4
  3500. */
  3501. fract(): Vector4;
  3502. /**
  3503. * Returns the Vector4 length (float).
  3504. * @returns the length
  3505. */
  3506. length(): number;
  3507. /**
  3508. * Returns the Vector4 squared length (float).
  3509. * @returns the length squared
  3510. */
  3511. lengthSquared(): number;
  3512. /**
  3513. * Normalizes in place the Vector4.
  3514. * @returns the updated Vector4.
  3515. */
  3516. normalize(): Vector4;
  3517. /**
  3518. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3519. * @returns this converted to a new vector3
  3520. */
  3521. toVector3(): Vector3;
  3522. /**
  3523. * Returns a new Vector4 copied from the current one.
  3524. * @returns the new cloned vector
  3525. */
  3526. clone(): Vector4;
  3527. /**
  3528. * Updates the current Vector4 with the given one coordinates.
  3529. * @param source the source vector to copy from
  3530. * @returns the updated Vector4.
  3531. */
  3532. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3533. /**
  3534. * Updates the current Vector4 coordinates with the given floats.
  3535. * @param x float to copy from
  3536. * @param y float to copy from
  3537. * @param z float to copy from
  3538. * @param w float to copy from
  3539. * @returns the updated Vector4.
  3540. */
  3541. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3542. /**
  3543. * Updates the current Vector4 coordinates with the given floats.
  3544. * @param x float to set from
  3545. * @param y float to set from
  3546. * @param z float to set from
  3547. * @param w float to set from
  3548. * @returns the updated Vector4.
  3549. */
  3550. set(x: number, y: number, z: number, w: number): Vector4;
  3551. /**
  3552. * Copies the given float to the current Vector3 coordinates
  3553. * @param v defines the x, y, z and w coordinates of the operand
  3554. * @returns the current updated Vector3
  3555. */
  3556. setAll(v: number): Vector4;
  3557. /**
  3558. * Returns a new Vector4 set from the starting index of the given array.
  3559. * @param array the array to pull values from
  3560. * @param offset the offset into the array to start at
  3561. * @returns the new vector
  3562. */
  3563. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3564. /**
  3565. * Updates the given vector "result" from the starting index of the given array.
  3566. * @param array the array to pull values from
  3567. * @param offset the offset into the array to start at
  3568. * @param result the vector to store the result in
  3569. */
  3570. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3571. /**
  3572. * Updates the given vector "result" from the starting index of the given Float32Array.
  3573. * @param array the array to pull values from
  3574. * @param offset the offset into the array to start at
  3575. * @param result the vector to store the result in
  3576. */
  3577. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3578. /**
  3579. * Updates the given vector "result" coordinates from the given floats.
  3580. * @param x float to set from
  3581. * @param y float to set from
  3582. * @param z float to set from
  3583. * @param w float to set from
  3584. * @param result the vector to the floats in
  3585. */
  3586. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3587. /**
  3588. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3589. * @returns the new vector
  3590. */
  3591. static Zero(): Vector4;
  3592. /**
  3593. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3594. * @returns the new vector
  3595. */
  3596. static One(): Vector4;
  3597. /**
  3598. * Returns a new normalized Vector4 from the given one.
  3599. * @param vector the vector to normalize
  3600. * @returns the vector
  3601. */
  3602. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3603. /**
  3604. * Updates the given vector "result" from the normalization of the given one.
  3605. * @param vector the vector to normalize
  3606. * @param result the vector to store the result in
  3607. */
  3608. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3609. /**
  3610. * Returns a vector with the minimum values from the left and right vectors
  3611. * @param left left vector to minimize
  3612. * @param right right vector to minimize
  3613. * @returns a new vector with the minimum of the left and right vector values
  3614. */
  3615. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3616. /**
  3617. * Returns a vector with the maximum values from the left and right vectors
  3618. * @param left left vector to maximize
  3619. * @param right right vector to maximize
  3620. * @returns a new vector with the maximum of the left and right vector values
  3621. */
  3622. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3623. /**
  3624. * Returns the distance (float) between the vectors "value1" and "value2".
  3625. * @param value1 value to calulate the distance between
  3626. * @param value2 value to calulate the distance between
  3627. * @return the distance between the two vectors
  3628. */
  3629. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3630. /**
  3631. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3632. * @param value1 value to calulate the distance between
  3633. * @param value2 value to calulate the distance between
  3634. * @return the distance between the two vectors squared
  3635. */
  3636. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3637. /**
  3638. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3639. * @param value1 value to calulate the center between
  3640. * @param value2 value to calulate the center between
  3641. * @return the center between the two vectors
  3642. */
  3643. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3644. /**
  3645. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3646. * This methods computes transformed normalized direction vectors only.
  3647. * @param vector the vector to transform
  3648. * @param transformation the transformation matrix to apply
  3649. * @returns the new vector
  3650. */
  3651. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3652. /**
  3653. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3654. * This methods computes transformed normalized direction vectors only.
  3655. * @param vector the vector to transform
  3656. * @param transformation the transformation matrix to apply
  3657. * @param result the vector to store the result in
  3658. */
  3659. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3660. /**
  3661. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3662. * This methods computes transformed normalized direction vectors only.
  3663. * @param x value to transform
  3664. * @param y value to transform
  3665. * @param z value to transform
  3666. * @param w value to transform
  3667. * @param transformation the transformation matrix to apply
  3668. * @param result the vector to store the results in
  3669. */
  3670. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3671. /**
  3672. * Creates a new Vector4 from a Vector3
  3673. * @param source defines the source data
  3674. * @param w defines the 4th component (default is 0)
  3675. * @returns a new Vector4
  3676. */
  3677. static FromVector3(source: Vector3, w?: number): Vector4;
  3678. }
  3679. /**
  3680. * Class used to store quaternion data
  3681. * @see https://en.wikipedia.org/wiki/Quaternion
  3682. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  3683. */
  3684. export class Quaternion {
  3685. /** @hidden */
  3686. _x: number;
  3687. /** @hidden */
  3688. _y: number;
  3689. /** @hidden */
  3690. _z: number;
  3691. /** @hidden */
  3692. _w: number;
  3693. /** @hidden */
  3694. _isDirty: boolean;
  3695. /** Gets or sets the x coordinate */
  3696. get x(): number;
  3697. set x(value: number);
  3698. /** Gets or sets the y coordinate */
  3699. get y(): number;
  3700. set y(value: number);
  3701. /** Gets or sets the z coordinate */
  3702. get z(): number;
  3703. set z(value: number);
  3704. /** Gets or sets the w coordinate */
  3705. get w(): number;
  3706. set w(value: number);
  3707. /**
  3708. * Creates a new Quaternion from the given floats
  3709. * @param x defines the first component (0 by default)
  3710. * @param y defines the second component (0 by default)
  3711. * @param z defines the third component (0 by default)
  3712. * @param w defines the fourth component (1.0 by default)
  3713. */
  3714. constructor(x?: number, y?: number, z?: number, w?: number);
  3715. /**
  3716. * Gets a string representation for the current quaternion
  3717. * @returns a string with the Quaternion coordinates
  3718. */
  3719. toString(): string;
  3720. /**
  3721. * Gets the class name of the quaternion
  3722. * @returns the string "Quaternion"
  3723. */
  3724. getClassName(): string;
  3725. /**
  3726. * Gets a hash code for this quaternion
  3727. * @returns the quaternion hash code
  3728. */
  3729. getHashCode(): number;
  3730. /**
  3731. * Copy the quaternion to an array
  3732. * @returns a new array populated with 4 elements from the quaternion coordinates
  3733. */
  3734. asArray(): number[];
  3735. /**
  3736. * Check if two quaternions are equals
  3737. * @param otherQuaternion defines the second operand
  3738. * @return true if the current quaternion and the given one coordinates are strictly equals
  3739. */
  3740. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3741. /**
  3742. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3743. * @param otherQuaternion defines the other quaternion
  3744. * @param epsilon defines the minimal distance to consider equality
  3745. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3746. */
  3747. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3748. /**
  3749. * Clone the current quaternion
  3750. * @returns a new quaternion copied from the current one
  3751. */
  3752. clone(): Quaternion;
  3753. /**
  3754. * Copy a quaternion to the current one
  3755. * @param other defines the other quaternion
  3756. * @returns the updated current quaternion
  3757. */
  3758. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3759. /**
  3760. * Updates the current quaternion with the given float coordinates
  3761. * @param x defines the x coordinate
  3762. * @param y defines the y coordinate
  3763. * @param z defines the z coordinate
  3764. * @param w defines the w coordinate
  3765. * @returns the updated current quaternion
  3766. */
  3767. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3768. /**
  3769. * Updates the current quaternion from the given float coordinates
  3770. * @param x defines the x coordinate
  3771. * @param y defines the y coordinate
  3772. * @param z defines the z coordinate
  3773. * @param w defines the w coordinate
  3774. * @returns the updated current quaternion
  3775. */
  3776. set(x: number, y: number, z: number, w: number): Quaternion;
  3777. /**
  3778. * Adds two quaternions
  3779. * @param other defines the second operand
  3780. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3781. */
  3782. add(other: DeepImmutable<Quaternion>): Quaternion;
  3783. /**
  3784. * Add a quaternion to the current one
  3785. * @param other defines the quaternion to add
  3786. * @returns the current quaternion
  3787. */
  3788. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3789. /**
  3790. * Subtract two quaternions
  3791. * @param other defines the second operand
  3792. * @returns a new quaternion as the subtraction result of the given one from the current one
  3793. */
  3794. subtract(other: Quaternion): Quaternion;
  3795. /**
  3796. * Multiplies the current quaternion by a scale factor
  3797. * @param value defines the scale factor
  3798. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3799. */
  3800. scale(value: number): Quaternion;
  3801. /**
  3802. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3803. * @param scale defines the scale factor
  3804. * @param result defines the Quaternion object where to store the result
  3805. * @returns the unmodified current quaternion
  3806. */
  3807. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3808. /**
  3809. * Multiplies in place the current quaternion by a scale factor
  3810. * @param value defines the scale factor
  3811. * @returns the current modified quaternion
  3812. */
  3813. scaleInPlace(value: number): Quaternion;
  3814. /**
  3815. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3816. * @param scale defines the scale factor
  3817. * @param result defines the Quaternion object where to store the result
  3818. * @returns the unmodified current quaternion
  3819. */
  3820. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3821. /**
  3822. * Multiplies two quaternions
  3823. * @param q1 defines the second operand
  3824. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3825. */
  3826. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3827. /**
  3828. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3829. * @param q1 defines the second operand
  3830. * @param result defines the target quaternion
  3831. * @returns the current quaternion
  3832. */
  3833. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3834. /**
  3835. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3836. * @param q1 defines the second operand
  3837. * @returns the currentupdated quaternion
  3838. */
  3839. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3840. /**
  3841. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3842. * @param ref defines the target quaternion
  3843. * @returns the current quaternion
  3844. */
  3845. conjugateToRef(ref: Quaternion): Quaternion;
  3846. /**
  3847. * Conjugates in place (1-q) the current quaternion
  3848. * @returns the current updated quaternion
  3849. */
  3850. conjugateInPlace(): Quaternion;
  3851. /**
  3852. * Conjugates in place (1-q) the current quaternion
  3853. * @returns a new quaternion
  3854. */
  3855. conjugate(): Quaternion;
  3856. /**
  3857. * Gets length of current quaternion
  3858. * @returns the quaternion length (float)
  3859. */
  3860. length(): number;
  3861. /**
  3862. * Normalize in place the current quaternion
  3863. * @returns the current updated quaternion
  3864. */
  3865. normalize(): Quaternion;
  3866. /**
  3867. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3868. * @param order is a reserved parameter and is ignore for now
  3869. * @returns a new Vector3 containing the Euler angles
  3870. */
  3871. toEulerAngles(order?: string): Vector3;
  3872. /**
  3873. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3874. * @param result defines the vector which will be filled with the Euler angles
  3875. * @param order is a reserved parameter and is ignore for now
  3876. * @returns the current unchanged quaternion
  3877. */
  3878. toEulerAnglesToRef(result: Vector3): Quaternion;
  3879. /**
  3880. * Updates the given rotation matrix with the current quaternion values
  3881. * @param result defines the target matrix
  3882. * @returns the current unchanged quaternion
  3883. */
  3884. toRotationMatrix(result: Matrix): Quaternion;
  3885. /**
  3886. * Updates the current quaternion from the given rotation matrix values
  3887. * @param matrix defines the source matrix
  3888. * @returns the current updated quaternion
  3889. */
  3890. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3891. /**
  3892. * Creates a new quaternion from a rotation matrix
  3893. * @param matrix defines the source matrix
  3894. * @returns a new quaternion created from the given rotation matrix values
  3895. */
  3896. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3897. /**
  3898. * Updates the given quaternion with the given rotation matrix values
  3899. * @param matrix defines the source matrix
  3900. * @param result defines the target quaternion
  3901. */
  3902. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3903. /**
  3904. * Returns the dot product (float) between the quaternions "left" and "right"
  3905. * @param left defines the left operand
  3906. * @param right defines the right operand
  3907. * @returns the dot product
  3908. */
  3909. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3910. /**
  3911. * Checks if the two quaternions are close to each other
  3912. * @param quat0 defines the first quaternion to check
  3913. * @param quat1 defines the second quaternion to check
  3914. * @returns true if the two quaternions are close to each other
  3915. */
  3916. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3917. /**
  3918. * Creates an empty quaternion
  3919. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3920. */
  3921. static Zero(): Quaternion;
  3922. /**
  3923. * Inverse a given quaternion
  3924. * @param q defines the source quaternion
  3925. * @returns a new quaternion as the inverted current quaternion
  3926. */
  3927. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3928. /**
  3929. * Inverse a given quaternion
  3930. * @param q defines the source quaternion
  3931. * @param result the quaternion the result will be stored in
  3932. * @returns the result quaternion
  3933. */
  3934. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3935. /**
  3936. * Creates an identity quaternion
  3937. * @returns the identity quaternion
  3938. */
  3939. static Identity(): Quaternion;
  3940. /**
  3941. * Gets a boolean indicating if the given quaternion is identity
  3942. * @param quaternion defines the quaternion to check
  3943. * @returns true if the quaternion is identity
  3944. */
  3945. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3946. /**
  3947. * Creates a quaternion from a rotation around an axis
  3948. * @param axis defines the axis to use
  3949. * @param angle defines the angle to use
  3950. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3951. */
  3952. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3953. /**
  3954. * Creates a rotation around an axis and stores it into the given quaternion
  3955. * @param axis defines the axis to use
  3956. * @param angle defines the angle to use
  3957. * @param result defines the target quaternion
  3958. * @returns the target quaternion
  3959. */
  3960. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3961. /**
  3962. * Creates a new quaternion from data stored into an array
  3963. * @param array defines the data source
  3964. * @param offset defines the offset in the source array where the data starts
  3965. * @returns a new quaternion
  3966. */
  3967. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3968. /**
  3969. * Updates the given quaternion "result" from the starting index of the given array.
  3970. * @param array the array to pull values from
  3971. * @param offset the offset into the array to start at
  3972. * @param result the quaternion to store the result in
  3973. */
  3974. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3975. /**
  3976. * Create a quaternion from Euler rotation angles
  3977. * @param x Pitch
  3978. * @param y Yaw
  3979. * @param z Roll
  3980. * @returns the new Quaternion
  3981. */
  3982. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3983. /**
  3984. * Updates a quaternion from Euler rotation angles
  3985. * @param x Pitch
  3986. * @param y Yaw
  3987. * @param z Roll
  3988. * @param result the quaternion to store the result
  3989. * @returns the updated quaternion
  3990. */
  3991. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3992. /**
  3993. * Create a quaternion from Euler rotation vector
  3994. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3995. * @returns the new Quaternion
  3996. */
  3997. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3998. /**
  3999. * Updates a quaternion from Euler rotation vector
  4000. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4001. * @param result the quaternion to store the result
  4002. * @returns the updated quaternion
  4003. */
  4004. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4005. /**
  4006. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4007. * @param yaw defines the rotation around Y axis
  4008. * @param pitch defines the rotation around X axis
  4009. * @param roll defines the rotation around Z axis
  4010. * @returns the new quaternion
  4011. */
  4012. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4013. /**
  4014. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4015. * @param yaw defines the rotation around Y axis
  4016. * @param pitch defines the rotation around X axis
  4017. * @param roll defines the rotation around Z axis
  4018. * @param result defines the target quaternion
  4019. */
  4020. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4021. /**
  4022. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4023. * @param alpha defines the rotation around first axis
  4024. * @param beta defines the rotation around second axis
  4025. * @param gamma defines the rotation around third axis
  4026. * @returns the new quaternion
  4027. */
  4028. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4029. /**
  4030. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4031. * @param alpha defines the rotation around first axis
  4032. * @param beta defines the rotation around second axis
  4033. * @param gamma defines the rotation around third axis
  4034. * @param result defines the target quaternion
  4035. */
  4036. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4037. /**
  4038. * 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)
  4039. * @param axis1 defines the first axis
  4040. * @param axis2 defines the second axis
  4041. * @param axis3 defines the third axis
  4042. * @returns the new quaternion
  4043. */
  4044. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4045. /**
  4046. * 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
  4047. * @param axis1 defines the first axis
  4048. * @param axis2 defines the second axis
  4049. * @param axis3 defines the third axis
  4050. * @param ref defines the target quaternion
  4051. */
  4052. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4053. /**
  4054. * Interpolates between two quaternions
  4055. * @param left defines first quaternion
  4056. * @param right defines second quaternion
  4057. * @param amount defines the gradient to use
  4058. * @returns the new interpolated quaternion
  4059. */
  4060. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4061. /**
  4062. * Interpolates between two quaternions and stores it into a target quaternion
  4063. * @param left defines first quaternion
  4064. * @param right defines second quaternion
  4065. * @param amount defines the gradient to use
  4066. * @param result defines the target quaternion
  4067. */
  4068. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4069. /**
  4070. * Interpolate between two quaternions using Hermite interpolation
  4071. * @param value1 defines first quaternion
  4072. * @param tangent1 defines the incoming tangent
  4073. * @param value2 defines second quaternion
  4074. * @param tangent2 defines the outgoing tangent
  4075. * @param amount defines the target quaternion
  4076. * @returns the new interpolated quaternion
  4077. */
  4078. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4079. }
  4080. /**
  4081. * Class used to store matrix data (4x4)
  4082. */
  4083. export class Matrix {
  4084. /**
  4085. * Gets the precision of matrix computations
  4086. */
  4087. static get Use64Bits(): boolean;
  4088. private static _updateFlagSeed;
  4089. private static _identityReadOnly;
  4090. private _isIdentity;
  4091. private _isIdentityDirty;
  4092. private _isIdentity3x2;
  4093. private _isIdentity3x2Dirty;
  4094. /**
  4095. * Gets the update flag of the matrix which is an unique number for the matrix.
  4096. * It will be incremented every time the matrix data change.
  4097. * You can use it to speed the comparison between two versions of the same matrix.
  4098. */
  4099. updateFlag: number;
  4100. private readonly _m;
  4101. /**
  4102. * Gets the internal data of the matrix
  4103. */
  4104. get m(): DeepImmutable<Float32Array | Array<number>>;
  4105. /** @hidden */
  4106. _markAsUpdated(): void;
  4107. /** @hidden */
  4108. private _updateIdentityStatus;
  4109. /**
  4110. * Creates an empty matrix (filled with zeros)
  4111. */
  4112. constructor();
  4113. /**
  4114. * Check if the current matrix is identity
  4115. * @returns true is the matrix is the identity matrix
  4116. */
  4117. isIdentity(): boolean;
  4118. /**
  4119. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4120. * @returns true is the matrix is the identity matrix
  4121. */
  4122. isIdentityAs3x2(): boolean;
  4123. /**
  4124. * Gets the determinant of the matrix
  4125. * @returns the matrix determinant
  4126. */
  4127. determinant(): number;
  4128. /**
  4129. * Returns the matrix as a Float32Array or Array<number>
  4130. * @returns the matrix underlying array
  4131. */
  4132. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4133. /**
  4134. * Returns the matrix as a Float32Array or Array<number>
  4135. * @returns the matrix underlying array.
  4136. */
  4137. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4138. /**
  4139. * Inverts the current matrix in place
  4140. * @returns the current inverted matrix
  4141. */
  4142. invert(): Matrix;
  4143. /**
  4144. * Sets all the matrix elements to zero
  4145. * @returns the current matrix
  4146. */
  4147. reset(): Matrix;
  4148. /**
  4149. * Adds the current matrix with a second one
  4150. * @param other defines the matrix to add
  4151. * @returns a new matrix as the addition of the current matrix and the given one
  4152. */
  4153. add(other: DeepImmutable<Matrix>): Matrix;
  4154. /**
  4155. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4156. * @param other defines the matrix to add
  4157. * @param result defines the target matrix
  4158. * @returns the current matrix
  4159. */
  4160. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4161. /**
  4162. * Adds in place the given matrix to the current matrix
  4163. * @param other defines the second operand
  4164. * @returns the current updated matrix
  4165. */
  4166. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4167. /**
  4168. * Sets the given matrix to the current inverted Matrix
  4169. * @param other defines the target matrix
  4170. * @returns the unmodified current matrix
  4171. */
  4172. invertToRef(other: Matrix): Matrix;
  4173. /**
  4174. * add a value at the specified position in the current Matrix
  4175. * @param index the index of the value within the matrix. between 0 and 15.
  4176. * @param value the value to be added
  4177. * @returns the current updated matrix
  4178. */
  4179. addAtIndex(index: number, value: number): Matrix;
  4180. /**
  4181. * mutiply the specified position in the current Matrix by a value
  4182. * @param index the index of the value within the matrix. between 0 and 15.
  4183. * @param value the value to be added
  4184. * @returns the current updated matrix
  4185. */
  4186. multiplyAtIndex(index: number, value: number): Matrix;
  4187. /**
  4188. * Inserts the translation vector (using 3 floats) in the current matrix
  4189. * @param x defines the 1st component of the translation
  4190. * @param y defines the 2nd component of the translation
  4191. * @param z defines the 3rd component of the translation
  4192. * @returns the current updated matrix
  4193. */
  4194. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4195. /**
  4196. * Adds the translation vector (using 3 floats) in the current matrix
  4197. * @param x defines the 1st component of the translation
  4198. * @param y defines the 2nd component of the translation
  4199. * @param z defines the 3rd component of the translation
  4200. * @returns the current updated matrix
  4201. */
  4202. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4203. /**
  4204. * Inserts the translation vector in the current matrix
  4205. * @param vector3 defines the translation to insert
  4206. * @returns the current updated matrix
  4207. */
  4208. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4209. /**
  4210. * Gets the translation value of the current matrix
  4211. * @returns a new Vector3 as the extracted translation from the matrix
  4212. */
  4213. getTranslation(): Vector3;
  4214. /**
  4215. * Fill a Vector3 with the extracted translation from the matrix
  4216. * @param result defines the Vector3 where to store the translation
  4217. * @returns the current matrix
  4218. */
  4219. getTranslationToRef(result: Vector3): Matrix;
  4220. /**
  4221. * Remove rotation and scaling part from the matrix
  4222. * @returns the updated matrix
  4223. */
  4224. removeRotationAndScaling(): Matrix;
  4225. /**
  4226. * Multiply two matrices
  4227. * @param other defines the second operand
  4228. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4229. */
  4230. multiply(other: DeepImmutable<Matrix>): Matrix;
  4231. /**
  4232. * Copy the current matrix from the given one
  4233. * @param other defines the source matrix
  4234. * @returns the current updated matrix
  4235. */
  4236. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4237. /**
  4238. * Populates the given array from the starting index with the current matrix values
  4239. * @param array defines the target array
  4240. * @param offset defines the offset in the target array where to start storing values
  4241. * @returns the current matrix
  4242. */
  4243. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4244. /**
  4245. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4246. * @param other defines the second operand
  4247. * @param result defines the matrix where to store the multiplication
  4248. * @returns the current matrix
  4249. */
  4250. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4251. /**
  4252. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4253. * @param other defines the second operand
  4254. * @param result defines the array where to store the multiplication
  4255. * @param offset defines the offset in the target array where to start storing values
  4256. * @returns the current matrix
  4257. */
  4258. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4259. /**
  4260. * Check equality between this matrix and a second one
  4261. * @param value defines the second matrix to compare
  4262. * @returns true is the current matrix and the given one values are strictly equal
  4263. */
  4264. equals(value: DeepImmutable<Matrix>): boolean;
  4265. /**
  4266. * Clone the current matrix
  4267. * @returns a new matrix from the current matrix
  4268. */
  4269. clone(): Matrix;
  4270. /**
  4271. * Returns the name of the current matrix class
  4272. * @returns the string "Matrix"
  4273. */
  4274. getClassName(): string;
  4275. /**
  4276. * Gets the hash code of the current matrix
  4277. * @returns the hash code
  4278. */
  4279. getHashCode(): number;
  4280. /**
  4281. * Decomposes the current Matrix into a translation, rotation and scaling components
  4282. * @param scale defines the scale vector3 given as a reference to update
  4283. * @param rotation defines the rotation quaternion given as a reference to update
  4284. * @param translation defines the translation vector3 given as a reference to update
  4285. * @returns true if operation was successful
  4286. */
  4287. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4288. /**
  4289. * Gets specific row of the matrix
  4290. * @param index defines the number of the row to get
  4291. * @returns the index-th row of the current matrix as a new Vector4
  4292. */
  4293. getRow(index: number): Nullable<Vector4>;
  4294. /**
  4295. * Sets the index-th row of the current matrix to the vector4 values
  4296. * @param index defines the number of the row to set
  4297. * @param row defines the target vector4
  4298. * @returns the updated current matrix
  4299. */
  4300. setRow(index: number, row: Vector4): Matrix;
  4301. /**
  4302. * Compute the transpose of the matrix
  4303. * @returns the new transposed matrix
  4304. */
  4305. transpose(): Matrix;
  4306. /**
  4307. * Compute the transpose of the matrix and store it in a given matrix
  4308. * @param result defines the target matrix
  4309. * @returns the current matrix
  4310. */
  4311. transposeToRef(result: Matrix): Matrix;
  4312. /**
  4313. * Sets the index-th row of the current matrix with the given 4 x float values
  4314. * @param index defines the row index
  4315. * @param x defines the x component to set
  4316. * @param y defines the y component to set
  4317. * @param z defines the z component to set
  4318. * @param w defines the w component to set
  4319. * @returns the updated current matrix
  4320. */
  4321. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4322. /**
  4323. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4324. * @param scale defines the scale factor
  4325. * @returns a new matrix
  4326. */
  4327. scale(scale: number): Matrix;
  4328. /**
  4329. * Scale the current matrix values by a factor to a given result matrix
  4330. * @param scale defines the scale factor
  4331. * @param result defines the matrix to store the result
  4332. * @returns the current matrix
  4333. */
  4334. scaleToRef(scale: number, result: Matrix): Matrix;
  4335. /**
  4336. * Scale the current matrix values by a factor and add the result to a given matrix
  4337. * @param scale defines the scale factor
  4338. * @param result defines the Matrix to store the result
  4339. * @returns the current matrix
  4340. */
  4341. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4342. /**
  4343. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4344. * @param ref matrix to store the result
  4345. */
  4346. toNormalMatrix(ref: Matrix): void;
  4347. /**
  4348. * Gets only rotation part of the current matrix
  4349. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4350. */
  4351. getRotationMatrix(): Matrix;
  4352. /**
  4353. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4354. * @param result defines the target matrix to store data to
  4355. * @returns the current matrix
  4356. */
  4357. getRotationMatrixToRef(result: Matrix): Matrix;
  4358. /**
  4359. * Toggles model matrix from being right handed to left handed in place and vice versa
  4360. */
  4361. toggleModelMatrixHandInPlace(): void;
  4362. /**
  4363. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4364. */
  4365. toggleProjectionMatrixHandInPlace(): void;
  4366. /**
  4367. * Creates a matrix from an array
  4368. * @param array defines the source array
  4369. * @param offset defines an offset in the source array
  4370. * @returns a new Matrix set from the starting index of the given array
  4371. */
  4372. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4373. /**
  4374. * Copy the content of an array into a given matrix
  4375. * @param array defines the source array
  4376. * @param offset defines an offset in the source array
  4377. * @param result defines the target matrix
  4378. */
  4379. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4380. /**
  4381. * Stores an array into a matrix after having multiplied each component by a given factor
  4382. * @param array defines the source array
  4383. * @param offset defines the offset in the source array
  4384. * @param scale defines the scaling factor
  4385. * @param result defines the target matrix
  4386. */
  4387. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4388. /**
  4389. * Gets an identity matrix that must not be updated
  4390. */
  4391. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4392. /**
  4393. * Stores a list of values (16) inside a given matrix
  4394. * @param initialM11 defines 1st value of 1st row
  4395. * @param initialM12 defines 2nd value of 1st row
  4396. * @param initialM13 defines 3rd value of 1st row
  4397. * @param initialM14 defines 4th value of 1st row
  4398. * @param initialM21 defines 1st value of 2nd row
  4399. * @param initialM22 defines 2nd value of 2nd row
  4400. * @param initialM23 defines 3rd value of 2nd row
  4401. * @param initialM24 defines 4th value of 2nd row
  4402. * @param initialM31 defines 1st value of 3rd row
  4403. * @param initialM32 defines 2nd value of 3rd row
  4404. * @param initialM33 defines 3rd value of 3rd row
  4405. * @param initialM34 defines 4th value of 3rd row
  4406. * @param initialM41 defines 1st value of 4th row
  4407. * @param initialM42 defines 2nd value of 4th row
  4408. * @param initialM43 defines 3rd value of 4th row
  4409. * @param initialM44 defines 4th value of 4th row
  4410. * @param result defines the target matrix
  4411. */
  4412. 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;
  4413. /**
  4414. * Creates new matrix from a list of values (16)
  4415. * @param initialM11 defines 1st value of 1st row
  4416. * @param initialM12 defines 2nd value of 1st row
  4417. * @param initialM13 defines 3rd value of 1st row
  4418. * @param initialM14 defines 4th value of 1st row
  4419. * @param initialM21 defines 1st value of 2nd row
  4420. * @param initialM22 defines 2nd value of 2nd row
  4421. * @param initialM23 defines 3rd value of 2nd row
  4422. * @param initialM24 defines 4th value of 2nd row
  4423. * @param initialM31 defines 1st value of 3rd row
  4424. * @param initialM32 defines 2nd value of 3rd row
  4425. * @param initialM33 defines 3rd value of 3rd row
  4426. * @param initialM34 defines 4th value of 3rd row
  4427. * @param initialM41 defines 1st value of 4th row
  4428. * @param initialM42 defines 2nd value of 4th row
  4429. * @param initialM43 defines 3rd value of 4th row
  4430. * @param initialM44 defines 4th value of 4th row
  4431. * @returns the new matrix
  4432. */
  4433. 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;
  4434. /**
  4435. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4436. * @param scale defines the scale vector3
  4437. * @param rotation defines the rotation quaternion
  4438. * @param translation defines the translation vector3
  4439. * @returns a new matrix
  4440. */
  4441. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4442. /**
  4443. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4444. * @param scale defines the scale vector3
  4445. * @param rotation defines the rotation quaternion
  4446. * @param translation defines the translation vector3
  4447. * @param result defines the target matrix
  4448. */
  4449. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4450. /**
  4451. * Creates a new identity matrix
  4452. * @returns a new identity matrix
  4453. */
  4454. static Identity(): Matrix;
  4455. /**
  4456. * Creates a new identity matrix and stores the result in a given matrix
  4457. * @param result defines the target matrix
  4458. */
  4459. static IdentityToRef(result: Matrix): void;
  4460. /**
  4461. * Creates a new zero matrix
  4462. * @returns a new zero matrix
  4463. */
  4464. static Zero(): Matrix;
  4465. /**
  4466. * Creates a new rotation matrix for "angle" radians around the X axis
  4467. * @param angle defines the angle (in radians) to use
  4468. * @return the new matrix
  4469. */
  4470. static RotationX(angle: number): Matrix;
  4471. /**
  4472. * Creates a new matrix as the invert of a given matrix
  4473. * @param source defines the source matrix
  4474. * @returns the new matrix
  4475. */
  4476. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4477. /**
  4478. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4479. * @param angle defines the angle (in radians) to use
  4480. * @param result defines the target matrix
  4481. */
  4482. static RotationXToRef(angle: number, result: Matrix): void;
  4483. /**
  4484. * Creates a new rotation matrix for "angle" radians around the Y axis
  4485. * @param angle defines the angle (in radians) to use
  4486. * @return the new matrix
  4487. */
  4488. static RotationY(angle: number): Matrix;
  4489. /**
  4490. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4491. * @param angle defines the angle (in radians) to use
  4492. * @param result defines the target matrix
  4493. */
  4494. static RotationYToRef(angle: number, result: Matrix): void;
  4495. /**
  4496. * Creates a new rotation matrix for "angle" radians around the Z axis
  4497. * @param angle defines the angle (in radians) to use
  4498. * @return the new matrix
  4499. */
  4500. static RotationZ(angle: number): Matrix;
  4501. /**
  4502. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4503. * @param angle defines the angle (in radians) to use
  4504. * @param result defines the target matrix
  4505. */
  4506. static RotationZToRef(angle: number, result: Matrix): void;
  4507. /**
  4508. * Creates a new rotation matrix for "angle" radians around the given axis
  4509. * @param axis defines the axis to use
  4510. * @param angle defines the angle (in radians) to use
  4511. * @return the new matrix
  4512. */
  4513. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4514. /**
  4515. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4516. * @param axis defines the axis to use
  4517. * @param angle defines the angle (in radians) to use
  4518. * @param result defines the target matrix
  4519. */
  4520. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4521. /**
  4522. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4523. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4524. * @param from defines the vector to align
  4525. * @param to defines the vector to align to
  4526. * @param result defines the target matrix
  4527. */
  4528. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4529. /**
  4530. * Creates a rotation matrix
  4531. * @param yaw defines the yaw angle in radians (Y axis)
  4532. * @param pitch defines the pitch angle in radians (X axis)
  4533. * @param roll defines the roll angle in radians (Z axis)
  4534. * @returns the new rotation matrix
  4535. */
  4536. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4537. /**
  4538. * Creates a rotation matrix and stores it in a given matrix
  4539. * @param yaw defines the yaw angle in radians (Y axis)
  4540. * @param pitch defines the pitch angle in radians (X axis)
  4541. * @param roll defines the roll angle in radians (Z axis)
  4542. * @param result defines the target matrix
  4543. */
  4544. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4545. /**
  4546. * Creates a scaling matrix
  4547. * @param x defines the scale factor on X axis
  4548. * @param y defines the scale factor on Y axis
  4549. * @param z defines the scale factor on Z axis
  4550. * @returns the new matrix
  4551. */
  4552. static Scaling(x: number, y: number, z: number): Matrix;
  4553. /**
  4554. * Creates a scaling matrix and stores it in a given matrix
  4555. * @param x defines the scale factor on X axis
  4556. * @param y defines the scale factor on Y axis
  4557. * @param z defines the scale factor on Z axis
  4558. * @param result defines the target matrix
  4559. */
  4560. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4561. /**
  4562. * Creates a translation matrix
  4563. * @param x defines the translation on X axis
  4564. * @param y defines the translation on Y axis
  4565. * @param z defines the translationon Z axis
  4566. * @returns the new matrix
  4567. */
  4568. static Translation(x: number, y: number, z: number): Matrix;
  4569. /**
  4570. * Creates a translation matrix and stores it in a given matrix
  4571. * @param x defines the translation on X axis
  4572. * @param y defines the translation on Y axis
  4573. * @param z defines the translationon Z axis
  4574. * @param result defines the target matrix
  4575. */
  4576. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4577. /**
  4578. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4579. * @param startValue defines the start value
  4580. * @param endValue defines the end value
  4581. * @param gradient defines the gradient factor
  4582. * @returns the new matrix
  4583. */
  4584. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4585. /**
  4586. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4587. * @param startValue defines the start value
  4588. * @param endValue defines the end value
  4589. * @param gradient defines the gradient factor
  4590. * @param result defines the Matrix object where to store data
  4591. */
  4592. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4593. /**
  4594. * Builds a new matrix whose values are computed by:
  4595. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4596. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4597. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4598. * @param startValue defines the first matrix
  4599. * @param endValue defines the second matrix
  4600. * @param gradient defines the gradient between the two matrices
  4601. * @returns the new matrix
  4602. */
  4603. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4604. /**
  4605. * Update a matrix to values which are computed by:
  4606. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4607. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4608. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4609. * @param startValue defines the first matrix
  4610. * @param endValue defines the second matrix
  4611. * @param gradient defines the gradient between the two matrices
  4612. * @param result defines the target matrix
  4613. */
  4614. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4615. /**
  4616. * 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"
  4617. * This function works in left handed mode
  4618. * @param eye defines the final position of the entity
  4619. * @param target defines where the entity should look at
  4620. * @param up defines the up vector for the entity
  4621. * @returns the new matrix
  4622. */
  4623. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4624. /**
  4625. * 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".
  4626. * This function works in left handed mode
  4627. * @param eye defines the final position of the entity
  4628. * @param target defines where the entity should look at
  4629. * @param up defines the up vector for the entity
  4630. * @param result defines the target matrix
  4631. */
  4632. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, 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 right 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 LookAtRH(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 right 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 LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4651. /**
  4652. * Create a left-handed orthographic projection matrix
  4653. * @param width defines the viewport width
  4654. * @param height defines the viewport height
  4655. * @param znear defines the near clip plane
  4656. * @param zfar defines the far clip plane
  4657. * @returns a new matrix as a left-handed orthographic projection matrix
  4658. */
  4659. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4660. /**
  4661. * Store a left-handed orthographic projection to a given matrix
  4662. * @param width defines the viewport width
  4663. * @param height defines the viewport height
  4664. * @param znear defines the near clip plane
  4665. * @param zfar defines the far clip plane
  4666. * @param result defines the target matrix
  4667. */
  4668. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4669. /**
  4670. * Create a left-handed orthographic projection matrix
  4671. * @param left defines the viewport left coordinate
  4672. * @param right defines the viewport right coordinate
  4673. * @param bottom defines the viewport bottom coordinate
  4674. * @param top defines the viewport top coordinate
  4675. * @param znear defines the near clip plane
  4676. * @param zfar defines the far clip plane
  4677. * @returns a new matrix as a left-handed orthographic projection matrix
  4678. */
  4679. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4680. /**
  4681. * Stores a left-handed orthographic projection into a given matrix
  4682. * @param left defines the viewport left coordinate
  4683. * @param right defines the viewport right coordinate
  4684. * @param bottom defines the viewport bottom coordinate
  4685. * @param top defines the viewport top coordinate
  4686. * @param znear defines the near clip plane
  4687. * @param zfar defines the far clip plane
  4688. * @param result defines the target matrix
  4689. */
  4690. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4691. /**
  4692. * Creates a right-handed orthographic projection matrix
  4693. * @param left defines the viewport left coordinate
  4694. * @param right defines the viewport right coordinate
  4695. * @param bottom defines the viewport bottom coordinate
  4696. * @param top defines the viewport top coordinate
  4697. * @param znear defines the near clip plane
  4698. * @param zfar defines the far clip plane
  4699. * @returns a new matrix as a right-handed orthographic projection matrix
  4700. */
  4701. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4702. /**
  4703. * Stores a right-handed orthographic projection into a given matrix
  4704. * @param left defines the viewport left coordinate
  4705. * @param right defines the viewport right coordinate
  4706. * @param bottom defines the viewport bottom coordinate
  4707. * @param top defines the viewport top coordinate
  4708. * @param znear defines the near clip plane
  4709. * @param zfar defines the far clip plane
  4710. * @param result defines the target matrix
  4711. */
  4712. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4713. /**
  4714. * Creates a left-handed perspective projection matrix
  4715. * @param width defines the viewport width
  4716. * @param height defines the viewport height
  4717. * @param znear defines the near clip plane
  4718. * @param zfar defines the far clip plane
  4719. * @returns a new matrix as a left-handed perspective projection matrix
  4720. */
  4721. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4722. /**
  4723. * Creates a left-handed perspective projection matrix
  4724. * @param fov defines the horizontal field of view
  4725. * @param aspect defines the aspect ratio
  4726. * @param znear defines the near clip plane
  4727. * @param zfar defines the far clip plane
  4728. * @returns a new matrix as a left-handed perspective projection matrix
  4729. */
  4730. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4731. /**
  4732. * Stores a left-handed perspective projection into a given matrix
  4733. * @param fov defines the horizontal field of view
  4734. * @param aspect defines the aspect ratio
  4735. * @param znear defines the near clip plane
  4736. * @param zfar defines the far clip plane
  4737. * @param result defines the target matrix
  4738. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4739. */
  4740. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4741. /**
  4742. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4743. * @param fov defines the horizontal field of view
  4744. * @param aspect defines the aspect ratio
  4745. * @param znear defines the near clip plane
  4746. * @param zfar not used as infinity is used as far clip
  4747. * @param result defines the target matrix
  4748. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4749. */
  4750. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4751. /**
  4752. * Creates a right-handed perspective projection matrix
  4753. * @param fov defines the horizontal field of view
  4754. * @param aspect defines the aspect ratio
  4755. * @param znear defines the near clip plane
  4756. * @param zfar defines the far clip plane
  4757. * @returns a new matrix as a right-handed perspective projection matrix
  4758. */
  4759. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4760. /**
  4761. * Stores a right-handed perspective projection into a given matrix
  4762. * @param fov defines the horizontal field of view
  4763. * @param aspect defines the aspect ratio
  4764. * @param znear defines the near clip plane
  4765. * @param zfar defines the far clip plane
  4766. * @param result defines the target matrix
  4767. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4768. */
  4769. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4770. /**
  4771. * Stores a right-handed perspective projection into a given matrix
  4772. * @param fov defines the horizontal field of view
  4773. * @param aspect defines the aspect ratio
  4774. * @param znear defines the near clip plane
  4775. * @param zfar not used as infinity is used as far clip
  4776. * @param result defines the target matrix
  4777. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4778. */
  4779. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4780. /**
  4781. * Stores a perspective projection for WebVR info a given matrix
  4782. * @param fov defines the field of view
  4783. * @param znear defines the near clip plane
  4784. * @param zfar defines the far clip plane
  4785. * @param result defines the target matrix
  4786. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4787. */
  4788. static PerspectiveFovWebVRToRef(fov: {
  4789. upDegrees: number;
  4790. downDegrees: number;
  4791. leftDegrees: number;
  4792. rightDegrees: number;
  4793. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4794. /**
  4795. * Computes a complete transformation matrix
  4796. * @param viewport defines the viewport to use
  4797. * @param world defines the world matrix
  4798. * @param view defines the view matrix
  4799. * @param projection defines the projection matrix
  4800. * @param zmin defines the near clip plane
  4801. * @param zmax defines the far clip plane
  4802. * @returns the transformation matrix
  4803. */
  4804. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4805. /**
  4806. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4807. * @param matrix defines the matrix to use
  4808. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4809. */
  4810. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4811. /**
  4812. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4813. * @param matrix defines the matrix to use
  4814. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4815. */
  4816. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4817. /**
  4818. * Compute the transpose of a given matrix
  4819. * @param matrix defines the matrix to transpose
  4820. * @returns the new matrix
  4821. */
  4822. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4823. /**
  4824. * Compute the transpose of a matrix and store it in a target matrix
  4825. * @param matrix defines the matrix to transpose
  4826. * @param result defines the target matrix
  4827. */
  4828. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4829. /**
  4830. * Computes a reflection matrix from a plane
  4831. * @param plane defines the reflection plane
  4832. * @returns a new matrix
  4833. */
  4834. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4835. /**
  4836. * Computes a reflection matrix from a plane
  4837. * @param plane defines the reflection plane
  4838. * @param result defines the target matrix
  4839. */
  4840. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4841. /**
  4842. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4843. * @param xaxis defines the value of the 1st axis
  4844. * @param yaxis defines the value of the 2nd axis
  4845. * @param zaxis defines the value of the 3rd axis
  4846. * @param result defines the target matrix
  4847. */
  4848. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4849. /**
  4850. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4851. * @param quat defines the quaternion to use
  4852. * @param result defines the target matrix
  4853. */
  4854. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4855. }
  4856. /**
  4857. * @hidden
  4858. */
  4859. export class TmpVectors {
  4860. static Vector2: Vector2[];
  4861. static Vector3: Vector3[];
  4862. static Vector4: Vector4[];
  4863. static Quaternion: Quaternion[];
  4864. static Matrix: Matrix[];
  4865. }
  4866. }
  4867. declare module "babylonjs/Maths/math.path" {
  4868. import { DeepImmutable, Nullable } from "babylonjs/types";
  4869. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4870. /**
  4871. * Defines potential orientation for back face culling
  4872. */
  4873. export enum Orientation {
  4874. /**
  4875. * Clockwise
  4876. */
  4877. CW = 0,
  4878. /** Counter clockwise */
  4879. CCW = 1
  4880. }
  4881. /** Class used to represent a Bezier curve */
  4882. export class BezierCurve {
  4883. /**
  4884. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4885. * @param t defines the time
  4886. * @param x1 defines the left coordinate on X axis
  4887. * @param y1 defines the left coordinate on Y axis
  4888. * @param x2 defines the right coordinate on X axis
  4889. * @param y2 defines the right coordinate on Y axis
  4890. * @returns the interpolated value
  4891. */
  4892. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4893. }
  4894. /**
  4895. * Defines angle representation
  4896. */
  4897. export class Angle {
  4898. private _radians;
  4899. /**
  4900. * Creates an Angle object of "radians" radians (float).
  4901. * @param radians the angle in radians
  4902. */
  4903. constructor(radians: number);
  4904. /**
  4905. * Get value in degrees
  4906. * @returns the Angle value in degrees (float)
  4907. */
  4908. degrees(): number;
  4909. /**
  4910. * Get value in radians
  4911. * @returns the Angle value in radians (float)
  4912. */
  4913. radians(): number;
  4914. /**
  4915. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  4916. * @param a defines first point as the origin
  4917. * @param b defines point
  4918. * @returns a new Angle
  4919. */
  4920. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4921. /**
  4922. * Gets a new Angle object from the given float in radians
  4923. * @param radians defines the angle value in radians
  4924. * @returns a new Angle
  4925. */
  4926. static FromRadians(radians: number): Angle;
  4927. /**
  4928. * Gets a new Angle object from the given float in degrees
  4929. * @param degrees defines the angle value in degrees
  4930. * @returns a new Angle
  4931. */
  4932. static FromDegrees(degrees: number): Angle;
  4933. }
  4934. /**
  4935. * This represents an arc in a 2d space.
  4936. */
  4937. export class Arc2 {
  4938. /** Defines the start point of the arc */
  4939. startPoint: Vector2;
  4940. /** Defines the mid point of the arc */
  4941. midPoint: Vector2;
  4942. /** Defines the end point of the arc */
  4943. endPoint: Vector2;
  4944. /**
  4945. * Defines the center point of the arc.
  4946. */
  4947. centerPoint: Vector2;
  4948. /**
  4949. * Defines the radius of the arc.
  4950. */
  4951. radius: number;
  4952. /**
  4953. * Defines the angle of the arc (from mid point to end point).
  4954. */
  4955. angle: Angle;
  4956. /**
  4957. * Defines the start angle of the arc (from start point to middle point).
  4958. */
  4959. startAngle: Angle;
  4960. /**
  4961. * Defines the orientation of the arc (clock wise/counter clock wise).
  4962. */
  4963. orientation: Orientation;
  4964. /**
  4965. * Creates an Arc object from the three given points : start, middle and end.
  4966. * @param startPoint Defines the start point of the arc
  4967. * @param midPoint Defines the midlle point of the arc
  4968. * @param endPoint Defines the end point of the arc
  4969. */
  4970. constructor(
  4971. /** Defines the start point of the arc */
  4972. startPoint: Vector2,
  4973. /** Defines the mid point of the arc */
  4974. midPoint: Vector2,
  4975. /** Defines the end point of the arc */
  4976. endPoint: Vector2);
  4977. }
  4978. /**
  4979. * Represents a 2D path made up of multiple 2D points
  4980. */
  4981. export class Path2 {
  4982. private _points;
  4983. private _length;
  4984. /**
  4985. * If the path start and end point are the same
  4986. */
  4987. closed: boolean;
  4988. /**
  4989. * Creates a Path2 object from the starting 2D coordinates x and y.
  4990. * @param x the starting points x value
  4991. * @param y the starting points y value
  4992. */
  4993. constructor(x: number, y: number);
  4994. /**
  4995. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4996. * @param x the added points x value
  4997. * @param y the added points y value
  4998. * @returns the updated Path2.
  4999. */
  5000. addLineTo(x: number, y: number): Path2;
  5001. /**
  5002. * 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.
  5003. * @param midX middle point x value
  5004. * @param midY middle point y value
  5005. * @param endX end point x value
  5006. * @param endY end point y value
  5007. * @param numberOfSegments (default: 36)
  5008. * @returns the updated Path2.
  5009. */
  5010. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5011. /**
  5012. * Closes the Path2.
  5013. * @returns the Path2.
  5014. */
  5015. close(): Path2;
  5016. /**
  5017. * Gets the sum of the distance between each sequential point in the path
  5018. * @returns the Path2 total length (float).
  5019. */
  5020. length(): number;
  5021. /**
  5022. * Gets the points which construct the path
  5023. * @returns the Path2 internal array of points.
  5024. */
  5025. getPoints(): Vector2[];
  5026. /**
  5027. * Retreives the point at the distance aways from the starting point
  5028. * @param normalizedLengthPosition the length along the path to retreive the point from
  5029. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5030. */
  5031. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5032. /**
  5033. * Creates a new path starting from an x and y position
  5034. * @param x starting x value
  5035. * @param y starting y value
  5036. * @returns a new Path2 starting at the coordinates (x, y).
  5037. */
  5038. static StartingAt(x: number, y: number): Path2;
  5039. }
  5040. /**
  5041. * Represents a 3D path made up of multiple 3D points
  5042. */
  5043. export class Path3D {
  5044. /**
  5045. * an array of Vector3, the curve axis of the Path3D
  5046. */
  5047. path: Vector3[];
  5048. private _curve;
  5049. private _distances;
  5050. private _tangents;
  5051. private _normals;
  5052. private _binormals;
  5053. private _raw;
  5054. private _alignTangentsWithPath;
  5055. private readonly _pointAtData;
  5056. /**
  5057. * new Path3D(path, normal, raw)
  5058. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5059. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5060. * @param path an array of Vector3, the curve axis of the Path3D
  5061. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5062. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5063. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5064. */
  5065. constructor(
  5066. /**
  5067. * an array of Vector3, the curve axis of the Path3D
  5068. */
  5069. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5070. /**
  5071. * Returns the Path3D array of successive Vector3 designing its curve.
  5072. * @returns the Path3D array of successive Vector3 designing its curve.
  5073. */
  5074. getCurve(): Vector3[];
  5075. /**
  5076. * Returns the Path3D array of successive Vector3 designing its curve.
  5077. * @returns the Path3D array of successive Vector3 designing its curve.
  5078. */
  5079. getPoints(): Vector3[];
  5080. /**
  5081. * @returns the computed length (float) of the path.
  5082. */
  5083. length(): number;
  5084. /**
  5085. * Returns an array populated with tangent vectors on each Path3D curve point.
  5086. * @returns an array populated with tangent vectors on each Path3D curve point.
  5087. */
  5088. getTangents(): Vector3[];
  5089. /**
  5090. * Returns an array populated with normal vectors on each Path3D curve point.
  5091. * @returns an array populated with normal vectors on each Path3D curve point.
  5092. */
  5093. getNormals(): Vector3[];
  5094. /**
  5095. * Returns an array populated with binormal vectors on each Path3D curve point.
  5096. * @returns an array populated with binormal vectors on each Path3D curve point.
  5097. */
  5098. getBinormals(): Vector3[];
  5099. /**
  5100. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5101. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5102. */
  5103. getDistances(): number[];
  5104. /**
  5105. * Returns an interpolated point along this path
  5106. * @param position the position of the point along this path, from 0.0 to 1.0
  5107. * @returns a new Vector3 as the point
  5108. */
  5109. getPointAt(position: number): Vector3;
  5110. /**
  5111. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5112. * @param position the position of the point along this path, from 0.0 to 1.0
  5113. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5114. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5115. */
  5116. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5117. /**
  5118. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5119. * @param position the position of the point along this path, from 0.0 to 1.0
  5120. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5121. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5122. */
  5123. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5124. /**
  5125. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5126. * @param position the position of the point along this path, from 0.0 to 1.0
  5127. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5128. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5129. */
  5130. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5131. /**
  5132. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5133. * @param position the position of the point along this path, from 0.0 to 1.0
  5134. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5135. */
  5136. getDistanceAt(position: number): number;
  5137. /**
  5138. * Returns the array index of the previous point of an interpolated point along this path
  5139. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5140. * @returns the array index
  5141. */
  5142. getPreviousPointIndexAt(position: number): number;
  5143. /**
  5144. * 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)
  5145. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5146. * @returns the sub position
  5147. */
  5148. getSubPositionAt(position: number): number;
  5149. /**
  5150. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5151. * @param target the vector of which to get the closest position to
  5152. * @returns the position of the closest virtual point on this path to the target vector
  5153. */
  5154. getClosestPositionTo(target: Vector3): number;
  5155. /**
  5156. * Returns a sub path (slice) of this path
  5157. * @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
  5158. * @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
  5159. * @returns a sub path (slice) of this path
  5160. */
  5161. slice(start?: number, end?: number): Path3D;
  5162. /**
  5163. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5164. * @param path path which all values are copied into the curves points
  5165. * @param firstNormal which should be projected onto the curve
  5166. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5167. * @returns the same object updated.
  5168. */
  5169. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5170. private _compute;
  5171. private _getFirstNonNullVector;
  5172. private _getLastNonNullVector;
  5173. private _normalVector;
  5174. /**
  5175. * Updates the point at data for an interpolated point along this curve
  5176. * @param position the position of the point along this curve, from 0.0 to 1.0
  5177. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5178. * @returns the (updated) point at data
  5179. */
  5180. private _updatePointAtData;
  5181. /**
  5182. * Updates the point at data from the specified parameters
  5183. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5184. * @param point the interpolated point
  5185. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5186. */
  5187. private _setPointAtData;
  5188. /**
  5189. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5190. */
  5191. private _updateInterpolationMatrix;
  5192. }
  5193. /**
  5194. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5195. * A Curve3 is designed from a series of successive Vector3.
  5196. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5197. */
  5198. export class Curve3 {
  5199. private _points;
  5200. private _length;
  5201. /**
  5202. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5203. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5204. * @param v1 (Vector3) the control point
  5205. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5206. * @param nbPoints (integer) the wanted number of points in the curve
  5207. * @returns the created Curve3
  5208. */
  5209. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5210. /**
  5211. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5212. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5213. * @param v1 (Vector3) the first control point
  5214. * @param v2 (Vector3) the second control point
  5215. * @param v3 (Vector3) the end point of the Cubic Bezier
  5216. * @param nbPoints (integer) the wanted number of points in the curve
  5217. * @returns the created Curve3
  5218. */
  5219. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5220. /**
  5221. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5222. * @param p1 (Vector3) the origin point of the Hermite Spline
  5223. * @param t1 (Vector3) the tangent vector at the origin point
  5224. * @param p2 (Vector3) the end point of the Hermite Spline
  5225. * @param t2 (Vector3) the tangent vector at the end point
  5226. * @param nbPoints (integer) the wanted number of points in the curve
  5227. * @returns the created Curve3
  5228. */
  5229. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5230. /**
  5231. * Returns a Curve3 object along a CatmullRom Spline curve :
  5232. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5233. * @param nbPoints (integer) the wanted number of points between each curve control points
  5234. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5235. * @returns the created Curve3
  5236. */
  5237. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5238. /**
  5239. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5240. * A Curve3 is designed from a series of successive Vector3.
  5241. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5242. * @param points points which make up the curve
  5243. */
  5244. constructor(points: Vector3[]);
  5245. /**
  5246. * @returns the Curve3 stored array of successive Vector3
  5247. */
  5248. getPoints(): Vector3[];
  5249. /**
  5250. * @returns the computed length (float) of the curve.
  5251. */
  5252. length(): number;
  5253. /**
  5254. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5255. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5256. * curveA and curveB keep unchanged.
  5257. * @param curve the curve to continue from this curve
  5258. * @returns the newly constructed curve
  5259. */
  5260. continue(curve: DeepImmutable<Curve3>): Curve3;
  5261. private _computeLength;
  5262. }
  5263. }
  5264. declare module "babylonjs/Animations/easing" {
  5265. /**
  5266. * This represents the main contract an easing function should follow.
  5267. * Easing functions are used throughout the animation system.
  5268. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5269. */
  5270. export interface IEasingFunction {
  5271. /**
  5272. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5273. * of the easing function.
  5274. * The link below provides some of the most common examples of easing functions.
  5275. * @see https://easings.net/
  5276. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5277. * @returns the corresponding value on the curve defined by the easing function
  5278. */
  5279. ease(gradient: number): number;
  5280. }
  5281. /**
  5282. * Base class used for every default easing function.
  5283. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5284. */
  5285. export class EasingFunction implements IEasingFunction {
  5286. /**
  5287. * Interpolation follows the mathematical formula associated with the easing function.
  5288. */
  5289. static readonly EASINGMODE_EASEIN: number;
  5290. /**
  5291. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5292. */
  5293. static readonly EASINGMODE_EASEOUT: number;
  5294. /**
  5295. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5296. */
  5297. static readonly EASINGMODE_EASEINOUT: number;
  5298. private _easingMode;
  5299. /**
  5300. * Sets the easing mode of the current function.
  5301. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5302. */
  5303. setEasingMode(easingMode: number): void;
  5304. /**
  5305. * Gets the current easing mode.
  5306. * @returns the easing mode
  5307. */
  5308. getEasingMode(): number;
  5309. /**
  5310. * @hidden
  5311. */
  5312. easeInCore(gradient: number): number;
  5313. /**
  5314. * Given an input gradient between 0 and 1, this returns the corresponding value
  5315. * of the easing function.
  5316. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5317. * @returns the corresponding value on the curve defined by the easing function
  5318. */
  5319. ease(gradient: number): number;
  5320. }
  5321. /**
  5322. * Easing function with a circle shape (see link below).
  5323. * @see https://easings.net/#easeInCirc
  5324. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5325. */
  5326. export class CircleEase extends EasingFunction implements IEasingFunction {
  5327. /** @hidden */
  5328. easeInCore(gradient: number): number;
  5329. }
  5330. /**
  5331. * Easing function with a ease back shape (see link below).
  5332. * @see https://easings.net/#easeInBack
  5333. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5334. */
  5335. export class BackEase extends EasingFunction implements IEasingFunction {
  5336. /** Defines the amplitude of the function */
  5337. amplitude: number;
  5338. /**
  5339. * Instantiates a back ease easing
  5340. * @see https://easings.net/#easeInBack
  5341. * @param amplitude Defines the amplitude of the function
  5342. */
  5343. constructor(
  5344. /** Defines the amplitude of the function */
  5345. amplitude?: number);
  5346. /** @hidden */
  5347. easeInCore(gradient: number): number;
  5348. }
  5349. /**
  5350. * Easing function with a bouncing shape (see link below).
  5351. * @see https://easings.net/#easeInBounce
  5352. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5353. */
  5354. export class BounceEase extends EasingFunction implements IEasingFunction {
  5355. /** Defines the number of bounces */
  5356. bounces: number;
  5357. /** Defines the amplitude of the bounce */
  5358. bounciness: number;
  5359. /**
  5360. * Instantiates a bounce easing
  5361. * @see https://easings.net/#easeInBounce
  5362. * @param bounces Defines the number of bounces
  5363. * @param bounciness Defines the amplitude of the bounce
  5364. */
  5365. constructor(
  5366. /** Defines the number of bounces */
  5367. bounces?: number,
  5368. /** Defines the amplitude of the bounce */
  5369. bounciness?: number);
  5370. /** @hidden */
  5371. easeInCore(gradient: number): number;
  5372. }
  5373. /**
  5374. * Easing function with a power of 3 shape (see link below).
  5375. * @see https://easings.net/#easeInCubic
  5376. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5377. */
  5378. export class CubicEase extends EasingFunction implements IEasingFunction {
  5379. /** @hidden */
  5380. easeInCore(gradient: number): number;
  5381. }
  5382. /**
  5383. * Easing function with an elastic shape (see link below).
  5384. * @see https://easings.net/#easeInElastic
  5385. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5386. */
  5387. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5388. /** Defines the number of oscillations*/
  5389. oscillations: number;
  5390. /** Defines the amplitude of the oscillations*/
  5391. springiness: number;
  5392. /**
  5393. * Instantiates an elastic easing function
  5394. * @see https://easings.net/#easeInElastic
  5395. * @param oscillations Defines the number of oscillations
  5396. * @param springiness Defines the amplitude of the oscillations
  5397. */
  5398. constructor(
  5399. /** Defines the number of oscillations*/
  5400. oscillations?: number,
  5401. /** Defines the amplitude of the oscillations*/
  5402. springiness?: number);
  5403. /** @hidden */
  5404. easeInCore(gradient: number): number;
  5405. }
  5406. /**
  5407. * Easing function with an exponential shape (see link below).
  5408. * @see https://easings.net/#easeInExpo
  5409. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5410. */
  5411. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5412. /** Defines the exponent of the function */
  5413. exponent: number;
  5414. /**
  5415. * Instantiates an exponential easing function
  5416. * @see https://easings.net/#easeInExpo
  5417. * @param exponent Defines the exponent of the function
  5418. */
  5419. constructor(
  5420. /** Defines the exponent of the function */
  5421. exponent?: number);
  5422. /** @hidden */
  5423. easeInCore(gradient: number): number;
  5424. }
  5425. /**
  5426. * Easing function with a power shape (see link below).
  5427. * @see https://easings.net/#easeInQuad
  5428. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5429. */
  5430. export class PowerEase extends EasingFunction implements IEasingFunction {
  5431. /** Defines the power of the function */
  5432. power: number;
  5433. /**
  5434. * Instantiates an power base easing function
  5435. * @see https://easings.net/#easeInQuad
  5436. * @param power Defines the power of the function
  5437. */
  5438. constructor(
  5439. /** Defines the power of the function */
  5440. power?: number);
  5441. /** @hidden */
  5442. easeInCore(gradient: number): number;
  5443. }
  5444. /**
  5445. * Easing function with a power of 2 shape (see link below).
  5446. * @see https://easings.net/#easeInQuad
  5447. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5448. */
  5449. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5450. /** @hidden */
  5451. easeInCore(gradient: number): number;
  5452. }
  5453. /**
  5454. * Easing function with a power of 4 shape (see link below).
  5455. * @see https://easings.net/#easeInQuart
  5456. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5457. */
  5458. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5459. /** @hidden */
  5460. easeInCore(gradient: number): number;
  5461. }
  5462. /**
  5463. * Easing function with a power of 5 shape (see link below).
  5464. * @see https://easings.net/#easeInQuint
  5465. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5466. */
  5467. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5468. /** @hidden */
  5469. easeInCore(gradient: number): number;
  5470. }
  5471. /**
  5472. * Easing function with a sin shape (see link below).
  5473. * @see https://easings.net/#easeInSine
  5474. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5475. */
  5476. export class SineEase extends EasingFunction implements IEasingFunction {
  5477. /** @hidden */
  5478. easeInCore(gradient: number): number;
  5479. }
  5480. /**
  5481. * Easing function with a bezier shape (see link below).
  5482. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5483. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5484. */
  5485. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5486. /** Defines the x component of the start tangent in the bezier curve */
  5487. x1: number;
  5488. /** Defines the y component of the start tangent in the bezier curve */
  5489. y1: number;
  5490. /** Defines the x component of the end tangent in the bezier curve */
  5491. x2: number;
  5492. /** Defines the y component of the end tangent in the bezier curve */
  5493. y2: number;
  5494. /**
  5495. * Instantiates a bezier function
  5496. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5497. * @param x1 Defines the x component of the start tangent in the bezier curve
  5498. * @param y1 Defines the y component of the start tangent in the bezier curve
  5499. * @param x2 Defines the x component of the end tangent in the bezier curve
  5500. * @param y2 Defines the y component of the end tangent in the bezier curve
  5501. */
  5502. constructor(
  5503. /** Defines the x component of the start tangent in the bezier curve */
  5504. x1?: number,
  5505. /** Defines the y component of the start tangent in the bezier curve */
  5506. y1?: number,
  5507. /** Defines the x component of the end tangent in the bezier curve */
  5508. x2?: number,
  5509. /** Defines the y component of the end tangent in the bezier curve */
  5510. y2?: number);
  5511. /** @hidden */
  5512. easeInCore(gradient: number): number;
  5513. }
  5514. }
  5515. declare module "babylonjs/Maths/math.color" {
  5516. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5517. /**
  5518. * Class used to hold a RBG color
  5519. */
  5520. export class Color3 {
  5521. /**
  5522. * Defines the red component (between 0 and 1, default is 0)
  5523. */
  5524. r: number;
  5525. /**
  5526. * Defines the green component (between 0 and 1, default is 0)
  5527. */
  5528. g: number;
  5529. /**
  5530. * Defines the blue component (between 0 and 1, default is 0)
  5531. */
  5532. b: number;
  5533. /**
  5534. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5535. * @param r defines the red component (between 0 and 1, default is 0)
  5536. * @param g defines the green component (between 0 and 1, default is 0)
  5537. * @param b defines the blue component (between 0 and 1, default is 0)
  5538. */
  5539. constructor(
  5540. /**
  5541. * Defines the red component (between 0 and 1, default is 0)
  5542. */
  5543. r?: number,
  5544. /**
  5545. * Defines the green component (between 0 and 1, default is 0)
  5546. */
  5547. g?: number,
  5548. /**
  5549. * Defines the blue component (between 0 and 1, default is 0)
  5550. */
  5551. b?: number);
  5552. /**
  5553. * Creates a string with the Color3 current values
  5554. * @returns the string representation of the Color3 object
  5555. */
  5556. toString(): string;
  5557. /**
  5558. * Returns the string "Color3"
  5559. * @returns "Color3"
  5560. */
  5561. getClassName(): string;
  5562. /**
  5563. * Compute the Color3 hash code
  5564. * @returns an unique number that can be used to hash Color3 objects
  5565. */
  5566. getHashCode(): number;
  5567. /**
  5568. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5569. * @param array defines the array where to store the r,g,b components
  5570. * @param index defines an optional index in the target array to define where to start storing values
  5571. * @returns the current Color3 object
  5572. */
  5573. toArray(array: FloatArray, index?: number): Color3;
  5574. /**
  5575. * Update the current color with values stored in an array from the starting index of the given array
  5576. * @param array defines the source array
  5577. * @param offset defines an offset in the source array
  5578. * @returns the current Color3 object
  5579. */
  5580. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5581. /**
  5582. * Returns a new Color4 object from the current Color3 and the given alpha
  5583. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5584. * @returns a new Color4 object
  5585. */
  5586. toColor4(alpha?: number): Color4;
  5587. /**
  5588. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5589. * @returns the new array
  5590. */
  5591. asArray(): number[];
  5592. /**
  5593. * Returns the luminance value
  5594. * @returns a float value
  5595. */
  5596. toLuminance(): number;
  5597. /**
  5598. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5599. * @param otherColor defines the second operand
  5600. * @returns the new Color3 object
  5601. */
  5602. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5603. /**
  5604. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5605. * @param otherColor defines the second operand
  5606. * @param result defines the Color3 object where to store the result
  5607. * @returns the current Color3
  5608. */
  5609. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5610. /**
  5611. * Determines equality between Color3 objects
  5612. * @param otherColor defines the second operand
  5613. * @returns true if the rgb values are equal to the given ones
  5614. */
  5615. equals(otherColor: DeepImmutable<Color3>): boolean;
  5616. /**
  5617. * Determines equality between the current Color3 object and a set of r,b,g values
  5618. * @param r defines the red component to check
  5619. * @param g defines the green component to check
  5620. * @param b defines the blue component to check
  5621. * @returns true if the rgb values are equal to the given ones
  5622. */
  5623. equalsFloats(r: number, g: number, b: number): boolean;
  5624. /**
  5625. * Multiplies in place each rgb value by scale
  5626. * @param scale defines the scaling factor
  5627. * @returns the updated Color3
  5628. */
  5629. scale(scale: number): Color3;
  5630. /**
  5631. * Multiplies the rgb values by scale and stores the result into "result"
  5632. * @param scale defines the scaling factor
  5633. * @param result defines the Color3 object where to store the result
  5634. * @returns the unmodified current Color3
  5635. */
  5636. scaleToRef(scale: number, result: Color3): Color3;
  5637. /**
  5638. * Scale the current Color3 values by a factor and add the result to a given Color3
  5639. * @param scale defines the scale factor
  5640. * @param result defines color to store the result into
  5641. * @returns the unmodified current Color3
  5642. */
  5643. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5644. /**
  5645. * Clamps the rgb values by the min and max values and stores the result into "result"
  5646. * @param min defines minimum clamping value (default is 0)
  5647. * @param max defines maximum clamping value (default is 1)
  5648. * @param result defines color to store the result into
  5649. * @returns the original Color3
  5650. */
  5651. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5652. /**
  5653. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5654. * @param otherColor defines the second operand
  5655. * @returns the new Color3
  5656. */
  5657. add(otherColor: DeepImmutable<Color3>): Color3;
  5658. /**
  5659. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5660. * @param otherColor defines the second operand
  5661. * @param result defines Color3 object to store the result into
  5662. * @returns the unmodified current Color3
  5663. */
  5664. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5665. /**
  5666. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5667. * @param otherColor defines the second operand
  5668. * @returns the new Color3
  5669. */
  5670. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5671. /**
  5672. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5673. * @param otherColor defines the second operand
  5674. * @param result defines Color3 object to store the result into
  5675. * @returns the unmodified current Color3
  5676. */
  5677. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5678. /**
  5679. * Copy the current object
  5680. * @returns a new Color3 copied the current one
  5681. */
  5682. clone(): Color3;
  5683. /**
  5684. * Copies the rgb values from the source in the current Color3
  5685. * @param source defines the source Color3 object
  5686. * @returns the updated Color3 object
  5687. */
  5688. copyFrom(source: DeepImmutable<Color3>): Color3;
  5689. /**
  5690. * Updates the Color3 rgb values from the given floats
  5691. * @param r defines the red component to read from
  5692. * @param g defines the green component to read from
  5693. * @param b defines the blue component to read from
  5694. * @returns the current Color3 object
  5695. */
  5696. copyFromFloats(r: number, g: number, b: number): Color3;
  5697. /**
  5698. * Updates the Color3 rgb values from the given floats
  5699. * @param r defines the red component to read from
  5700. * @param g defines the green component to read from
  5701. * @param b defines the blue component to read from
  5702. * @returns the current Color3 object
  5703. */
  5704. set(r: number, g: number, b: number): Color3;
  5705. /**
  5706. * Compute the Color3 hexadecimal code as a string
  5707. * @returns a string containing the hexadecimal representation of the Color3 object
  5708. */
  5709. toHexString(): string;
  5710. /**
  5711. * Computes a new Color3 converted from the current one to linear space
  5712. * @returns a new Color3 object
  5713. */
  5714. toLinearSpace(): Color3;
  5715. /**
  5716. * Converts current color in rgb space to HSV values
  5717. * @returns a new color3 representing the HSV values
  5718. */
  5719. toHSV(): Color3;
  5720. /**
  5721. * Converts current color in rgb space to HSV values
  5722. * @param result defines the Color3 where to store the HSV values
  5723. */
  5724. toHSVToRef(result: Color3): void;
  5725. /**
  5726. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5727. * @param convertedColor defines the Color3 object where to store the linear space version
  5728. * @returns the unmodified Color3
  5729. */
  5730. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5731. /**
  5732. * Computes a new Color3 converted from the current one to gamma space
  5733. * @returns a new Color3 object
  5734. */
  5735. toGammaSpace(): Color3;
  5736. /**
  5737. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5738. * @param convertedColor defines the Color3 object where to store the gamma space version
  5739. * @returns the unmodified Color3
  5740. */
  5741. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5742. private static _BlackReadOnly;
  5743. /**
  5744. * Convert Hue, saturation and value to a Color3 (RGB)
  5745. * @param hue defines the hue
  5746. * @param saturation defines the saturation
  5747. * @param value defines the value
  5748. * @param result defines the Color3 where to store the RGB values
  5749. */
  5750. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5751. /**
  5752. * Creates a new Color3 from the string containing valid hexadecimal values
  5753. * @param hex defines a string containing valid hexadecimal values
  5754. * @returns a new Color3 object
  5755. */
  5756. static FromHexString(hex: string): Color3;
  5757. /**
  5758. * Creates a new Color3 from the starting index of the given array
  5759. * @param array defines the source array
  5760. * @param offset defines an offset in the source array
  5761. * @returns a new Color3 object
  5762. */
  5763. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5764. /**
  5765. * Creates a new Color3 from the starting index element of the given array
  5766. * @param array defines the source array to read from
  5767. * @param offset defines the offset in the source array
  5768. * @param result defines the target Color3 object
  5769. */
  5770. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  5771. /**
  5772. * Creates a new Color3 from integer values (< 256)
  5773. * @param r defines the red component to read from (value between 0 and 255)
  5774. * @param g defines the green component to read from (value between 0 and 255)
  5775. * @param b defines the blue component to read from (value between 0 and 255)
  5776. * @returns a new Color3 object
  5777. */
  5778. static FromInts(r: number, g: number, b: number): Color3;
  5779. /**
  5780. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5781. * @param start defines the start Color3 value
  5782. * @param end defines the end Color3 value
  5783. * @param amount defines the gradient value between start and end
  5784. * @returns a new Color3 object
  5785. */
  5786. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5787. /**
  5788. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5789. * @param left defines the start value
  5790. * @param right defines the end value
  5791. * @param amount defines the gradient factor
  5792. * @param result defines the Color3 object where to store the result
  5793. */
  5794. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5795. /**
  5796. * Returns a Color3 value containing a red color
  5797. * @returns a new Color3 object
  5798. */
  5799. static Red(): Color3;
  5800. /**
  5801. * Returns a Color3 value containing a green color
  5802. * @returns a new Color3 object
  5803. */
  5804. static Green(): Color3;
  5805. /**
  5806. * Returns a Color3 value containing a blue color
  5807. * @returns a new Color3 object
  5808. */
  5809. static Blue(): Color3;
  5810. /**
  5811. * Returns a Color3 value containing a black color
  5812. * @returns a new Color3 object
  5813. */
  5814. static Black(): Color3;
  5815. /**
  5816. * Gets a Color3 value containing a black color that must not be updated
  5817. */
  5818. static get BlackReadOnly(): DeepImmutable<Color3>;
  5819. /**
  5820. * Returns a Color3 value containing a white color
  5821. * @returns a new Color3 object
  5822. */
  5823. static White(): Color3;
  5824. /**
  5825. * Returns a Color3 value containing a purple color
  5826. * @returns a new Color3 object
  5827. */
  5828. static Purple(): Color3;
  5829. /**
  5830. * Returns a Color3 value containing a magenta color
  5831. * @returns a new Color3 object
  5832. */
  5833. static Magenta(): Color3;
  5834. /**
  5835. * Returns a Color3 value containing a yellow color
  5836. * @returns a new Color3 object
  5837. */
  5838. static Yellow(): Color3;
  5839. /**
  5840. * Returns a Color3 value containing a gray color
  5841. * @returns a new Color3 object
  5842. */
  5843. static Gray(): Color3;
  5844. /**
  5845. * Returns a Color3 value containing a teal color
  5846. * @returns a new Color3 object
  5847. */
  5848. static Teal(): Color3;
  5849. /**
  5850. * Returns a Color3 value containing a random color
  5851. * @returns a new Color3 object
  5852. */
  5853. static Random(): Color3;
  5854. }
  5855. /**
  5856. * Class used to hold a RBGA color
  5857. */
  5858. export class Color4 {
  5859. /**
  5860. * Defines the red component (between 0 and 1, default is 0)
  5861. */
  5862. r: number;
  5863. /**
  5864. * Defines the green component (between 0 and 1, default is 0)
  5865. */
  5866. g: number;
  5867. /**
  5868. * Defines the blue component (between 0 and 1, default is 0)
  5869. */
  5870. b: number;
  5871. /**
  5872. * Defines the alpha component (between 0 and 1, default is 1)
  5873. */
  5874. a: number;
  5875. /**
  5876. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5877. * @param r defines the red component (between 0 and 1, default is 0)
  5878. * @param g defines the green component (between 0 and 1, default is 0)
  5879. * @param b defines the blue component (between 0 and 1, default is 0)
  5880. * @param a defines the alpha component (between 0 and 1, default is 1)
  5881. */
  5882. constructor(
  5883. /**
  5884. * Defines the red component (between 0 and 1, default is 0)
  5885. */
  5886. r?: number,
  5887. /**
  5888. * Defines the green component (between 0 and 1, default is 0)
  5889. */
  5890. g?: number,
  5891. /**
  5892. * Defines the blue component (between 0 and 1, default is 0)
  5893. */
  5894. b?: number,
  5895. /**
  5896. * Defines the alpha component (between 0 and 1, default is 1)
  5897. */
  5898. a?: number);
  5899. /**
  5900. * Adds in place the given Color4 values to the current Color4 object
  5901. * @param right defines the second operand
  5902. * @returns the current updated Color4 object
  5903. */
  5904. addInPlace(right: DeepImmutable<Color4>): Color4;
  5905. /**
  5906. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5907. * @returns the new array
  5908. */
  5909. asArray(): number[];
  5910. /**
  5911. * Stores from the starting index in the given array the Color4 successive values
  5912. * @param array defines the array where to store the r,g,b components
  5913. * @param index defines an optional index in the target array to define where to start storing values
  5914. * @returns the current Color4 object
  5915. */
  5916. toArray(array: number[], index?: number): Color4;
  5917. /**
  5918. * Update the current color with values stored in an array from the starting index of the given array
  5919. * @param array defines the source array
  5920. * @param offset defines an offset in the source array
  5921. * @returns the current Color4 object
  5922. */
  5923. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5924. /**
  5925. * Determines equality between Color4 objects
  5926. * @param otherColor defines the second operand
  5927. * @returns true if the rgba values are equal to the given ones
  5928. */
  5929. equals(otherColor: DeepImmutable<Color4>): boolean;
  5930. /**
  5931. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5932. * @param right defines the second operand
  5933. * @returns a new Color4 object
  5934. */
  5935. add(right: DeepImmutable<Color4>): Color4;
  5936. /**
  5937. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5938. * @param right defines the second operand
  5939. * @returns a new Color4 object
  5940. */
  5941. subtract(right: DeepImmutable<Color4>): Color4;
  5942. /**
  5943. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5944. * @param right defines the second operand
  5945. * @param result defines the Color4 object where to store the result
  5946. * @returns the current Color4 object
  5947. */
  5948. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5949. /**
  5950. * Creates a new Color4 with the current Color4 values multiplied by scale
  5951. * @param scale defines the scaling factor to apply
  5952. * @returns a new Color4 object
  5953. */
  5954. scale(scale: number): Color4;
  5955. /**
  5956. * Multiplies the current Color4 values by scale and stores the result in "result"
  5957. * @param scale defines the scaling factor to apply
  5958. * @param result defines the Color4 object where to store the result
  5959. * @returns the current unmodified Color4
  5960. */
  5961. scaleToRef(scale: number, result: Color4): Color4;
  5962. /**
  5963. * Scale the current Color4 values by a factor and add the result to a given Color4
  5964. * @param scale defines the scale factor
  5965. * @param result defines the Color4 object where to store the result
  5966. * @returns the unmodified current Color4
  5967. */
  5968. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5969. /**
  5970. * Clamps the rgb values by the min and max values and stores the result into "result"
  5971. * @param min defines minimum clamping value (default is 0)
  5972. * @param max defines maximum clamping value (default is 1)
  5973. * @param result defines color to store the result into.
  5974. * @returns the cuurent Color4
  5975. */
  5976. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5977. /**
  5978. * Multipy an Color4 value by another and return a new Color4 object
  5979. * @param color defines the Color4 value to multiply by
  5980. * @returns a new Color4 object
  5981. */
  5982. multiply(color: Color4): Color4;
  5983. /**
  5984. * Multipy a Color4 value by another and push the result in a reference value
  5985. * @param color defines the Color4 value to multiply by
  5986. * @param result defines the Color4 to fill the result in
  5987. * @returns the result Color4
  5988. */
  5989. multiplyToRef(color: Color4, result: Color4): Color4;
  5990. /**
  5991. * Creates a string with the Color4 current values
  5992. * @returns the string representation of the Color4 object
  5993. */
  5994. toString(): string;
  5995. /**
  5996. * Returns the string "Color4"
  5997. * @returns "Color4"
  5998. */
  5999. getClassName(): string;
  6000. /**
  6001. * Compute the Color4 hash code
  6002. * @returns an unique number that can be used to hash Color4 objects
  6003. */
  6004. getHashCode(): number;
  6005. /**
  6006. * Creates a new Color4 copied from the current one
  6007. * @returns a new Color4 object
  6008. */
  6009. clone(): Color4;
  6010. /**
  6011. * Copies the given Color4 values into the current one
  6012. * @param source defines the source Color4 object
  6013. * @returns the current updated Color4 object
  6014. */
  6015. copyFrom(source: Color4): Color4;
  6016. /**
  6017. * Copies the given float values into the current one
  6018. * @param r defines the red component to read from
  6019. * @param g defines the green component to read from
  6020. * @param b defines the blue component to read from
  6021. * @param a defines the alpha component to read from
  6022. * @returns the current updated Color4 object
  6023. */
  6024. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6025. /**
  6026. * Copies the given float values into the current one
  6027. * @param r defines the red component to read from
  6028. * @param g defines the green component to read from
  6029. * @param b defines the blue component to read from
  6030. * @param a defines the alpha component to read from
  6031. * @returns the current updated Color4 object
  6032. */
  6033. set(r: number, g: number, b: number, a: number): Color4;
  6034. /**
  6035. * Compute the Color4 hexadecimal code as a string
  6036. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6037. * @returns a string containing the hexadecimal representation of the Color4 object
  6038. */
  6039. toHexString(returnAsColor3?: boolean): string;
  6040. /**
  6041. * Computes a new Color4 converted from the current one to linear space
  6042. * @returns a new Color4 object
  6043. */
  6044. toLinearSpace(): Color4;
  6045. /**
  6046. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6047. * @param convertedColor defines the Color4 object where to store the linear space version
  6048. * @returns the unmodified Color4
  6049. */
  6050. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6051. /**
  6052. * Computes a new Color4 converted from the current one to gamma space
  6053. * @returns a new Color4 object
  6054. */
  6055. toGammaSpace(): Color4;
  6056. /**
  6057. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6058. * @param convertedColor defines the Color4 object where to store the gamma space version
  6059. * @returns the unmodified Color4
  6060. */
  6061. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6062. /**
  6063. * Creates a new Color4 from the string containing valid hexadecimal values
  6064. * @param hex defines a string containing valid hexadecimal values
  6065. * @returns a new Color4 object
  6066. */
  6067. static FromHexString(hex: string): Color4;
  6068. /**
  6069. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6070. * @param left defines the start value
  6071. * @param right defines the end value
  6072. * @param amount defines the gradient factor
  6073. * @returns a new Color4 object
  6074. */
  6075. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6076. /**
  6077. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6078. * @param left defines the start value
  6079. * @param right defines the end value
  6080. * @param amount defines the gradient factor
  6081. * @param result defines the Color4 object where to store data
  6082. */
  6083. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6084. /**
  6085. * Creates a new Color4 from a Color3 and an alpha value
  6086. * @param color3 defines the source Color3 to read from
  6087. * @param alpha defines the alpha component (1.0 by default)
  6088. * @returns a new Color4 object
  6089. */
  6090. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6091. /**
  6092. * Creates a new Color4 from the starting index element of the given array
  6093. * @param array defines the source array to read from
  6094. * @param offset defines the offset in the source array
  6095. * @returns a new Color4 object
  6096. */
  6097. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6098. /**
  6099. * Creates a new Color4 from the starting index element of the given array
  6100. * @param array defines the source array to read from
  6101. * @param offset defines the offset in the source array
  6102. * @param result defines the target Color4 object
  6103. */
  6104. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6105. /**
  6106. * Creates a new Color3 from integer values (< 256)
  6107. * @param r defines the red component to read from (value between 0 and 255)
  6108. * @param g defines the green component to read from (value between 0 and 255)
  6109. * @param b defines the blue component to read from (value between 0 and 255)
  6110. * @param a defines the alpha component to read from (value between 0 and 255)
  6111. * @returns a new Color3 object
  6112. */
  6113. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6114. /**
  6115. * Check the content of a given array and convert it to an array containing RGBA data
  6116. * If the original array was already containing count * 4 values then it is returned directly
  6117. * @param colors defines the array to check
  6118. * @param count defines the number of RGBA data to expect
  6119. * @returns an array containing count * 4 values (RGBA)
  6120. */
  6121. static CheckColors4(colors: number[], count: number): number[];
  6122. }
  6123. /**
  6124. * @hidden
  6125. */
  6126. export class TmpColors {
  6127. static Color3: Color3[];
  6128. static Color4: Color4[];
  6129. }
  6130. }
  6131. declare module "babylonjs/Animations/animationKey" {
  6132. /**
  6133. * Defines an interface which represents an animation key frame
  6134. */
  6135. export interface IAnimationKey {
  6136. /**
  6137. * Frame of the key frame
  6138. */
  6139. frame: number;
  6140. /**
  6141. * Value at the specifies key frame
  6142. */
  6143. value: any;
  6144. /**
  6145. * The input tangent for the cubic hermite spline
  6146. */
  6147. inTangent?: any;
  6148. /**
  6149. * The output tangent for the cubic hermite spline
  6150. */
  6151. outTangent?: any;
  6152. /**
  6153. * The animation interpolation type
  6154. */
  6155. interpolation?: AnimationKeyInterpolation;
  6156. }
  6157. /**
  6158. * Enum for the animation key frame interpolation type
  6159. */
  6160. export enum AnimationKeyInterpolation {
  6161. /**
  6162. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6163. */
  6164. STEP = 1
  6165. }
  6166. }
  6167. declare module "babylonjs/Animations/animationRange" {
  6168. /**
  6169. * Represents the range of an animation
  6170. */
  6171. export class AnimationRange {
  6172. /**The name of the animation range**/
  6173. name: string;
  6174. /**The starting frame of the animation */
  6175. from: number;
  6176. /**The ending frame of the animation*/
  6177. to: number;
  6178. /**
  6179. * Initializes the range of an animation
  6180. * @param name The name of the animation range
  6181. * @param from The starting frame of the animation
  6182. * @param to The ending frame of the animation
  6183. */
  6184. constructor(
  6185. /**The name of the animation range**/
  6186. name: string,
  6187. /**The starting frame of the animation */
  6188. from: number,
  6189. /**The ending frame of the animation*/
  6190. to: number);
  6191. /**
  6192. * Makes a copy of the animation range
  6193. * @returns A copy of the animation range
  6194. */
  6195. clone(): AnimationRange;
  6196. }
  6197. }
  6198. declare module "babylonjs/Animations/animationEvent" {
  6199. /**
  6200. * Composed of a frame, and an action function
  6201. */
  6202. export class AnimationEvent {
  6203. /** The frame for which the event is triggered **/
  6204. frame: number;
  6205. /** The event to perform when triggered **/
  6206. action: (currentFrame: number) => void;
  6207. /** Specifies if the event should be triggered only once**/
  6208. onlyOnce?: boolean | undefined;
  6209. /**
  6210. * Specifies if the animation event is done
  6211. */
  6212. isDone: boolean;
  6213. /**
  6214. * Initializes the animation event
  6215. * @param frame The frame for which the event is triggered
  6216. * @param action The event to perform when triggered
  6217. * @param onlyOnce Specifies if the event should be triggered only once
  6218. */
  6219. constructor(
  6220. /** The frame for which the event is triggered **/
  6221. frame: number,
  6222. /** The event to perform when triggered **/
  6223. action: (currentFrame: number) => void,
  6224. /** Specifies if the event should be triggered only once**/
  6225. onlyOnce?: boolean | undefined);
  6226. /** @hidden */
  6227. _clone(): AnimationEvent;
  6228. }
  6229. }
  6230. declare module "babylonjs/Behaviors/behavior" {
  6231. import { Nullable } from "babylonjs/types";
  6232. /**
  6233. * Interface used to define a behavior
  6234. */
  6235. export interface Behavior<T> {
  6236. /** gets or sets behavior's name */
  6237. name: string;
  6238. /**
  6239. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6240. */
  6241. init(): void;
  6242. /**
  6243. * Called when the behavior is attached to a target
  6244. * @param target defines the target where the behavior is attached to
  6245. */
  6246. attach(target: T): void;
  6247. /**
  6248. * Called when the behavior is detached from its target
  6249. */
  6250. detach(): void;
  6251. }
  6252. /**
  6253. * Interface implemented by classes supporting behaviors
  6254. */
  6255. export interface IBehaviorAware<T> {
  6256. /**
  6257. * Attach a behavior
  6258. * @param behavior defines the behavior to attach
  6259. * @returns the current host
  6260. */
  6261. addBehavior(behavior: Behavior<T>): T;
  6262. /**
  6263. * Remove a behavior from the current object
  6264. * @param behavior defines the behavior to detach
  6265. * @returns the current host
  6266. */
  6267. removeBehavior(behavior: Behavior<T>): T;
  6268. /**
  6269. * Gets a behavior using its name to search
  6270. * @param name defines the name to search
  6271. * @returns the behavior or null if not found
  6272. */
  6273. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6274. }
  6275. }
  6276. declare module "babylonjs/Misc/smartArray" {
  6277. /**
  6278. * Defines an array and its length.
  6279. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6280. */
  6281. export interface ISmartArrayLike<T> {
  6282. /**
  6283. * The data of the array.
  6284. */
  6285. data: Array<T>;
  6286. /**
  6287. * The active length of the array.
  6288. */
  6289. length: number;
  6290. }
  6291. /**
  6292. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6293. */
  6294. export class SmartArray<T> implements ISmartArrayLike<T> {
  6295. /**
  6296. * The full set of data from the array.
  6297. */
  6298. data: Array<T>;
  6299. /**
  6300. * The active length of the array.
  6301. */
  6302. length: number;
  6303. protected _id: number;
  6304. /**
  6305. * Instantiates a Smart Array.
  6306. * @param capacity defines the default capacity of the array.
  6307. */
  6308. constructor(capacity: number);
  6309. /**
  6310. * Pushes a value at the end of the active data.
  6311. * @param value defines the object to push in the array.
  6312. */
  6313. push(value: T): void;
  6314. /**
  6315. * Iterates over the active data and apply the lambda to them.
  6316. * @param func defines the action to apply on each value.
  6317. */
  6318. forEach(func: (content: T) => void): void;
  6319. /**
  6320. * Sorts the full sets of data.
  6321. * @param compareFn defines the comparison function to apply.
  6322. */
  6323. sort(compareFn: (a: T, b: T) => number): void;
  6324. /**
  6325. * Resets the active data to an empty array.
  6326. */
  6327. reset(): void;
  6328. /**
  6329. * Releases all the data from the array as well as the array.
  6330. */
  6331. dispose(): void;
  6332. /**
  6333. * Concats the active data with a given array.
  6334. * @param array defines the data to concatenate with.
  6335. */
  6336. concat(array: any): void;
  6337. /**
  6338. * Returns the position of a value in the active data.
  6339. * @param value defines the value to find the index for
  6340. * @returns the index if found in the active data otherwise -1
  6341. */
  6342. indexOf(value: T): number;
  6343. /**
  6344. * Returns whether an element is part of the active data.
  6345. * @param value defines the value to look for
  6346. * @returns true if found in the active data otherwise false
  6347. */
  6348. contains(value: T): boolean;
  6349. private static _GlobalId;
  6350. }
  6351. /**
  6352. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6353. * The data in this array can only be present once
  6354. */
  6355. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6356. private _duplicateId;
  6357. /**
  6358. * Pushes a value at the end of the active data.
  6359. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6360. * @param value defines the object to push in the array.
  6361. */
  6362. push(value: T): void;
  6363. /**
  6364. * Pushes a value at the end of the active data.
  6365. * If the data is already present, it won t be added again
  6366. * @param value defines the object to push in the array.
  6367. * @returns true if added false if it was already present
  6368. */
  6369. pushNoDuplicate(value: T): boolean;
  6370. /**
  6371. * Resets the active data to an empty array.
  6372. */
  6373. reset(): void;
  6374. /**
  6375. * Concats the active data with a given array.
  6376. * This ensures no dupplicate will be present in the result.
  6377. * @param array defines the data to concatenate with.
  6378. */
  6379. concatWithNoDuplicate(array: any): void;
  6380. }
  6381. }
  6382. declare module "babylonjs/Cameras/cameraInputsManager" {
  6383. import { Nullable } from "babylonjs/types";
  6384. import { Camera } from "babylonjs/Cameras/camera";
  6385. /**
  6386. * @ignore
  6387. * This is a list of all the different input types that are available in the application.
  6388. * Fo instance: ArcRotateCameraGamepadInput...
  6389. */
  6390. export var CameraInputTypes: {};
  6391. /**
  6392. * This is the contract to implement in order to create a new input class.
  6393. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6394. */
  6395. export interface ICameraInput<TCamera extends Camera> {
  6396. /**
  6397. * Defines the camera the input is attached to.
  6398. */
  6399. camera: Nullable<TCamera>;
  6400. /**
  6401. * Gets the class name of the current intput.
  6402. * @returns the class name
  6403. */
  6404. getClassName(): string;
  6405. /**
  6406. * Get the friendly name associated with the input class.
  6407. * @returns the input friendly name
  6408. */
  6409. getSimpleName(): string;
  6410. /**
  6411. * Attach the input controls to a specific dom element to get the input from.
  6412. * @param element Defines the element the controls should be listened from
  6413. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6414. */
  6415. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6416. /**
  6417. * Detach the current controls from the specified dom element.
  6418. * @param element Defines the element to stop listening the inputs from
  6419. */
  6420. detachControl(element: Nullable<HTMLElement>): void;
  6421. /**
  6422. * Update the current camera state depending on the inputs that have been used this frame.
  6423. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6424. */
  6425. checkInputs?: () => void;
  6426. }
  6427. /**
  6428. * Represents a map of input types to input instance or input index to input instance.
  6429. */
  6430. export interface CameraInputsMap<TCamera extends Camera> {
  6431. /**
  6432. * Accessor to the input by input type.
  6433. */
  6434. [name: string]: ICameraInput<TCamera>;
  6435. /**
  6436. * Accessor to the input by input index.
  6437. */
  6438. [idx: number]: ICameraInput<TCamera>;
  6439. }
  6440. /**
  6441. * This represents the input manager used within a camera.
  6442. * It helps dealing with all the different kind of input attached to a camera.
  6443. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6444. */
  6445. export class CameraInputsManager<TCamera extends Camera> {
  6446. /**
  6447. * Defines the list of inputs attahed to the camera.
  6448. */
  6449. attached: CameraInputsMap<TCamera>;
  6450. /**
  6451. * Defines the dom element the camera is collecting inputs from.
  6452. * This is null if the controls have not been attached.
  6453. */
  6454. attachedElement: Nullable<HTMLElement>;
  6455. /**
  6456. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6457. */
  6458. noPreventDefault: boolean;
  6459. /**
  6460. * Defined the camera the input manager belongs to.
  6461. */
  6462. camera: TCamera;
  6463. /**
  6464. * Update the current camera state depending on the inputs that have been used this frame.
  6465. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6466. */
  6467. checkInputs: () => void;
  6468. /**
  6469. * Instantiate a new Camera Input Manager.
  6470. * @param camera Defines the camera the input manager blongs to
  6471. */
  6472. constructor(camera: TCamera);
  6473. /**
  6474. * Add an input method to a camera
  6475. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6476. * @param input camera input method
  6477. */
  6478. add(input: ICameraInput<TCamera>): void;
  6479. /**
  6480. * Remove a specific input method from a camera
  6481. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6482. * @param inputToRemove camera input method
  6483. */
  6484. remove(inputToRemove: ICameraInput<TCamera>): void;
  6485. /**
  6486. * Remove a specific input type from a camera
  6487. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6488. * @param inputType the type of the input to remove
  6489. */
  6490. removeByType(inputType: string): void;
  6491. private _addCheckInputs;
  6492. /**
  6493. * Attach the input controls to the currently attached dom element to listen the events from.
  6494. * @param input Defines the input to attach
  6495. */
  6496. attachInput(input: ICameraInput<TCamera>): void;
  6497. /**
  6498. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6499. * @param element Defines the dom element to collect the events from
  6500. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6501. */
  6502. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6503. /**
  6504. * Detach the current manager inputs controls from a specific dom element.
  6505. * @param element Defines the dom element to collect the events from
  6506. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6507. */
  6508. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6509. /**
  6510. * Rebuild the dynamic inputCheck function from the current list of
  6511. * defined inputs in the manager.
  6512. */
  6513. rebuildInputCheck(): void;
  6514. /**
  6515. * Remove all attached input methods from a camera
  6516. */
  6517. clear(): void;
  6518. /**
  6519. * Serialize the current input manager attached to a camera.
  6520. * This ensures than once parsed,
  6521. * the input associated to the camera will be identical to the current ones
  6522. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6523. */
  6524. serialize(serializedCamera: any): void;
  6525. /**
  6526. * Parses an input manager serialized JSON to restore the previous list of inputs
  6527. * and states associated to a camera.
  6528. * @param parsedCamera Defines the JSON to parse
  6529. */
  6530. parse(parsedCamera: any): void;
  6531. }
  6532. }
  6533. declare module "babylonjs/Meshes/buffer" {
  6534. import { Nullable, DataArray } from "babylonjs/types";
  6535. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6536. /**
  6537. * Class used to store data that will be store in GPU memory
  6538. */
  6539. export class Buffer {
  6540. private _engine;
  6541. private _buffer;
  6542. /** @hidden */
  6543. _data: Nullable<DataArray>;
  6544. private _updatable;
  6545. private _instanced;
  6546. private _divisor;
  6547. /**
  6548. * Gets the byte stride.
  6549. */
  6550. readonly byteStride: number;
  6551. /**
  6552. * Constructor
  6553. * @param engine the engine
  6554. * @param data the data to use for this buffer
  6555. * @param updatable whether the data is updatable
  6556. * @param stride the stride (optional)
  6557. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6558. * @param instanced whether the buffer is instanced (optional)
  6559. * @param useBytes set to true if the stride in in bytes (optional)
  6560. * @param divisor sets an optional divisor for instances (1 by default)
  6561. */
  6562. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6563. /**
  6564. * Create a new VertexBuffer based on the current buffer
  6565. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6566. * @param offset defines offset in the buffer (0 by default)
  6567. * @param size defines the size in floats of attributes (position is 3 for instance)
  6568. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6569. * @param instanced defines if the vertex buffer contains indexed data
  6570. * @param useBytes defines if the offset and stride are in bytes *
  6571. * @param divisor sets an optional divisor for instances (1 by default)
  6572. * @returns the new vertex buffer
  6573. */
  6574. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6575. /**
  6576. * Gets a boolean indicating if the Buffer is updatable?
  6577. * @returns true if the buffer is updatable
  6578. */
  6579. isUpdatable(): boolean;
  6580. /**
  6581. * Gets current buffer's data
  6582. * @returns a DataArray or null
  6583. */
  6584. getData(): Nullable<DataArray>;
  6585. /**
  6586. * Gets underlying native buffer
  6587. * @returns underlying native buffer
  6588. */
  6589. getBuffer(): Nullable<DataBuffer>;
  6590. /**
  6591. * Gets the stride in float32 units (i.e. byte stride / 4).
  6592. * May not be an integer if the byte stride is not divisible by 4.
  6593. * @returns the stride in float32 units
  6594. * @deprecated Please use byteStride instead.
  6595. */
  6596. getStrideSize(): number;
  6597. /**
  6598. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6599. * @param data defines the data to store
  6600. */
  6601. create(data?: Nullable<DataArray>): void;
  6602. /** @hidden */
  6603. _rebuild(): void;
  6604. /**
  6605. * Update current buffer data
  6606. * @param data defines the data to store
  6607. */
  6608. update(data: DataArray): void;
  6609. /**
  6610. * Updates the data directly.
  6611. * @param data the new data
  6612. * @param offset the new offset
  6613. * @param vertexCount the vertex count (optional)
  6614. * @param useBytes set to true if the offset is in bytes
  6615. */
  6616. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6617. /**
  6618. * Release all resources
  6619. */
  6620. dispose(): void;
  6621. }
  6622. /**
  6623. * Specialized buffer used to store vertex data
  6624. */
  6625. export class VertexBuffer {
  6626. /** @hidden */
  6627. _buffer: Buffer;
  6628. private _kind;
  6629. private _size;
  6630. private _ownsBuffer;
  6631. private _instanced;
  6632. private _instanceDivisor;
  6633. /**
  6634. * The byte type.
  6635. */
  6636. static readonly BYTE: number;
  6637. /**
  6638. * The unsigned byte type.
  6639. */
  6640. static readonly UNSIGNED_BYTE: number;
  6641. /**
  6642. * The short type.
  6643. */
  6644. static readonly SHORT: number;
  6645. /**
  6646. * The unsigned short type.
  6647. */
  6648. static readonly UNSIGNED_SHORT: number;
  6649. /**
  6650. * The integer type.
  6651. */
  6652. static readonly INT: number;
  6653. /**
  6654. * The unsigned integer type.
  6655. */
  6656. static readonly UNSIGNED_INT: number;
  6657. /**
  6658. * The float type.
  6659. */
  6660. static readonly FLOAT: number;
  6661. /**
  6662. * Gets or sets the instance divisor when in instanced mode
  6663. */
  6664. get instanceDivisor(): number;
  6665. set instanceDivisor(value: number);
  6666. /**
  6667. * Gets the byte stride.
  6668. */
  6669. readonly byteStride: number;
  6670. /**
  6671. * Gets the byte offset.
  6672. */
  6673. readonly byteOffset: number;
  6674. /**
  6675. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6676. */
  6677. readonly normalized: boolean;
  6678. /**
  6679. * Gets the data type of each component in the array.
  6680. */
  6681. readonly type: number;
  6682. /**
  6683. * Constructor
  6684. * @param engine the engine
  6685. * @param data the data to use for this vertex buffer
  6686. * @param kind the vertex buffer kind
  6687. * @param updatable whether the data is updatable
  6688. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6689. * @param stride the stride (optional)
  6690. * @param instanced whether the buffer is instanced (optional)
  6691. * @param offset the offset of the data (optional)
  6692. * @param size the number of components (optional)
  6693. * @param type the type of the component (optional)
  6694. * @param normalized whether the data contains normalized data (optional)
  6695. * @param useBytes set to true if stride and offset are in bytes (optional)
  6696. * @param divisor defines the instance divisor to use (1 by default)
  6697. */
  6698. 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);
  6699. /** @hidden */
  6700. _rebuild(): void;
  6701. /**
  6702. * Returns the kind of the VertexBuffer (string)
  6703. * @returns a string
  6704. */
  6705. getKind(): string;
  6706. /**
  6707. * Gets a boolean indicating if the VertexBuffer is updatable?
  6708. * @returns true if the buffer is updatable
  6709. */
  6710. isUpdatable(): boolean;
  6711. /**
  6712. * Gets current buffer's data
  6713. * @returns a DataArray or null
  6714. */
  6715. getData(): Nullable<DataArray>;
  6716. /**
  6717. * Gets underlying native buffer
  6718. * @returns underlying native buffer
  6719. */
  6720. getBuffer(): Nullable<DataBuffer>;
  6721. /**
  6722. * Gets the stride in float32 units (i.e. byte stride / 4).
  6723. * May not be an integer if the byte stride is not divisible by 4.
  6724. * @returns the stride in float32 units
  6725. * @deprecated Please use byteStride instead.
  6726. */
  6727. getStrideSize(): number;
  6728. /**
  6729. * Returns the offset as a multiple of the type byte length.
  6730. * @returns the offset in bytes
  6731. * @deprecated Please use byteOffset instead.
  6732. */
  6733. getOffset(): number;
  6734. /**
  6735. * Returns the number of components per vertex attribute (integer)
  6736. * @returns the size in float
  6737. */
  6738. getSize(): number;
  6739. /**
  6740. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6741. * @returns true if this buffer is instanced
  6742. */
  6743. getIsInstanced(): boolean;
  6744. /**
  6745. * Returns the instancing divisor, zero for non-instanced (integer).
  6746. * @returns a number
  6747. */
  6748. getInstanceDivisor(): number;
  6749. /**
  6750. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6751. * @param data defines the data to store
  6752. */
  6753. create(data?: DataArray): void;
  6754. /**
  6755. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6756. * This function will create a new buffer if the current one is not updatable
  6757. * @param data defines the data to store
  6758. */
  6759. update(data: DataArray): void;
  6760. /**
  6761. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6762. * Returns the directly updated WebGLBuffer.
  6763. * @param data the new data
  6764. * @param offset the new offset
  6765. * @param useBytes set to true if the offset is in bytes
  6766. */
  6767. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6768. /**
  6769. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6770. */
  6771. dispose(): void;
  6772. /**
  6773. * Enumerates each value of this vertex buffer as numbers.
  6774. * @param count the number of values to enumerate
  6775. * @param callback the callback function called for each value
  6776. */
  6777. forEach(count: number, callback: (value: number, index: number) => void): void;
  6778. /**
  6779. * Positions
  6780. */
  6781. static readonly PositionKind: string;
  6782. /**
  6783. * Normals
  6784. */
  6785. static readonly NormalKind: string;
  6786. /**
  6787. * Tangents
  6788. */
  6789. static readonly TangentKind: string;
  6790. /**
  6791. * Texture coordinates
  6792. */
  6793. static readonly UVKind: string;
  6794. /**
  6795. * Texture coordinates 2
  6796. */
  6797. static readonly UV2Kind: string;
  6798. /**
  6799. * Texture coordinates 3
  6800. */
  6801. static readonly UV3Kind: string;
  6802. /**
  6803. * Texture coordinates 4
  6804. */
  6805. static readonly UV4Kind: string;
  6806. /**
  6807. * Texture coordinates 5
  6808. */
  6809. static readonly UV5Kind: string;
  6810. /**
  6811. * Texture coordinates 6
  6812. */
  6813. static readonly UV6Kind: string;
  6814. /**
  6815. * Colors
  6816. */
  6817. static readonly ColorKind: string;
  6818. /**
  6819. * Matrix indices (for bones)
  6820. */
  6821. static readonly MatricesIndicesKind: string;
  6822. /**
  6823. * Matrix weights (for bones)
  6824. */
  6825. static readonly MatricesWeightsKind: string;
  6826. /**
  6827. * Additional matrix indices (for bones)
  6828. */
  6829. static readonly MatricesIndicesExtraKind: string;
  6830. /**
  6831. * Additional matrix weights (for bones)
  6832. */
  6833. static readonly MatricesWeightsExtraKind: string;
  6834. /**
  6835. * Deduces the stride given a kind.
  6836. * @param kind The kind string to deduce
  6837. * @returns The deduced stride
  6838. */
  6839. static DeduceStride(kind: string): number;
  6840. /**
  6841. * Gets the byte length of the given type.
  6842. * @param type the type
  6843. * @returns the number of bytes
  6844. */
  6845. static GetTypeByteLength(type: number): number;
  6846. /**
  6847. * Enumerates each value of the given parameters as numbers.
  6848. * @param data the data to enumerate
  6849. * @param byteOffset the byte offset of the data
  6850. * @param byteStride the byte stride of the data
  6851. * @param componentCount the number of components per element
  6852. * @param componentType the type of the component
  6853. * @param count the number of values to enumerate
  6854. * @param normalized whether the data is normalized
  6855. * @param callback the callback function called for each value
  6856. */
  6857. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6858. private static _GetFloatValue;
  6859. }
  6860. }
  6861. declare module "babylonjs/Collisions/intersectionInfo" {
  6862. import { Nullable } from "babylonjs/types";
  6863. /**
  6864. * @hidden
  6865. */
  6866. export class IntersectionInfo {
  6867. bu: Nullable<number>;
  6868. bv: Nullable<number>;
  6869. distance: number;
  6870. faceId: number;
  6871. subMeshId: number;
  6872. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6873. }
  6874. }
  6875. declare module "babylonjs/Culling/boundingSphere" {
  6876. import { DeepImmutable } from "babylonjs/types";
  6877. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6878. import { Plane } from "babylonjs/Maths/math.plane";
  6879. /**
  6880. * Class used to store bounding sphere information
  6881. */
  6882. export class BoundingSphere {
  6883. /**
  6884. * Gets the center of the bounding sphere in local space
  6885. */
  6886. readonly center: Vector3;
  6887. /**
  6888. * Radius of the bounding sphere in local space
  6889. */
  6890. radius: number;
  6891. /**
  6892. * Gets the center of the bounding sphere in world space
  6893. */
  6894. readonly centerWorld: Vector3;
  6895. /**
  6896. * Radius of the bounding sphere in world space
  6897. */
  6898. radiusWorld: number;
  6899. /**
  6900. * Gets the minimum vector in local space
  6901. */
  6902. readonly minimum: Vector3;
  6903. /**
  6904. * Gets the maximum vector in local space
  6905. */
  6906. readonly maximum: Vector3;
  6907. private _worldMatrix;
  6908. private static readonly TmpVector3;
  6909. /**
  6910. * Creates a new bounding sphere
  6911. * @param min defines the minimum vector (in local space)
  6912. * @param max defines the maximum vector (in local space)
  6913. * @param worldMatrix defines the new world matrix
  6914. */
  6915. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6916. /**
  6917. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6918. * @param min defines the new minimum vector (in local space)
  6919. * @param max defines the new maximum vector (in local space)
  6920. * @param worldMatrix defines the new world matrix
  6921. */
  6922. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6923. /**
  6924. * Scale the current bounding sphere by applying a scale factor
  6925. * @param factor defines the scale factor to apply
  6926. * @returns the current bounding box
  6927. */
  6928. scale(factor: number): BoundingSphere;
  6929. /**
  6930. * Gets the world matrix of the bounding box
  6931. * @returns a matrix
  6932. */
  6933. getWorldMatrix(): DeepImmutable<Matrix>;
  6934. /** @hidden */
  6935. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6936. /**
  6937. * Tests if the bounding sphere is intersecting the frustum planes
  6938. * @param frustumPlanes defines the frustum planes to test
  6939. * @returns true if there is an intersection
  6940. */
  6941. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6942. /**
  6943. * Tests if the bounding sphere center is in between the frustum planes.
  6944. * Used for optimistic fast inclusion.
  6945. * @param frustumPlanes defines the frustum planes to test
  6946. * @returns true if the sphere center is in between the frustum planes
  6947. */
  6948. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6949. /**
  6950. * Tests if a point is inside the bounding sphere
  6951. * @param point defines the point to test
  6952. * @returns true if the point is inside the bounding sphere
  6953. */
  6954. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6955. /**
  6956. * Checks if two sphere intersct
  6957. * @param sphere0 sphere 0
  6958. * @param sphere1 sphere 1
  6959. * @returns true if the speres intersect
  6960. */
  6961. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6962. }
  6963. }
  6964. declare module "babylonjs/Culling/boundingBox" {
  6965. import { DeepImmutable } from "babylonjs/types";
  6966. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6967. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6968. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6969. import { Plane } from "babylonjs/Maths/math.plane";
  6970. /**
  6971. * Class used to store bounding box information
  6972. */
  6973. export class BoundingBox implements ICullable {
  6974. /**
  6975. * Gets the 8 vectors representing the bounding box in local space
  6976. */
  6977. readonly vectors: Vector3[];
  6978. /**
  6979. * Gets the center of the bounding box in local space
  6980. */
  6981. readonly center: Vector3;
  6982. /**
  6983. * Gets the center of the bounding box in world space
  6984. */
  6985. readonly centerWorld: Vector3;
  6986. /**
  6987. * Gets the extend size in local space
  6988. */
  6989. readonly extendSize: Vector3;
  6990. /**
  6991. * Gets the extend size in world space
  6992. */
  6993. readonly extendSizeWorld: Vector3;
  6994. /**
  6995. * Gets the OBB (object bounding box) directions
  6996. */
  6997. readonly directions: Vector3[];
  6998. /**
  6999. * Gets the 8 vectors representing the bounding box in world space
  7000. */
  7001. readonly vectorsWorld: Vector3[];
  7002. /**
  7003. * Gets the minimum vector in world space
  7004. */
  7005. readonly minimumWorld: Vector3;
  7006. /**
  7007. * Gets the maximum vector in world space
  7008. */
  7009. readonly maximumWorld: Vector3;
  7010. /**
  7011. * Gets the minimum vector in local space
  7012. */
  7013. readonly minimum: Vector3;
  7014. /**
  7015. * Gets the maximum vector in local space
  7016. */
  7017. readonly maximum: Vector3;
  7018. private _worldMatrix;
  7019. private static readonly TmpVector3;
  7020. /**
  7021. * @hidden
  7022. */
  7023. _tag: number;
  7024. /**
  7025. * Creates a new bounding box
  7026. * @param min defines the minimum vector (in local space)
  7027. * @param max defines the maximum vector (in local space)
  7028. * @param worldMatrix defines the new world matrix
  7029. */
  7030. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7031. /**
  7032. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7033. * @param min defines the new minimum vector (in local space)
  7034. * @param max defines the new maximum vector (in local space)
  7035. * @param worldMatrix defines the new world matrix
  7036. */
  7037. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7038. /**
  7039. * Scale the current bounding box by applying a scale factor
  7040. * @param factor defines the scale factor to apply
  7041. * @returns the current bounding box
  7042. */
  7043. scale(factor: number): BoundingBox;
  7044. /**
  7045. * Gets the world matrix of the bounding box
  7046. * @returns a matrix
  7047. */
  7048. getWorldMatrix(): DeepImmutable<Matrix>;
  7049. /** @hidden */
  7050. _update(world: DeepImmutable<Matrix>): void;
  7051. /**
  7052. * Tests if the bounding box is intersecting the frustum planes
  7053. * @param frustumPlanes defines the frustum planes to test
  7054. * @returns true if there is an intersection
  7055. */
  7056. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7057. /**
  7058. * Tests if the bounding box is entirely inside the frustum planes
  7059. * @param frustumPlanes defines the frustum planes to test
  7060. * @returns true if there is an inclusion
  7061. */
  7062. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7063. /**
  7064. * Tests if a point is inside the bounding box
  7065. * @param point defines the point to test
  7066. * @returns true if the point is inside the bounding box
  7067. */
  7068. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7069. /**
  7070. * Tests if the bounding box intersects with a bounding sphere
  7071. * @param sphere defines the sphere to test
  7072. * @returns true if there is an intersection
  7073. */
  7074. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7075. /**
  7076. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7077. * @param min defines the min vector to use
  7078. * @param max defines the max vector to use
  7079. * @returns true if there is an intersection
  7080. */
  7081. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7082. /**
  7083. * Tests if two bounding boxes are intersections
  7084. * @param box0 defines the first box to test
  7085. * @param box1 defines the second box to test
  7086. * @returns true if there is an intersection
  7087. */
  7088. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7089. /**
  7090. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7091. * @param minPoint defines the minimum vector of the bounding box
  7092. * @param maxPoint defines the maximum vector of the bounding box
  7093. * @param sphereCenter defines the sphere center
  7094. * @param sphereRadius defines the sphere radius
  7095. * @returns true if there is an intersection
  7096. */
  7097. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7098. /**
  7099. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7100. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7101. * @param frustumPlanes defines the frustum planes to test
  7102. * @return true if there is an inclusion
  7103. */
  7104. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7105. /**
  7106. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7107. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7108. * @param frustumPlanes defines the frustum planes to test
  7109. * @return true if there is an intersection
  7110. */
  7111. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7112. }
  7113. }
  7114. declare module "babylonjs/Collisions/collider" {
  7115. import { Nullable, IndicesArray } from "babylonjs/types";
  7116. import { Vector3 } from "babylonjs/Maths/math.vector";
  7117. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7118. import { Plane } from "babylonjs/Maths/math.plane";
  7119. /** @hidden */
  7120. export class Collider {
  7121. /** Define if a collision was found */
  7122. collisionFound: boolean;
  7123. /**
  7124. * Define last intersection point in local space
  7125. */
  7126. intersectionPoint: Vector3;
  7127. /**
  7128. * Define last collided mesh
  7129. */
  7130. collidedMesh: Nullable<AbstractMesh>;
  7131. private _collisionPoint;
  7132. private _planeIntersectionPoint;
  7133. private _tempVector;
  7134. private _tempVector2;
  7135. private _tempVector3;
  7136. private _tempVector4;
  7137. private _edge;
  7138. private _baseToVertex;
  7139. private _destinationPoint;
  7140. private _slidePlaneNormal;
  7141. private _displacementVector;
  7142. /** @hidden */
  7143. _radius: Vector3;
  7144. /** @hidden */
  7145. _retry: number;
  7146. private _velocity;
  7147. private _basePoint;
  7148. private _epsilon;
  7149. /** @hidden */
  7150. _velocityWorldLength: number;
  7151. /** @hidden */
  7152. _basePointWorld: Vector3;
  7153. private _velocityWorld;
  7154. private _normalizedVelocity;
  7155. /** @hidden */
  7156. _initialVelocity: Vector3;
  7157. /** @hidden */
  7158. _initialPosition: Vector3;
  7159. private _nearestDistance;
  7160. private _collisionMask;
  7161. get collisionMask(): number;
  7162. set collisionMask(mask: number);
  7163. /**
  7164. * Gets the plane normal used to compute the sliding response (in local space)
  7165. */
  7166. get slidePlaneNormal(): Vector3;
  7167. /** @hidden */
  7168. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7169. /** @hidden */
  7170. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7171. /** @hidden */
  7172. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7173. /** @hidden */
  7174. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7175. /** @hidden */
  7176. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7177. /** @hidden */
  7178. _getResponse(pos: Vector3, vel: Vector3): void;
  7179. }
  7180. }
  7181. declare module "babylonjs/Culling/boundingInfo" {
  7182. import { DeepImmutable } from "babylonjs/types";
  7183. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7184. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7185. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7186. import { Plane } from "babylonjs/Maths/math.plane";
  7187. import { Collider } from "babylonjs/Collisions/collider";
  7188. /**
  7189. * Interface for cullable objects
  7190. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7191. */
  7192. export interface ICullable {
  7193. /**
  7194. * Checks if the object or part of the object is in the frustum
  7195. * @param frustumPlanes Camera near/planes
  7196. * @returns true if the object is in frustum otherwise false
  7197. */
  7198. isInFrustum(frustumPlanes: Plane[]): boolean;
  7199. /**
  7200. * Checks if a cullable object (mesh...) is in the camera frustum
  7201. * Unlike isInFrustum this cheks the full bounding box
  7202. * @param frustumPlanes Camera near/planes
  7203. * @returns true if the object is in frustum otherwise false
  7204. */
  7205. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7206. }
  7207. /**
  7208. * Info for a bounding data of a mesh
  7209. */
  7210. export class BoundingInfo implements ICullable {
  7211. /**
  7212. * Bounding box for the mesh
  7213. */
  7214. readonly boundingBox: BoundingBox;
  7215. /**
  7216. * Bounding sphere for the mesh
  7217. */
  7218. readonly boundingSphere: BoundingSphere;
  7219. private _isLocked;
  7220. private static readonly TmpVector3;
  7221. /**
  7222. * Constructs bounding info
  7223. * @param minimum min vector of the bounding box/sphere
  7224. * @param maximum max vector of the bounding box/sphere
  7225. * @param worldMatrix defines the new world matrix
  7226. */
  7227. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7228. /**
  7229. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7230. * @param min defines the new minimum vector (in local space)
  7231. * @param max defines the new maximum vector (in local space)
  7232. * @param worldMatrix defines the new world matrix
  7233. */
  7234. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7235. /**
  7236. * min vector of the bounding box/sphere
  7237. */
  7238. get minimum(): Vector3;
  7239. /**
  7240. * max vector of the bounding box/sphere
  7241. */
  7242. get maximum(): Vector3;
  7243. /**
  7244. * If the info is locked and won't be updated to avoid perf overhead
  7245. */
  7246. get isLocked(): boolean;
  7247. set isLocked(value: boolean);
  7248. /**
  7249. * Updates the bounding sphere and box
  7250. * @param world world matrix to be used to update
  7251. */
  7252. update(world: DeepImmutable<Matrix>): void;
  7253. /**
  7254. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7255. * @param center New center of the bounding info
  7256. * @param extend New extend of the bounding info
  7257. * @returns the current bounding info
  7258. */
  7259. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7260. /**
  7261. * Scale the current bounding info by applying a scale factor
  7262. * @param factor defines the scale factor to apply
  7263. * @returns the current bounding info
  7264. */
  7265. scale(factor: number): BoundingInfo;
  7266. /**
  7267. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7268. * @param frustumPlanes defines the frustum to test
  7269. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7270. * @returns true if the bounding info is in the frustum planes
  7271. */
  7272. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7273. /**
  7274. * Gets the world distance between the min and max points of the bounding box
  7275. */
  7276. get diagonalLength(): number;
  7277. /**
  7278. * Checks if a cullable object (mesh...) is in the camera frustum
  7279. * Unlike isInFrustum this cheks the full bounding box
  7280. * @param frustumPlanes Camera near/planes
  7281. * @returns true if the object is in frustum otherwise false
  7282. */
  7283. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7284. /** @hidden */
  7285. _checkCollision(collider: Collider): boolean;
  7286. /**
  7287. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7288. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7289. * @param point the point to check intersection with
  7290. * @returns if the point intersects
  7291. */
  7292. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7293. /**
  7294. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7295. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7296. * @param boundingInfo the bounding info to check intersection with
  7297. * @param precise if the intersection should be done using OBB
  7298. * @returns if the bounding info intersects
  7299. */
  7300. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7301. }
  7302. }
  7303. declare module "babylonjs/Maths/math.functions" {
  7304. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7305. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7306. /**
  7307. * Extracts minimum and maximum values from a list of indexed positions
  7308. * @param positions defines the positions to use
  7309. * @param indices defines the indices to the positions
  7310. * @param indexStart defines the start index
  7311. * @param indexCount defines the end index
  7312. * @param bias defines bias value to add to the result
  7313. * @return minimum and maximum values
  7314. */
  7315. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7316. minimum: Vector3;
  7317. maximum: Vector3;
  7318. };
  7319. /**
  7320. * Extracts minimum and maximum values from a list of positions
  7321. * @param positions defines the positions to use
  7322. * @param start defines the start index in the positions array
  7323. * @param count defines the number of positions to handle
  7324. * @param bias defines bias value to add to the result
  7325. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7326. * @return minimum and maximum values
  7327. */
  7328. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7329. minimum: Vector3;
  7330. maximum: Vector3;
  7331. };
  7332. }
  7333. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7334. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7335. /** @hidden */
  7336. export class WebGLDataBuffer extends DataBuffer {
  7337. private _buffer;
  7338. constructor(resource: WebGLBuffer);
  7339. get underlyingResource(): any;
  7340. }
  7341. }
  7342. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7343. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7344. import { Nullable } from "babylonjs/types";
  7345. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7346. /** @hidden */
  7347. export class WebGLPipelineContext implements IPipelineContext {
  7348. engine: ThinEngine;
  7349. program: Nullable<WebGLProgram>;
  7350. context?: WebGLRenderingContext;
  7351. vertexShader?: WebGLShader;
  7352. fragmentShader?: WebGLShader;
  7353. isParallelCompiled: boolean;
  7354. onCompiled?: () => void;
  7355. transformFeedback?: WebGLTransformFeedback | null;
  7356. vertexCompilationError: Nullable<string>;
  7357. fragmentCompilationError: Nullable<string>;
  7358. programLinkError: Nullable<string>;
  7359. programValidationError: Nullable<string>;
  7360. get isAsync(): boolean;
  7361. get isReady(): boolean;
  7362. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7363. _getVertexShaderCode(): string | null;
  7364. _getFragmentShaderCode(): string | null;
  7365. }
  7366. }
  7367. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7368. import { FloatArray, Nullable } from "babylonjs/types";
  7369. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7370. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7371. module "babylonjs/Engines/thinEngine" {
  7372. interface ThinEngine {
  7373. /**
  7374. * Create an uniform buffer
  7375. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7376. * @param elements defines the content of the uniform buffer
  7377. * @returns the webGL uniform buffer
  7378. */
  7379. createUniformBuffer(elements: FloatArray): DataBuffer;
  7380. /**
  7381. * Create a dynamic uniform buffer
  7382. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7383. * @param elements defines the content of the uniform buffer
  7384. * @returns the webGL uniform buffer
  7385. */
  7386. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7387. /**
  7388. * Update an existing uniform buffer
  7389. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7390. * @param uniformBuffer defines the target uniform buffer
  7391. * @param elements defines the content to update
  7392. * @param offset defines the offset in the uniform buffer where update should start
  7393. * @param count defines the size of the data to update
  7394. */
  7395. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7396. /**
  7397. * Bind an uniform buffer to the current webGL context
  7398. * @param buffer defines the buffer to bind
  7399. */
  7400. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7401. /**
  7402. * Bind a buffer to the current webGL context at a given location
  7403. * @param buffer defines the buffer to bind
  7404. * @param location defines the index where to bind the buffer
  7405. */
  7406. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7407. /**
  7408. * Bind a specific block at a given index in a specific shader program
  7409. * @param pipelineContext defines the pipeline context to use
  7410. * @param blockName defines the block name
  7411. * @param index defines the index where to bind the block
  7412. */
  7413. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7414. }
  7415. }
  7416. }
  7417. declare module "babylonjs/Materials/uniformBuffer" {
  7418. import { Nullable, FloatArray } from "babylonjs/types";
  7419. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7420. import { Engine } from "babylonjs/Engines/engine";
  7421. import { Effect } from "babylonjs/Materials/effect";
  7422. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7423. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7424. import { Color3 } from "babylonjs/Maths/math.color";
  7425. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7426. /**
  7427. * Uniform buffer objects.
  7428. *
  7429. * Handles blocks of uniform on the GPU.
  7430. *
  7431. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7432. *
  7433. * For more information, please refer to :
  7434. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7435. */
  7436. export class UniformBuffer {
  7437. private _engine;
  7438. private _buffer;
  7439. private _data;
  7440. private _bufferData;
  7441. private _dynamic?;
  7442. private _uniformLocations;
  7443. private _uniformSizes;
  7444. private _uniformLocationPointer;
  7445. private _needSync;
  7446. private _noUBO;
  7447. private _currentEffect;
  7448. /** @hidden */
  7449. _alreadyBound: boolean;
  7450. private static _MAX_UNIFORM_SIZE;
  7451. private static _tempBuffer;
  7452. /**
  7453. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7454. * This is dynamic to allow compat with webgl 1 and 2.
  7455. * You will need to pass the name of the uniform as well as the value.
  7456. */
  7457. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7458. /**
  7459. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7460. * This is dynamic to allow compat with webgl 1 and 2.
  7461. * You will need to pass the name of the uniform as well as the value.
  7462. */
  7463. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7464. /**
  7465. * Lambda to Update a single float in a uniform buffer.
  7466. * This is dynamic to allow compat with webgl 1 and 2.
  7467. * You will need to pass the name of the uniform as well as the value.
  7468. */
  7469. updateFloat: (name: string, x: number) => void;
  7470. /**
  7471. * Lambda to Update a vec2 of float in a uniform buffer.
  7472. * This is dynamic to allow compat with webgl 1 and 2.
  7473. * You will need to pass the name of the uniform as well as the value.
  7474. */
  7475. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7476. /**
  7477. * Lambda to Update a vec3 of float in a uniform buffer.
  7478. * This is dynamic to allow compat with webgl 1 and 2.
  7479. * You will need to pass the name of the uniform as well as the value.
  7480. */
  7481. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7482. /**
  7483. * Lambda to Update a vec4 of float in a uniform buffer.
  7484. * This is dynamic to allow compat with webgl 1 and 2.
  7485. * You will need to pass the name of the uniform as well as the value.
  7486. */
  7487. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7488. /**
  7489. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7490. * This is dynamic to allow compat with webgl 1 and 2.
  7491. * You will need to pass the name of the uniform as well as the value.
  7492. */
  7493. updateMatrix: (name: string, mat: Matrix) => void;
  7494. /**
  7495. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7496. * This is dynamic to allow compat with webgl 1 and 2.
  7497. * You will need to pass the name of the uniform as well as the value.
  7498. */
  7499. updateVector3: (name: string, vector: Vector3) => void;
  7500. /**
  7501. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7502. * This is dynamic to allow compat with webgl 1 and 2.
  7503. * You will need to pass the name of the uniform as well as the value.
  7504. */
  7505. updateVector4: (name: string, vector: Vector4) => void;
  7506. /**
  7507. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7508. * This is dynamic to allow compat with webgl 1 and 2.
  7509. * You will need to pass the name of the uniform as well as the value.
  7510. */
  7511. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7512. /**
  7513. * Lambda to Update vec4 of float from a Color 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. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7518. /**
  7519. * Instantiates a new Uniform buffer objects.
  7520. *
  7521. * Handles blocks of uniform on the GPU.
  7522. *
  7523. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7524. *
  7525. * For more information, please refer to :
  7526. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7527. * @param engine Define the engine the buffer is associated with
  7528. * @param data Define the data contained in the buffer
  7529. * @param dynamic Define if the buffer is updatable
  7530. */
  7531. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7532. /**
  7533. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7534. * or just falling back on setUniformXXX calls.
  7535. */
  7536. get useUbo(): boolean;
  7537. /**
  7538. * Indicates if the WebGL underlying uniform buffer is in sync
  7539. * with the javascript cache data.
  7540. */
  7541. get isSync(): boolean;
  7542. /**
  7543. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7544. * Also, a dynamic UniformBuffer will disable cache verification and always
  7545. * update the underlying WebGL uniform buffer to the GPU.
  7546. * @returns if Dynamic, otherwise false
  7547. */
  7548. isDynamic(): boolean;
  7549. /**
  7550. * The data cache on JS side.
  7551. * @returns the underlying data as a float array
  7552. */
  7553. getData(): Float32Array;
  7554. /**
  7555. * The underlying WebGL Uniform buffer.
  7556. * @returns the webgl buffer
  7557. */
  7558. getBuffer(): Nullable<DataBuffer>;
  7559. /**
  7560. * std140 layout specifies how to align data within an UBO structure.
  7561. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7562. * for specs.
  7563. */
  7564. private _fillAlignment;
  7565. /**
  7566. * Adds an uniform in the buffer.
  7567. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7568. * for the layout to be correct !
  7569. * @param name Name of the uniform, as used in the uniform block in the shader.
  7570. * @param size Data size, or data directly.
  7571. */
  7572. addUniform(name: string, size: number | number[]): void;
  7573. /**
  7574. * Adds a Matrix 4x4 to the uniform buffer.
  7575. * @param name Name of the uniform, as used in the uniform block in the shader.
  7576. * @param mat A 4x4 matrix.
  7577. */
  7578. addMatrix(name: string, mat: Matrix): void;
  7579. /**
  7580. * Adds a vec2 to the uniform buffer.
  7581. * @param name Name of the uniform, as used in the uniform block in the shader.
  7582. * @param x Define the x component value of the vec2
  7583. * @param y Define the y component value of the vec2
  7584. */
  7585. addFloat2(name: string, x: number, y: number): void;
  7586. /**
  7587. * Adds a vec3 to the uniform buffer.
  7588. * @param name Name of the uniform, as used in the uniform block in the shader.
  7589. * @param x Define the x component value of the vec3
  7590. * @param y Define the y component value of the vec3
  7591. * @param z Define the z component value of the vec3
  7592. */
  7593. addFloat3(name: string, x: number, y: number, z: number): void;
  7594. /**
  7595. * Adds a vec3 to the uniform buffer.
  7596. * @param name Name of the uniform, as used in the uniform block in the shader.
  7597. * @param color Define the vec3 from a Color
  7598. */
  7599. addColor3(name: string, color: Color3): void;
  7600. /**
  7601. * Adds a vec4 to the uniform buffer.
  7602. * @param name Name of the uniform, as used in the uniform block in the shader.
  7603. * @param color Define the rgb components from a Color
  7604. * @param alpha Define the a component of the vec4
  7605. */
  7606. addColor4(name: string, color: Color3, alpha: number): void;
  7607. /**
  7608. * Adds a vec3 to the uniform buffer.
  7609. * @param name Name of the uniform, as used in the uniform block in the shader.
  7610. * @param vector Define the vec3 components from a Vector
  7611. */
  7612. addVector3(name: string, vector: Vector3): void;
  7613. /**
  7614. * Adds a Matrix 3x3 to the uniform buffer.
  7615. * @param name Name of the uniform, as used in the uniform block in the shader.
  7616. */
  7617. addMatrix3x3(name: string): void;
  7618. /**
  7619. * Adds a Matrix 2x2 to the uniform buffer.
  7620. * @param name Name of the uniform, as used in the uniform block in the shader.
  7621. */
  7622. addMatrix2x2(name: string): void;
  7623. /**
  7624. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7625. */
  7626. create(): void;
  7627. /** @hidden */
  7628. _rebuild(): void;
  7629. /**
  7630. * Updates the WebGL Uniform Buffer on the GPU.
  7631. * If the `dynamic` flag is set to true, no cache comparison is done.
  7632. * Otherwise, the buffer will be updated only if the cache differs.
  7633. */
  7634. update(): void;
  7635. /**
  7636. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7637. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7638. * @param data Define the flattened data
  7639. * @param size Define the size of the data.
  7640. */
  7641. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7642. private _valueCache;
  7643. private _cacheMatrix;
  7644. private _updateMatrix3x3ForUniform;
  7645. private _updateMatrix3x3ForEffect;
  7646. private _updateMatrix2x2ForEffect;
  7647. private _updateMatrix2x2ForUniform;
  7648. private _updateFloatForEffect;
  7649. private _updateFloatForUniform;
  7650. private _updateFloat2ForEffect;
  7651. private _updateFloat2ForUniform;
  7652. private _updateFloat3ForEffect;
  7653. private _updateFloat3ForUniform;
  7654. private _updateFloat4ForEffect;
  7655. private _updateFloat4ForUniform;
  7656. private _updateMatrixForEffect;
  7657. private _updateMatrixForUniform;
  7658. private _updateVector3ForEffect;
  7659. private _updateVector3ForUniform;
  7660. private _updateVector4ForEffect;
  7661. private _updateVector4ForUniform;
  7662. private _updateColor3ForEffect;
  7663. private _updateColor3ForUniform;
  7664. private _updateColor4ForEffect;
  7665. private _updateColor4ForUniform;
  7666. /**
  7667. * Sets a sampler uniform on the effect.
  7668. * @param name Define the name of the sampler.
  7669. * @param texture Define the texture to set in the sampler
  7670. */
  7671. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7672. /**
  7673. * Directly updates the value of the uniform in the cache AND on the GPU.
  7674. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7675. * @param data Define the flattened data
  7676. */
  7677. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7678. /**
  7679. * Binds this uniform buffer to an effect.
  7680. * @param effect Define the effect to bind the buffer to
  7681. * @param name Name of the uniform block in the shader.
  7682. */
  7683. bindToEffect(effect: Effect, name: string): void;
  7684. /**
  7685. * Disposes the uniform buffer.
  7686. */
  7687. dispose(): void;
  7688. }
  7689. }
  7690. declare module "babylonjs/Misc/iInspectable" {
  7691. /**
  7692. * Enum that determines the text-wrapping mode to use.
  7693. */
  7694. export enum InspectableType {
  7695. /**
  7696. * Checkbox for booleans
  7697. */
  7698. Checkbox = 0,
  7699. /**
  7700. * Sliders for numbers
  7701. */
  7702. Slider = 1,
  7703. /**
  7704. * Vector3
  7705. */
  7706. Vector3 = 2,
  7707. /**
  7708. * Quaternions
  7709. */
  7710. Quaternion = 3,
  7711. /**
  7712. * Color3
  7713. */
  7714. Color3 = 4,
  7715. /**
  7716. * String
  7717. */
  7718. String = 5
  7719. }
  7720. /**
  7721. * Interface used to define custom inspectable properties.
  7722. * This interface is used by the inspector to display custom property grids
  7723. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7724. */
  7725. export interface IInspectable {
  7726. /**
  7727. * Gets the label to display
  7728. */
  7729. label: string;
  7730. /**
  7731. * Gets the name of the property to edit
  7732. */
  7733. propertyName: string;
  7734. /**
  7735. * Gets the type of the editor to use
  7736. */
  7737. type: InspectableType;
  7738. /**
  7739. * Gets the minimum value of the property when using in "slider" mode
  7740. */
  7741. min?: number;
  7742. /**
  7743. * Gets the maximum value of the property when using in "slider" mode
  7744. */
  7745. max?: number;
  7746. /**
  7747. * Gets the setp to use when using in "slider" mode
  7748. */
  7749. step?: number;
  7750. }
  7751. }
  7752. declare module "babylonjs/Misc/timingTools" {
  7753. /**
  7754. * Class used to provide helper for timing
  7755. */
  7756. export class TimingTools {
  7757. /**
  7758. * Polyfill for setImmediate
  7759. * @param action defines the action to execute after the current execution block
  7760. */
  7761. static SetImmediate(action: () => void): void;
  7762. }
  7763. }
  7764. declare module "babylonjs/Misc/instantiationTools" {
  7765. /**
  7766. * Class used to enable instatition of objects by class name
  7767. */
  7768. export class InstantiationTools {
  7769. /**
  7770. * Use this object to register external classes like custom textures or material
  7771. * to allow the laoders to instantiate them
  7772. */
  7773. static RegisteredExternalClasses: {
  7774. [key: string]: Object;
  7775. };
  7776. /**
  7777. * Tries to instantiate a new object from a given class name
  7778. * @param className defines the class name to instantiate
  7779. * @returns the new object or null if the system was not able to do the instantiation
  7780. */
  7781. static Instantiate(className: string): any;
  7782. }
  7783. }
  7784. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7785. /**
  7786. * Define options used to create a depth texture
  7787. */
  7788. export class DepthTextureCreationOptions {
  7789. /** Specifies whether or not a stencil should be allocated in the texture */
  7790. generateStencil?: boolean;
  7791. /** Specifies whether or not bilinear filtering is enable on the texture */
  7792. bilinearFiltering?: boolean;
  7793. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7794. comparisonFunction?: number;
  7795. /** Specifies if the created texture is a cube texture */
  7796. isCube?: boolean;
  7797. }
  7798. }
  7799. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7800. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7801. import { Nullable } from "babylonjs/types";
  7802. import { Scene } from "babylonjs/scene";
  7803. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7804. module "babylonjs/Engines/thinEngine" {
  7805. interface ThinEngine {
  7806. /**
  7807. * Creates a depth stencil cube texture.
  7808. * This is only available in WebGL 2.
  7809. * @param size The size of face edge in the cube texture.
  7810. * @param options The options defining the cube texture.
  7811. * @returns The cube texture
  7812. */
  7813. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7814. /**
  7815. * Creates a cube texture
  7816. * @param rootUrl defines the url where the files to load is located
  7817. * @param scene defines the current scene
  7818. * @param files defines the list of files to load (1 per face)
  7819. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7820. * @param onLoad defines an optional callback raised when the texture is loaded
  7821. * @param onError defines an optional callback raised if there is an issue to load the texture
  7822. * @param format defines the format of the data
  7823. * @param forcedExtension defines the extension to use to pick the right loader
  7824. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7825. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7826. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7827. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7828. * @returns the cube texture as an InternalTexture
  7829. */
  7830. 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;
  7831. /**
  7832. * Creates a cube texture
  7833. * @param rootUrl defines the url where the files to load is located
  7834. * @param scene defines the current scene
  7835. * @param files defines the list of files to load (1 per face)
  7836. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7837. * @param onLoad defines an optional callback raised when the texture is loaded
  7838. * @param onError defines an optional callback raised if there is an issue to load the texture
  7839. * @param format defines the format of the data
  7840. * @param forcedExtension defines the extension to use to pick the right loader
  7841. * @returns the cube texture as an InternalTexture
  7842. */
  7843. 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;
  7844. /**
  7845. * Creates a cube texture
  7846. * @param rootUrl defines the url where the files to load is located
  7847. * @param scene defines the current scene
  7848. * @param files defines the list of files to load (1 per face)
  7849. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7850. * @param onLoad defines an optional callback raised when the texture is loaded
  7851. * @param onError defines an optional callback raised if there is an issue to load the texture
  7852. * @param format defines the format of the data
  7853. * @param forcedExtension defines the extension to use to pick the right loader
  7854. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7855. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7856. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7857. * @returns the cube texture as an InternalTexture
  7858. */
  7859. 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;
  7860. /** @hidden */
  7861. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7862. /** @hidden */
  7863. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7864. /** @hidden */
  7865. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7866. /** @hidden */
  7867. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7868. /**
  7869. * @hidden
  7870. */
  7871. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7872. }
  7873. }
  7874. }
  7875. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7876. import { Nullable } from "babylonjs/types";
  7877. import { Scene } from "babylonjs/scene";
  7878. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7879. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7880. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7881. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7882. import { Observable } from "babylonjs/Misc/observable";
  7883. /**
  7884. * Class for creating a cube texture
  7885. */
  7886. export class CubeTexture extends BaseTexture {
  7887. private _delayedOnLoad;
  7888. /**
  7889. * Observable triggered once the texture has been loaded.
  7890. */
  7891. onLoadObservable: Observable<CubeTexture>;
  7892. /**
  7893. * The url of the texture
  7894. */
  7895. url: string;
  7896. /**
  7897. * Gets or sets the center of the bounding box associated with the cube texture.
  7898. * It must define where the camera used to render the texture was set
  7899. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7900. */
  7901. boundingBoxPosition: Vector3;
  7902. private _boundingBoxSize;
  7903. /**
  7904. * Gets or sets the size of the bounding box associated with the cube texture
  7905. * When defined, the cubemap will switch to local mode
  7906. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7907. * @example https://www.babylonjs-playground.com/#RNASML
  7908. */
  7909. set boundingBoxSize(value: Vector3);
  7910. /**
  7911. * Returns the bounding box size
  7912. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7913. */
  7914. get boundingBoxSize(): Vector3;
  7915. protected _rotationY: number;
  7916. /**
  7917. * Sets texture matrix rotation angle around Y axis in radians.
  7918. */
  7919. set rotationY(value: number);
  7920. /**
  7921. * Gets texture matrix rotation angle around Y axis radians.
  7922. */
  7923. get rotationY(): number;
  7924. /**
  7925. * Are mip maps generated for this texture or not.
  7926. */
  7927. get noMipmap(): boolean;
  7928. private _noMipmap;
  7929. private _files;
  7930. protected _forcedExtension: Nullable<string>;
  7931. private _extensions;
  7932. private _textureMatrix;
  7933. private _format;
  7934. private _createPolynomials;
  7935. /**
  7936. * Creates a cube texture from an array of image urls
  7937. * @param files defines an array of image urls
  7938. * @param scene defines the hosting scene
  7939. * @param noMipmap specifies if mip maps are not used
  7940. * @returns a cube texture
  7941. */
  7942. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7943. /**
  7944. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7945. * @param url defines the url of the prefiltered texture
  7946. * @param scene defines the scene the texture is attached to
  7947. * @param forcedExtension defines the extension of the file if different from the url
  7948. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7949. * @return the prefiltered texture
  7950. */
  7951. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7952. /**
  7953. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7954. * as prefiltered data.
  7955. * @param rootUrl defines the url of the texture or the root name of the six images
  7956. * @param null defines the scene or engine the texture is attached to
  7957. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7958. * @param noMipmap defines if mipmaps should be created or not
  7959. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7960. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7961. * @param onError defines a callback triggered in case of error during load
  7962. * @param format defines the internal format to use for the texture once loaded
  7963. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7964. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7965. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7966. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7967. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7968. * @return the cube texture
  7969. */
  7970. 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);
  7971. /**
  7972. * Get the current class name of the texture useful for serialization or dynamic coding.
  7973. * @returns "CubeTexture"
  7974. */
  7975. getClassName(): string;
  7976. /**
  7977. * Update the url (and optional buffer) of this texture if url was null during construction.
  7978. * @param url the url of the texture
  7979. * @param forcedExtension defines the extension to use
  7980. * @param onLoad callback called when the texture is loaded (defaults to null)
  7981. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7982. */
  7983. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7984. /**
  7985. * Delays loading of the cube texture
  7986. * @param forcedExtension defines the extension to use
  7987. */
  7988. delayLoad(forcedExtension?: string): void;
  7989. /**
  7990. * Returns the reflection texture matrix
  7991. * @returns the reflection texture matrix
  7992. */
  7993. getReflectionTextureMatrix(): Matrix;
  7994. /**
  7995. * Sets the reflection texture matrix
  7996. * @param value Reflection texture matrix
  7997. */
  7998. setReflectionTextureMatrix(value: Matrix): void;
  7999. /**
  8000. * Parses text to create a cube texture
  8001. * @param parsedTexture define the serialized text to read from
  8002. * @param scene defines the hosting scene
  8003. * @param rootUrl defines the root url of the cube texture
  8004. * @returns a cube texture
  8005. */
  8006. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8007. /**
  8008. * Makes a clone, or deep copy, of the cube texture
  8009. * @returns a new cube texture
  8010. */
  8011. clone(): CubeTexture;
  8012. }
  8013. }
  8014. declare module "babylonjs/Materials/materialDefines" {
  8015. /**
  8016. * Manages the defines for the Material
  8017. */
  8018. export class MaterialDefines {
  8019. /** @hidden */
  8020. protected _keys: string[];
  8021. private _isDirty;
  8022. /** @hidden */
  8023. _renderId: number;
  8024. /** @hidden */
  8025. _areLightsDirty: boolean;
  8026. /** @hidden */
  8027. _areLightsDisposed: boolean;
  8028. /** @hidden */
  8029. _areAttributesDirty: boolean;
  8030. /** @hidden */
  8031. _areTexturesDirty: boolean;
  8032. /** @hidden */
  8033. _areFresnelDirty: boolean;
  8034. /** @hidden */
  8035. _areMiscDirty: boolean;
  8036. /** @hidden */
  8037. _areImageProcessingDirty: boolean;
  8038. /** @hidden */
  8039. _normals: boolean;
  8040. /** @hidden */
  8041. _uvs: boolean;
  8042. /** @hidden */
  8043. _needNormals: boolean;
  8044. /** @hidden */
  8045. _needUVs: boolean;
  8046. [id: string]: any;
  8047. /**
  8048. * Specifies if the material needs to be re-calculated
  8049. */
  8050. get isDirty(): boolean;
  8051. /**
  8052. * Marks the material to indicate that it has been re-calculated
  8053. */
  8054. markAsProcessed(): void;
  8055. /**
  8056. * Marks the material to indicate that it needs to be re-calculated
  8057. */
  8058. markAsUnprocessed(): void;
  8059. /**
  8060. * Marks the material to indicate all of its defines need to be re-calculated
  8061. */
  8062. markAllAsDirty(): void;
  8063. /**
  8064. * Marks the material to indicate that image processing needs to be re-calculated
  8065. */
  8066. markAsImageProcessingDirty(): void;
  8067. /**
  8068. * Marks the material to indicate the lights need to be re-calculated
  8069. * @param disposed Defines whether the light is dirty due to dispose or not
  8070. */
  8071. markAsLightDirty(disposed?: boolean): void;
  8072. /**
  8073. * Marks the attribute state as changed
  8074. */
  8075. markAsAttributesDirty(): void;
  8076. /**
  8077. * Marks the texture state as changed
  8078. */
  8079. markAsTexturesDirty(): void;
  8080. /**
  8081. * Marks the fresnel state as changed
  8082. */
  8083. markAsFresnelDirty(): void;
  8084. /**
  8085. * Marks the misc state as changed
  8086. */
  8087. markAsMiscDirty(): void;
  8088. /**
  8089. * Rebuilds the material defines
  8090. */
  8091. rebuild(): void;
  8092. /**
  8093. * Specifies if two material defines are equal
  8094. * @param other - A material define instance to compare to
  8095. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8096. */
  8097. isEqual(other: MaterialDefines): boolean;
  8098. /**
  8099. * Clones this instance's defines to another instance
  8100. * @param other - material defines to clone values to
  8101. */
  8102. cloneTo(other: MaterialDefines): void;
  8103. /**
  8104. * Resets the material define values
  8105. */
  8106. reset(): void;
  8107. /**
  8108. * Converts the material define values to a string
  8109. * @returns - String of material define information
  8110. */
  8111. toString(): string;
  8112. }
  8113. }
  8114. declare module "babylonjs/Materials/colorCurves" {
  8115. import { Effect } from "babylonjs/Materials/effect";
  8116. /**
  8117. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8118. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8119. * 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;
  8120. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8121. */
  8122. export class ColorCurves {
  8123. private _dirty;
  8124. private _tempColor;
  8125. private _globalCurve;
  8126. private _highlightsCurve;
  8127. private _midtonesCurve;
  8128. private _shadowsCurve;
  8129. private _positiveCurve;
  8130. private _negativeCurve;
  8131. private _globalHue;
  8132. private _globalDensity;
  8133. private _globalSaturation;
  8134. private _globalExposure;
  8135. /**
  8136. * Gets the global Hue value.
  8137. * 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).
  8138. */
  8139. get globalHue(): number;
  8140. /**
  8141. * Sets the global Hue value.
  8142. * 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).
  8143. */
  8144. set globalHue(value: number);
  8145. /**
  8146. * Gets the global Density value.
  8147. * 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.
  8148. * Values less than zero provide a filter of opposite hue.
  8149. */
  8150. get globalDensity(): number;
  8151. /**
  8152. * Sets the global Density value.
  8153. * 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.
  8154. * Values less than zero provide a filter of opposite hue.
  8155. */
  8156. set globalDensity(value: number);
  8157. /**
  8158. * Gets the global Saturation value.
  8159. * 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.
  8160. */
  8161. get globalSaturation(): number;
  8162. /**
  8163. * Sets the global Saturation value.
  8164. * 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.
  8165. */
  8166. set globalSaturation(value: number);
  8167. /**
  8168. * Gets the global Exposure value.
  8169. * 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.
  8170. */
  8171. get globalExposure(): number;
  8172. /**
  8173. * Sets the global Exposure value.
  8174. * 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.
  8175. */
  8176. set globalExposure(value: number);
  8177. private _highlightsHue;
  8178. private _highlightsDensity;
  8179. private _highlightsSaturation;
  8180. private _highlightsExposure;
  8181. /**
  8182. * Gets the highlights Hue value.
  8183. * 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).
  8184. */
  8185. get highlightsHue(): number;
  8186. /**
  8187. * Sets the highlights Hue value.
  8188. * 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).
  8189. */
  8190. set highlightsHue(value: number);
  8191. /**
  8192. * Gets the highlights Density value.
  8193. * 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.
  8194. * Values less than zero provide a filter of opposite hue.
  8195. */
  8196. get highlightsDensity(): number;
  8197. /**
  8198. * Sets the highlights Density value.
  8199. * 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.
  8200. * Values less than zero provide a filter of opposite hue.
  8201. */
  8202. set highlightsDensity(value: number);
  8203. /**
  8204. * Gets the highlights Saturation value.
  8205. * 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.
  8206. */
  8207. get highlightsSaturation(): number;
  8208. /**
  8209. * Sets the highlights Saturation value.
  8210. * 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.
  8211. */
  8212. set highlightsSaturation(value: number);
  8213. /**
  8214. * Gets the highlights Exposure value.
  8215. * 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.
  8216. */
  8217. get highlightsExposure(): number;
  8218. /**
  8219. * Sets the highlights Exposure value.
  8220. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8221. */
  8222. set highlightsExposure(value: number);
  8223. private _midtonesHue;
  8224. private _midtonesDensity;
  8225. private _midtonesSaturation;
  8226. private _midtonesExposure;
  8227. /**
  8228. * Gets the midtones Hue value.
  8229. * 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).
  8230. */
  8231. get midtonesHue(): number;
  8232. /**
  8233. * Sets the midtones Hue value.
  8234. * 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).
  8235. */
  8236. set midtonesHue(value: number);
  8237. /**
  8238. * Gets the midtones Density value.
  8239. * 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.
  8240. * Values less than zero provide a filter of opposite hue.
  8241. */
  8242. get midtonesDensity(): number;
  8243. /**
  8244. * Sets the midtones Density value.
  8245. * 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.
  8246. * Values less than zero provide a filter of opposite hue.
  8247. */
  8248. set midtonesDensity(value: number);
  8249. /**
  8250. * Gets the midtones Saturation value.
  8251. * 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.
  8252. */
  8253. get midtonesSaturation(): number;
  8254. /**
  8255. * Sets the midtones Saturation value.
  8256. * 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.
  8257. */
  8258. set midtonesSaturation(value: number);
  8259. /**
  8260. * Gets the midtones Exposure value.
  8261. * 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.
  8262. */
  8263. get midtonesExposure(): number;
  8264. /**
  8265. * Sets the midtones Exposure value.
  8266. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8267. */
  8268. set midtonesExposure(value: number);
  8269. private _shadowsHue;
  8270. private _shadowsDensity;
  8271. private _shadowsSaturation;
  8272. private _shadowsExposure;
  8273. /**
  8274. * Gets the shadows Hue value.
  8275. * 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).
  8276. */
  8277. get shadowsHue(): number;
  8278. /**
  8279. * Sets the shadows Hue value.
  8280. * 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).
  8281. */
  8282. set shadowsHue(value: number);
  8283. /**
  8284. * Gets the shadows Density value.
  8285. * 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.
  8286. * Values less than zero provide a filter of opposite hue.
  8287. */
  8288. get shadowsDensity(): number;
  8289. /**
  8290. * Sets the shadows Density value.
  8291. * 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.
  8292. * Values less than zero provide a filter of opposite hue.
  8293. */
  8294. set shadowsDensity(value: number);
  8295. /**
  8296. * Gets the shadows Saturation value.
  8297. * 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.
  8298. */
  8299. get shadowsSaturation(): number;
  8300. /**
  8301. * Sets the shadows Saturation value.
  8302. * 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.
  8303. */
  8304. set shadowsSaturation(value: number);
  8305. /**
  8306. * Gets the shadows Exposure value.
  8307. * 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.
  8308. */
  8309. get shadowsExposure(): number;
  8310. /**
  8311. * Sets the shadows Exposure value.
  8312. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8313. */
  8314. set shadowsExposure(value: number);
  8315. /**
  8316. * Returns the class name
  8317. * @returns The class name
  8318. */
  8319. getClassName(): string;
  8320. /**
  8321. * Binds the color curves to the shader.
  8322. * @param colorCurves The color curve to bind
  8323. * @param effect The effect to bind to
  8324. * @param positiveUniform The positive uniform shader parameter
  8325. * @param neutralUniform The neutral uniform shader parameter
  8326. * @param negativeUniform The negative uniform shader parameter
  8327. */
  8328. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8329. /**
  8330. * Prepare the list of uniforms associated with the ColorCurves effects.
  8331. * @param uniformsList The list of uniforms used in the effect
  8332. */
  8333. static PrepareUniforms(uniformsList: string[]): void;
  8334. /**
  8335. * Returns color grading data based on a hue, density, saturation and exposure value.
  8336. * @param filterHue The hue of the color filter.
  8337. * @param filterDensity The density of the color filter.
  8338. * @param saturation The saturation.
  8339. * @param exposure The exposure.
  8340. * @param result The result data container.
  8341. */
  8342. private getColorGradingDataToRef;
  8343. /**
  8344. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8345. * @param value The input slider value in range [-100,100].
  8346. * @returns Adjusted value.
  8347. */
  8348. private static applyColorGradingSliderNonlinear;
  8349. /**
  8350. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8351. * @param hue The hue (H) input.
  8352. * @param saturation The saturation (S) input.
  8353. * @param brightness The brightness (B) input.
  8354. * @result An RGBA color represented as Vector4.
  8355. */
  8356. private static fromHSBToRef;
  8357. /**
  8358. * Returns a value clamped between min and max
  8359. * @param value The value to clamp
  8360. * @param min The minimum of value
  8361. * @param max The maximum of value
  8362. * @returns The clamped value.
  8363. */
  8364. private static clamp;
  8365. /**
  8366. * Clones the current color curve instance.
  8367. * @return The cloned curves
  8368. */
  8369. clone(): ColorCurves;
  8370. /**
  8371. * Serializes the current color curve instance to a json representation.
  8372. * @return a JSON representation
  8373. */
  8374. serialize(): any;
  8375. /**
  8376. * Parses the color curve from a json representation.
  8377. * @param source the JSON source to parse
  8378. * @return The parsed curves
  8379. */
  8380. static Parse(source: any): ColorCurves;
  8381. }
  8382. }
  8383. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8384. import { Observable } from "babylonjs/Misc/observable";
  8385. import { Nullable } from "babylonjs/types";
  8386. import { Color4 } from "babylonjs/Maths/math.color";
  8387. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8388. import { Effect } from "babylonjs/Materials/effect";
  8389. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8390. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8391. /**
  8392. * Interface to follow in your material defines to integrate easily the
  8393. * Image proccessing functions.
  8394. * @hidden
  8395. */
  8396. export interface IImageProcessingConfigurationDefines {
  8397. IMAGEPROCESSING: boolean;
  8398. VIGNETTE: boolean;
  8399. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8400. VIGNETTEBLENDMODEOPAQUE: boolean;
  8401. TONEMAPPING: boolean;
  8402. TONEMAPPING_ACES: boolean;
  8403. CONTRAST: boolean;
  8404. EXPOSURE: boolean;
  8405. COLORCURVES: boolean;
  8406. COLORGRADING: boolean;
  8407. COLORGRADING3D: boolean;
  8408. SAMPLER3DGREENDEPTH: boolean;
  8409. SAMPLER3DBGRMAP: boolean;
  8410. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8411. }
  8412. /**
  8413. * @hidden
  8414. */
  8415. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8416. IMAGEPROCESSING: boolean;
  8417. VIGNETTE: boolean;
  8418. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8419. VIGNETTEBLENDMODEOPAQUE: boolean;
  8420. TONEMAPPING: boolean;
  8421. TONEMAPPING_ACES: boolean;
  8422. CONTRAST: boolean;
  8423. COLORCURVES: boolean;
  8424. COLORGRADING: boolean;
  8425. COLORGRADING3D: boolean;
  8426. SAMPLER3DGREENDEPTH: boolean;
  8427. SAMPLER3DBGRMAP: boolean;
  8428. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8429. EXPOSURE: boolean;
  8430. constructor();
  8431. }
  8432. /**
  8433. * This groups together the common properties used for image processing either in direct forward pass
  8434. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8435. * or not.
  8436. */
  8437. export class ImageProcessingConfiguration {
  8438. /**
  8439. * Default tone mapping applied in BabylonJS.
  8440. */
  8441. static readonly TONEMAPPING_STANDARD: number;
  8442. /**
  8443. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8444. * to other engines rendering to increase portability.
  8445. */
  8446. static readonly TONEMAPPING_ACES: number;
  8447. /**
  8448. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8449. */
  8450. colorCurves: Nullable<ColorCurves>;
  8451. private _colorCurvesEnabled;
  8452. /**
  8453. * Gets wether the color curves effect is enabled.
  8454. */
  8455. get colorCurvesEnabled(): boolean;
  8456. /**
  8457. * Sets wether the color curves effect is enabled.
  8458. */
  8459. set colorCurvesEnabled(value: boolean);
  8460. private _colorGradingTexture;
  8461. /**
  8462. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8463. */
  8464. get colorGradingTexture(): Nullable<BaseTexture>;
  8465. /**
  8466. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8467. */
  8468. set colorGradingTexture(value: Nullable<BaseTexture>);
  8469. private _colorGradingEnabled;
  8470. /**
  8471. * Gets wether the color grading effect is enabled.
  8472. */
  8473. get colorGradingEnabled(): boolean;
  8474. /**
  8475. * Sets wether the color grading effect is enabled.
  8476. */
  8477. set colorGradingEnabled(value: boolean);
  8478. private _colorGradingWithGreenDepth;
  8479. /**
  8480. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8481. */
  8482. get colorGradingWithGreenDepth(): boolean;
  8483. /**
  8484. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8485. */
  8486. set colorGradingWithGreenDepth(value: boolean);
  8487. private _colorGradingBGR;
  8488. /**
  8489. * Gets wether the color grading texture contains BGR values.
  8490. */
  8491. get colorGradingBGR(): boolean;
  8492. /**
  8493. * Sets wether the color grading texture contains BGR values.
  8494. */
  8495. set colorGradingBGR(value: boolean);
  8496. /** @hidden */
  8497. _exposure: number;
  8498. /**
  8499. * Gets the Exposure used in the effect.
  8500. */
  8501. get exposure(): number;
  8502. /**
  8503. * Sets the Exposure used in the effect.
  8504. */
  8505. set exposure(value: number);
  8506. private _toneMappingEnabled;
  8507. /**
  8508. * Gets wether the tone mapping effect is enabled.
  8509. */
  8510. get toneMappingEnabled(): boolean;
  8511. /**
  8512. * Sets wether the tone mapping effect is enabled.
  8513. */
  8514. set toneMappingEnabled(value: boolean);
  8515. private _toneMappingType;
  8516. /**
  8517. * Gets the type of tone mapping effect.
  8518. */
  8519. get toneMappingType(): number;
  8520. /**
  8521. * Sets the type of tone mapping effect used in BabylonJS.
  8522. */
  8523. set toneMappingType(value: number);
  8524. protected _contrast: number;
  8525. /**
  8526. * Gets the contrast used in the effect.
  8527. */
  8528. get contrast(): number;
  8529. /**
  8530. * Sets the contrast used in the effect.
  8531. */
  8532. set contrast(value: number);
  8533. /**
  8534. * Vignette stretch size.
  8535. */
  8536. vignetteStretch: number;
  8537. /**
  8538. * Vignette centre X Offset.
  8539. */
  8540. vignetteCentreX: number;
  8541. /**
  8542. * Vignette centre Y Offset.
  8543. */
  8544. vignetteCentreY: number;
  8545. /**
  8546. * Vignette weight or intensity of the vignette effect.
  8547. */
  8548. vignetteWeight: number;
  8549. /**
  8550. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8551. * if vignetteEnabled is set to true.
  8552. */
  8553. vignetteColor: Color4;
  8554. /**
  8555. * Camera field of view used by the Vignette effect.
  8556. */
  8557. vignetteCameraFov: number;
  8558. private _vignetteBlendMode;
  8559. /**
  8560. * Gets the vignette blend mode allowing different kind of effect.
  8561. */
  8562. get vignetteBlendMode(): number;
  8563. /**
  8564. * Sets the vignette blend mode allowing different kind of effect.
  8565. */
  8566. set vignetteBlendMode(value: number);
  8567. private _vignetteEnabled;
  8568. /**
  8569. * Gets wether the vignette effect is enabled.
  8570. */
  8571. get vignetteEnabled(): boolean;
  8572. /**
  8573. * Sets wether the vignette effect is enabled.
  8574. */
  8575. set vignetteEnabled(value: boolean);
  8576. private _applyByPostProcess;
  8577. /**
  8578. * Gets wether the image processing is applied through a post process or not.
  8579. */
  8580. get applyByPostProcess(): boolean;
  8581. /**
  8582. * Sets wether the image processing is applied through a post process or not.
  8583. */
  8584. set applyByPostProcess(value: boolean);
  8585. private _isEnabled;
  8586. /**
  8587. * Gets wether the image processing is enabled or not.
  8588. */
  8589. get isEnabled(): boolean;
  8590. /**
  8591. * Sets wether the image processing is enabled or not.
  8592. */
  8593. set isEnabled(value: boolean);
  8594. /**
  8595. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8596. */
  8597. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8598. /**
  8599. * Method called each time the image processing information changes requires to recompile the effect.
  8600. */
  8601. protected _updateParameters(): void;
  8602. /**
  8603. * Gets the current class name.
  8604. * @return "ImageProcessingConfiguration"
  8605. */
  8606. getClassName(): string;
  8607. /**
  8608. * Prepare the list of uniforms associated with the Image Processing effects.
  8609. * @param uniforms The list of uniforms used in the effect
  8610. * @param defines the list of defines currently in use
  8611. */
  8612. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8613. /**
  8614. * Prepare the list of samplers associated with the Image Processing effects.
  8615. * @param samplersList The list of uniforms used in the effect
  8616. * @param defines the list of defines currently in use
  8617. */
  8618. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8619. /**
  8620. * Prepare the list of defines associated to the shader.
  8621. * @param defines the list of defines to complete
  8622. * @param forPostProcess Define if we are currently in post process mode or not
  8623. */
  8624. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8625. /**
  8626. * Returns true if all the image processing information are ready.
  8627. * @returns True if ready, otherwise, false
  8628. */
  8629. isReady(): boolean;
  8630. /**
  8631. * Binds the image processing to the shader.
  8632. * @param effect The effect to bind to
  8633. * @param overrideAspectRatio Override the aspect ratio of the effect
  8634. */
  8635. bind(effect: Effect, overrideAspectRatio?: number): void;
  8636. /**
  8637. * Clones the current image processing instance.
  8638. * @return The cloned image processing
  8639. */
  8640. clone(): ImageProcessingConfiguration;
  8641. /**
  8642. * Serializes the current image processing instance to a json representation.
  8643. * @return a JSON representation
  8644. */
  8645. serialize(): any;
  8646. /**
  8647. * Parses the image processing from a json representation.
  8648. * @param source the JSON source to parse
  8649. * @return The parsed image processing
  8650. */
  8651. static Parse(source: any): ImageProcessingConfiguration;
  8652. private static _VIGNETTEMODE_MULTIPLY;
  8653. private static _VIGNETTEMODE_OPAQUE;
  8654. /**
  8655. * Used to apply the vignette as a mix with the pixel color.
  8656. */
  8657. static get VIGNETTEMODE_MULTIPLY(): number;
  8658. /**
  8659. * Used to apply the vignette as a replacement of the pixel color.
  8660. */
  8661. static get VIGNETTEMODE_OPAQUE(): number;
  8662. }
  8663. }
  8664. declare module "babylonjs/Shaders/postprocess.vertex" {
  8665. /** @hidden */
  8666. export var postprocessVertexShader: {
  8667. name: string;
  8668. shader: string;
  8669. };
  8670. }
  8671. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8672. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8673. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8674. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8675. module "babylonjs/Engines/thinEngine" {
  8676. interface ThinEngine {
  8677. /**
  8678. * Creates a new render target texture
  8679. * @param size defines the size of the texture
  8680. * @param options defines the options used to create the texture
  8681. * @returns a new render target texture stored in an InternalTexture
  8682. */
  8683. createRenderTargetTexture(size: number | {
  8684. width: number;
  8685. height: number;
  8686. layers?: number;
  8687. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8688. /**
  8689. * Creates a depth stencil texture.
  8690. * This is only available in WebGL 2 or with the depth texture extension available.
  8691. * @param size The size of face edge in the texture.
  8692. * @param options The options defining the texture.
  8693. * @returns The texture
  8694. */
  8695. createDepthStencilTexture(size: number | {
  8696. width: number;
  8697. height: number;
  8698. layers?: number;
  8699. }, options: DepthTextureCreationOptions): InternalTexture;
  8700. /** @hidden */
  8701. _createDepthStencilTexture(size: number | {
  8702. width: number;
  8703. height: number;
  8704. layers?: number;
  8705. }, options: DepthTextureCreationOptions): InternalTexture;
  8706. }
  8707. }
  8708. }
  8709. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  8710. /**
  8711. * Defines the kind of connection point for node based material
  8712. */
  8713. export enum NodeMaterialBlockConnectionPointTypes {
  8714. /** Float */
  8715. Float = 1,
  8716. /** Int */
  8717. Int = 2,
  8718. /** Vector2 */
  8719. Vector2 = 4,
  8720. /** Vector3 */
  8721. Vector3 = 8,
  8722. /** Vector4 */
  8723. Vector4 = 16,
  8724. /** Color3 */
  8725. Color3 = 32,
  8726. /** Color4 */
  8727. Color4 = 64,
  8728. /** Matrix */
  8729. Matrix = 128,
  8730. /** Custom object */
  8731. Object = 256,
  8732. /** Detect type based on connection */
  8733. AutoDetect = 1024,
  8734. /** Output type that will be defined by input type */
  8735. BasedOnInput = 2048
  8736. }
  8737. }
  8738. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  8739. /**
  8740. * Enum used to define the target of a block
  8741. */
  8742. export enum NodeMaterialBlockTargets {
  8743. /** Vertex shader */
  8744. Vertex = 1,
  8745. /** Fragment shader */
  8746. Fragment = 2,
  8747. /** Neutral */
  8748. Neutral = 4,
  8749. /** Vertex and Fragment */
  8750. VertexAndFragment = 3
  8751. }
  8752. }
  8753. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  8754. /**
  8755. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8756. */
  8757. export enum NodeMaterialBlockConnectionPointMode {
  8758. /** Value is an uniform */
  8759. Uniform = 0,
  8760. /** Value is a mesh attribute */
  8761. Attribute = 1,
  8762. /** Value is a varying between vertex and fragment shaders */
  8763. Varying = 2,
  8764. /** Mode is undefined */
  8765. Undefined = 3
  8766. }
  8767. }
  8768. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  8769. /**
  8770. * Enum used to define system values e.g. values automatically provided by the system
  8771. */
  8772. export enum NodeMaterialSystemValues {
  8773. /** World */
  8774. World = 1,
  8775. /** View */
  8776. View = 2,
  8777. /** Projection */
  8778. Projection = 3,
  8779. /** ViewProjection */
  8780. ViewProjection = 4,
  8781. /** WorldView */
  8782. WorldView = 5,
  8783. /** WorldViewProjection */
  8784. WorldViewProjection = 6,
  8785. /** CameraPosition */
  8786. CameraPosition = 7,
  8787. /** Fog Color */
  8788. FogColor = 8,
  8789. /** Delta time */
  8790. DeltaTime = 9
  8791. }
  8792. }
  8793. declare module "babylonjs/Maths/math.axis" {
  8794. import { Vector3 } from "babylonjs/Maths/math.vector";
  8795. /** Defines supported spaces */
  8796. export enum Space {
  8797. /** Local (object) space */
  8798. LOCAL = 0,
  8799. /** World space */
  8800. WORLD = 1,
  8801. /** Bone space */
  8802. BONE = 2
  8803. }
  8804. /** Defines the 3 main axes */
  8805. export class Axis {
  8806. /** X axis */
  8807. static X: Vector3;
  8808. /** Y axis */
  8809. static Y: Vector3;
  8810. /** Z axis */
  8811. static Z: Vector3;
  8812. }
  8813. }
  8814. declare module "babylonjs/Maths/math.frustum" {
  8815. import { Matrix } from "babylonjs/Maths/math.vector";
  8816. import { DeepImmutable } from "babylonjs/types";
  8817. import { Plane } from "babylonjs/Maths/math.plane";
  8818. /**
  8819. * Represents a camera frustum
  8820. */
  8821. export class Frustum {
  8822. /**
  8823. * Gets the planes representing the frustum
  8824. * @param transform matrix to be applied to the returned planes
  8825. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8826. */
  8827. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8828. /**
  8829. * Gets the near frustum plane transformed by the transform matrix
  8830. * @param transform transformation matrix to be applied to the resulting frustum plane
  8831. * @param frustumPlane the resuling frustum plane
  8832. */
  8833. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8834. /**
  8835. * Gets the far frustum plane transformed by the transform matrix
  8836. * @param transform transformation matrix to be applied to the resulting frustum plane
  8837. * @param frustumPlane the resuling frustum plane
  8838. */
  8839. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8840. /**
  8841. * Gets the left frustum plane transformed by the transform matrix
  8842. * @param transform transformation matrix to be applied to the resulting frustum plane
  8843. * @param frustumPlane the resuling frustum plane
  8844. */
  8845. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8846. /**
  8847. * Gets the right frustum plane transformed by the transform matrix
  8848. * @param transform transformation matrix to be applied to the resulting frustum plane
  8849. * @param frustumPlane the resuling frustum plane
  8850. */
  8851. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8852. /**
  8853. * Gets the top frustum plane transformed by the transform matrix
  8854. * @param transform transformation matrix to be applied to the resulting frustum plane
  8855. * @param frustumPlane the resuling frustum plane
  8856. */
  8857. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8858. /**
  8859. * Gets the bottom frustum plane transformed by the transform matrix
  8860. * @param transform transformation matrix to be applied to the resulting frustum plane
  8861. * @param frustumPlane the resuling frustum plane
  8862. */
  8863. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8864. /**
  8865. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8866. * @param transform transformation matrix to be applied to the resulting frustum planes
  8867. * @param frustumPlanes the resuling frustum planes
  8868. */
  8869. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8870. }
  8871. }
  8872. declare module "babylonjs/Maths/math.size" {
  8873. /**
  8874. * Interface for the size containing width and height
  8875. */
  8876. export interface ISize {
  8877. /**
  8878. * Width
  8879. */
  8880. width: number;
  8881. /**
  8882. * Heighht
  8883. */
  8884. height: number;
  8885. }
  8886. /**
  8887. * Size containing widht and height
  8888. */
  8889. export class Size implements ISize {
  8890. /**
  8891. * Width
  8892. */
  8893. width: number;
  8894. /**
  8895. * Height
  8896. */
  8897. height: number;
  8898. /**
  8899. * Creates a Size object from the given width and height (floats).
  8900. * @param width width of the new size
  8901. * @param height height of the new size
  8902. */
  8903. constructor(width: number, height: number);
  8904. /**
  8905. * Returns a string with the Size width and height
  8906. * @returns a string with the Size width and height
  8907. */
  8908. toString(): string;
  8909. /**
  8910. * "Size"
  8911. * @returns the string "Size"
  8912. */
  8913. getClassName(): string;
  8914. /**
  8915. * Returns the Size hash code.
  8916. * @returns a hash code for a unique width and height
  8917. */
  8918. getHashCode(): number;
  8919. /**
  8920. * Updates the current size from the given one.
  8921. * @param src the given size
  8922. */
  8923. copyFrom(src: Size): void;
  8924. /**
  8925. * Updates in place the current Size from the given floats.
  8926. * @param width width of the new size
  8927. * @param height height of the new size
  8928. * @returns the updated Size.
  8929. */
  8930. copyFromFloats(width: number, height: number): Size;
  8931. /**
  8932. * Updates in place the current Size from the given floats.
  8933. * @param width width to set
  8934. * @param height height to set
  8935. * @returns the updated Size.
  8936. */
  8937. set(width: number, height: number): Size;
  8938. /**
  8939. * Multiplies the width and height by numbers
  8940. * @param w factor to multiple the width by
  8941. * @param h factor to multiple the height by
  8942. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8943. */
  8944. multiplyByFloats(w: number, h: number): Size;
  8945. /**
  8946. * Clones the size
  8947. * @returns a new Size copied from the given one.
  8948. */
  8949. clone(): Size;
  8950. /**
  8951. * True if the current Size and the given one width and height are strictly equal.
  8952. * @param other the other size to compare against
  8953. * @returns True if the current Size and the given one width and height are strictly equal.
  8954. */
  8955. equals(other: Size): boolean;
  8956. /**
  8957. * The surface of the Size : width * height (float).
  8958. */
  8959. get surface(): number;
  8960. /**
  8961. * Create a new size of zero
  8962. * @returns a new Size set to (0.0, 0.0)
  8963. */
  8964. static Zero(): Size;
  8965. /**
  8966. * Sums the width and height of two sizes
  8967. * @param otherSize size to add to this size
  8968. * @returns a new Size set as the addition result of the current Size and the given one.
  8969. */
  8970. add(otherSize: Size): Size;
  8971. /**
  8972. * Subtracts the width and height of two
  8973. * @param otherSize size to subtract to this size
  8974. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8975. */
  8976. subtract(otherSize: Size): Size;
  8977. /**
  8978. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8979. * @param start starting size to lerp between
  8980. * @param end end size to lerp between
  8981. * @param amount amount to lerp between the start and end values
  8982. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8983. */
  8984. static Lerp(start: Size, end: Size, amount: number): Size;
  8985. }
  8986. }
  8987. declare module "babylonjs/Maths/math.vertexFormat" {
  8988. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8989. /**
  8990. * Contains position and normal vectors for a vertex
  8991. */
  8992. export class PositionNormalVertex {
  8993. /** the position of the vertex (defaut: 0,0,0) */
  8994. position: Vector3;
  8995. /** the normal of the vertex (defaut: 0,1,0) */
  8996. normal: Vector3;
  8997. /**
  8998. * Creates a PositionNormalVertex
  8999. * @param position the position of the vertex (defaut: 0,0,0)
  9000. * @param normal the normal of the vertex (defaut: 0,1,0)
  9001. */
  9002. constructor(
  9003. /** the position of the vertex (defaut: 0,0,0) */
  9004. position?: Vector3,
  9005. /** the normal of the vertex (defaut: 0,1,0) */
  9006. normal?: Vector3);
  9007. /**
  9008. * Clones the PositionNormalVertex
  9009. * @returns the cloned PositionNormalVertex
  9010. */
  9011. clone(): PositionNormalVertex;
  9012. }
  9013. /**
  9014. * Contains position, normal and uv vectors for a vertex
  9015. */
  9016. export class PositionNormalTextureVertex {
  9017. /** the position of the vertex (defaut: 0,0,0) */
  9018. position: Vector3;
  9019. /** the normal of the vertex (defaut: 0,1,0) */
  9020. normal: Vector3;
  9021. /** the uv of the vertex (default: 0,0) */
  9022. uv: Vector2;
  9023. /**
  9024. * Creates a PositionNormalTextureVertex
  9025. * @param position the position of the vertex (defaut: 0,0,0)
  9026. * @param normal the normal of the vertex (defaut: 0,1,0)
  9027. * @param uv the uv of the vertex (default: 0,0)
  9028. */
  9029. constructor(
  9030. /** the position of the vertex (defaut: 0,0,0) */
  9031. position?: Vector3,
  9032. /** the normal of the vertex (defaut: 0,1,0) */
  9033. normal?: Vector3,
  9034. /** the uv of the vertex (default: 0,0) */
  9035. uv?: Vector2);
  9036. /**
  9037. * Clones the PositionNormalTextureVertex
  9038. * @returns the cloned PositionNormalTextureVertex
  9039. */
  9040. clone(): PositionNormalTextureVertex;
  9041. }
  9042. }
  9043. declare module "babylonjs/Maths/math" {
  9044. export * from "babylonjs/Maths/math.axis";
  9045. export * from "babylonjs/Maths/math.color";
  9046. export * from "babylonjs/Maths/math.constants";
  9047. export * from "babylonjs/Maths/math.frustum";
  9048. export * from "babylonjs/Maths/math.path";
  9049. export * from "babylonjs/Maths/math.plane";
  9050. export * from "babylonjs/Maths/math.size";
  9051. export * from "babylonjs/Maths/math.vector";
  9052. export * from "babylonjs/Maths/math.vertexFormat";
  9053. export * from "babylonjs/Maths/math.viewport";
  9054. }
  9055. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  9056. /**
  9057. * Enum defining the type of animations supported by InputBlock
  9058. */
  9059. export enum AnimatedInputBlockTypes {
  9060. /** No animation */
  9061. None = 0,
  9062. /** Time based animation. Will only work for floats */
  9063. Time = 1
  9064. }
  9065. }
  9066. declare module "babylonjs/Lights/shadowLight" {
  9067. import { Camera } from "babylonjs/Cameras/camera";
  9068. import { Scene } from "babylonjs/scene";
  9069. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9070. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9071. import { Light } from "babylonjs/Lights/light";
  9072. /**
  9073. * Interface describing all the common properties and methods a shadow light needs to implement.
  9074. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9075. * as well as binding the different shadow properties to the effects.
  9076. */
  9077. export interface IShadowLight extends Light {
  9078. /**
  9079. * The light id in the scene (used in scene.findLighById for instance)
  9080. */
  9081. id: string;
  9082. /**
  9083. * The position the shdow will be casted from.
  9084. */
  9085. position: Vector3;
  9086. /**
  9087. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9088. */
  9089. direction: Vector3;
  9090. /**
  9091. * The transformed position. Position of the light in world space taking parenting in account.
  9092. */
  9093. transformedPosition: Vector3;
  9094. /**
  9095. * The transformed direction. Direction of the light in world space taking parenting in account.
  9096. */
  9097. transformedDirection: Vector3;
  9098. /**
  9099. * The friendly name of the light in the scene.
  9100. */
  9101. name: string;
  9102. /**
  9103. * Defines the shadow projection clipping minimum z value.
  9104. */
  9105. shadowMinZ: number;
  9106. /**
  9107. * Defines the shadow projection clipping maximum z value.
  9108. */
  9109. shadowMaxZ: number;
  9110. /**
  9111. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9112. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9113. */
  9114. computeTransformedInformation(): boolean;
  9115. /**
  9116. * Gets the scene the light belongs to.
  9117. * @returns The scene
  9118. */
  9119. getScene(): Scene;
  9120. /**
  9121. * Callback defining a custom Projection Matrix Builder.
  9122. * This can be used to override the default projection matrix computation.
  9123. */
  9124. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9125. /**
  9126. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9127. * @param matrix The materix to updated with the projection information
  9128. * @param viewMatrix The transform matrix of the light
  9129. * @param renderList The list of mesh to render in the map
  9130. * @returns The current light
  9131. */
  9132. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9133. /**
  9134. * Gets the current depth scale used in ESM.
  9135. * @returns The scale
  9136. */
  9137. getDepthScale(): number;
  9138. /**
  9139. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9140. * @returns true if a cube texture needs to be use
  9141. */
  9142. needCube(): boolean;
  9143. /**
  9144. * Detects if the projection matrix requires to be recomputed this frame.
  9145. * @returns true if it requires to be recomputed otherwise, false.
  9146. */
  9147. needProjectionMatrixCompute(): boolean;
  9148. /**
  9149. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9150. */
  9151. forceProjectionMatrixCompute(): void;
  9152. /**
  9153. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9154. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9155. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9156. */
  9157. getShadowDirection(faceIndex?: number): Vector3;
  9158. /**
  9159. * Gets the minZ used for shadow according to both the scene and the light.
  9160. * @param activeCamera The camera we are returning the min for
  9161. * @returns the depth min z
  9162. */
  9163. getDepthMinZ(activeCamera: Camera): number;
  9164. /**
  9165. * Gets the maxZ used for shadow according to both the scene and the light.
  9166. * @param activeCamera The camera we are returning the max for
  9167. * @returns the depth max z
  9168. */
  9169. getDepthMaxZ(activeCamera: Camera): number;
  9170. }
  9171. /**
  9172. * Base implementation IShadowLight
  9173. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9174. */
  9175. export abstract class ShadowLight extends Light implements IShadowLight {
  9176. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9177. protected _position: Vector3;
  9178. protected _setPosition(value: Vector3): void;
  9179. /**
  9180. * Sets the position the shadow will be casted from. Also use as the light position for both
  9181. * point and spot lights.
  9182. */
  9183. get position(): Vector3;
  9184. /**
  9185. * Sets the position the shadow will be casted from. Also use as the light position for both
  9186. * point and spot lights.
  9187. */
  9188. set position(value: Vector3);
  9189. protected _direction: Vector3;
  9190. protected _setDirection(value: Vector3): void;
  9191. /**
  9192. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9193. * Also use as the light direction on spot and directional lights.
  9194. */
  9195. get direction(): Vector3;
  9196. /**
  9197. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9198. * Also use as the light direction on spot and directional lights.
  9199. */
  9200. set direction(value: Vector3);
  9201. protected _shadowMinZ: number;
  9202. /**
  9203. * Gets the shadow projection clipping minimum z value.
  9204. */
  9205. get shadowMinZ(): number;
  9206. /**
  9207. * Sets the shadow projection clipping minimum z value.
  9208. */
  9209. set shadowMinZ(value: number);
  9210. protected _shadowMaxZ: number;
  9211. /**
  9212. * Sets the shadow projection clipping maximum z value.
  9213. */
  9214. get shadowMaxZ(): number;
  9215. /**
  9216. * Gets the shadow projection clipping maximum z value.
  9217. */
  9218. set shadowMaxZ(value: number);
  9219. /**
  9220. * Callback defining a custom Projection Matrix Builder.
  9221. * This can be used to override the default projection matrix computation.
  9222. */
  9223. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9224. /**
  9225. * The transformed position. Position of the light in world space taking parenting in account.
  9226. */
  9227. transformedPosition: Vector3;
  9228. /**
  9229. * The transformed direction. Direction of the light in world space taking parenting in account.
  9230. */
  9231. transformedDirection: Vector3;
  9232. private _needProjectionMatrixCompute;
  9233. /**
  9234. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9235. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9236. */
  9237. computeTransformedInformation(): boolean;
  9238. /**
  9239. * Return the depth scale used for the shadow map.
  9240. * @returns the depth scale.
  9241. */
  9242. getDepthScale(): number;
  9243. /**
  9244. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9245. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9246. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9247. */
  9248. getShadowDirection(faceIndex?: number): Vector3;
  9249. /**
  9250. * Returns the ShadowLight absolute position in the World.
  9251. * @returns the position vector in world space
  9252. */
  9253. getAbsolutePosition(): Vector3;
  9254. /**
  9255. * Sets the ShadowLight direction toward the passed target.
  9256. * @param target The point to target in local space
  9257. * @returns the updated ShadowLight direction
  9258. */
  9259. setDirectionToTarget(target: Vector3): Vector3;
  9260. /**
  9261. * Returns the light rotation in euler definition.
  9262. * @returns the x y z rotation in local space.
  9263. */
  9264. getRotation(): Vector3;
  9265. /**
  9266. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9267. * @returns true if a cube texture needs to be use
  9268. */
  9269. needCube(): boolean;
  9270. /**
  9271. * Detects if the projection matrix requires to be recomputed this frame.
  9272. * @returns true if it requires to be recomputed otherwise, false.
  9273. */
  9274. needProjectionMatrixCompute(): boolean;
  9275. /**
  9276. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9277. */
  9278. forceProjectionMatrixCompute(): void;
  9279. /** @hidden */
  9280. _initCache(): void;
  9281. /** @hidden */
  9282. _isSynchronized(): boolean;
  9283. /**
  9284. * Computes the world matrix of the node
  9285. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9286. * @returns the world matrix
  9287. */
  9288. computeWorldMatrix(force?: boolean): Matrix;
  9289. /**
  9290. * Gets the minZ used for shadow according to both the scene and the light.
  9291. * @param activeCamera The camera we are returning the min for
  9292. * @returns the depth min z
  9293. */
  9294. getDepthMinZ(activeCamera: Camera): number;
  9295. /**
  9296. * Gets the maxZ used for shadow according to both the scene and the light.
  9297. * @param activeCamera The camera we are returning the max for
  9298. * @returns the depth max z
  9299. */
  9300. getDepthMaxZ(activeCamera: Camera): number;
  9301. /**
  9302. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9303. * @param matrix The materix to updated with the projection information
  9304. * @param viewMatrix The transform matrix of the light
  9305. * @param renderList The list of mesh to render in the map
  9306. * @returns The current light
  9307. */
  9308. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9309. }
  9310. }
  9311. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9312. /** @hidden */
  9313. export var packingFunctions: {
  9314. name: string;
  9315. shader: string;
  9316. };
  9317. }
  9318. declare module "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions" {
  9319. /** @hidden */
  9320. export var bayerDitherFunctions: {
  9321. name: string;
  9322. shader: string;
  9323. };
  9324. }
  9325. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration" {
  9326. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9327. import "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions";
  9328. /** @hidden */
  9329. export var shadowMapFragmentDeclaration: {
  9330. name: string;
  9331. shader: string;
  9332. };
  9333. }
  9334. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9335. /** @hidden */
  9336. export var clipPlaneFragmentDeclaration: {
  9337. name: string;
  9338. shader: string;
  9339. };
  9340. }
  9341. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9342. /** @hidden */
  9343. export var clipPlaneFragment: {
  9344. name: string;
  9345. shader: string;
  9346. };
  9347. }
  9348. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragment" {
  9349. /** @hidden */
  9350. export var shadowMapFragment: {
  9351. name: string;
  9352. shader: string;
  9353. };
  9354. }
  9355. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9356. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration";
  9357. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9358. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9359. import "babylonjs/Shaders/ShadersInclude/shadowMapFragment";
  9360. /** @hidden */
  9361. export var shadowMapPixelShader: {
  9362. name: string;
  9363. shader: string;
  9364. };
  9365. }
  9366. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9367. /** @hidden */
  9368. export var bonesDeclaration: {
  9369. name: string;
  9370. shader: string;
  9371. };
  9372. }
  9373. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9374. /** @hidden */
  9375. export var morphTargetsVertexGlobalDeclaration: {
  9376. name: string;
  9377. shader: string;
  9378. };
  9379. }
  9380. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9381. /** @hidden */
  9382. export var morphTargetsVertexDeclaration: {
  9383. name: string;
  9384. shader: string;
  9385. };
  9386. }
  9387. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9388. /** @hidden */
  9389. export var instancesDeclaration: {
  9390. name: string;
  9391. shader: string;
  9392. };
  9393. }
  9394. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9395. /** @hidden */
  9396. export var helperFunctions: {
  9397. name: string;
  9398. shader: string;
  9399. };
  9400. }
  9401. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration" {
  9402. /** @hidden */
  9403. export var shadowMapVertexDeclaration: {
  9404. name: string;
  9405. shader: string;
  9406. };
  9407. }
  9408. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9409. /** @hidden */
  9410. export var clipPlaneVertexDeclaration: {
  9411. name: string;
  9412. shader: string;
  9413. };
  9414. }
  9415. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9416. /** @hidden */
  9417. export var morphTargetsVertex: {
  9418. name: string;
  9419. shader: string;
  9420. };
  9421. }
  9422. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9423. /** @hidden */
  9424. export var instancesVertex: {
  9425. name: string;
  9426. shader: string;
  9427. };
  9428. }
  9429. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9430. /** @hidden */
  9431. export var bonesVertex: {
  9432. name: string;
  9433. shader: string;
  9434. };
  9435. }
  9436. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias" {
  9437. /** @hidden */
  9438. export var shadowMapVertexNormalBias: {
  9439. name: string;
  9440. shader: string;
  9441. };
  9442. }
  9443. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric" {
  9444. /** @hidden */
  9445. export var shadowMapVertexMetric: {
  9446. name: string;
  9447. shader: string;
  9448. };
  9449. }
  9450. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9451. /** @hidden */
  9452. export var clipPlaneVertex: {
  9453. name: string;
  9454. shader: string;
  9455. };
  9456. }
  9457. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9458. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9459. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9460. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9461. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9462. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9463. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration";
  9464. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9465. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9466. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9467. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9468. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias";
  9469. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric";
  9470. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9471. /** @hidden */
  9472. export var shadowMapVertexShader: {
  9473. name: string;
  9474. shader: string;
  9475. };
  9476. }
  9477. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9478. /** @hidden */
  9479. export var depthBoxBlurPixelShader: {
  9480. name: string;
  9481. shader: string;
  9482. };
  9483. }
  9484. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow" {
  9485. /** @hidden */
  9486. export var shadowMapFragmentSoftTransparentShadow: {
  9487. name: string;
  9488. shader: string;
  9489. };
  9490. }
  9491. declare module "babylonjs/Materials/effectFallbacks" {
  9492. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9493. import { Effect } from "babylonjs/Materials/effect";
  9494. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9495. /**
  9496. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9497. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9498. */
  9499. export class EffectFallbacks implements IEffectFallbacks {
  9500. private _defines;
  9501. private _currentRank;
  9502. private _maxRank;
  9503. private _mesh;
  9504. /**
  9505. * Removes the fallback from the bound mesh.
  9506. */
  9507. unBindMesh(): void;
  9508. /**
  9509. * Adds a fallback on the specified property.
  9510. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9511. * @param define The name of the define in the shader
  9512. */
  9513. addFallback(rank: number, define: string): void;
  9514. /**
  9515. * Sets the mesh to use CPU skinning when needing to fallback.
  9516. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9517. * @param mesh The mesh to use the fallbacks.
  9518. */
  9519. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9520. /**
  9521. * Checks to see if more fallbacks are still availible.
  9522. */
  9523. get hasMoreFallbacks(): boolean;
  9524. /**
  9525. * Removes the defines that should be removed when falling back.
  9526. * @param currentDefines defines the current define statements for the shader.
  9527. * @param effect defines the current effect we try to compile
  9528. * @returns The resulting defines with defines of the current rank removed.
  9529. */
  9530. reduce(currentDefines: string, effect: Effect): string;
  9531. }
  9532. }
  9533. declare module "babylonjs/Actions/action" {
  9534. import { Observable } from "babylonjs/Misc/observable";
  9535. import { Condition } from "babylonjs/Actions/condition";
  9536. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  9537. import { Scene } from "babylonjs/scene";
  9538. import { ActionManager } from "babylonjs/Actions/actionManager";
  9539. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9540. import { Node } from "babylonjs/node";
  9541. /**
  9542. * Interface used to define Action
  9543. */
  9544. export interface IAction {
  9545. /**
  9546. * Trigger for the action
  9547. */
  9548. trigger: number;
  9549. /** Options of the trigger */
  9550. triggerOptions: any;
  9551. /**
  9552. * Gets the trigger parameters
  9553. * @returns the trigger parameters
  9554. */
  9555. getTriggerParameter(): any;
  9556. /**
  9557. * Internal only - executes current action event
  9558. * @hidden
  9559. */
  9560. _executeCurrent(evt?: ActionEvent): void;
  9561. /**
  9562. * Serialize placeholder for child classes
  9563. * @param parent of child
  9564. * @returns the serialized object
  9565. */
  9566. serialize(parent: any): any;
  9567. /**
  9568. * Internal only
  9569. * @hidden
  9570. */
  9571. _prepare(): void;
  9572. /**
  9573. * Internal only - manager for action
  9574. * @hidden
  9575. */
  9576. _actionManager: AbstractActionManager;
  9577. /**
  9578. * Adds action to chain of actions, may be a DoNothingAction
  9579. * @param action defines the next action to execute
  9580. * @returns The action passed in
  9581. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9582. */
  9583. then(action: IAction): IAction;
  9584. }
  9585. /**
  9586. * The action to be carried out following a trigger
  9587. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9588. */
  9589. export class Action implements IAction {
  9590. /** the trigger, with or without parameters, for the action */
  9591. triggerOptions: any;
  9592. /**
  9593. * Trigger for the action
  9594. */
  9595. trigger: number;
  9596. /**
  9597. * Internal only - manager for action
  9598. * @hidden
  9599. */
  9600. _actionManager: ActionManager;
  9601. private _nextActiveAction;
  9602. private _child;
  9603. private _condition?;
  9604. private _triggerParameter;
  9605. /**
  9606. * An event triggered prior to action being executed.
  9607. */
  9608. onBeforeExecuteObservable: Observable<Action>;
  9609. /**
  9610. * Creates a new Action
  9611. * @param triggerOptions the trigger, with or without parameters, for the action
  9612. * @param condition an optional determinant of action
  9613. */
  9614. constructor(
  9615. /** the trigger, with or without parameters, for the action */
  9616. triggerOptions: any, condition?: Condition);
  9617. /**
  9618. * Internal only
  9619. * @hidden
  9620. */
  9621. _prepare(): void;
  9622. /**
  9623. * Gets the trigger parameters
  9624. * @returns the trigger parameters
  9625. */
  9626. getTriggerParameter(): any;
  9627. /**
  9628. * Internal only - executes current action event
  9629. * @hidden
  9630. */
  9631. _executeCurrent(evt?: ActionEvent): void;
  9632. /**
  9633. * Execute placeholder for child classes
  9634. * @param evt optional action event
  9635. */
  9636. execute(evt?: ActionEvent): void;
  9637. /**
  9638. * Skips to next active action
  9639. */
  9640. skipToNextActiveAction(): void;
  9641. /**
  9642. * Adds action to chain of actions, may be a DoNothingAction
  9643. * @param action defines the next action to execute
  9644. * @returns The action passed in
  9645. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9646. */
  9647. then(action: Action): Action;
  9648. /**
  9649. * Internal only
  9650. * @hidden
  9651. */
  9652. _getProperty(propertyPath: string): string;
  9653. /**
  9654. * Internal only
  9655. * @hidden
  9656. */
  9657. _getEffectiveTarget(target: any, propertyPath: string): any;
  9658. /**
  9659. * Serialize placeholder for child classes
  9660. * @param parent of child
  9661. * @returns the serialized object
  9662. */
  9663. serialize(parent: any): any;
  9664. /**
  9665. * Internal only called by serialize
  9666. * @hidden
  9667. */
  9668. protected _serialize(serializedAction: any, parent?: any): any;
  9669. /**
  9670. * Internal only
  9671. * @hidden
  9672. */
  9673. static _SerializeValueAsString: (value: any) => string;
  9674. /**
  9675. * Internal only
  9676. * @hidden
  9677. */
  9678. static _GetTargetProperty: (target: Scene | Node) => {
  9679. name: string;
  9680. targetType: string;
  9681. value: string;
  9682. };
  9683. }
  9684. }
  9685. declare module "babylonjs/Actions/condition" {
  9686. import { ActionManager } from "babylonjs/Actions/actionManager";
  9687. /**
  9688. * A Condition applied to an Action
  9689. */
  9690. export class Condition {
  9691. /**
  9692. * Internal only - manager for action
  9693. * @hidden
  9694. */
  9695. _actionManager: ActionManager;
  9696. /**
  9697. * Internal only
  9698. * @hidden
  9699. */
  9700. _evaluationId: number;
  9701. /**
  9702. * Internal only
  9703. * @hidden
  9704. */
  9705. _currentResult: boolean;
  9706. /**
  9707. * Creates a new Condition
  9708. * @param actionManager the manager of the action the condition is applied to
  9709. */
  9710. constructor(actionManager: ActionManager);
  9711. /**
  9712. * Check if the current condition is valid
  9713. * @returns a boolean
  9714. */
  9715. isValid(): boolean;
  9716. /**
  9717. * Internal only
  9718. * @hidden
  9719. */
  9720. _getProperty(propertyPath: string): string;
  9721. /**
  9722. * Internal only
  9723. * @hidden
  9724. */
  9725. _getEffectiveTarget(target: any, propertyPath: string): any;
  9726. /**
  9727. * Serialize placeholder for child classes
  9728. * @returns the serialized object
  9729. */
  9730. serialize(): any;
  9731. /**
  9732. * Internal only
  9733. * @hidden
  9734. */
  9735. protected _serialize(serializedCondition: any): any;
  9736. }
  9737. /**
  9738. * Defines specific conditional operators as extensions of Condition
  9739. */
  9740. export class ValueCondition extends Condition {
  9741. /** path to specify the property of the target the conditional operator uses */
  9742. propertyPath: string;
  9743. /** the value compared by the conditional operator against the current value of the property */
  9744. value: any;
  9745. /** the conditional operator, default ValueCondition.IsEqual */
  9746. operator: number;
  9747. /**
  9748. * Internal only
  9749. * @hidden
  9750. */
  9751. private static _IsEqual;
  9752. /**
  9753. * Internal only
  9754. * @hidden
  9755. */
  9756. private static _IsDifferent;
  9757. /**
  9758. * Internal only
  9759. * @hidden
  9760. */
  9761. private static _IsGreater;
  9762. /**
  9763. * Internal only
  9764. * @hidden
  9765. */
  9766. private static _IsLesser;
  9767. /**
  9768. * returns the number for IsEqual
  9769. */
  9770. static get IsEqual(): number;
  9771. /**
  9772. * Returns the number for IsDifferent
  9773. */
  9774. static get IsDifferent(): number;
  9775. /**
  9776. * Returns the number for IsGreater
  9777. */
  9778. static get IsGreater(): number;
  9779. /**
  9780. * Returns the number for IsLesser
  9781. */
  9782. static get IsLesser(): number;
  9783. /**
  9784. * Internal only The action manager for the condition
  9785. * @hidden
  9786. */
  9787. _actionManager: ActionManager;
  9788. /**
  9789. * Internal only
  9790. * @hidden
  9791. */
  9792. private _target;
  9793. /**
  9794. * Internal only
  9795. * @hidden
  9796. */
  9797. private _effectiveTarget;
  9798. /**
  9799. * Internal only
  9800. * @hidden
  9801. */
  9802. private _property;
  9803. /**
  9804. * Creates a new ValueCondition
  9805. * @param actionManager manager for the action the condition applies to
  9806. * @param target for the action
  9807. * @param propertyPath path to specify the property of the target the conditional operator uses
  9808. * @param value the value compared by the conditional operator against the current value of the property
  9809. * @param operator the conditional operator, default ValueCondition.IsEqual
  9810. */
  9811. constructor(actionManager: ActionManager, target: any,
  9812. /** path to specify the property of the target the conditional operator uses */
  9813. propertyPath: string,
  9814. /** the value compared by the conditional operator against the current value of the property */
  9815. value: any,
  9816. /** the conditional operator, default ValueCondition.IsEqual */
  9817. operator?: number);
  9818. /**
  9819. * Compares the given value with the property value for the specified conditional operator
  9820. * @returns the result of the comparison
  9821. */
  9822. isValid(): boolean;
  9823. /**
  9824. * Serialize the ValueCondition into a JSON compatible object
  9825. * @returns serialization object
  9826. */
  9827. serialize(): any;
  9828. /**
  9829. * Gets the name of the conditional operator for the ValueCondition
  9830. * @param operator the conditional operator
  9831. * @returns the name
  9832. */
  9833. static GetOperatorName(operator: number): string;
  9834. }
  9835. /**
  9836. * Defines a predicate condition as an extension of Condition
  9837. */
  9838. export class PredicateCondition extends Condition {
  9839. /** defines the predicate function used to validate the condition */
  9840. predicate: () => boolean;
  9841. /**
  9842. * Internal only - manager for action
  9843. * @hidden
  9844. */
  9845. _actionManager: ActionManager;
  9846. /**
  9847. * Creates a new PredicateCondition
  9848. * @param actionManager manager for the action the condition applies to
  9849. * @param predicate defines the predicate function used to validate the condition
  9850. */
  9851. constructor(actionManager: ActionManager,
  9852. /** defines the predicate function used to validate the condition */
  9853. predicate: () => boolean);
  9854. /**
  9855. * @returns the validity of the predicate condition
  9856. */
  9857. isValid(): boolean;
  9858. }
  9859. /**
  9860. * Defines a state condition as an extension of Condition
  9861. */
  9862. export class StateCondition extends Condition {
  9863. /** Value to compare with target state */
  9864. value: string;
  9865. /**
  9866. * Internal only - manager for action
  9867. * @hidden
  9868. */
  9869. _actionManager: ActionManager;
  9870. /**
  9871. * Internal only
  9872. * @hidden
  9873. */
  9874. private _target;
  9875. /**
  9876. * Creates a new StateCondition
  9877. * @param actionManager manager for the action the condition applies to
  9878. * @param target of the condition
  9879. * @param value to compare with target state
  9880. */
  9881. constructor(actionManager: ActionManager, target: any,
  9882. /** Value to compare with target state */
  9883. value: string);
  9884. /**
  9885. * Gets a boolean indicating if the current condition is met
  9886. * @returns the validity of the state
  9887. */
  9888. isValid(): boolean;
  9889. /**
  9890. * Serialize the StateCondition into a JSON compatible object
  9891. * @returns serialization object
  9892. */
  9893. serialize(): any;
  9894. }
  9895. }
  9896. declare module "babylonjs/Actions/directActions" {
  9897. import { Action } from "babylonjs/Actions/action";
  9898. import { Condition } from "babylonjs/Actions/condition";
  9899. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9900. /**
  9901. * This defines an action responsible to toggle a boolean once triggered.
  9902. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9903. */
  9904. export class SwitchBooleanAction extends Action {
  9905. /**
  9906. * The path to the boolean property in the target object
  9907. */
  9908. propertyPath: string;
  9909. private _target;
  9910. private _effectiveTarget;
  9911. private _property;
  9912. /**
  9913. * Instantiate the action
  9914. * @param triggerOptions defines the trigger options
  9915. * @param target defines the object containing the boolean
  9916. * @param propertyPath defines the path to the boolean property in the target object
  9917. * @param condition defines the trigger related conditions
  9918. */
  9919. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9920. /** @hidden */
  9921. _prepare(): void;
  9922. /**
  9923. * Execute the action toggle the boolean value.
  9924. */
  9925. execute(): void;
  9926. /**
  9927. * Serializes the actions and its related information.
  9928. * @param parent defines the object to serialize in
  9929. * @returns the serialized object
  9930. */
  9931. serialize(parent: any): any;
  9932. }
  9933. /**
  9934. * This defines an action responsible to set a the state field of the target
  9935. * to a desired value once triggered.
  9936. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9937. */
  9938. export class SetStateAction extends Action {
  9939. /**
  9940. * The value to store in the state field.
  9941. */
  9942. value: string;
  9943. private _target;
  9944. /**
  9945. * Instantiate the action
  9946. * @param triggerOptions defines the trigger options
  9947. * @param target defines the object containing the state property
  9948. * @param value defines the value to store in the state field
  9949. * @param condition defines the trigger related conditions
  9950. */
  9951. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9952. /**
  9953. * Execute the action and store the value on the target state property.
  9954. */
  9955. execute(): void;
  9956. /**
  9957. * Serializes the actions and its related information.
  9958. * @param parent defines the object to serialize in
  9959. * @returns the serialized object
  9960. */
  9961. serialize(parent: any): any;
  9962. }
  9963. /**
  9964. * This defines an action responsible to set a property of the target
  9965. * to a desired value once triggered.
  9966. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9967. */
  9968. export class SetValueAction extends Action {
  9969. /**
  9970. * The path of the property to set in the target.
  9971. */
  9972. propertyPath: string;
  9973. /**
  9974. * The value to set in the property
  9975. */
  9976. value: any;
  9977. private _target;
  9978. private _effectiveTarget;
  9979. private _property;
  9980. /**
  9981. * Instantiate the action
  9982. * @param triggerOptions defines the trigger options
  9983. * @param target defines the object containing the property
  9984. * @param propertyPath defines the path of the property to set in the target
  9985. * @param value defines the value to set in the property
  9986. * @param condition defines the trigger related conditions
  9987. */
  9988. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9989. /** @hidden */
  9990. _prepare(): void;
  9991. /**
  9992. * Execute the action and set the targetted property to the desired value.
  9993. */
  9994. execute(): void;
  9995. /**
  9996. * Serializes the actions and its related information.
  9997. * @param parent defines the object to serialize in
  9998. * @returns the serialized object
  9999. */
  10000. serialize(parent: any): any;
  10001. }
  10002. /**
  10003. * This defines an action responsible to increment the target value
  10004. * to a desired value once triggered.
  10005. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10006. */
  10007. export class IncrementValueAction extends Action {
  10008. /**
  10009. * The path of the property to increment in the target.
  10010. */
  10011. propertyPath: string;
  10012. /**
  10013. * The value we should increment the property by.
  10014. */
  10015. value: any;
  10016. private _target;
  10017. private _effectiveTarget;
  10018. private _property;
  10019. /**
  10020. * Instantiate the action
  10021. * @param triggerOptions defines the trigger options
  10022. * @param target defines the object containing the property
  10023. * @param propertyPath defines the path of the property to increment in the target
  10024. * @param value defines the value value we should increment the property by
  10025. * @param condition defines the trigger related conditions
  10026. */
  10027. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10028. /** @hidden */
  10029. _prepare(): void;
  10030. /**
  10031. * Execute the action and increment the target of the value amount.
  10032. */
  10033. execute(): void;
  10034. /**
  10035. * Serializes the actions and its related information.
  10036. * @param parent defines the object to serialize in
  10037. * @returns the serialized object
  10038. */
  10039. serialize(parent: any): any;
  10040. }
  10041. /**
  10042. * This defines an action responsible to start an animation once triggered.
  10043. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10044. */
  10045. export class PlayAnimationAction extends Action {
  10046. /**
  10047. * Where the animation should start (animation frame)
  10048. */
  10049. from: number;
  10050. /**
  10051. * Where the animation should stop (animation frame)
  10052. */
  10053. to: number;
  10054. /**
  10055. * Define if the animation should loop or stop after the first play.
  10056. */
  10057. loop?: boolean;
  10058. private _target;
  10059. /**
  10060. * Instantiate the action
  10061. * @param triggerOptions defines the trigger options
  10062. * @param target defines the target animation or animation name
  10063. * @param from defines from where the animation should start (animation frame)
  10064. * @param end defines where the animation should stop (animation frame)
  10065. * @param loop defines if the animation should loop or stop after the first play
  10066. * @param condition defines the trigger related conditions
  10067. */
  10068. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10069. /** @hidden */
  10070. _prepare(): void;
  10071. /**
  10072. * Execute the action and play the animation.
  10073. */
  10074. execute(): void;
  10075. /**
  10076. * Serializes the actions and its related information.
  10077. * @param parent defines the object to serialize in
  10078. * @returns the serialized object
  10079. */
  10080. serialize(parent: any): any;
  10081. }
  10082. /**
  10083. * This defines an action responsible to stop an animation once triggered.
  10084. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10085. */
  10086. export class StopAnimationAction extends Action {
  10087. private _target;
  10088. /**
  10089. * Instantiate the action
  10090. * @param triggerOptions defines the trigger options
  10091. * @param target defines the target animation or animation name
  10092. * @param condition defines the trigger related conditions
  10093. */
  10094. constructor(triggerOptions: any, target: any, condition?: Condition);
  10095. /** @hidden */
  10096. _prepare(): void;
  10097. /**
  10098. * Execute the action and stop the animation.
  10099. */
  10100. execute(): void;
  10101. /**
  10102. * Serializes the actions and its related information.
  10103. * @param parent defines the object to serialize in
  10104. * @returns the serialized object
  10105. */
  10106. serialize(parent: any): any;
  10107. }
  10108. /**
  10109. * This defines an action responsible that does nothing once triggered.
  10110. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10111. */
  10112. export class DoNothingAction extends Action {
  10113. /**
  10114. * Instantiate the action
  10115. * @param triggerOptions defines the trigger options
  10116. * @param condition defines the trigger related conditions
  10117. */
  10118. constructor(triggerOptions?: any, condition?: Condition);
  10119. /**
  10120. * Execute the action and do nothing.
  10121. */
  10122. execute(): void;
  10123. /**
  10124. * Serializes the actions and its related information.
  10125. * @param parent defines the object to serialize in
  10126. * @returns the serialized object
  10127. */
  10128. serialize(parent: any): any;
  10129. }
  10130. /**
  10131. * This defines an action responsible to trigger several actions once triggered.
  10132. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10133. */
  10134. export class CombineAction extends Action {
  10135. /**
  10136. * The list of aggregated animations to run.
  10137. */
  10138. children: Action[];
  10139. /**
  10140. * Instantiate the action
  10141. * @param triggerOptions defines the trigger options
  10142. * @param children defines the list of aggregated animations to run
  10143. * @param condition defines the trigger related conditions
  10144. */
  10145. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10146. /** @hidden */
  10147. _prepare(): void;
  10148. /**
  10149. * Execute the action and executes all the aggregated actions.
  10150. */
  10151. execute(evt: ActionEvent): void;
  10152. /**
  10153. * Serializes the actions and its related information.
  10154. * @param parent defines the object to serialize in
  10155. * @returns the serialized object
  10156. */
  10157. serialize(parent: any): any;
  10158. }
  10159. /**
  10160. * This defines an action responsible to run code (external event) once triggered.
  10161. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10162. */
  10163. export class ExecuteCodeAction extends Action {
  10164. /**
  10165. * The callback function to run.
  10166. */
  10167. func: (evt: ActionEvent) => void;
  10168. /**
  10169. * Instantiate the action
  10170. * @param triggerOptions defines the trigger options
  10171. * @param func defines the callback function to run
  10172. * @param condition defines the trigger related conditions
  10173. */
  10174. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10175. /**
  10176. * Execute the action and run the attached code.
  10177. */
  10178. execute(evt: ActionEvent): void;
  10179. }
  10180. /**
  10181. * This defines an action responsible to set the parent property of the target once triggered.
  10182. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10183. */
  10184. export class SetParentAction extends Action {
  10185. private _parent;
  10186. private _target;
  10187. /**
  10188. * Instantiate the action
  10189. * @param triggerOptions defines the trigger options
  10190. * @param target defines the target containing the parent property
  10191. * @param parent defines from where the animation should start (animation frame)
  10192. * @param condition defines the trigger related conditions
  10193. */
  10194. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10195. /** @hidden */
  10196. _prepare(): void;
  10197. /**
  10198. * Execute the action and set the parent property.
  10199. */
  10200. execute(): void;
  10201. /**
  10202. * Serializes the actions and its related information.
  10203. * @param parent defines the object to serialize in
  10204. * @returns the serialized object
  10205. */
  10206. serialize(parent: any): any;
  10207. }
  10208. }
  10209. declare module "babylonjs/Actions/actionManager" {
  10210. import { Nullable } from "babylonjs/types";
  10211. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10212. import { Scene } from "babylonjs/scene";
  10213. import { IAction } from "babylonjs/Actions/action";
  10214. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10215. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10216. /**
  10217. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10218. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10219. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10220. */
  10221. export class ActionManager extends AbstractActionManager {
  10222. /**
  10223. * Nothing
  10224. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10225. */
  10226. static readonly NothingTrigger: number;
  10227. /**
  10228. * On pick
  10229. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10230. */
  10231. static readonly OnPickTrigger: number;
  10232. /**
  10233. * On left pick
  10234. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10235. */
  10236. static readonly OnLeftPickTrigger: number;
  10237. /**
  10238. * On right pick
  10239. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10240. */
  10241. static readonly OnRightPickTrigger: number;
  10242. /**
  10243. * On center pick
  10244. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10245. */
  10246. static readonly OnCenterPickTrigger: number;
  10247. /**
  10248. * On pick down
  10249. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10250. */
  10251. static readonly OnPickDownTrigger: number;
  10252. /**
  10253. * On double pick
  10254. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10255. */
  10256. static readonly OnDoublePickTrigger: number;
  10257. /**
  10258. * On pick up
  10259. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10260. */
  10261. static readonly OnPickUpTrigger: number;
  10262. /**
  10263. * On pick out.
  10264. * This trigger will only be raised if you also declared a OnPickDown
  10265. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10266. */
  10267. static readonly OnPickOutTrigger: number;
  10268. /**
  10269. * On long press
  10270. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10271. */
  10272. static readonly OnLongPressTrigger: number;
  10273. /**
  10274. * On pointer over
  10275. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10276. */
  10277. static readonly OnPointerOverTrigger: number;
  10278. /**
  10279. * On pointer out
  10280. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10281. */
  10282. static readonly OnPointerOutTrigger: number;
  10283. /**
  10284. * On every frame
  10285. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10286. */
  10287. static readonly OnEveryFrameTrigger: number;
  10288. /**
  10289. * On intersection enter
  10290. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10291. */
  10292. static readonly OnIntersectionEnterTrigger: number;
  10293. /**
  10294. * On intersection exit
  10295. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10296. */
  10297. static readonly OnIntersectionExitTrigger: number;
  10298. /**
  10299. * On key down
  10300. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10301. */
  10302. static readonly OnKeyDownTrigger: number;
  10303. /**
  10304. * On key up
  10305. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10306. */
  10307. static readonly OnKeyUpTrigger: number;
  10308. private _scene;
  10309. /**
  10310. * Creates a new action manager
  10311. * @param scene defines the hosting scene
  10312. */
  10313. constructor(scene: Scene);
  10314. /**
  10315. * Releases all associated resources
  10316. */
  10317. dispose(): void;
  10318. /**
  10319. * Gets hosting scene
  10320. * @returns the hosting scene
  10321. */
  10322. getScene(): Scene;
  10323. /**
  10324. * Does this action manager handles actions of any of the given triggers
  10325. * @param triggers defines the triggers to be tested
  10326. * @return a boolean indicating whether one (or more) of the triggers is handled
  10327. */
  10328. hasSpecificTriggers(triggers: number[]): boolean;
  10329. /**
  10330. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10331. * speed.
  10332. * @param triggerA defines the trigger to be tested
  10333. * @param triggerB defines the trigger to be tested
  10334. * @return a boolean indicating whether one (or more) of the triggers is handled
  10335. */
  10336. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10337. /**
  10338. * Does this action manager handles actions of a given trigger
  10339. * @param trigger defines the trigger to be tested
  10340. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10341. * @return whether the trigger is handled
  10342. */
  10343. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10344. /**
  10345. * Does this action manager has pointer triggers
  10346. */
  10347. get hasPointerTriggers(): boolean;
  10348. /**
  10349. * Does this action manager has pick triggers
  10350. */
  10351. get hasPickTriggers(): boolean;
  10352. /**
  10353. * Registers an action to this action manager
  10354. * @param action defines the action to be registered
  10355. * @return the action amended (prepared) after registration
  10356. */
  10357. registerAction(action: IAction): Nullable<IAction>;
  10358. /**
  10359. * Unregisters an action to this action manager
  10360. * @param action defines the action to be unregistered
  10361. * @return a boolean indicating whether the action has been unregistered
  10362. */
  10363. unregisterAction(action: IAction): Boolean;
  10364. /**
  10365. * Process a specific trigger
  10366. * @param trigger defines the trigger to process
  10367. * @param evt defines the event details to be processed
  10368. */
  10369. processTrigger(trigger: number, evt?: IActionEvent): void;
  10370. /** @hidden */
  10371. _getEffectiveTarget(target: any, propertyPath: string): any;
  10372. /** @hidden */
  10373. _getProperty(propertyPath: string): string;
  10374. /**
  10375. * Serialize this manager to a JSON object
  10376. * @param name defines the property name to store this manager
  10377. * @returns a JSON representation of this manager
  10378. */
  10379. serialize(name: string): any;
  10380. /**
  10381. * Creates a new ActionManager from a JSON data
  10382. * @param parsedActions defines the JSON data to read from
  10383. * @param object defines the hosting mesh
  10384. * @param scene defines the hosting scene
  10385. */
  10386. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10387. /**
  10388. * Get a trigger name by index
  10389. * @param trigger defines the trigger index
  10390. * @returns a trigger name
  10391. */
  10392. static GetTriggerName(trigger: number): string;
  10393. }
  10394. }
  10395. declare module "babylonjs/Sprites/sprite" {
  10396. import { Vector3 } from "babylonjs/Maths/math.vector";
  10397. import { Nullable } from "babylonjs/types";
  10398. import { ActionManager } from "babylonjs/Actions/actionManager";
  10399. import { ISpriteManager, SpriteManager } from "babylonjs/Sprites/spriteManager";
  10400. import { Color4 } from "babylonjs/Maths/math.color";
  10401. import { Observable } from "babylonjs/Misc/observable";
  10402. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  10403. import { Animation } from "babylonjs/Animations/animation";
  10404. /**
  10405. * Class used to represent a sprite
  10406. * @see https://doc.babylonjs.com/babylon101/sprites
  10407. */
  10408. export class Sprite implements IAnimatable {
  10409. /** defines the name */
  10410. name: string;
  10411. /** Gets or sets the current world position */
  10412. position: Vector3;
  10413. /** Gets or sets the main color */
  10414. color: Color4;
  10415. /** Gets or sets the width */
  10416. width: number;
  10417. /** Gets or sets the height */
  10418. height: number;
  10419. /** Gets or sets rotation angle */
  10420. angle: number;
  10421. /** Gets or sets the cell index in the sprite sheet */
  10422. cellIndex: number;
  10423. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10424. cellRef: string;
  10425. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10426. invertU: boolean;
  10427. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10428. invertV: boolean;
  10429. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10430. disposeWhenFinishedAnimating: boolean;
  10431. /** Gets the list of attached animations */
  10432. animations: Nullable<Array<Animation>>;
  10433. /** Gets or sets a boolean indicating if the sprite can be picked */
  10434. isPickable: boolean;
  10435. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10436. useAlphaForPicking: boolean;
  10437. /** @hidden */
  10438. _xOffset: number;
  10439. /** @hidden */
  10440. _yOffset: number;
  10441. /** @hidden */
  10442. _xSize: number;
  10443. /** @hidden */
  10444. _ySize: number;
  10445. /**
  10446. * Gets or sets the associated action manager
  10447. */
  10448. actionManager: Nullable<ActionManager>;
  10449. /**
  10450. * An event triggered when the control has been disposed
  10451. */
  10452. onDisposeObservable: Observable<Sprite>;
  10453. private _animationStarted;
  10454. private _loopAnimation;
  10455. private _fromIndex;
  10456. private _toIndex;
  10457. private _delay;
  10458. private _direction;
  10459. private _manager;
  10460. private _time;
  10461. private _onAnimationEnd;
  10462. /**
  10463. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10464. */
  10465. isVisible: boolean;
  10466. /**
  10467. * Gets or sets the sprite size
  10468. */
  10469. get size(): number;
  10470. set size(value: number);
  10471. /**
  10472. * Returns a boolean indicating if the animation is started
  10473. */
  10474. get animationStarted(): boolean;
  10475. /**
  10476. * Gets or sets the unique id of the sprite
  10477. */
  10478. uniqueId: number;
  10479. /**
  10480. * Gets the manager of this sprite
  10481. */
  10482. get manager(): ISpriteManager;
  10483. /**
  10484. * Creates a new Sprite
  10485. * @param name defines the name
  10486. * @param manager defines the manager
  10487. */
  10488. constructor(
  10489. /** defines the name */
  10490. name: string, manager: ISpriteManager);
  10491. /**
  10492. * Returns the string "Sprite"
  10493. * @returns "Sprite"
  10494. */
  10495. getClassName(): string;
  10496. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10497. get fromIndex(): number;
  10498. set fromIndex(value: number);
  10499. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10500. get toIndex(): number;
  10501. set toIndex(value: number);
  10502. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10503. get loopAnimation(): boolean;
  10504. set loopAnimation(value: boolean);
  10505. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10506. get delay(): number;
  10507. set delay(value: number);
  10508. /**
  10509. * Starts an animation
  10510. * @param from defines the initial key
  10511. * @param to defines the end key
  10512. * @param loop defines if the animation must loop
  10513. * @param delay defines the start delay (in ms)
  10514. * @param onAnimationEnd defines a callback to call when animation ends
  10515. */
  10516. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10517. /** Stops current animation (if any) */
  10518. stopAnimation(): void;
  10519. /** @hidden */
  10520. _animate(deltaTime: number): void;
  10521. /** Release associated resources */
  10522. dispose(): void;
  10523. /**
  10524. * Serializes the sprite to a JSON object
  10525. * @returns the JSON object
  10526. */
  10527. serialize(): any;
  10528. /**
  10529. * Parses a JSON object to create a new sprite
  10530. * @param parsedSprite The JSON object to parse
  10531. * @param manager defines the hosting manager
  10532. * @returns the new sprite
  10533. */
  10534. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10535. }
  10536. }
  10537. declare module "babylonjs/Collisions/pickingInfo" {
  10538. import { Nullable } from "babylonjs/types";
  10539. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  10540. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10541. import { Sprite } from "babylonjs/Sprites/sprite";
  10542. import { Ray } from "babylonjs/Culling/ray";
  10543. /**
  10544. * Information about the result of picking within a scene
  10545. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10546. */
  10547. export class PickingInfo {
  10548. /** @hidden */
  10549. _pickingUnavailable: boolean;
  10550. /**
  10551. * If the pick collided with an object
  10552. */
  10553. hit: boolean;
  10554. /**
  10555. * Distance away where the pick collided
  10556. */
  10557. distance: number;
  10558. /**
  10559. * The location of pick collision
  10560. */
  10561. pickedPoint: Nullable<Vector3>;
  10562. /**
  10563. * The mesh corresponding the the pick collision
  10564. */
  10565. pickedMesh: Nullable<AbstractMesh>;
  10566. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10567. bu: number;
  10568. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10569. bv: number;
  10570. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10571. faceId: number;
  10572. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10573. subMeshFaceId: number;
  10574. /** Id of the the submesh that was picked */
  10575. subMeshId: number;
  10576. /** If a sprite was picked, this will be the sprite the pick collided with */
  10577. pickedSprite: Nullable<Sprite>;
  10578. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  10579. thinInstanceIndex: number;
  10580. /**
  10581. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10582. */
  10583. originMesh: Nullable<AbstractMesh>;
  10584. /**
  10585. * The ray that was used to perform the picking.
  10586. */
  10587. ray: Nullable<Ray>;
  10588. /**
  10589. * Gets the normal correspodning to the face the pick collided with
  10590. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10591. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10592. * @returns The normal correspodning to the face the pick collided with
  10593. */
  10594. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10595. /**
  10596. * Gets the texture coordinates of where the pick occured
  10597. * @returns the vector containing the coordnates of the texture
  10598. */
  10599. getTextureCoordinates(): Nullable<Vector2>;
  10600. }
  10601. }
  10602. declare module "babylonjs/Culling/ray" {
  10603. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10604. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10605. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10606. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10607. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10608. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10609. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10610. import { Plane } from "babylonjs/Maths/math.plane";
  10611. /**
  10612. * Class representing a ray with position and direction
  10613. */
  10614. export class Ray {
  10615. /** origin point */
  10616. origin: Vector3;
  10617. /** direction */
  10618. direction: Vector3;
  10619. /** length of the ray */
  10620. length: number;
  10621. private static readonly _TmpVector3;
  10622. private _tmpRay;
  10623. /**
  10624. * Creates a new ray
  10625. * @param origin origin point
  10626. * @param direction direction
  10627. * @param length length of the ray
  10628. */
  10629. constructor(
  10630. /** origin point */
  10631. origin: Vector3,
  10632. /** direction */
  10633. direction: Vector3,
  10634. /** length of the ray */
  10635. length?: number);
  10636. /**
  10637. * Checks if the ray intersects a box
  10638. * This does not account for the ray lenght by design to improve perfs.
  10639. * @param minimum bound of the box
  10640. * @param maximum bound of the box
  10641. * @param intersectionTreshold extra extend to be added to the box in all direction
  10642. * @returns if the box was hit
  10643. */
  10644. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10645. /**
  10646. * Checks if the ray intersects a box
  10647. * This does not account for the ray lenght by design to improve perfs.
  10648. * @param box the bounding box to check
  10649. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10650. * @returns if the box was hit
  10651. */
  10652. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10653. /**
  10654. * If the ray hits a sphere
  10655. * @param sphere the bounding sphere to check
  10656. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10657. * @returns true if it hits the sphere
  10658. */
  10659. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10660. /**
  10661. * If the ray hits a triange
  10662. * @param vertex0 triangle vertex
  10663. * @param vertex1 triangle vertex
  10664. * @param vertex2 triangle vertex
  10665. * @returns intersection information if hit
  10666. */
  10667. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10668. /**
  10669. * Checks if ray intersects a plane
  10670. * @param plane the plane to check
  10671. * @returns the distance away it was hit
  10672. */
  10673. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10674. /**
  10675. * Calculate the intercept of a ray on a given axis
  10676. * @param axis to check 'x' | 'y' | 'z'
  10677. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10678. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10679. */
  10680. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10681. /**
  10682. * Checks if ray intersects a mesh
  10683. * @param mesh the mesh to check
  10684. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10685. * @returns picking info of the intersecton
  10686. */
  10687. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10688. /**
  10689. * Checks if ray intersects a mesh
  10690. * @param meshes the meshes to check
  10691. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10692. * @param results array to store result in
  10693. * @returns Array of picking infos
  10694. */
  10695. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10696. private _comparePickingInfo;
  10697. private static smallnum;
  10698. private static rayl;
  10699. /**
  10700. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10701. * @param sega the first point of the segment to test the intersection against
  10702. * @param segb the second point of the segment to test the intersection against
  10703. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10704. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10705. */
  10706. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10707. /**
  10708. * Update the ray from viewport position
  10709. * @param x position
  10710. * @param y y position
  10711. * @param viewportWidth viewport width
  10712. * @param viewportHeight viewport height
  10713. * @param world world matrix
  10714. * @param view view matrix
  10715. * @param projection projection matrix
  10716. * @returns this ray updated
  10717. */
  10718. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10719. /**
  10720. * Creates a ray with origin and direction of 0,0,0
  10721. * @returns the new ray
  10722. */
  10723. static Zero(): Ray;
  10724. /**
  10725. * Creates a new ray from screen space and viewport
  10726. * @param x position
  10727. * @param y y position
  10728. * @param viewportWidth viewport width
  10729. * @param viewportHeight viewport height
  10730. * @param world world matrix
  10731. * @param view view matrix
  10732. * @param projection projection matrix
  10733. * @returns new ray
  10734. */
  10735. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10736. /**
  10737. * 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
  10738. * transformed to the given world matrix.
  10739. * @param origin The origin point
  10740. * @param end The end point
  10741. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10742. * @returns the new ray
  10743. */
  10744. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10745. /**
  10746. * Transforms a ray by a matrix
  10747. * @param ray ray to transform
  10748. * @param matrix matrix to apply
  10749. * @returns the resulting new ray
  10750. */
  10751. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10752. /**
  10753. * Transforms a ray by a matrix
  10754. * @param ray ray to transform
  10755. * @param matrix matrix to apply
  10756. * @param result ray to store result in
  10757. */
  10758. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10759. /**
  10760. * Unproject a ray from screen space to object space
  10761. * @param sourceX defines the screen space x coordinate to use
  10762. * @param sourceY defines the screen space y coordinate to use
  10763. * @param viewportWidth defines the current width of the viewport
  10764. * @param viewportHeight defines the current height of the viewport
  10765. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10766. * @param view defines the view matrix to use
  10767. * @param projection defines the projection matrix to use
  10768. */
  10769. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10770. }
  10771. /**
  10772. * Type used to define predicate used to select faces when a mesh intersection is detected
  10773. */
  10774. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10775. module "babylonjs/scene" {
  10776. interface Scene {
  10777. /** @hidden */
  10778. _tempPickingRay: Nullable<Ray>;
  10779. /** @hidden */
  10780. _cachedRayForTransform: Ray;
  10781. /** @hidden */
  10782. _pickWithRayInverseMatrix: Matrix;
  10783. /** @hidden */
  10784. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10785. /** @hidden */
  10786. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10787. /** @hidden */
  10788. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10789. }
  10790. }
  10791. }
  10792. declare module "babylonjs/sceneComponent" {
  10793. import { Scene } from "babylonjs/scene";
  10794. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10795. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10796. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  10797. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  10798. import { Nullable } from "babylonjs/types";
  10799. import { Camera } from "babylonjs/Cameras/camera";
  10800. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10801. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10802. import { AbstractScene } from "babylonjs/abstractScene";
  10803. import { Mesh } from "babylonjs/Meshes/mesh";
  10804. /**
  10805. * Groups all the scene component constants in one place to ease maintenance.
  10806. * @hidden
  10807. */
  10808. export class SceneComponentConstants {
  10809. static readonly NAME_EFFECTLAYER: string;
  10810. static readonly NAME_LAYER: string;
  10811. static readonly NAME_LENSFLARESYSTEM: string;
  10812. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10813. static readonly NAME_PARTICLESYSTEM: string;
  10814. static readonly NAME_GAMEPAD: string;
  10815. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10816. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10817. static readonly NAME_PREPASSRENDERER: string;
  10818. static readonly NAME_DEPTHRENDERER: string;
  10819. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10820. static readonly NAME_SPRITE: string;
  10821. static readonly NAME_OUTLINERENDERER: string;
  10822. static readonly NAME_PROCEDURALTEXTURE: string;
  10823. static readonly NAME_SHADOWGENERATOR: string;
  10824. static readonly NAME_OCTREE: string;
  10825. static readonly NAME_PHYSICSENGINE: string;
  10826. static readonly NAME_AUDIO: string;
  10827. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10828. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10829. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10830. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10831. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10832. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10833. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10834. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10835. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10836. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10837. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10838. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10839. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10840. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10841. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10842. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10843. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10844. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10845. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10846. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10847. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10848. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10849. static readonly STEP_AFTERRENDER_AUDIO: number;
  10850. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10851. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10852. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10853. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10854. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10855. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10856. static readonly STEP_POINTERMOVE_SPRITE: number;
  10857. static readonly STEP_POINTERDOWN_SPRITE: number;
  10858. static readonly STEP_POINTERUP_SPRITE: number;
  10859. }
  10860. /**
  10861. * This represents a scene component.
  10862. *
  10863. * This is used to decouple the dependency the scene is having on the different workloads like
  10864. * layers, post processes...
  10865. */
  10866. export interface ISceneComponent {
  10867. /**
  10868. * The name of the component. Each component must have a unique name.
  10869. */
  10870. name: string;
  10871. /**
  10872. * The scene the component belongs to.
  10873. */
  10874. scene: Scene;
  10875. /**
  10876. * Register the component to one instance of a scene.
  10877. */
  10878. register(): void;
  10879. /**
  10880. * Rebuilds the elements related to this component in case of
  10881. * context lost for instance.
  10882. */
  10883. rebuild(): void;
  10884. /**
  10885. * Disposes the component and the associated ressources.
  10886. */
  10887. dispose(): void;
  10888. }
  10889. /**
  10890. * This represents a SERIALIZABLE scene component.
  10891. *
  10892. * This extends Scene Component to add Serialization methods on top.
  10893. */
  10894. export interface ISceneSerializableComponent extends ISceneComponent {
  10895. /**
  10896. * Adds all the elements from the container to the scene
  10897. * @param container the container holding the elements
  10898. */
  10899. addFromContainer(container: AbstractScene): void;
  10900. /**
  10901. * Removes all the elements in the container from the scene
  10902. * @param container contains the elements to remove
  10903. * @param dispose if the removed element should be disposed (default: false)
  10904. */
  10905. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10906. /**
  10907. * Serializes the component data to the specified json object
  10908. * @param serializationObject The object to serialize to
  10909. */
  10910. serialize(serializationObject: any): void;
  10911. }
  10912. /**
  10913. * Strong typing of a Mesh related stage step action
  10914. */
  10915. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10916. /**
  10917. * Strong typing of a Evaluate Sub Mesh related stage step action
  10918. */
  10919. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10920. /**
  10921. * Strong typing of a Active Mesh related stage step action
  10922. */
  10923. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10924. /**
  10925. * Strong typing of a Camera related stage step action
  10926. */
  10927. export type CameraStageAction = (camera: Camera) => void;
  10928. /**
  10929. * Strong typing of a Camera Frame buffer related stage step action
  10930. */
  10931. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10932. /**
  10933. * Strong typing of a Render Target related stage step action
  10934. */
  10935. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10936. /**
  10937. * Strong typing of a RenderingGroup related stage step action
  10938. */
  10939. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10940. /**
  10941. * Strong typing of a Mesh Render related stage step action
  10942. */
  10943. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10944. /**
  10945. * Strong typing of a simple stage step action
  10946. */
  10947. export type SimpleStageAction = () => void;
  10948. /**
  10949. * Strong typing of a render target action.
  10950. */
  10951. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10952. /**
  10953. * Strong typing of a pointer move action.
  10954. */
  10955. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10956. /**
  10957. * Strong typing of a pointer up/down action.
  10958. */
  10959. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10960. /**
  10961. * Representation of a stage in the scene (Basically a list of ordered steps)
  10962. * @hidden
  10963. */
  10964. export class Stage<T extends Function> extends Array<{
  10965. index: number;
  10966. component: ISceneComponent;
  10967. action: T;
  10968. }> {
  10969. /**
  10970. * Hide ctor from the rest of the world.
  10971. * @param items The items to add.
  10972. */
  10973. private constructor();
  10974. /**
  10975. * Creates a new Stage.
  10976. * @returns A new instance of a Stage
  10977. */
  10978. static Create<T extends Function>(): Stage<T>;
  10979. /**
  10980. * Registers a step in an ordered way in the targeted stage.
  10981. * @param index Defines the position to register the step in
  10982. * @param component Defines the component attached to the step
  10983. * @param action Defines the action to launch during the step
  10984. */
  10985. registerStep(index: number, component: ISceneComponent, action: T): void;
  10986. /**
  10987. * Clears all the steps from the stage.
  10988. */
  10989. clear(): void;
  10990. }
  10991. }
  10992. declare module "babylonjs/Sprites/spriteSceneComponent" {
  10993. import { Nullable } from "babylonjs/types";
  10994. import { Observable } from "babylonjs/Misc/observable";
  10995. import { Scene } from "babylonjs/scene";
  10996. import { Sprite } from "babylonjs/Sprites/sprite";
  10997. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  10998. import { Ray } from "babylonjs/Culling/ray";
  10999. import { Camera } from "babylonjs/Cameras/camera";
  11000. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11001. import { ISceneComponent } from "babylonjs/sceneComponent";
  11002. module "babylonjs/scene" {
  11003. interface Scene {
  11004. /** @hidden */
  11005. _pointerOverSprite: Nullable<Sprite>;
  11006. /** @hidden */
  11007. _pickedDownSprite: Nullable<Sprite>;
  11008. /** @hidden */
  11009. _tempSpritePickingRay: Nullable<Ray>;
  11010. /**
  11011. * All of the sprite managers added to this scene
  11012. * @see https://doc.babylonjs.com/babylon101/sprites
  11013. */
  11014. spriteManagers: Array<ISpriteManager>;
  11015. /**
  11016. * An event triggered when sprites rendering is about to start
  11017. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11018. */
  11019. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11020. /**
  11021. * An event triggered when sprites rendering is done
  11022. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11023. */
  11024. onAfterSpritesRenderingObservable: Observable<Scene>;
  11025. /** @hidden */
  11026. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11027. /** Launch a ray to try to pick a sprite in the scene
  11028. * @param x position on screen
  11029. * @param y position on screen
  11030. * @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
  11031. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11032. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11033. * @returns a PickingInfo
  11034. */
  11035. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11036. /** Use the given ray to pick a sprite in the scene
  11037. * @param ray The ray (in world space) to use to pick meshes
  11038. * @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
  11039. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11040. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11041. * @returns a PickingInfo
  11042. */
  11043. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11044. /** @hidden */
  11045. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11046. /** Launch a ray to try to pick sprites in the scene
  11047. * @param x position on screen
  11048. * @param y position on screen
  11049. * @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
  11050. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11051. * @returns a PickingInfo array
  11052. */
  11053. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11054. /** Use the given ray to pick sprites in the scene
  11055. * @param ray The ray (in world space) to use to pick meshes
  11056. * @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
  11057. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11058. * @returns a PickingInfo array
  11059. */
  11060. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11061. /**
  11062. * Force the sprite under the pointer
  11063. * @param sprite defines the sprite to use
  11064. */
  11065. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11066. /**
  11067. * Gets the sprite under the pointer
  11068. * @returns a Sprite or null if no sprite is under the pointer
  11069. */
  11070. getPointerOverSprite(): Nullable<Sprite>;
  11071. }
  11072. }
  11073. /**
  11074. * Defines the sprite scene component responsible to manage sprites
  11075. * in a given scene.
  11076. */
  11077. export class SpriteSceneComponent implements ISceneComponent {
  11078. /**
  11079. * The component name helpfull to identify the component in the list of scene components.
  11080. */
  11081. readonly name: string;
  11082. /**
  11083. * The scene the component belongs to.
  11084. */
  11085. scene: Scene;
  11086. /** @hidden */
  11087. private _spritePredicate;
  11088. /**
  11089. * Creates a new instance of the component for the given scene
  11090. * @param scene Defines the scene to register the component in
  11091. */
  11092. constructor(scene: Scene);
  11093. /**
  11094. * Registers the component in a given scene
  11095. */
  11096. register(): void;
  11097. /**
  11098. * Rebuilds the elements related to this component in case of
  11099. * context lost for instance.
  11100. */
  11101. rebuild(): void;
  11102. /**
  11103. * Disposes the component and the associated ressources.
  11104. */
  11105. dispose(): void;
  11106. private _pickSpriteButKeepRay;
  11107. private _pointerMove;
  11108. private _pointerDown;
  11109. private _pointerUp;
  11110. }
  11111. }
  11112. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11113. /** @hidden */
  11114. export var fogFragmentDeclaration: {
  11115. name: string;
  11116. shader: string;
  11117. };
  11118. }
  11119. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11120. /** @hidden */
  11121. export var fogFragment: {
  11122. name: string;
  11123. shader: string;
  11124. };
  11125. }
  11126. declare module "babylonjs/Shaders/sprites.fragment" {
  11127. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11128. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11129. /** @hidden */
  11130. export var spritesPixelShader: {
  11131. name: string;
  11132. shader: string;
  11133. };
  11134. }
  11135. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11136. /** @hidden */
  11137. export var fogVertexDeclaration: {
  11138. name: string;
  11139. shader: string;
  11140. };
  11141. }
  11142. declare module "babylonjs/Shaders/sprites.vertex" {
  11143. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11144. /** @hidden */
  11145. export var spritesVertexShader: {
  11146. name: string;
  11147. shader: string;
  11148. };
  11149. }
  11150. declare module "babylonjs/Sprites/spriteManager" {
  11151. import { IDisposable, Scene } from "babylonjs/scene";
  11152. import { Nullable } from "babylonjs/types";
  11153. import { Observable } from "babylonjs/Misc/observable";
  11154. import { Sprite } from "babylonjs/Sprites/sprite";
  11155. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11156. import { Camera } from "babylonjs/Cameras/camera";
  11157. import { Texture } from "babylonjs/Materials/Textures/texture";
  11158. import "babylonjs/Shaders/sprites.fragment";
  11159. import "babylonjs/Shaders/sprites.vertex";
  11160. import { Ray } from "babylonjs/Culling/ray";
  11161. /**
  11162. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11163. */
  11164. export interface ISpriteManager extends IDisposable {
  11165. /**
  11166. * Gets manager's name
  11167. */
  11168. name: string;
  11169. /**
  11170. * Restricts the camera to viewing objects with the same layerMask.
  11171. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11172. */
  11173. layerMask: number;
  11174. /**
  11175. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11176. */
  11177. isPickable: boolean;
  11178. /**
  11179. * Gets the hosting scene
  11180. */
  11181. scene: Scene;
  11182. /**
  11183. * Specifies the rendering group id for this mesh (0 by default)
  11184. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11185. */
  11186. renderingGroupId: number;
  11187. /**
  11188. * Defines the list of sprites managed by the manager.
  11189. */
  11190. sprites: Array<Sprite>;
  11191. /**
  11192. * Gets or sets the spritesheet texture
  11193. */
  11194. texture: Texture;
  11195. /** Defines the default width of a cell in the spritesheet */
  11196. cellWidth: number;
  11197. /** Defines the default height of a cell in the spritesheet */
  11198. cellHeight: number;
  11199. /**
  11200. * Tests the intersection of a sprite with a specific ray.
  11201. * @param ray The ray we are sending to test the collision
  11202. * @param camera The camera space we are sending rays in
  11203. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11204. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11205. * @returns picking info or null.
  11206. */
  11207. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11208. /**
  11209. * Intersects the sprites with a ray
  11210. * @param ray defines the ray to intersect with
  11211. * @param camera defines the current active camera
  11212. * @param predicate defines a predicate used to select candidate sprites
  11213. * @returns null if no hit or a PickingInfo array
  11214. */
  11215. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11216. /**
  11217. * Renders the list of sprites on screen.
  11218. */
  11219. render(): void;
  11220. }
  11221. /**
  11222. * Class used to manage multiple sprites on the same spritesheet
  11223. * @see https://doc.babylonjs.com/babylon101/sprites
  11224. */
  11225. export class SpriteManager implements ISpriteManager {
  11226. /** defines the manager's name */
  11227. name: string;
  11228. /** Define the Url to load snippets */
  11229. static SnippetUrl: string;
  11230. /** Snippet ID if the manager was created from the snippet server */
  11231. snippetId: string;
  11232. /** Gets the list of sprites */
  11233. sprites: Sprite[];
  11234. /** Gets or sets the rendering group id (0 by default) */
  11235. renderingGroupId: number;
  11236. /** Gets or sets camera layer mask */
  11237. layerMask: number;
  11238. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11239. fogEnabled: boolean;
  11240. /** Gets or sets a boolean indicating if the sprites are pickable */
  11241. isPickable: boolean;
  11242. /** Defines the default width of a cell in the spritesheet */
  11243. cellWidth: number;
  11244. /** Defines the default height of a cell in the spritesheet */
  11245. cellHeight: number;
  11246. /** Associative array from JSON sprite data file */
  11247. private _cellData;
  11248. /** Array of sprite names from JSON sprite data file */
  11249. private _spriteMap;
  11250. /** True when packed cell data from JSON file is ready*/
  11251. private _packedAndReady;
  11252. private _textureContent;
  11253. private _useInstancing;
  11254. /**
  11255. * An event triggered when the manager is disposed.
  11256. */
  11257. onDisposeObservable: Observable<SpriteManager>;
  11258. private _onDisposeObserver;
  11259. /**
  11260. * Callback called when the manager is disposed
  11261. */
  11262. set onDispose(callback: () => void);
  11263. private _capacity;
  11264. private _fromPacked;
  11265. private _spriteTexture;
  11266. private _epsilon;
  11267. private _scene;
  11268. private _vertexData;
  11269. private _buffer;
  11270. private _vertexBuffers;
  11271. private _spriteBuffer;
  11272. private _indexBuffer;
  11273. private _effectBase;
  11274. private _effectFog;
  11275. private _vertexBufferSize;
  11276. /**
  11277. * Gets or sets the unique id of the sprite
  11278. */
  11279. uniqueId: number;
  11280. /**
  11281. * Gets the array of sprites
  11282. */
  11283. get children(): Sprite[];
  11284. /**
  11285. * Gets the hosting scene
  11286. */
  11287. get scene(): Scene;
  11288. /**
  11289. * Gets the capacity of the manager
  11290. */
  11291. get capacity(): number;
  11292. /**
  11293. * Gets or sets the spritesheet texture
  11294. */
  11295. get texture(): Texture;
  11296. set texture(value: Texture);
  11297. private _blendMode;
  11298. /**
  11299. * Blend mode use to render the particle, it can be any of
  11300. * the static Constants.ALPHA_x properties provided in this class.
  11301. * Default value is Constants.ALPHA_COMBINE
  11302. */
  11303. get blendMode(): number;
  11304. set blendMode(blendMode: number);
  11305. /** Disables writing to the depth buffer when rendering the sprites.
  11306. * It can be handy to disable depth writing when using textures without alpha channel
  11307. * and setting some specific blend modes.
  11308. */
  11309. disableDepthWrite: boolean;
  11310. /**
  11311. * Creates a new sprite manager
  11312. * @param name defines the manager's name
  11313. * @param imgUrl defines the sprite sheet url
  11314. * @param capacity defines the maximum allowed number of sprites
  11315. * @param cellSize defines the size of a sprite cell
  11316. * @param scene defines the hosting scene
  11317. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11318. * @param samplingMode defines the smapling mode to use with spritesheet
  11319. * @param fromPacked set to false; do not alter
  11320. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11321. */
  11322. constructor(
  11323. /** defines the manager's name */
  11324. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11325. /**
  11326. * Returns the string "SpriteManager"
  11327. * @returns "SpriteManager"
  11328. */
  11329. getClassName(): string;
  11330. private _makePacked;
  11331. private _appendSpriteVertex;
  11332. private _checkTextureAlpha;
  11333. /**
  11334. * Intersects the sprites with a ray
  11335. * @param ray defines the ray to intersect with
  11336. * @param camera defines the current active camera
  11337. * @param predicate defines a predicate used to select candidate sprites
  11338. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11339. * @returns null if no hit or a PickingInfo
  11340. */
  11341. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11342. /**
  11343. * Intersects the sprites with a ray
  11344. * @param ray defines the ray to intersect with
  11345. * @param camera defines the current active camera
  11346. * @param predicate defines a predicate used to select candidate sprites
  11347. * @returns null if no hit or a PickingInfo array
  11348. */
  11349. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11350. /**
  11351. * Render all child sprites
  11352. */
  11353. render(): void;
  11354. /**
  11355. * Release associated resources
  11356. */
  11357. dispose(): void;
  11358. /**
  11359. * Serializes the sprite manager to a JSON object
  11360. * @param serializeTexture defines if the texture must be serialized as well
  11361. * @returns the JSON object
  11362. */
  11363. serialize(serializeTexture?: boolean): any;
  11364. /**
  11365. * Parses a JSON object to create a new sprite manager.
  11366. * @param parsedManager The JSON object to parse
  11367. * @param scene The scene to create the sprite managerin
  11368. * @param rootUrl The root url to use to load external dependencies like texture
  11369. * @returns the new sprite manager
  11370. */
  11371. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11372. /**
  11373. * Creates a sprite manager from a snippet saved in a remote file
  11374. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11375. * @param url defines the url to load from
  11376. * @param scene defines the hosting scene
  11377. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11378. * @returns a promise that will resolve to the new sprite manager
  11379. */
  11380. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11381. /**
  11382. * Creates a sprite manager from a snippet saved by the sprite editor
  11383. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  11384. * @param scene defines the hosting scene
  11385. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11386. * @returns a promise that will resolve to the new sprite manager
  11387. */
  11388. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11389. }
  11390. }
  11391. declare module "babylonjs/Misc/gradients" {
  11392. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  11393. /** Interface used by value gradients (color, factor, ...) */
  11394. export interface IValueGradient {
  11395. /**
  11396. * Gets or sets the gradient value (between 0 and 1)
  11397. */
  11398. gradient: number;
  11399. }
  11400. /** Class used to store color4 gradient */
  11401. export class ColorGradient implements IValueGradient {
  11402. /**
  11403. * Gets or sets the gradient value (between 0 and 1)
  11404. */
  11405. gradient: number;
  11406. /**
  11407. * Gets or sets first associated color
  11408. */
  11409. color1: Color4;
  11410. /**
  11411. * Gets or sets second associated color
  11412. */
  11413. color2?: Color4 | undefined;
  11414. /**
  11415. * Creates a new color4 gradient
  11416. * @param gradient gets or sets the gradient value (between 0 and 1)
  11417. * @param color1 gets or sets first associated color
  11418. * @param color2 gets or sets first second color
  11419. */
  11420. constructor(
  11421. /**
  11422. * Gets or sets the gradient value (between 0 and 1)
  11423. */
  11424. gradient: number,
  11425. /**
  11426. * Gets or sets first associated color
  11427. */
  11428. color1: Color4,
  11429. /**
  11430. * Gets or sets second associated color
  11431. */
  11432. color2?: Color4 | undefined);
  11433. /**
  11434. * Will get a color picked randomly between color1 and color2.
  11435. * If color2 is undefined then color1 will be used
  11436. * @param result defines the target Color4 to store the result in
  11437. */
  11438. getColorToRef(result: Color4): void;
  11439. }
  11440. /** Class used to store color 3 gradient */
  11441. export class Color3Gradient implements IValueGradient {
  11442. /**
  11443. * Gets or sets the gradient value (between 0 and 1)
  11444. */
  11445. gradient: number;
  11446. /**
  11447. * Gets or sets the associated color
  11448. */
  11449. color: Color3;
  11450. /**
  11451. * Creates a new color3 gradient
  11452. * @param gradient gets or sets the gradient value (between 0 and 1)
  11453. * @param color gets or sets associated color
  11454. */
  11455. constructor(
  11456. /**
  11457. * Gets or sets the gradient value (between 0 and 1)
  11458. */
  11459. gradient: number,
  11460. /**
  11461. * Gets or sets the associated color
  11462. */
  11463. color: Color3);
  11464. }
  11465. /** Class used to store factor gradient */
  11466. export class FactorGradient implements IValueGradient {
  11467. /**
  11468. * Gets or sets the gradient value (between 0 and 1)
  11469. */
  11470. gradient: number;
  11471. /**
  11472. * Gets or sets first associated factor
  11473. */
  11474. factor1: number;
  11475. /**
  11476. * Gets or sets second associated factor
  11477. */
  11478. factor2?: number | undefined;
  11479. /**
  11480. * Creates a new factor gradient
  11481. * @param gradient gets or sets the gradient value (between 0 and 1)
  11482. * @param factor1 gets or sets first associated factor
  11483. * @param factor2 gets or sets second associated factor
  11484. */
  11485. constructor(
  11486. /**
  11487. * Gets or sets the gradient value (between 0 and 1)
  11488. */
  11489. gradient: number,
  11490. /**
  11491. * Gets or sets first associated factor
  11492. */
  11493. factor1: number,
  11494. /**
  11495. * Gets or sets second associated factor
  11496. */
  11497. factor2?: number | undefined);
  11498. /**
  11499. * Will get a number picked randomly between factor1 and factor2.
  11500. * If factor2 is undefined then factor1 will be used
  11501. * @returns the picked number
  11502. */
  11503. getFactor(): number;
  11504. }
  11505. /**
  11506. * Helper used to simplify some generic gradient tasks
  11507. */
  11508. export class GradientHelper {
  11509. /**
  11510. * Gets the current gradient from an array of IValueGradient
  11511. * @param ratio defines the current ratio to get
  11512. * @param gradients defines the array of IValueGradient
  11513. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11514. */
  11515. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11516. }
  11517. }
  11518. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  11519. import { Nullable } from "babylonjs/types";
  11520. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11521. import { Scene } from "babylonjs/scene";
  11522. module "babylonjs/Engines/thinEngine" {
  11523. interface ThinEngine {
  11524. /**
  11525. * Creates a raw texture
  11526. * @param data defines the data to store in the texture
  11527. * @param width defines the width of the texture
  11528. * @param height defines the height of the texture
  11529. * @param format defines the format of the data
  11530. * @param generateMipMaps defines if the engine should generate the mip levels
  11531. * @param invertY defines if data must be stored with Y axis inverted
  11532. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11533. * @param compression defines the compression used (null by default)
  11534. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11535. * @returns the raw texture inside an InternalTexture
  11536. */
  11537. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11538. /**
  11539. * Update a raw texture
  11540. * @param texture defines the texture to update
  11541. * @param data defines the data to store in the texture
  11542. * @param format defines the format of the data
  11543. * @param invertY defines if data must be stored with Y axis inverted
  11544. */
  11545. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11546. /**
  11547. * Update a raw texture
  11548. * @param texture defines the texture to update
  11549. * @param data defines the data to store in the texture
  11550. * @param format defines the format of the data
  11551. * @param invertY defines if data must be stored with Y axis inverted
  11552. * @param compression defines the compression used (null by default)
  11553. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11554. */
  11555. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11556. /**
  11557. * Creates a new raw cube texture
  11558. * @param data defines the array of data to use to create each face
  11559. * @param size defines the size of the textures
  11560. * @param format defines the format of the data
  11561. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11562. * @param generateMipMaps defines if the engine should generate the mip levels
  11563. * @param invertY defines if data must be stored with Y axis inverted
  11564. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11565. * @param compression defines the compression used (null by default)
  11566. * @returns the cube texture as an InternalTexture
  11567. */
  11568. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11569. /**
  11570. * Update a raw cube texture
  11571. * @param texture defines the texture to udpdate
  11572. * @param data defines the data to store
  11573. * @param format defines the data format
  11574. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11575. * @param invertY defines if data must be stored with Y axis inverted
  11576. */
  11577. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11578. /**
  11579. * Update a raw cube texture
  11580. * @param texture defines the texture to udpdate
  11581. * @param data defines the data to store
  11582. * @param format defines the data format
  11583. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11584. * @param invertY defines if data must be stored with Y axis inverted
  11585. * @param compression defines the compression used (null by default)
  11586. */
  11587. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11588. /**
  11589. * Update a raw cube texture
  11590. * @param texture defines the texture to udpdate
  11591. * @param data defines the data to store
  11592. * @param format defines the data format
  11593. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11594. * @param invertY defines if data must be stored with Y axis inverted
  11595. * @param compression defines the compression used (null by default)
  11596. * @param level defines which level of the texture to update
  11597. */
  11598. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11599. /**
  11600. * Creates a new raw cube texture from a specified url
  11601. * @param url defines the url where the data is located
  11602. * @param scene defines the current scene
  11603. * @param size defines the size of the textures
  11604. * @param format defines the format of the data
  11605. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11606. * @param noMipmap defines if the engine should avoid generating the mip levels
  11607. * @param callback defines a callback used to extract texture data from loaded data
  11608. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11609. * @param onLoad defines a callback called when texture is loaded
  11610. * @param onError defines a callback called if there is an error
  11611. * @returns the cube texture as an InternalTexture
  11612. */
  11613. 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;
  11614. /**
  11615. * Creates a new raw cube texture from a specified url
  11616. * @param url defines the url where the data is located
  11617. * @param scene defines the current scene
  11618. * @param size defines the size of the textures
  11619. * @param format defines the format of the data
  11620. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11621. * @param noMipmap defines if the engine should avoid generating the mip levels
  11622. * @param callback defines a callback used to extract texture data from loaded data
  11623. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11624. * @param onLoad defines a callback called when texture is loaded
  11625. * @param onError defines a callback called if there is an error
  11626. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11627. * @param invertY defines if data must be stored with Y axis inverted
  11628. * @returns the cube texture as an InternalTexture
  11629. */
  11630. 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;
  11631. /**
  11632. * Creates a new raw 3D texture
  11633. * @param data defines the data used to create the texture
  11634. * @param width defines the width of the texture
  11635. * @param height defines the height of the texture
  11636. * @param depth defines the depth of the texture
  11637. * @param format defines the format of the texture
  11638. * @param generateMipMaps defines if the engine must generate mip levels
  11639. * @param invertY defines if data must be stored with Y axis inverted
  11640. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11641. * @param compression defines the compressed used (can be null)
  11642. * @param textureType defines the compressed used (can be null)
  11643. * @returns a new raw 3D texture (stored in an InternalTexture)
  11644. */
  11645. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11646. /**
  11647. * Update a raw 3D texture
  11648. * @param texture defines the texture to update
  11649. * @param data defines the data to store
  11650. * @param format defines the data format
  11651. * @param invertY defines if data must be stored with Y axis inverted
  11652. */
  11653. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11654. /**
  11655. * Update a raw 3D texture
  11656. * @param texture defines the texture to update
  11657. * @param data defines the data to store
  11658. * @param format defines the data format
  11659. * @param invertY defines if data must be stored with Y axis inverted
  11660. * @param compression defines the used compression (can be null)
  11661. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11662. */
  11663. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11664. /**
  11665. * Creates a new raw 2D array texture
  11666. * @param data defines the data used to create the texture
  11667. * @param width defines the width of the texture
  11668. * @param height defines the height of the texture
  11669. * @param depth defines the number of layers of the texture
  11670. * @param format defines the format of the texture
  11671. * @param generateMipMaps defines if the engine must generate mip levels
  11672. * @param invertY defines if data must be stored with Y axis inverted
  11673. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11674. * @param compression defines the compressed used (can be null)
  11675. * @param textureType defines the compressed used (can be null)
  11676. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11677. */
  11678. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11679. /**
  11680. * Update a raw 2D array texture
  11681. * @param texture defines the texture to update
  11682. * @param data defines the data to store
  11683. * @param format defines the data format
  11684. * @param invertY defines if data must be stored with Y axis inverted
  11685. */
  11686. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11687. /**
  11688. * Update a raw 2D array texture
  11689. * @param texture defines the texture to update
  11690. * @param data defines the data to store
  11691. * @param format defines the data format
  11692. * @param invertY defines if data must be stored with Y axis inverted
  11693. * @param compression defines the used compression (can be null)
  11694. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11695. */
  11696. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11697. }
  11698. }
  11699. }
  11700. declare module "babylonjs/Materials/Textures/rawTexture" {
  11701. import { Texture } from "babylonjs/Materials/Textures/texture";
  11702. import "babylonjs/Engines/Extensions/engine.rawTexture";
  11703. import { Nullable } from "babylonjs/types";
  11704. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  11705. import { Scene } from "babylonjs/scene";
  11706. /**
  11707. * Raw texture can help creating a texture directly from an array of data.
  11708. * This can be super useful if you either get the data from an uncompressed source or
  11709. * if you wish to create your texture pixel by pixel.
  11710. */
  11711. export class RawTexture extends Texture {
  11712. /**
  11713. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11714. */
  11715. format: number;
  11716. /**
  11717. * Instantiates a new RawTexture.
  11718. * Raw texture can help creating a texture directly from an array of data.
  11719. * This can be super useful if you either get the data from an uncompressed source or
  11720. * if you wish to create your texture pixel by pixel.
  11721. * @param data define the array of data to use to create the texture
  11722. * @param width define the width of the texture
  11723. * @param height define the height of the texture
  11724. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11725. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11726. * @param generateMipMaps define whether mip maps should be generated or not
  11727. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11728. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11729. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11730. */
  11731. constructor(data: ArrayBufferView, width: number, height: number,
  11732. /**
  11733. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11734. */
  11735. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11736. /**
  11737. * Updates the texture underlying data.
  11738. * @param data Define the new data of the texture
  11739. */
  11740. update(data: ArrayBufferView): void;
  11741. /**
  11742. * Creates a luminance texture from some data.
  11743. * @param data Define the texture data
  11744. * @param width Define the width of the texture
  11745. * @param height Define the height of the texture
  11746. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11747. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11748. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11749. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11750. * @returns the luminance texture
  11751. */
  11752. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11753. /**
  11754. * Creates a luminance alpha texture from some data.
  11755. * @param data Define the texture data
  11756. * @param width Define the width of the texture
  11757. * @param height Define the height of the texture
  11758. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11759. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11760. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11761. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11762. * @returns the luminance alpha texture
  11763. */
  11764. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11765. /**
  11766. * Creates an alpha texture from some data.
  11767. * @param data Define the texture data
  11768. * @param width Define the width of the texture
  11769. * @param height Define the height of the texture
  11770. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11771. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11772. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11773. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11774. * @returns the alpha texture
  11775. */
  11776. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11777. /**
  11778. * Creates a RGB texture from some data.
  11779. * @param data Define the texture data
  11780. * @param width Define the width of the texture
  11781. * @param height Define the height of the texture
  11782. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11783. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11784. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11785. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11786. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11787. * @returns the RGB alpha texture
  11788. */
  11789. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11790. /**
  11791. * Creates a RGBA texture from some data.
  11792. * @param data Define the texture data
  11793. * @param width Define the width of the texture
  11794. * @param height Define the height of the texture
  11795. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11796. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11797. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11798. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11799. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11800. * @returns the RGBA texture
  11801. */
  11802. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11803. /**
  11804. * Creates a R texture from some data.
  11805. * @param data Define the texture data
  11806. * @param width Define the width of the texture
  11807. * @param height Define the height of the texture
  11808. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11809. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11810. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11811. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11812. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11813. * @returns the R texture
  11814. */
  11815. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11816. }
  11817. }
  11818. declare module "babylonjs/Engines/Extensions/engine.dynamicBuffer" {
  11819. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  11820. import { IndicesArray, DataArray } from "babylonjs/types";
  11821. module "babylonjs/Engines/thinEngine" {
  11822. interface ThinEngine {
  11823. /**
  11824. * Update a dynamic index buffer
  11825. * @param indexBuffer defines the target index buffer
  11826. * @param indices defines the data to update
  11827. * @param offset defines the offset in the target index buffer where update should start
  11828. */
  11829. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  11830. /**
  11831. * Updates a dynamic vertex buffer.
  11832. * @param vertexBuffer the vertex buffer to update
  11833. * @param data the data used to update the vertex buffer
  11834. * @param byteOffset the byte offset of the data
  11835. * @param byteLength the byte length of the data
  11836. */
  11837. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11838. }
  11839. }
  11840. }
  11841. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  11842. import { Scene } from "babylonjs/scene";
  11843. import { ISceneComponent } from "babylonjs/sceneComponent";
  11844. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11845. module "babylonjs/abstractScene" {
  11846. interface AbstractScene {
  11847. /**
  11848. * The list of procedural textures added to the scene
  11849. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11850. */
  11851. proceduralTextures: Array<ProceduralTexture>;
  11852. }
  11853. }
  11854. /**
  11855. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11856. * in a given scene.
  11857. */
  11858. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11859. /**
  11860. * The component name helpfull to identify the component in the list of scene components.
  11861. */
  11862. readonly name: string;
  11863. /**
  11864. * The scene the component belongs to.
  11865. */
  11866. scene: Scene;
  11867. /**
  11868. * Creates a new instance of the component for the given scene
  11869. * @param scene Defines the scene to register the component in
  11870. */
  11871. constructor(scene: Scene);
  11872. /**
  11873. * Registers the component in a given scene
  11874. */
  11875. register(): void;
  11876. /**
  11877. * Rebuilds the elements related to this component in case of
  11878. * context lost for instance.
  11879. */
  11880. rebuild(): void;
  11881. /**
  11882. * Disposes the component and the associated ressources.
  11883. */
  11884. dispose(): void;
  11885. private _beforeClear;
  11886. }
  11887. }
  11888. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  11889. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11890. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  11891. module "babylonjs/Engines/thinEngine" {
  11892. interface ThinEngine {
  11893. /**
  11894. * Creates a new render target cube texture
  11895. * @param size defines the size of the texture
  11896. * @param options defines the options used to create the texture
  11897. * @returns a new render target cube texture stored in an InternalTexture
  11898. */
  11899. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11900. }
  11901. }
  11902. }
  11903. declare module "babylonjs/Shaders/procedural.vertex" {
  11904. /** @hidden */
  11905. export var proceduralVertexShader: {
  11906. name: string;
  11907. shader: string;
  11908. };
  11909. }
  11910. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  11911. import { Observable } from "babylonjs/Misc/observable";
  11912. import { Nullable } from "babylonjs/types";
  11913. import { Scene } from "babylonjs/scene";
  11914. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11915. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11916. import { Effect } from "babylonjs/Materials/effect";
  11917. import { Texture } from "babylonjs/Materials/Textures/texture";
  11918. import "babylonjs/Engines/Extensions/engine.renderTarget";
  11919. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  11920. import "babylonjs/Shaders/procedural.vertex";
  11921. /**
  11922. * 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.
  11923. * This is the base class of any Procedural texture and contains most of the shareable code.
  11924. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11925. */
  11926. export class ProceduralTexture extends Texture {
  11927. isCube: boolean;
  11928. /**
  11929. * Define if the texture is enabled or not (disabled texture will not render)
  11930. */
  11931. isEnabled: boolean;
  11932. /**
  11933. * Define if the texture must be cleared before rendering (default is true)
  11934. */
  11935. autoClear: boolean;
  11936. /**
  11937. * Callback called when the texture is generated
  11938. */
  11939. onGenerated: () => void;
  11940. /**
  11941. * Event raised when the texture is generated
  11942. */
  11943. onGeneratedObservable: Observable<ProceduralTexture>;
  11944. /** @hidden */
  11945. _generateMipMaps: boolean;
  11946. /** @hidden **/
  11947. _effect: Effect;
  11948. /** @hidden */
  11949. _textures: {
  11950. [key: string]: Texture;
  11951. };
  11952. /** @hidden */
  11953. protected _fallbackTexture: Nullable<Texture>;
  11954. private _size;
  11955. private _currentRefreshId;
  11956. private _frameId;
  11957. private _refreshRate;
  11958. private _vertexBuffers;
  11959. private _indexBuffer;
  11960. private _uniforms;
  11961. private _samplers;
  11962. private _fragment;
  11963. private _floats;
  11964. private _ints;
  11965. private _floatsArrays;
  11966. private _colors3;
  11967. private _colors4;
  11968. private _vectors2;
  11969. private _vectors3;
  11970. private _matrices;
  11971. private _fallbackTextureUsed;
  11972. private _fullEngine;
  11973. private _cachedDefines;
  11974. private _contentUpdateId;
  11975. private _contentData;
  11976. /**
  11977. * Instantiates a new procedural texture.
  11978. * 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.
  11979. * This is the base class of any Procedural texture and contains most of the shareable code.
  11980. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11981. * @param name Define the name of the texture
  11982. * @param size Define the size of the texture to create
  11983. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11984. * @param scene Define the scene the texture belongs to
  11985. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11986. * @param generateMipMaps Define if the texture should creates mip maps or not
  11987. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11988. */
  11989. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11990. /**
  11991. * The effect that is created when initializing the post process.
  11992. * @returns The created effect corresponding the the postprocess.
  11993. */
  11994. getEffect(): Effect;
  11995. /**
  11996. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11997. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11998. */
  11999. getContent(): Nullable<ArrayBufferView>;
  12000. private _createIndexBuffer;
  12001. /** @hidden */
  12002. _rebuild(): void;
  12003. /**
  12004. * Resets the texture in order to recreate its associated resources.
  12005. * This can be called in case of context loss
  12006. */
  12007. reset(): void;
  12008. protected _getDefines(): string;
  12009. /**
  12010. * Is the texture ready to be used ? (rendered at least once)
  12011. * @returns true if ready, otherwise, false.
  12012. */
  12013. isReady(): boolean;
  12014. /**
  12015. * Resets the refresh counter of the texture and start bak from scratch.
  12016. * Could be useful to regenerate the texture if it is setup to render only once.
  12017. */
  12018. resetRefreshCounter(): void;
  12019. /**
  12020. * Set the fragment shader to use in order to render the texture.
  12021. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  12022. */
  12023. setFragment(fragment: any): void;
  12024. /**
  12025. * Define the refresh rate of the texture or the rendering frequency.
  12026. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  12027. */
  12028. get refreshRate(): number;
  12029. set refreshRate(value: number);
  12030. /** @hidden */
  12031. _shouldRender(): boolean;
  12032. /**
  12033. * Get the size the texture is rendering at.
  12034. * @returns the size (texture is always squared)
  12035. */
  12036. getRenderSize(): number;
  12037. /**
  12038. * Resize the texture to new value.
  12039. * @param size Define the new size the texture should have
  12040. * @param generateMipMaps Define whether the new texture should create mip maps
  12041. */
  12042. resize(size: number, generateMipMaps: boolean): void;
  12043. private _checkUniform;
  12044. /**
  12045. * Set a texture in the shader program used to render.
  12046. * @param name Define the name of the uniform samplers as defined in the shader
  12047. * @param texture Define the texture to bind to this sampler
  12048. * @return the texture itself allowing "fluent" like uniform updates
  12049. */
  12050. setTexture(name: string, texture: Texture): ProceduralTexture;
  12051. /**
  12052. * Set a float in the shader.
  12053. * @param name Define the name of the uniform as defined in the shader
  12054. * @param value Define the value to give to the uniform
  12055. * @return the texture itself allowing "fluent" like uniform updates
  12056. */
  12057. setFloat(name: string, value: number): ProceduralTexture;
  12058. /**
  12059. * Set a int in the shader.
  12060. * @param name Define the name of the uniform as defined in the shader
  12061. * @param value Define the value to give to the uniform
  12062. * @return the texture itself allowing "fluent" like uniform updates
  12063. */
  12064. setInt(name: string, value: number): ProceduralTexture;
  12065. /**
  12066. * Set an array of floats in the shader.
  12067. * @param name Define the name of the uniform as defined in the shader
  12068. * @param value Define the value to give to the uniform
  12069. * @return the texture itself allowing "fluent" like uniform updates
  12070. */
  12071. setFloats(name: string, value: number[]): ProceduralTexture;
  12072. /**
  12073. * Set a vec3 in the shader from a Color3.
  12074. * @param name Define the name of the uniform as defined in the shader
  12075. * @param value Define the value to give to the uniform
  12076. * @return the texture itself allowing "fluent" like uniform updates
  12077. */
  12078. setColor3(name: string, value: Color3): ProceduralTexture;
  12079. /**
  12080. * Set a vec4 in the shader from a Color4.
  12081. * @param name Define the name of the uniform as defined in the shader
  12082. * @param value Define the value to give to the uniform
  12083. * @return the texture itself allowing "fluent" like uniform updates
  12084. */
  12085. setColor4(name: string, value: Color4): ProceduralTexture;
  12086. /**
  12087. * Set a vec2 in the shader from a Vector2.
  12088. * @param name Define the name of the uniform as defined in the shader
  12089. * @param value Define the value to give to the uniform
  12090. * @return the texture itself allowing "fluent" like uniform updates
  12091. */
  12092. setVector2(name: string, value: Vector2): ProceduralTexture;
  12093. /**
  12094. * Set a vec3 in the shader from a Vector3.
  12095. * @param name Define the name of the uniform as defined in the shader
  12096. * @param value Define the value to give to the uniform
  12097. * @return the texture itself allowing "fluent" like uniform updates
  12098. */
  12099. setVector3(name: string, value: Vector3): ProceduralTexture;
  12100. /**
  12101. * Set a mat4 in the shader from a MAtrix.
  12102. * @param name Define the name of the uniform as defined in the shader
  12103. * @param value Define the value to give to the uniform
  12104. * @return the texture itself allowing "fluent" like uniform updates
  12105. */
  12106. setMatrix(name: string, value: Matrix): ProceduralTexture;
  12107. /**
  12108. * Render the texture to its associated render target.
  12109. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  12110. */
  12111. render(useCameraPostProcess?: boolean): void;
  12112. /**
  12113. * Clone the texture.
  12114. * @returns the cloned texture
  12115. */
  12116. clone(): ProceduralTexture;
  12117. /**
  12118. * Dispose the texture and release its asoociated resources.
  12119. */
  12120. dispose(): void;
  12121. }
  12122. }
  12123. declare module "babylonjs/Particles/baseParticleSystem" {
  12124. import { Nullable } from "babylonjs/types";
  12125. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  12126. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12127. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  12128. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  12129. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  12130. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12131. import { Color4 } from "babylonjs/Maths/math.color";
  12132. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12133. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  12134. import { Animation } from "babylonjs/Animations/animation";
  12135. import { Scene } from "babylonjs/scene";
  12136. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  12137. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  12138. /**
  12139. * This represents the base class for particle system in Babylon.
  12140. * 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.
  12141. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12142. * @example https://doc.babylonjs.com/babylon101/particles
  12143. */
  12144. export class BaseParticleSystem {
  12145. /**
  12146. * Source color is added to the destination color without alpha affecting the result
  12147. */
  12148. static BLENDMODE_ONEONE: number;
  12149. /**
  12150. * Blend current color and particle color using particle’s alpha
  12151. */
  12152. static BLENDMODE_STANDARD: number;
  12153. /**
  12154. * Add current color and particle color multiplied by particle’s alpha
  12155. */
  12156. static BLENDMODE_ADD: number;
  12157. /**
  12158. * Multiply current color with particle color
  12159. */
  12160. static BLENDMODE_MULTIPLY: number;
  12161. /**
  12162. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  12163. */
  12164. static BLENDMODE_MULTIPLYADD: number;
  12165. /**
  12166. * List of animations used by the particle system.
  12167. */
  12168. animations: Animation[];
  12169. /**
  12170. * Gets or sets the unique id of the particle system
  12171. */
  12172. uniqueId: number;
  12173. /**
  12174. * The id of the Particle system.
  12175. */
  12176. id: string;
  12177. /**
  12178. * The friendly name of the Particle system.
  12179. */
  12180. name: string;
  12181. /**
  12182. * Snippet ID if the particle system was created from the snippet server
  12183. */
  12184. snippetId: string;
  12185. /**
  12186. * The rendering group used by the Particle system to chose when to render.
  12187. */
  12188. renderingGroupId: number;
  12189. /**
  12190. * The emitter represents the Mesh or position we are attaching the particle system to.
  12191. */
  12192. emitter: Nullable<AbstractMesh | Vector3>;
  12193. /**
  12194. * The maximum number of particles to emit per frame
  12195. */
  12196. emitRate: number;
  12197. /**
  12198. * If you want to launch only a few particles at once, that can be done, as well.
  12199. */
  12200. manualEmitCount: number;
  12201. /**
  12202. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12203. */
  12204. updateSpeed: number;
  12205. /**
  12206. * The amount of time the particle system is running (depends of the overall update speed).
  12207. */
  12208. targetStopDuration: number;
  12209. /**
  12210. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  12211. */
  12212. disposeOnStop: boolean;
  12213. /**
  12214. * Minimum power of emitting particles.
  12215. */
  12216. minEmitPower: number;
  12217. /**
  12218. * Maximum power of emitting particles.
  12219. */
  12220. maxEmitPower: number;
  12221. /**
  12222. * Minimum life time of emitting particles.
  12223. */
  12224. minLifeTime: number;
  12225. /**
  12226. * Maximum life time of emitting particles.
  12227. */
  12228. maxLifeTime: number;
  12229. /**
  12230. * Minimum Size of emitting particles.
  12231. */
  12232. minSize: number;
  12233. /**
  12234. * Maximum Size of emitting particles.
  12235. */
  12236. maxSize: number;
  12237. /**
  12238. * Minimum scale of emitting particles on X axis.
  12239. */
  12240. minScaleX: number;
  12241. /**
  12242. * Maximum scale of emitting particles on X axis.
  12243. */
  12244. maxScaleX: number;
  12245. /**
  12246. * Minimum scale of emitting particles on Y axis.
  12247. */
  12248. minScaleY: number;
  12249. /**
  12250. * Maximum scale of emitting particles on Y axis.
  12251. */
  12252. maxScaleY: number;
  12253. /**
  12254. * Gets or sets the minimal initial rotation in radians.
  12255. */
  12256. minInitialRotation: number;
  12257. /**
  12258. * Gets or sets the maximal initial rotation in radians.
  12259. */
  12260. maxInitialRotation: number;
  12261. /**
  12262. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12263. */
  12264. minAngularSpeed: number;
  12265. /**
  12266. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12267. */
  12268. maxAngularSpeed: number;
  12269. /**
  12270. * The texture used to render each particle. (this can be a spritesheet)
  12271. */
  12272. particleTexture: Nullable<BaseTexture>;
  12273. /**
  12274. * The layer mask we are rendering the particles through.
  12275. */
  12276. layerMask: number;
  12277. /**
  12278. * This can help using your own shader to render the particle system.
  12279. * The according effect will be created
  12280. */
  12281. customShader: any;
  12282. /**
  12283. * By default particle system starts as soon as they are created. This prevents the
  12284. * automatic start to happen and let you decide when to start emitting particles.
  12285. */
  12286. preventAutoStart: boolean;
  12287. private _noiseTexture;
  12288. /**
  12289. * Gets or sets a texture used to add random noise to particle positions
  12290. */
  12291. get noiseTexture(): Nullable<ProceduralTexture>;
  12292. set noiseTexture(value: Nullable<ProceduralTexture>);
  12293. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12294. noiseStrength: Vector3;
  12295. /**
  12296. * Callback triggered when the particle animation is ending.
  12297. */
  12298. onAnimationEnd: Nullable<() => void>;
  12299. /**
  12300. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12301. */
  12302. blendMode: number;
  12303. /**
  12304. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12305. * to override the particles.
  12306. */
  12307. forceDepthWrite: boolean;
  12308. /** 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 */
  12309. preWarmCycles: number;
  12310. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12311. preWarmStepOffset: number;
  12312. /**
  12313. * 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)
  12314. */
  12315. spriteCellChangeSpeed: number;
  12316. /**
  12317. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12318. */
  12319. startSpriteCellID: number;
  12320. /**
  12321. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12322. */
  12323. endSpriteCellID: number;
  12324. /**
  12325. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12326. */
  12327. spriteCellWidth: number;
  12328. /**
  12329. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12330. */
  12331. spriteCellHeight: number;
  12332. /**
  12333. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12334. */
  12335. spriteRandomStartCell: boolean;
  12336. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12337. translationPivot: Vector2;
  12338. /** @hidden */
  12339. protected _isAnimationSheetEnabled: boolean;
  12340. /**
  12341. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12342. */
  12343. beginAnimationOnStart: boolean;
  12344. /**
  12345. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12346. */
  12347. beginAnimationFrom: number;
  12348. /**
  12349. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12350. */
  12351. beginAnimationTo: number;
  12352. /**
  12353. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12354. */
  12355. beginAnimationLoop: boolean;
  12356. /**
  12357. * Gets or sets a world offset applied to all particles
  12358. */
  12359. worldOffset: Vector3;
  12360. /**
  12361. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12362. */
  12363. get isAnimationSheetEnabled(): boolean;
  12364. set isAnimationSheetEnabled(value: boolean);
  12365. /**
  12366. * Get hosting scene
  12367. * @returns the scene
  12368. */
  12369. getScene(): Nullable<Scene>;
  12370. /**
  12371. * You can use gravity if you want to give an orientation to your particles.
  12372. */
  12373. gravity: Vector3;
  12374. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12375. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12376. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12377. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12378. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12379. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12380. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12381. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12382. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12383. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12384. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12385. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12386. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12387. /**
  12388. * Defines the delay in milliseconds before starting the system (0 by default)
  12389. */
  12390. startDelay: number;
  12391. /**
  12392. * Gets the current list of drag gradients.
  12393. * You must use addDragGradient and removeDragGradient to udpate this list
  12394. * @returns the list of drag gradients
  12395. */
  12396. getDragGradients(): Nullable<Array<FactorGradient>>;
  12397. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12398. limitVelocityDamping: number;
  12399. /**
  12400. * Gets the current list of limit velocity gradients.
  12401. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12402. * @returns the list of limit velocity gradients
  12403. */
  12404. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12405. /**
  12406. * Gets the current list of color gradients.
  12407. * You must use addColorGradient and removeColorGradient to udpate this list
  12408. * @returns the list of color gradients
  12409. */
  12410. getColorGradients(): Nullable<Array<ColorGradient>>;
  12411. /**
  12412. * Gets the current list of size gradients.
  12413. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12414. * @returns the list of size gradients
  12415. */
  12416. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12417. /**
  12418. * Gets the current list of color remap gradients.
  12419. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12420. * @returns the list of color remap gradients
  12421. */
  12422. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12423. /**
  12424. * Gets the current list of alpha remap gradients.
  12425. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12426. * @returns the list of alpha remap gradients
  12427. */
  12428. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12429. /**
  12430. * Gets the current list of life time gradients.
  12431. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12432. * @returns the list of life time gradients
  12433. */
  12434. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12435. /**
  12436. * Gets the current list of angular speed gradients.
  12437. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12438. * @returns the list of angular speed gradients
  12439. */
  12440. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12441. /**
  12442. * Gets the current list of velocity gradients.
  12443. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12444. * @returns the list of velocity gradients
  12445. */
  12446. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12447. /**
  12448. * Gets the current list of start size gradients.
  12449. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12450. * @returns the list of start size gradients
  12451. */
  12452. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12453. /**
  12454. * Gets the current list of emit rate gradients.
  12455. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12456. * @returns the list of emit rate gradients
  12457. */
  12458. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12459. /**
  12460. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12461. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12462. */
  12463. get direction1(): Vector3;
  12464. set direction1(value: Vector3);
  12465. /**
  12466. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12467. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12468. */
  12469. get direction2(): Vector3;
  12470. set direction2(value: Vector3);
  12471. /**
  12472. * 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.
  12473. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12474. */
  12475. get minEmitBox(): Vector3;
  12476. set minEmitBox(value: Vector3);
  12477. /**
  12478. * 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.
  12479. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12480. */
  12481. get maxEmitBox(): Vector3;
  12482. set maxEmitBox(value: Vector3);
  12483. /**
  12484. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12485. */
  12486. color1: Color4;
  12487. /**
  12488. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12489. */
  12490. color2: Color4;
  12491. /**
  12492. * Color the particle will have at the end of its lifetime
  12493. */
  12494. colorDead: Color4;
  12495. /**
  12496. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12497. */
  12498. textureMask: Color4;
  12499. /**
  12500. * The particle emitter type defines the emitter used by the particle system.
  12501. * It can be for example box, sphere, or cone...
  12502. */
  12503. particleEmitterType: IParticleEmitterType;
  12504. /** @hidden */
  12505. _isSubEmitter: boolean;
  12506. /**
  12507. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12508. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12509. */
  12510. billboardMode: number;
  12511. protected _isBillboardBased: boolean;
  12512. /**
  12513. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12514. */
  12515. get isBillboardBased(): boolean;
  12516. set isBillboardBased(value: boolean);
  12517. /**
  12518. * The scene the particle system belongs to.
  12519. */
  12520. protected _scene: Nullable<Scene>;
  12521. /**
  12522. * The engine the particle system belongs to.
  12523. */
  12524. protected _engine: ThinEngine;
  12525. /**
  12526. * Local cache of defines for image processing.
  12527. */
  12528. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12529. /**
  12530. * Default configuration related to image processing available in the standard Material.
  12531. */
  12532. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  12533. /**
  12534. * Gets the image processing configuration used either in this material.
  12535. */
  12536. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  12537. /**
  12538. * Sets the Default image processing configuration used either in the this material.
  12539. *
  12540. * If sets to null, the scene one is in use.
  12541. */
  12542. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  12543. /**
  12544. * Attaches a new image processing configuration to the Standard Material.
  12545. * @param configuration
  12546. */
  12547. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12548. /** @hidden */
  12549. protected _reset(): void;
  12550. /** @hidden */
  12551. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12552. /**
  12553. * Instantiates a particle system.
  12554. * 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.
  12555. * @param name The name of the particle system
  12556. */
  12557. constructor(name: string);
  12558. /**
  12559. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12560. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12561. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12562. * @returns the emitter
  12563. */
  12564. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12565. /**
  12566. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12567. * @param radius The radius of the hemisphere to emit from
  12568. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12569. * @returns the emitter
  12570. */
  12571. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12572. /**
  12573. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12574. * @param radius The radius of the sphere to emit from
  12575. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12576. * @returns the emitter
  12577. */
  12578. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12579. /**
  12580. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12581. * @param radius The radius of the sphere to emit from
  12582. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12583. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12584. * @returns the emitter
  12585. */
  12586. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12587. /**
  12588. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12589. * @param radius The radius of the emission cylinder
  12590. * @param height The height of the emission cylinder
  12591. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12592. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12593. * @returns the emitter
  12594. */
  12595. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12596. /**
  12597. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12598. * @param radius The radius of the cylinder to emit from
  12599. * @param height The height of the emission cylinder
  12600. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12601. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12602. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12603. * @returns the emitter
  12604. */
  12605. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12606. /**
  12607. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12608. * @param radius The radius of the cone to emit from
  12609. * @param angle The base angle of the cone
  12610. * @returns the emitter
  12611. */
  12612. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12613. /**
  12614. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12615. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12616. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12617. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12618. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12619. * @returns the emitter
  12620. */
  12621. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12622. }
  12623. }
  12624. declare module "babylonjs/Particles/subEmitter" {
  12625. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12626. import { Scene } from "babylonjs/scene";
  12627. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12628. /**
  12629. * Type of sub emitter
  12630. */
  12631. export enum SubEmitterType {
  12632. /**
  12633. * Attached to the particle over it's lifetime
  12634. */
  12635. ATTACHED = 0,
  12636. /**
  12637. * Created when the particle dies
  12638. */
  12639. END = 1
  12640. }
  12641. /**
  12642. * Sub emitter class used to emit particles from an existing particle
  12643. */
  12644. export class SubEmitter {
  12645. /**
  12646. * the particle system to be used by the sub emitter
  12647. */
  12648. particleSystem: ParticleSystem;
  12649. /**
  12650. * Type of the submitter (Default: END)
  12651. */
  12652. type: SubEmitterType;
  12653. /**
  12654. * 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)
  12655. * Note: This only is supported when using an emitter of type Mesh
  12656. */
  12657. inheritDirection: boolean;
  12658. /**
  12659. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12660. */
  12661. inheritedVelocityAmount: number;
  12662. /**
  12663. * Creates a sub emitter
  12664. * @param particleSystem the particle system to be used by the sub emitter
  12665. */
  12666. constructor(
  12667. /**
  12668. * the particle system to be used by the sub emitter
  12669. */
  12670. particleSystem: ParticleSystem);
  12671. /**
  12672. * Clones the sub emitter
  12673. * @returns the cloned sub emitter
  12674. */
  12675. clone(): SubEmitter;
  12676. /**
  12677. * Serialize current object to a JSON object
  12678. * @returns the serialized object
  12679. */
  12680. serialize(): any;
  12681. /** @hidden */
  12682. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  12683. /**
  12684. * Creates a new SubEmitter from a serialized JSON version
  12685. * @param serializationObject defines the JSON object to read from
  12686. * @param sceneOrEngine defines the hosting scene or the hosting engine
  12687. * @param rootUrl defines the rootUrl for data loading
  12688. * @returns a new SubEmitter
  12689. */
  12690. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  12691. /** Release associated resources */
  12692. dispose(): void;
  12693. }
  12694. }
  12695. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  12696. /** @hidden */
  12697. export var imageProcessingDeclaration: {
  12698. name: string;
  12699. shader: string;
  12700. };
  12701. }
  12702. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  12703. /** @hidden */
  12704. export var imageProcessingFunctions: {
  12705. name: string;
  12706. shader: string;
  12707. };
  12708. }
  12709. declare module "babylonjs/Shaders/particles.fragment" {
  12710. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  12711. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  12712. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  12713. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  12714. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  12715. /** @hidden */
  12716. export var particlesPixelShader: {
  12717. name: string;
  12718. shader: string;
  12719. };
  12720. }
  12721. declare module "babylonjs/Shaders/particles.vertex" {
  12722. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  12723. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  12724. /** @hidden */
  12725. export var particlesVertexShader: {
  12726. name: string;
  12727. shader: string;
  12728. };
  12729. }
  12730. declare module "babylonjs/Misc/interfaces/iClipPlanesHolder" {
  12731. import { Nullable } from "babylonjs/types";
  12732. import { Plane } from "babylonjs/Maths/math";
  12733. /**
  12734. * Interface used to define entities containing multiple clip planes
  12735. */
  12736. export interface IClipPlanesHolder {
  12737. /**
  12738. * Gets or sets the active clipplane 1
  12739. */
  12740. clipPlane: Nullable<Plane>;
  12741. /**
  12742. * Gets or sets the active clipplane 2
  12743. */
  12744. clipPlane2: Nullable<Plane>;
  12745. /**
  12746. * Gets or sets the active clipplane 3
  12747. */
  12748. clipPlane3: Nullable<Plane>;
  12749. /**
  12750. * Gets or sets the active clipplane 4
  12751. */
  12752. clipPlane4: Nullable<Plane>;
  12753. /**
  12754. * Gets or sets the active clipplane 5
  12755. */
  12756. clipPlane5: Nullable<Plane>;
  12757. /**
  12758. * Gets or sets the active clipplane 6
  12759. */
  12760. clipPlane6: Nullable<Plane>;
  12761. }
  12762. }
  12763. declare module "babylonjs/Materials/thinMaterialHelper" {
  12764. import { Effect } from "babylonjs/Materials/effect";
  12765. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  12766. /**
  12767. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  12768. *
  12769. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  12770. *
  12771. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  12772. */
  12773. export class ThinMaterialHelper {
  12774. /**
  12775. * Binds the clip plane information from the holder to the effect.
  12776. * @param effect The effect we are binding the data to
  12777. * @param holder The entity containing the clip plane information
  12778. */
  12779. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  12780. }
  12781. }
  12782. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  12783. module "babylonjs/Engines/thinEngine" {
  12784. interface ThinEngine {
  12785. /**
  12786. * Sets alpha constants used by some alpha blending modes
  12787. * @param r defines the red component
  12788. * @param g defines the green component
  12789. * @param b defines the blue component
  12790. * @param a defines the alpha component
  12791. */
  12792. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  12793. /**
  12794. * Sets the current alpha mode
  12795. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  12796. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  12797. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12798. */
  12799. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12800. /**
  12801. * Gets the current alpha mode
  12802. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12803. * @returns the current alpha mode
  12804. */
  12805. getAlphaMode(): number;
  12806. /**
  12807. * Sets the current alpha equation
  12808. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  12809. */
  12810. setAlphaEquation(equation: number): void;
  12811. /**
  12812. * Gets the current alpha equation.
  12813. * @returns the current alpha equation
  12814. */
  12815. getAlphaEquation(): number;
  12816. }
  12817. }
  12818. }
  12819. declare module "babylonjs/Particles/particleSystem" {
  12820. import { Nullable } from "babylonjs/types";
  12821. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  12822. import { Observable } from "babylonjs/Misc/observable";
  12823. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12824. import { Effect } from "babylonjs/Materials/effect";
  12825. import { IDisposable } from "babylonjs/scene";
  12826. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  12827. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  12828. import { Particle } from "babylonjs/Particles/particle";
  12829. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12830. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  12831. import "babylonjs/Shaders/particles.fragment";
  12832. import "babylonjs/Shaders/particles.vertex";
  12833. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  12834. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12835. import "babylonjs/Engines/Extensions/engine.alpha";
  12836. import { Scene } from "babylonjs/scene";
  12837. /**
  12838. * This represents a particle system in Babylon.
  12839. * 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.
  12840. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12841. * @example https://doc.babylonjs.com/babylon101/particles
  12842. */
  12843. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12844. /**
  12845. * Billboard mode will only apply to Y axis
  12846. */
  12847. static readonly BILLBOARDMODE_Y: number;
  12848. /**
  12849. * Billboard mode will apply to all axes
  12850. */
  12851. static readonly BILLBOARDMODE_ALL: number;
  12852. /**
  12853. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12854. */
  12855. static readonly BILLBOARDMODE_STRETCHED: number;
  12856. /**
  12857. * This function can be defined to provide custom update for active particles.
  12858. * This function will be called instead of regular update (age, position, color, etc.).
  12859. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12860. */
  12861. updateFunction: (particles: Particle[]) => void;
  12862. private _emitterWorldMatrix;
  12863. /**
  12864. * This function can be defined to specify initial direction for every new particle.
  12865. * It by default use the emitterType defined function
  12866. */
  12867. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12868. /**
  12869. * This function can be defined to specify initial position for every new particle.
  12870. * It by default use the emitterType defined function
  12871. */
  12872. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12873. /**
  12874. * @hidden
  12875. */
  12876. _inheritedVelocityOffset: Vector3;
  12877. /**
  12878. * An event triggered when the system is disposed
  12879. */
  12880. onDisposeObservable: Observable<IParticleSystem>;
  12881. private _onDisposeObserver;
  12882. /**
  12883. * Sets a callback that will be triggered when the system is disposed
  12884. */
  12885. set onDispose(callback: () => void);
  12886. private _particles;
  12887. private _epsilon;
  12888. private _capacity;
  12889. private _stockParticles;
  12890. private _newPartsExcess;
  12891. private _vertexData;
  12892. private _vertexBuffer;
  12893. private _vertexBuffers;
  12894. private _spriteBuffer;
  12895. private _indexBuffer;
  12896. private _effect;
  12897. private _customEffect;
  12898. private _cachedDefines;
  12899. private _scaledColorStep;
  12900. private _colorDiff;
  12901. private _scaledDirection;
  12902. private _scaledGravity;
  12903. private _currentRenderId;
  12904. private _alive;
  12905. private _useInstancing;
  12906. private _started;
  12907. private _stopped;
  12908. private _actualFrame;
  12909. private _scaledUpdateSpeed;
  12910. private _vertexBufferSize;
  12911. /** @hidden */
  12912. _currentEmitRateGradient: Nullable<FactorGradient>;
  12913. /** @hidden */
  12914. _currentEmitRate1: number;
  12915. /** @hidden */
  12916. _currentEmitRate2: number;
  12917. /** @hidden */
  12918. _currentStartSizeGradient: Nullable<FactorGradient>;
  12919. /** @hidden */
  12920. _currentStartSize1: number;
  12921. /** @hidden */
  12922. _currentStartSize2: number;
  12923. private readonly _rawTextureWidth;
  12924. private _rampGradientsTexture;
  12925. private _useRampGradients;
  12926. /** Gets or sets a matrix to use to compute projection */
  12927. defaultProjectionMatrix: Matrix;
  12928. /** Gets or sets a matrix to use to compute view */
  12929. defaultViewMatrix: Matrix;
  12930. /** Gets or sets a boolean indicating that ramp gradients must be used
  12931. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12932. */
  12933. get useRampGradients(): boolean;
  12934. set useRampGradients(value: boolean);
  12935. /**
  12936. * 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.
  12937. * 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: [])
  12938. */
  12939. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12940. private _subEmitters;
  12941. /**
  12942. * @hidden
  12943. * If the particle systems emitter should be disposed when the particle system is disposed
  12944. */
  12945. _disposeEmitterOnDispose: boolean;
  12946. /**
  12947. * The current active Sub-systems, this property is used by the root particle system only.
  12948. */
  12949. activeSubSystems: Array<ParticleSystem>;
  12950. /**
  12951. * Specifies if the particles are updated in emitter local space or world space
  12952. */
  12953. isLocal: boolean;
  12954. private _rootParticleSystem;
  12955. /**
  12956. * Gets the current list of active particles
  12957. */
  12958. get particles(): Particle[];
  12959. /**
  12960. * Gets the number of particles active at the same time.
  12961. * @returns The number of active particles.
  12962. */
  12963. getActiveCount(): number;
  12964. /**
  12965. * Returns the string "ParticleSystem"
  12966. * @returns a string containing the class name
  12967. */
  12968. getClassName(): string;
  12969. /**
  12970. * Gets a boolean indicating that the system is stopping
  12971. * @returns true if the system is currently stopping
  12972. */
  12973. isStopping(): boolean;
  12974. /**
  12975. * Gets the custom effect used to render the particles
  12976. * @param blendMode Blend mode for which the effect should be retrieved
  12977. * @returns The effect
  12978. */
  12979. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12980. /**
  12981. * Sets the custom effect used to render the particles
  12982. * @param effect The effect to set
  12983. * @param blendMode Blend mode for which the effect should be set
  12984. */
  12985. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12986. /** @hidden */
  12987. private _onBeforeDrawParticlesObservable;
  12988. /**
  12989. * Observable that will be called just before the particles are drawn
  12990. */
  12991. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12992. /**
  12993. * Gets the name of the particle vertex shader
  12994. */
  12995. get vertexShaderName(): string;
  12996. /**
  12997. * Instantiates a particle system.
  12998. * 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.
  12999. * @param name The name of the particle system
  13000. * @param capacity The max number of particles alive at the same time
  13001. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  13002. * @param customEffect a custom effect used to change the way particles are rendered by default
  13003. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  13004. * @param epsilon Offset used to render the particles
  13005. */
  13006. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  13007. private _addFactorGradient;
  13008. private _removeFactorGradient;
  13009. /**
  13010. * Adds a new life time gradient
  13011. * @param gradient defines the gradient to use (between 0 and 1)
  13012. * @param factor defines the life time factor to affect to the specified gradient
  13013. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13014. * @returns the current particle system
  13015. */
  13016. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13017. /**
  13018. * Remove a specific life time gradient
  13019. * @param gradient defines the gradient to remove
  13020. * @returns the current particle system
  13021. */
  13022. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13023. /**
  13024. * Adds a new size gradient
  13025. * @param gradient defines the gradient to use (between 0 and 1)
  13026. * @param factor defines the size factor to affect to the specified gradient
  13027. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13028. * @returns the current particle system
  13029. */
  13030. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13031. /**
  13032. * Remove a specific size gradient
  13033. * @param gradient defines the gradient to remove
  13034. * @returns the current particle system
  13035. */
  13036. removeSizeGradient(gradient: number): IParticleSystem;
  13037. /**
  13038. * Adds a new color remap gradient
  13039. * @param gradient defines the gradient to use (between 0 and 1)
  13040. * @param min defines the color remap minimal range
  13041. * @param max defines the color remap maximal range
  13042. * @returns the current particle system
  13043. */
  13044. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13045. /**
  13046. * Remove a specific color remap gradient
  13047. * @param gradient defines the gradient to remove
  13048. * @returns the current particle system
  13049. */
  13050. removeColorRemapGradient(gradient: number): IParticleSystem;
  13051. /**
  13052. * Adds a new alpha remap gradient
  13053. * @param gradient defines the gradient to use (between 0 and 1)
  13054. * @param min defines the alpha remap minimal range
  13055. * @param max defines the alpha remap maximal range
  13056. * @returns the current particle system
  13057. */
  13058. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13059. /**
  13060. * Remove a specific alpha remap gradient
  13061. * @param gradient defines the gradient to remove
  13062. * @returns the current particle system
  13063. */
  13064. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  13065. /**
  13066. * Adds a new angular speed gradient
  13067. * @param gradient defines the gradient to use (between 0 and 1)
  13068. * @param factor defines the angular speed to affect to the specified gradient
  13069. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13070. * @returns the current particle system
  13071. */
  13072. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13073. /**
  13074. * Remove a specific angular speed gradient
  13075. * @param gradient defines the gradient to remove
  13076. * @returns the current particle system
  13077. */
  13078. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13079. /**
  13080. * Adds a new velocity gradient
  13081. * @param gradient defines the gradient to use (between 0 and 1)
  13082. * @param factor defines the velocity to affect to the specified gradient
  13083. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13084. * @returns the current particle system
  13085. */
  13086. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13087. /**
  13088. * Remove a specific velocity gradient
  13089. * @param gradient defines the gradient to remove
  13090. * @returns the current particle system
  13091. */
  13092. removeVelocityGradient(gradient: number): IParticleSystem;
  13093. /**
  13094. * Adds a new limit velocity gradient
  13095. * @param gradient defines the gradient to use (between 0 and 1)
  13096. * @param factor defines the limit velocity value to affect to the specified gradient
  13097. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13098. * @returns the current particle system
  13099. */
  13100. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13101. /**
  13102. * Remove a specific limit velocity gradient
  13103. * @param gradient defines the gradient to remove
  13104. * @returns the current particle system
  13105. */
  13106. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13107. /**
  13108. * Adds a new drag gradient
  13109. * @param gradient defines the gradient to use (between 0 and 1)
  13110. * @param factor defines the drag value to affect to the specified gradient
  13111. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13112. * @returns the current particle system
  13113. */
  13114. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13115. /**
  13116. * Remove a specific drag gradient
  13117. * @param gradient defines the gradient to remove
  13118. * @returns the current particle system
  13119. */
  13120. removeDragGradient(gradient: number): IParticleSystem;
  13121. /**
  13122. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13123. * @param gradient defines the gradient to use (between 0 and 1)
  13124. * @param factor defines the emit rate value to affect to the specified gradient
  13125. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13126. * @returns the current particle system
  13127. */
  13128. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13129. /**
  13130. * Remove a specific emit rate gradient
  13131. * @param gradient defines the gradient to remove
  13132. * @returns the current particle system
  13133. */
  13134. removeEmitRateGradient(gradient: number): IParticleSystem;
  13135. /**
  13136. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13137. * @param gradient defines the gradient to use (between 0 and 1)
  13138. * @param factor defines the start size value to affect to the specified gradient
  13139. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13140. * @returns the current particle system
  13141. */
  13142. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13143. /**
  13144. * Remove a specific start size gradient
  13145. * @param gradient defines the gradient to remove
  13146. * @returns the current particle system
  13147. */
  13148. removeStartSizeGradient(gradient: number): IParticleSystem;
  13149. private _createRampGradientTexture;
  13150. /**
  13151. * Gets the current list of ramp gradients.
  13152. * You must use addRampGradient and removeRampGradient to udpate this list
  13153. * @returns the list of ramp gradients
  13154. */
  13155. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13156. /** Force the system to rebuild all gradients that need to be resync */
  13157. forceRefreshGradients(): void;
  13158. private _syncRampGradientTexture;
  13159. /**
  13160. * Adds a new ramp gradient used to remap particle colors
  13161. * @param gradient defines the gradient to use (between 0 and 1)
  13162. * @param color defines the color to affect to the specified gradient
  13163. * @returns the current particle system
  13164. */
  13165. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  13166. /**
  13167. * Remove a specific ramp gradient
  13168. * @param gradient defines the gradient to remove
  13169. * @returns the current particle system
  13170. */
  13171. removeRampGradient(gradient: number): ParticleSystem;
  13172. /**
  13173. * Adds a new color gradient
  13174. * @param gradient defines the gradient to use (between 0 and 1)
  13175. * @param color1 defines the color to affect to the specified gradient
  13176. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13177. * @returns this particle system
  13178. */
  13179. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13180. /**
  13181. * Remove a specific color gradient
  13182. * @param gradient defines the gradient to remove
  13183. * @returns this particle system
  13184. */
  13185. removeColorGradient(gradient: number): IParticleSystem;
  13186. private _fetchR;
  13187. protected _reset(): void;
  13188. private _resetEffect;
  13189. private _createVertexBuffers;
  13190. private _createIndexBuffer;
  13191. /**
  13192. * Gets the maximum number of particles active at the same time.
  13193. * @returns The max number of active particles.
  13194. */
  13195. getCapacity(): number;
  13196. /**
  13197. * Gets whether there are still active particles in the system.
  13198. * @returns True if it is alive, otherwise false.
  13199. */
  13200. isAlive(): boolean;
  13201. /**
  13202. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13203. * @returns True if it has been started, otherwise false.
  13204. */
  13205. isStarted(): boolean;
  13206. private _prepareSubEmitterInternalArray;
  13207. /**
  13208. * Starts the particle system and begins to emit
  13209. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  13210. */
  13211. start(delay?: number): void;
  13212. /**
  13213. * Stops the particle system.
  13214. * @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.
  13215. */
  13216. stop(stopSubEmitters?: boolean): void;
  13217. /**
  13218. * Remove all active particles
  13219. */
  13220. reset(): void;
  13221. /**
  13222. * @hidden (for internal use only)
  13223. */
  13224. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  13225. /**
  13226. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  13227. * Its lifetime will start back at 0.
  13228. */
  13229. recycleParticle: (particle: Particle) => void;
  13230. private _stopSubEmitters;
  13231. private _createParticle;
  13232. private _removeFromRoot;
  13233. private _emitFromParticle;
  13234. private _update;
  13235. /** @hidden */
  13236. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  13237. /** @hidden */
  13238. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  13239. /**
  13240. * Fill the defines array according to the current settings of the particle system
  13241. * @param defines Array to be updated
  13242. * @param blendMode blend mode to take into account when updating the array
  13243. */
  13244. fillDefines(defines: Array<string>, blendMode: number): void;
  13245. /**
  13246. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  13247. * @param uniforms Uniforms array to fill
  13248. * @param attributes Attributes array to fill
  13249. * @param samplers Samplers array to fill
  13250. */
  13251. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  13252. /** @hidden */
  13253. private _getEffect;
  13254. /**
  13255. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13256. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  13257. */
  13258. animate(preWarmOnly?: boolean): void;
  13259. private _appendParticleVertices;
  13260. /**
  13261. * Rebuilds the particle system.
  13262. */
  13263. rebuild(): void;
  13264. /**
  13265. * Is this system ready to be used/rendered
  13266. * @return true if the system is ready
  13267. */
  13268. isReady(): boolean;
  13269. private _render;
  13270. /**
  13271. * Renders the particle system in its current state.
  13272. * @returns the current number of particles
  13273. */
  13274. render(): number;
  13275. /**
  13276. * Disposes the particle system and free the associated resources
  13277. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13278. */
  13279. dispose(disposeTexture?: boolean): void;
  13280. /**
  13281. * Clones the particle system.
  13282. * @param name The name of the cloned object
  13283. * @param newEmitter The new emitter to use
  13284. * @returns the cloned particle system
  13285. */
  13286. clone(name: string, newEmitter: any): ParticleSystem;
  13287. /**
  13288. * Serializes the particle system to a JSON object
  13289. * @param serializeTexture defines if the texture must be serialized as well
  13290. * @returns the JSON object
  13291. */
  13292. serialize(serializeTexture?: boolean): any;
  13293. /** @hidden */
  13294. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13295. /** @hidden */
  13296. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  13297. /**
  13298. * Parses a JSON object to create a particle system.
  13299. * @param parsedParticleSystem The JSON object to parse
  13300. * @param sceneOrEngine The scene or the engine to create the particle system in
  13301. * @param rootUrl The root url to use to load external dependencies like texture
  13302. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13303. * @returns the Parsed particle system
  13304. */
  13305. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13306. }
  13307. }
  13308. declare module "babylonjs/Particles/particle" {
  13309. import { Nullable } from "babylonjs/types";
  13310. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  13311. import { Color4 } from "babylonjs/Maths/math.color";
  13312. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  13313. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  13314. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  13315. /**
  13316. * A particle represents one of the element emitted by a particle system.
  13317. * This is mainly define by its coordinates, direction, velocity and age.
  13318. */
  13319. export class Particle {
  13320. /**
  13321. * The particle system the particle belongs to.
  13322. */
  13323. particleSystem: ParticleSystem;
  13324. private static _Count;
  13325. /**
  13326. * Unique ID of the particle
  13327. */
  13328. id: number;
  13329. /**
  13330. * The world position of the particle in the scene.
  13331. */
  13332. position: Vector3;
  13333. /**
  13334. * The world direction of the particle in the scene.
  13335. */
  13336. direction: Vector3;
  13337. /**
  13338. * The color of the particle.
  13339. */
  13340. color: Color4;
  13341. /**
  13342. * The color change of the particle per step.
  13343. */
  13344. colorStep: Color4;
  13345. /**
  13346. * Defines how long will the life of the particle be.
  13347. */
  13348. lifeTime: number;
  13349. /**
  13350. * The current age of the particle.
  13351. */
  13352. age: number;
  13353. /**
  13354. * The current size of the particle.
  13355. */
  13356. size: number;
  13357. /**
  13358. * The current scale of the particle.
  13359. */
  13360. scale: Vector2;
  13361. /**
  13362. * The current angle of the particle.
  13363. */
  13364. angle: number;
  13365. /**
  13366. * Defines how fast is the angle changing.
  13367. */
  13368. angularSpeed: number;
  13369. /**
  13370. * Defines the cell index used by the particle to be rendered from a sprite.
  13371. */
  13372. cellIndex: number;
  13373. /**
  13374. * The information required to support color remapping
  13375. */
  13376. remapData: Vector4;
  13377. /** @hidden */
  13378. _randomCellOffset?: number;
  13379. /** @hidden */
  13380. _initialDirection: Nullable<Vector3>;
  13381. /** @hidden */
  13382. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13383. /** @hidden */
  13384. _initialStartSpriteCellID: number;
  13385. /** @hidden */
  13386. _initialEndSpriteCellID: number;
  13387. /** @hidden */
  13388. _currentColorGradient: Nullable<ColorGradient>;
  13389. /** @hidden */
  13390. _currentColor1: Color4;
  13391. /** @hidden */
  13392. _currentColor2: Color4;
  13393. /** @hidden */
  13394. _currentSizeGradient: Nullable<FactorGradient>;
  13395. /** @hidden */
  13396. _currentSize1: number;
  13397. /** @hidden */
  13398. _currentSize2: number;
  13399. /** @hidden */
  13400. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13401. /** @hidden */
  13402. _currentAngularSpeed1: number;
  13403. /** @hidden */
  13404. _currentAngularSpeed2: number;
  13405. /** @hidden */
  13406. _currentVelocityGradient: Nullable<FactorGradient>;
  13407. /** @hidden */
  13408. _currentVelocity1: number;
  13409. /** @hidden */
  13410. _currentVelocity2: number;
  13411. /** @hidden */
  13412. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13413. /** @hidden */
  13414. _currentLimitVelocity1: number;
  13415. /** @hidden */
  13416. _currentLimitVelocity2: number;
  13417. /** @hidden */
  13418. _currentDragGradient: Nullable<FactorGradient>;
  13419. /** @hidden */
  13420. _currentDrag1: number;
  13421. /** @hidden */
  13422. _currentDrag2: number;
  13423. /** @hidden */
  13424. _randomNoiseCoordinates1: Vector3;
  13425. /** @hidden */
  13426. _randomNoiseCoordinates2: Vector3;
  13427. /** @hidden */
  13428. _localPosition?: Vector3;
  13429. /**
  13430. * Creates a new instance Particle
  13431. * @param particleSystem the particle system the particle belongs to
  13432. */
  13433. constructor(
  13434. /**
  13435. * The particle system the particle belongs to.
  13436. */
  13437. particleSystem: ParticleSystem);
  13438. private updateCellInfoFromSystem;
  13439. /**
  13440. * Defines how the sprite cell index is updated for the particle
  13441. */
  13442. updateCellIndex(): void;
  13443. /** @hidden */
  13444. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13445. /** @hidden */
  13446. _inheritParticleInfoToSubEmitters(): void;
  13447. /** @hidden */
  13448. _reset(): void;
  13449. /**
  13450. * Copy the properties of particle to another one.
  13451. * @param other the particle to copy the information to.
  13452. */
  13453. copyTo(other: Particle): void;
  13454. }
  13455. }
  13456. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  13457. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13458. import { Effect } from "babylonjs/Materials/effect";
  13459. import { Particle } from "babylonjs/Particles/particle";
  13460. import { Nullable } from "babylonjs/types";
  13461. import { Scene } from "babylonjs/scene";
  13462. /**
  13463. * Particle emitter represents a volume emitting particles.
  13464. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13465. */
  13466. export interface IParticleEmitterType {
  13467. /**
  13468. * Called by the particle System when the direction is computed for the created particle.
  13469. * @param worldMatrix is the world matrix of the particle system
  13470. * @param directionToUpdate is the direction vector to update with the result
  13471. * @param particle is the particle we are computed the direction for
  13472. * @param isLocal defines if the direction should be set in local space
  13473. */
  13474. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13475. /**
  13476. * Called by the particle System when the position is computed for the created particle.
  13477. * @param worldMatrix is the world matrix of the particle system
  13478. * @param positionToUpdate is the position vector to update with the result
  13479. * @param particle is the particle we are computed the position for
  13480. * @param isLocal defines if the position should be set in local space
  13481. */
  13482. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13483. /**
  13484. * Clones the current emitter and returns a copy of it
  13485. * @returns the new emitter
  13486. */
  13487. clone(): IParticleEmitterType;
  13488. /**
  13489. * Called by the GPUParticleSystem to setup the update shader
  13490. * @param effect defines the update shader
  13491. */
  13492. applyToShader(effect: Effect): void;
  13493. /**
  13494. * Returns a string to use to update the GPU particles update shader
  13495. * @returns the effect defines string
  13496. */
  13497. getEffectDefines(): string;
  13498. /**
  13499. * Returns a string representing the class name
  13500. * @returns a string containing the class name
  13501. */
  13502. getClassName(): string;
  13503. /**
  13504. * Serializes the particle system to a JSON object.
  13505. * @returns the JSON object
  13506. */
  13507. serialize(): any;
  13508. /**
  13509. * Parse properties from a JSON object
  13510. * @param serializationObject defines the JSON object
  13511. * @param scene defines the hosting scene
  13512. */
  13513. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13514. }
  13515. }
  13516. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  13517. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13518. import { Effect } from "babylonjs/Materials/effect";
  13519. import { Particle } from "babylonjs/Particles/particle";
  13520. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13521. /**
  13522. * Particle emitter emitting particles from the inside of a box.
  13523. * It emits the particles randomly between 2 given directions.
  13524. */
  13525. export class BoxParticleEmitter implements IParticleEmitterType {
  13526. /**
  13527. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13528. */
  13529. direction1: Vector3;
  13530. /**
  13531. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13532. */
  13533. direction2: Vector3;
  13534. /**
  13535. * 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.
  13536. */
  13537. minEmitBox: Vector3;
  13538. /**
  13539. * 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.
  13540. */
  13541. maxEmitBox: Vector3;
  13542. /**
  13543. * Creates a new instance BoxParticleEmitter
  13544. */
  13545. constructor();
  13546. /**
  13547. * Called by the particle System when the direction is computed for the created particle.
  13548. * @param worldMatrix is the world matrix of the particle system
  13549. * @param directionToUpdate is the direction vector to update with the result
  13550. * @param particle is the particle we are computed the direction for
  13551. * @param isLocal defines if the direction should be set in local space
  13552. */
  13553. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13554. /**
  13555. * Called by the particle System when the position is computed for the created particle.
  13556. * @param worldMatrix is the world matrix of the particle system
  13557. * @param positionToUpdate is the position vector to update with the result
  13558. * @param particle is the particle we are computed the position for
  13559. * @param isLocal defines if the position should be set in local space
  13560. */
  13561. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13562. /**
  13563. * Clones the current emitter and returns a copy of it
  13564. * @returns the new emitter
  13565. */
  13566. clone(): BoxParticleEmitter;
  13567. /**
  13568. * Called by the GPUParticleSystem to setup the update shader
  13569. * @param effect defines the update shader
  13570. */
  13571. applyToShader(effect: Effect): void;
  13572. /**
  13573. * Returns a string to use to update the GPU particles update shader
  13574. * @returns a string containng the defines string
  13575. */
  13576. getEffectDefines(): string;
  13577. /**
  13578. * Returns the string "BoxParticleEmitter"
  13579. * @returns a string containing the class name
  13580. */
  13581. getClassName(): string;
  13582. /**
  13583. * Serializes the particle system to a JSON object.
  13584. * @returns the JSON object
  13585. */
  13586. serialize(): any;
  13587. /**
  13588. * Parse properties from a JSON object
  13589. * @param serializationObject defines the JSON object
  13590. */
  13591. parse(serializationObject: any): void;
  13592. }
  13593. }
  13594. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  13595. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13596. import { Effect } from "babylonjs/Materials/effect";
  13597. import { Particle } from "babylonjs/Particles/particle";
  13598. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13599. /**
  13600. * Particle emitter emitting particles from the inside of a cone.
  13601. * It emits the particles alongside the cone volume from the base to the particle.
  13602. * The emission direction might be randomized.
  13603. */
  13604. export class ConeParticleEmitter implements IParticleEmitterType {
  13605. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13606. directionRandomizer: number;
  13607. private _radius;
  13608. private _angle;
  13609. private _height;
  13610. /**
  13611. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13612. */
  13613. radiusRange: number;
  13614. /**
  13615. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13616. */
  13617. heightRange: number;
  13618. /**
  13619. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13620. */
  13621. emitFromSpawnPointOnly: boolean;
  13622. /**
  13623. * Gets or sets the radius of the emission cone
  13624. */
  13625. get radius(): number;
  13626. set radius(value: number);
  13627. /**
  13628. * Gets or sets the angle of the emission cone
  13629. */
  13630. get angle(): number;
  13631. set angle(value: number);
  13632. private _buildHeight;
  13633. /**
  13634. * Creates a new instance ConeParticleEmitter
  13635. * @param radius the radius of the emission cone (1 by default)
  13636. * @param angle the cone base angle (PI by default)
  13637. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13638. */
  13639. constructor(radius?: number, angle?: number,
  13640. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13641. directionRandomizer?: number);
  13642. /**
  13643. * Called by the particle System when the direction is computed for the created particle.
  13644. * @param worldMatrix is the world matrix of the particle system
  13645. * @param directionToUpdate is the direction vector to update with the result
  13646. * @param particle is the particle we are computed the direction for
  13647. * @param isLocal defines if the direction should be set in local space
  13648. */
  13649. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13650. /**
  13651. * Called by the particle System when the position is computed for the created particle.
  13652. * @param worldMatrix is the world matrix of the particle system
  13653. * @param positionToUpdate is the position vector to update with the result
  13654. * @param particle is the particle we are computed the position for
  13655. * @param isLocal defines if the position should be set in local space
  13656. */
  13657. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13658. /**
  13659. * Clones the current emitter and returns a copy of it
  13660. * @returns the new emitter
  13661. */
  13662. clone(): ConeParticleEmitter;
  13663. /**
  13664. * Called by the GPUParticleSystem to setup the update shader
  13665. * @param effect defines the update shader
  13666. */
  13667. applyToShader(effect: Effect): void;
  13668. /**
  13669. * Returns a string to use to update the GPU particles update shader
  13670. * @returns a string containng the defines string
  13671. */
  13672. getEffectDefines(): string;
  13673. /**
  13674. * Returns the string "ConeParticleEmitter"
  13675. * @returns a string containing the class name
  13676. */
  13677. getClassName(): string;
  13678. /**
  13679. * Serializes the particle system to a JSON object.
  13680. * @returns the JSON object
  13681. */
  13682. serialize(): any;
  13683. /**
  13684. * Parse properties from a JSON object
  13685. * @param serializationObject defines the JSON object
  13686. */
  13687. parse(serializationObject: any): void;
  13688. }
  13689. }
  13690. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  13691. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13692. import { Effect } from "babylonjs/Materials/effect";
  13693. import { Particle } from "babylonjs/Particles/particle";
  13694. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13695. /**
  13696. * Particle emitter emitting particles from the inside of a cylinder.
  13697. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13698. */
  13699. export class CylinderParticleEmitter implements IParticleEmitterType {
  13700. /**
  13701. * The radius of the emission cylinder.
  13702. */
  13703. radius: number;
  13704. /**
  13705. * The height of the emission cylinder.
  13706. */
  13707. height: number;
  13708. /**
  13709. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13710. */
  13711. radiusRange: number;
  13712. /**
  13713. * How much to randomize the particle direction [0-1].
  13714. */
  13715. directionRandomizer: number;
  13716. /**
  13717. * Creates a new instance CylinderParticleEmitter
  13718. * @param radius the radius of the emission cylinder (1 by default)
  13719. * @param height the height of the emission cylinder (1 by default)
  13720. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13721. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13722. */
  13723. constructor(
  13724. /**
  13725. * The radius of the emission cylinder.
  13726. */
  13727. radius?: number,
  13728. /**
  13729. * The height of the emission cylinder.
  13730. */
  13731. height?: number,
  13732. /**
  13733. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13734. */
  13735. radiusRange?: number,
  13736. /**
  13737. * How much to randomize the particle direction [0-1].
  13738. */
  13739. directionRandomizer?: number);
  13740. /**
  13741. * Called by the particle System when the direction is computed for the created particle.
  13742. * @param worldMatrix is the world matrix of the particle system
  13743. * @param directionToUpdate is the direction vector to update with the result
  13744. * @param particle is the particle we are computed the direction for
  13745. * @param isLocal defines if the direction should be set in local space
  13746. */
  13747. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13748. /**
  13749. * Called by the particle System when the position is computed for the created particle.
  13750. * @param worldMatrix is the world matrix of the particle system
  13751. * @param positionToUpdate is the position vector to update with the result
  13752. * @param particle is the particle we are computed the position for
  13753. * @param isLocal defines if the position should be set in local space
  13754. */
  13755. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13756. /**
  13757. * Clones the current emitter and returns a copy of it
  13758. * @returns the new emitter
  13759. */
  13760. clone(): CylinderParticleEmitter;
  13761. /**
  13762. * Called by the GPUParticleSystem to setup the update shader
  13763. * @param effect defines the update shader
  13764. */
  13765. applyToShader(effect: Effect): void;
  13766. /**
  13767. * Returns a string to use to update the GPU particles update shader
  13768. * @returns a string containng the defines string
  13769. */
  13770. getEffectDefines(): string;
  13771. /**
  13772. * Returns the string "CylinderParticleEmitter"
  13773. * @returns a string containing the class name
  13774. */
  13775. getClassName(): string;
  13776. /**
  13777. * Serializes the particle system to a JSON object.
  13778. * @returns the JSON object
  13779. */
  13780. serialize(): any;
  13781. /**
  13782. * Parse properties from a JSON object
  13783. * @param serializationObject defines the JSON object
  13784. */
  13785. parse(serializationObject: any): void;
  13786. }
  13787. /**
  13788. * Particle emitter emitting particles from the inside of a cylinder.
  13789. * It emits the particles randomly between two vectors.
  13790. */
  13791. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13792. /**
  13793. * The min limit of the emission direction.
  13794. */
  13795. direction1: Vector3;
  13796. /**
  13797. * The max limit of the emission direction.
  13798. */
  13799. direction2: Vector3;
  13800. /**
  13801. * Creates a new instance CylinderDirectedParticleEmitter
  13802. * @param radius the radius of the emission cylinder (1 by default)
  13803. * @param height the height of the emission cylinder (1 by default)
  13804. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13805. * @param direction1 the min limit of the emission direction (up vector by default)
  13806. * @param direction2 the max limit of the emission direction (up vector by default)
  13807. */
  13808. constructor(radius?: number, height?: number, radiusRange?: number,
  13809. /**
  13810. * The min limit of the emission direction.
  13811. */
  13812. direction1?: Vector3,
  13813. /**
  13814. * The max limit of the emission direction.
  13815. */
  13816. direction2?: Vector3);
  13817. /**
  13818. * Called by the particle System when the direction is computed for the created particle.
  13819. * @param worldMatrix is the world matrix of the particle system
  13820. * @param directionToUpdate is the direction vector to update with the result
  13821. * @param particle is the particle we are computed the direction for
  13822. */
  13823. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13824. /**
  13825. * Clones the current emitter and returns a copy of it
  13826. * @returns the new emitter
  13827. */
  13828. clone(): CylinderDirectedParticleEmitter;
  13829. /**
  13830. * Called by the GPUParticleSystem to setup the update shader
  13831. * @param effect defines the update shader
  13832. */
  13833. applyToShader(effect: Effect): void;
  13834. /**
  13835. * Returns a string to use to update the GPU particles update shader
  13836. * @returns a string containng the defines string
  13837. */
  13838. getEffectDefines(): string;
  13839. /**
  13840. * Returns the string "CylinderDirectedParticleEmitter"
  13841. * @returns a string containing the class name
  13842. */
  13843. getClassName(): string;
  13844. /**
  13845. * Serializes the particle system to a JSON object.
  13846. * @returns the JSON object
  13847. */
  13848. serialize(): any;
  13849. /**
  13850. * Parse properties from a JSON object
  13851. * @param serializationObject defines the JSON object
  13852. */
  13853. parse(serializationObject: any): void;
  13854. }
  13855. }
  13856. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  13857. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13858. import { Effect } from "babylonjs/Materials/effect";
  13859. import { Particle } from "babylonjs/Particles/particle";
  13860. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13861. /**
  13862. * Particle emitter emitting particles from the inside of a hemisphere.
  13863. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13864. */
  13865. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13866. /**
  13867. * The radius of the emission hemisphere.
  13868. */
  13869. radius: number;
  13870. /**
  13871. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13872. */
  13873. radiusRange: number;
  13874. /**
  13875. * How much to randomize the particle direction [0-1].
  13876. */
  13877. directionRandomizer: number;
  13878. /**
  13879. * Creates a new instance HemisphericParticleEmitter
  13880. * @param radius the radius of the emission hemisphere (1 by default)
  13881. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13882. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13883. */
  13884. constructor(
  13885. /**
  13886. * The radius of the emission hemisphere.
  13887. */
  13888. radius?: number,
  13889. /**
  13890. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13891. */
  13892. radiusRange?: number,
  13893. /**
  13894. * How much to randomize the particle direction [0-1].
  13895. */
  13896. directionRandomizer?: number);
  13897. /**
  13898. * Called by the particle System when the direction is computed for the created particle.
  13899. * @param worldMatrix is the world matrix of the particle system
  13900. * @param directionToUpdate is the direction vector to update with the result
  13901. * @param particle is the particle we are computed the direction for
  13902. * @param isLocal defines if the direction should be set in local space
  13903. */
  13904. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13905. /**
  13906. * Called by the particle System when the position is computed for the created particle.
  13907. * @param worldMatrix is the world matrix of the particle system
  13908. * @param positionToUpdate is the position vector to update with the result
  13909. * @param particle is the particle we are computed the position for
  13910. * @param isLocal defines if the position should be set in local space
  13911. */
  13912. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13913. /**
  13914. * Clones the current emitter and returns a copy of it
  13915. * @returns the new emitter
  13916. */
  13917. clone(): HemisphericParticleEmitter;
  13918. /**
  13919. * Called by the GPUParticleSystem to setup the update shader
  13920. * @param effect defines the update shader
  13921. */
  13922. applyToShader(effect: Effect): void;
  13923. /**
  13924. * Returns a string to use to update the GPU particles update shader
  13925. * @returns a string containng the defines string
  13926. */
  13927. getEffectDefines(): string;
  13928. /**
  13929. * Returns the string "HemisphericParticleEmitter"
  13930. * @returns a string containing the class name
  13931. */
  13932. getClassName(): string;
  13933. /**
  13934. * Serializes the particle system to a JSON object.
  13935. * @returns the JSON object
  13936. */
  13937. serialize(): any;
  13938. /**
  13939. * Parse properties from a JSON object
  13940. * @param serializationObject defines the JSON object
  13941. */
  13942. parse(serializationObject: any): void;
  13943. }
  13944. }
  13945. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  13946. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13947. import { Effect } from "babylonjs/Materials/effect";
  13948. import { Particle } from "babylonjs/Particles/particle";
  13949. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13950. /**
  13951. * Particle emitter emitting particles from a point.
  13952. * It emits the particles randomly between 2 given directions.
  13953. */
  13954. export class PointParticleEmitter implements IParticleEmitterType {
  13955. /**
  13956. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13957. */
  13958. direction1: Vector3;
  13959. /**
  13960. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13961. */
  13962. direction2: Vector3;
  13963. /**
  13964. * Creates a new instance PointParticleEmitter
  13965. */
  13966. constructor();
  13967. /**
  13968. * Called by the particle System when the direction is computed for the created particle.
  13969. * @param worldMatrix is the world matrix of the particle system
  13970. * @param directionToUpdate is the direction vector to update with the result
  13971. * @param particle is the particle we are computed the direction for
  13972. * @param isLocal defines if the direction should be set in local space
  13973. */
  13974. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13975. /**
  13976. * Called by the particle System when the position is computed for the created particle.
  13977. * @param worldMatrix is the world matrix of the particle system
  13978. * @param positionToUpdate is the position vector to update with the result
  13979. * @param particle is the particle we are computed the position for
  13980. * @param isLocal defines if the position should be set in local space
  13981. */
  13982. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13983. /**
  13984. * Clones the current emitter and returns a copy of it
  13985. * @returns the new emitter
  13986. */
  13987. clone(): PointParticleEmitter;
  13988. /**
  13989. * Called by the GPUParticleSystem to setup the update shader
  13990. * @param effect defines the update shader
  13991. */
  13992. applyToShader(effect: Effect): void;
  13993. /**
  13994. * Returns a string to use to update the GPU particles update shader
  13995. * @returns a string containng the defines string
  13996. */
  13997. getEffectDefines(): string;
  13998. /**
  13999. * Returns the string "PointParticleEmitter"
  14000. * @returns a string containing the class name
  14001. */
  14002. getClassName(): string;
  14003. /**
  14004. * Serializes the particle system to a JSON object.
  14005. * @returns the JSON object
  14006. */
  14007. serialize(): any;
  14008. /**
  14009. * Parse properties from a JSON object
  14010. * @param serializationObject defines the JSON object
  14011. */
  14012. parse(serializationObject: any): void;
  14013. }
  14014. }
  14015. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  14016. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14017. import { Effect } from "babylonjs/Materials/effect";
  14018. import { Particle } from "babylonjs/Particles/particle";
  14019. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14020. /**
  14021. * Particle emitter emitting particles from the inside of a sphere.
  14022. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  14023. */
  14024. export class SphereParticleEmitter implements IParticleEmitterType {
  14025. /**
  14026. * The radius of the emission sphere.
  14027. */
  14028. radius: number;
  14029. /**
  14030. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14031. */
  14032. radiusRange: number;
  14033. /**
  14034. * How much to randomize the particle direction [0-1].
  14035. */
  14036. directionRandomizer: number;
  14037. /**
  14038. * Creates a new instance SphereParticleEmitter
  14039. * @param radius the radius of the emission sphere (1 by default)
  14040. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14041. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  14042. */
  14043. constructor(
  14044. /**
  14045. * The radius of the emission sphere.
  14046. */
  14047. radius?: number,
  14048. /**
  14049. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14050. */
  14051. radiusRange?: number,
  14052. /**
  14053. * How much to randomize the particle direction [0-1].
  14054. */
  14055. directionRandomizer?: number);
  14056. /**
  14057. * Called by the particle System when the direction is computed for the created particle.
  14058. * @param worldMatrix is the world matrix of the particle system
  14059. * @param directionToUpdate is the direction vector to update with the result
  14060. * @param particle is the particle we are computed the direction for
  14061. * @param isLocal defines if the direction should be set in local space
  14062. */
  14063. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14064. /**
  14065. * Called by the particle System when the position is computed for the created particle.
  14066. * @param worldMatrix is the world matrix of the particle system
  14067. * @param positionToUpdate is the position vector to update with the result
  14068. * @param particle is the particle we are computed the position for
  14069. * @param isLocal defines if the position should be set in local space
  14070. */
  14071. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14072. /**
  14073. * Clones the current emitter and returns a copy of it
  14074. * @returns the new emitter
  14075. */
  14076. clone(): SphereParticleEmitter;
  14077. /**
  14078. * Called by the GPUParticleSystem to setup the update shader
  14079. * @param effect defines the update shader
  14080. */
  14081. applyToShader(effect: Effect): void;
  14082. /**
  14083. * Returns a string to use to update the GPU particles update shader
  14084. * @returns a string containng the defines string
  14085. */
  14086. getEffectDefines(): string;
  14087. /**
  14088. * Returns the string "SphereParticleEmitter"
  14089. * @returns a string containing the class name
  14090. */
  14091. getClassName(): string;
  14092. /**
  14093. * Serializes the particle system to a JSON object.
  14094. * @returns the JSON object
  14095. */
  14096. serialize(): any;
  14097. /**
  14098. * Parse properties from a JSON object
  14099. * @param serializationObject defines the JSON object
  14100. */
  14101. parse(serializationObject: any): void;
  14102. }
  14103. /**
  14104. * Particle emitter emitting particles from the inside of a sphere.
  14105. * It emits the particles randomly between two vectors.
  14106. */
  14107. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  14108. /**
  14109. * The min limit of the emission direction.
  14110. */
  14111. direction1: Vector3;
  14112. /**
  14113. * The max limit of the emission direction.
  14114. */
  14115. direction2: Vector3;
  14116. /**
  14117. * Creates a new instance SphereDirectedParticleEmitter
  14118. * @param radius the radius of the emission sphere (1 by default)
  14119. * @param direction1 the min limit of the emission direction (up vector by default)
  14120. * @param direction2 the max limit of the emission direction (up vector by default)
  14121. */
  14122. constructor(radius?: number,
  14123. /**
  14124. * The min limit of the emission direction.
  14125. */
  14126. direction1?: Vector3,
  14127. /**
  14128. * The max limit of the emission direction.
  14129. */
  14130. direction2?: Vector3);
  14131. /**
  14132. * Called by the particle System when the direction is computed for the created particle.
  14133. * @param worldMatrix is the world matrix of the particle system
  14134. * @param directionToUpdate is the direction vector to update with the result
  14135. * @param particle is the particle we are computed the direction for
  14136. */
  14137. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14138. /**
  14139. * Clones the current emitter and returns a copy of it
  14140. * @returns the new emitter
  14141. */
  14142. clone(): SphereDirectedParticleEmitter;
  14143. /**
  14144. * Called by the GPUParticleSystem to setup the update shader
  14145. * @param effect defines the update shader
  14146. */
  14147. applyToShader(effect: Effect): void;
  14148. /**
  14149. * Returns a string to use to update the GPU particles update shader
  14150. * @returns a string containng the defines string
  14151. */
  14152. getEffectDefines(): string;
  14153. /**
  14154. * Returns the string "SphereDirectedParticleEmitter"
  14155. * @returns a string containing the class name
  14156. */
  14157. getClassName(): string;
  14158. /**
  14159. * Serializes the particle system to a JSON object.
  14160. * @returns the JSON object
  14161. */
  14162. serialize(): any;
  14163. /**
  14164. * Parse properties from a JSON object
  14165. * @param serializationObject defines the JSON object
  14166. */
  14167. parse(serializationObject: any): void;
  14168. }
  14169. }
  14170. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  14171. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14172. import { Effect } from "babylonjs/Materials/effect";
  14173. import { Particle } from "babylonjs/Particles/particle";
  14174. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14175. import { Nullable } from "babylonjs/types";
  14176. /**
  14177. * Particle emitter emitting particles from a custom list of positions.
  14178. */
  14179. export class CustomParticleEmitter implements IParticleEmitterType {
  14180. /**
  14181. * Gets or sets the position generator that will create the inital position of each particle.
  14182. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14183. */
  14184. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  14185. /**
  14186. * Gets or sets the destination generator that will create the final destination of each particle.
  14187. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14188. */
  14189. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  14190. /**
  14191. * Creates a new instance CustomParticleEmitter
  14192. */
  14193. constructor();
  14194. /**
  14195. * Called by the particle System when the direction is computed for the created particle.
  14196. * @param worldMatrix is the world matrix of the particle system
  14197. * @param directionToUpdate is the direction vector to update with the result
  14198. * @param particle is the particle we are computed the direction for
  14199. * @param isLocal defines if the direction should be set in local space
  14200. */
  14201. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14202. /**
  14203. * Called by the particle System when the position is computed for the created particle.
  14204. * @param worldMatrix is the world matrix of the particle system
  14205. * @param positionToUpdate is the position vector to update with the result
  14206. * @param particle is the particle we are computed the position for
  14207. * @param isLocal defines if the position should be set in local space
  14208. */
  14209. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14210. /**
  14211. * Clones the current emitter and returns a copy of it
  14212. * @returns the new emitter
  14213. */
  14214. clone(): CustomParticleEmitter;
  14215. /**
  14216. * Called by the GPUParticleSystem to setup the update shader
  14217. * @param effect defines the update shader
  14218. */
  14219. applyToShader(effect: Effect): void;
  14220. /**
  14221. * Returns a string to use to update the GPU particles update shader
  14222. * @returns a string containng the defines string
  14223. */
  14224. getEffectDefines(): string;
  14225. /**
  14226. * Returns the string "PointParticleEmitter"
  14227. * @returns a string containing the class name
  14228. */
  14229. getClassName(): string;
  14230. /**
  14231. * Serializes the particle system to a JSON object.
  14232. * @returns the JSON object
  14233. */
  14234. serialize(): any;
  14235. /**
  14236. * Parse properties from a JSON object
  14237. * @param serializationObject defines the JSON object
  14238. */
  14239. parse(serializationObject: any): void;
  14240. }
  14241. }
  14242. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  14243. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14244. import { Effect } from "babylonjs/Materials/effect";
  14245. import { Particle } from "babylonjs/Particles/particle";
  14246. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14247. import { Nullable } from "babylonjs/types";
  14248. import { Scene } from "babylonjs/scene";
  14249. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14250. /**
  14251. * Particle emitter emitting particles from the inside of a box.
  14252. * It emits the particles randomly between 2 given directions.
  14253. */
  14254. export class MeshParticleEmitter implements IParticleEmitterType {
  14255. private _indices;
  14256. private _positions;
  14257. private _normals;
  14258. private _storedNormal;
  14259. private _mesh;
  14260. /**
  14261. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14262. */
  14263. direction1: Vector3;
  14264. /**
  14265. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14266. */
  14267. direction2: Vector3;
  14268. /**
  14269. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  14270. */
  14271. useMeshNormalsForDirection: boolean;
  14272. /** Defines the mesh to use as source */
  14273. get mesh(): Nullable<AbstractMesh>;
  14274. set mesh(value: Nullable<AbstractMesh>);
  14275. /**
  14276. * Creates a new instance MeshParticleEmitter
  14277. * @param mesh defines the mesh to use as source
  14278. */
  14279. constructor(mesh?: Nullable<AbstractMesh>);
  14280. /**
  14281. * Called by the particle System when the direction is computed for the created particle.
  14282. * @param worldMatrix is the world matrix of the particle system
  14283. * @param directionToUpdate is the direction vector to update with the result
  14284. * @param particle is the particle we are computed the direction for
  14285. * @param isLocal defines if the direction should be set in local space
  14286. */
  14287. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14288. /**
  14289. * Called by the particle System when the position is computed for the created particle.
  14290. * @param worldMatrix is the world matrix of the particle system
  14291. * @param positionToUpdate is the position vector to update with the result
  14292. * @param particle is the particle we are computed the position for
  14293. * @param isLocal defines if the position should be set in local space
  14294. */
  14295. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14296. /**
  14297. * Clones the current emitter and returns a copy of it
  14298. * @returns the new emitter
  14299. */
  14300. clone(): MeshParticleEmitter;
  14301. /**
  14302. * Called by the GPUParticleSystem to setup the update shader
  14303. * @param effect defines the update shader
  14304. */
  14305. applyToShader(effect: Effect): void;
  14306. /**
  14307. * Returns a string to use to update the GPU particles update shader
  14308. * @returns a string containng the defines string
  14309. */
  14310. getEffectDefines(): string;
  14311. /**
  14312. * Returns the string "BoxParticleEmitter"
  14313. * @returns a string containing the class name
  14314. */
  14315. getClassName(): string;
  14316. /**
  14317. * Serializes the particle system to a JSON object.
  14318. * @returns the JSON object
  14319. */
  14320. serialize(): any;
  14321. /**
  14322. * Parse properties from a JSON object
  14323. * @param serializationObject defines the JSON object
  14324. * @param scene defines the hosting scene
  14325. */
  14326. parse(serializationObject: any, scene: Nullable<Scene>): void;
  14327. }
  14328. }
  14329. declare module "babylonjs/Particles/EmitterTypes/index" {
  14330. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  14331. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  14332. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  14333. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  14334. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14335. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  14336. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  14337. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  14338. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  14339. }
  14340. declare module "babylonjs/Particles/IParticleSystem" {
  14341. import { Nullable } from "babylonjs/types";
  14342. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14343. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  14344. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  14345. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14346. import { Scene } from "babylonjs/scene";
  14347. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  14348. import { Effect } from "babylonjs/Materials/effect";
  14349. import { Observable } from "babylonjs/Misc/observable";
  14350. import { Animation } from "babylonjs/Animations/animation";
  14351. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14352. /**
  14353. * Interface representing a particle system in Babylon.js.
  14354. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14355. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14356. */
  14357. export interface IParticleSystem {
  14358. /**
  14359. * List of animations used by the particle system.
  14360. */
  14361. animations: Animation[];
  14362. /**
  14363. * The id of the Particle system.
  14364. */
  14365. id: string;
  14366. /**
  14367. * The name of the Particle system.
  14368. */
  14369. name: string;
  14370. /**
  14371. * The emitter represents the Mesh or position we are attaching the particle system to.
  14372. */
  14373. emitter: Nullable<AbstractMesh | Vector3>;
  14374. /**
  14375. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14376. */
  14377. isBillboardBased: boolean;
  14378. /**
  14379. * The rendering group used by the Particle system to chose when to render.
  14380. */
  14381. renderingGroupId: number;
  14382. /**
  14383. * The layer mask we are rendering the particles through.
  14384. */
  14385. layerMask: number;
  14386. /**
  14387. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14388. */
  14389. updateSpeed: number;
  14390. /**
  14391. * The amount of time the particle system is running (depends of the overall update speed).
  14392. */
  14393. targetStopDuration: number;
  14394. /**
  14395. * The texture used to render each particle. (this can be a spritesheet)
  14396. */
  14397. particleTexture: Nullable<BaseTexture>;
  14398. /**
  14399. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14400. */
  14401. blendMode: number;
  14402. /**
  14403. * Minimum life time of emitting particles.
  14404. */
  14405. minLifeTime: number;
  14406. /**
  14407. * Maximum life time of emitting particles.
  14408. */
  14409. maxLifeTime: number;
  14410. /**
  14411. * Minimum Size of emitting particles.
  14412. */
  14413. minSize: number;
  14414. /**
  14415. * Maximum Size of emitting particles.
  14416. */
  14417. maxSize: number;
  14418. /**
  14419. * Minimum scale of emitting particles on X axis.
  14420. */
  14421. minScaleX: number;
  14422. /**
  14423. * Maximum scale of emitting particles on X axis.
  14424. */
  14425. maxScaleX: number;
  14426. /**
  14427. * Minimum scale of emitting particles on Y axis.
  14428. */
  14429. minScaleY: number;
  14430. /**
  14431. * Maximum scale of emitting particles on Y axis.
  14432. */
  14433. maxScaleY: number;
  14434. /**
  14435. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14436. */
  14437. color1: Color4;
  14438. /**
  14439. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14440. */
  14441. color2: Color4;
  14442. /**
  14443. * Color the particle will have at the end of its lifetime.
  14444. */
  14445. colorDead: Color4;
  14446. /**
  14447. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14448. */
  14449. emitRate: number;
  14450. /**
  14451. * You can use gravity if you want to give an orientation to your particles.
  14452. */
  14453. gravity: Vector3;
  14454. /**
  14455. * Minimum power of emitting particles.
  14456. */
  14457. minEmitPower: number;
  14458. /**
  14459. * Maximum power of emitting particles.
  14460. */
  14461. maxEmitPower: number;
  14462. /**
  14463. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14464. */
  14465. minAngularSpeed: number;
  14466. /**
  14467. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14468. */
  14469. maxAngularSpeed: number;
  14470. /**
  14471. * Gets or sets the minimal initial rotation in radians.
  14472. */
  14473. minInitialRotation: number;
  14474. /**
  14475. * Gets or sets the maximal initial rotation in radians.
  14476. */
  14477. maxInitialRotation: number;
  14478. /**
  14479. * The particle emitter type defines the emitter used by the particle system.
  14480. * It can be for example box, sphere, or cone...
  14481. */
  14482. particleEmitterType: Nullable<IParticleEmitterType>;
  14483. /**
  14484. * Defines the delay in milliseconds before starting the system (0 by default)
  14485. */
  14486. startDelay: number;
  14487. /**
  14488. * 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
  14489. */
  14490. preWarmCycles: number;
  14491. /**
  14492. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14493. */
  14494. preWarmStepOffset: number;
  14495. /**
  14496. * 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)
  14497. */
  14498. spriteCellChangeSpeed: number;
  14499. /**
  14500. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14501. */
  14502. startSpriteCellID: number;
  14503. /**
  14504. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14505. */
  14506. endSpriteCellID: number;
  14507. /**
  14508. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14509. */
  14510. spriteCellWidth: number;
  14511. /**
  14512. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14513. */
  14514. spriteCellHeight: number;
  14515. /**
  14516. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14517. */
  14518. spriteRandomStartCell: boolean;
  14519. /**
  14520. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14521. */
  14522. isAnimationSheetEnabled: boolean;
  14523. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14524. translationPivot: Vector2;
  14525. /**
  14526. * Gets or sets a texture used to add random noise to particle positions
  14527. */
  14528. noiseTexture: Nullable<BaseTexture>;
  14529. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14530. noiseStrength: Vector3;
  14531. /**
  14532. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14533. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14534. */
  14535. billboardMode: number;
  14536. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14537. limitVelocityDamping: number;
  14538. /**
  14539. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14540. */
  14541. beginAnimationOnStart: boolean;
  14542. /**
  14543. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14544. */
  14545. beginAnimationFrom: number;
  14546. /**
  14547. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14548. */
  14549. beginAnimationTo: number;
  14550. /**
  14551. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14552. */
  14553. beginAnimationLoop: boolean;
  14554. /**
  14555. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14556. */
  14557. disposeOnStop: boolean;
  14558. /**
  14559. * Specifies if the particles are updated in emitter local space or world space
  14560. */
  14561. isLocal: boolean;
  14562. /** Snippet ID if the particle system was created from the snippet server */
  14563. snippetId: string;
  14564. /** Gets or sets a matrix to use to compute projection */
  14565. defaultProjectionMatrix: Matrix;
  14566. /**
  14567. * Gets the maximum number of particles active at the same time.
  14568. * @returns The max number of active particles.
  14569. */
  14570. getCapacity(): number;
  14571. /**
  14572. * Gets the number of particles active at the same time.
  14573. * @returns The number of active particles.
  14574. */
  14575. getActiveCount(): number;
  14576. /**
  14577. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14578. * @returns True if it has been started, otherwise false.
  14579. */
  14580. isStarted(): boolean;
  14581. /**
  14582. * Animates the particle system for this frame.
  14583. */
  14584. animate(): void;
  14585. /**
  14586. * Renders the particle system in its current state.
  14587. * @returns the current number of particles
  14588. */
  14589. render(): number;
  14590. /**
  14591. * Dispose the particle system and frees its associated resources.
  14592. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14593. */
  14594. dispose(disposeTexture?: boolean): void;
  14595. /**
  14596. * An event triggered when the system is disposed
  14597. */
  14598. onDisposeObservable: Observable<IParticleSystem>;
  14599. /**
  14600. * Clones the particle system.
  14601. * @param name The name of the cloned object
  14602. * @param newEmitter The new emitter to use
  14603. * @returns the cloned particle system
  14604. */
  14605. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14606. /**
  14607. * Serializes the particle system to a JSON object
  14608. * @param serializeTexture defines if the texture must be serialized as well
  14609. * @returns the JSON object
  14610. */
  14611. serialize(serializeTexture: boolean): any;
  14612. /**
  14613. * Rebuild the particle system
  14614. */
  14615. rebuild(): void;
  14616. /** Force the system to rebuild all gradients that need to be resync */
  14617. forceRefreshGradients(): void;
  14618. /**
  14619. * Starts the particle system and begins to emit
  14620. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14621. */
  14622. start(delay?: number): void;
  14623. /**
  14624. * Stops the particle system.
  14625. */
  14626. stop(): void;
  14627. /**
  14628. * Remove all active particles
  14629. */
  14630. reset(): void;
  14631. /**
  14632. * Gets a boolean indicating that the system is stopping
  14633. * @returns true if the system is currently stopping
  14634. */
  14635. isStopping(): boolean;
  14636. /**
  14637. * Is this system ready to be used/rendered
  14638. * @return true if the system is ready
  14639. */
  14640. isReady(): boolean;
  14641. /**
  14642. * Returns the string "ParticleSystem"
  14643. * @returns a string containing the class name
  14644. */
  14645. getClassName(): string;
  14646. /**
  14647. * Gets the custom effect used to render the particles
  14648. * @param blendMode Blend mode for which the effect should be retrieved
  14649. * @returns The effect
  14650. */
  14651. getCustomEffect(blendMode: number): Nullable<Effect>;
  14652. /**
  14653. * Sets the custom effect used to render the particles
  14654. * @param effect The effect to set
  14655. * @param blendMode Blend mode for which the effect should be set
  14656. */
  14657. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14658. /**
  14659. * Fill the defines array according to the current settings of the particle system
  14660. * @param defines Array to be updated
  14661. * @param blendMode blend mode to take into account when updating the array
  14662. */
  14663. fillDefines(defines: Array<string>, blendMode: number): void;
  14664. /**
  14665. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14666. * @param uniforms Uniforms array to fill
  14667. * @param attributes Attributes array to fill
  14668. * @param samplers Samplers array to fill
  14669. */
  14670. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14671. /**
  14672. * Observable that will be called just before the particles are drawn
  14673. */
  14674. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14675. /**
  14676. * Gets the name of the particle vertex shader
  14677. */
  14678. vertexShaderName: string;
  14679. /**
  14680. * Adds a new color gradient
  14681. * @param gradient defines the gradient to use (between 0 and 1)
  14682. * @param color1 defines the color to affect to the specified gradient
  14683. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14684. * @returns the current particle system
  14685. */
  14686. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14687. /**
  14688. * Remove a specific color gradient
  14689. * @param gradient defines the gradient to remove
  14690. * @returns the current particle system
  14691. */
  14692. removeColorGradient(gradient: number): IParticleSystem;
  14693. /**
  14694. * Adds a new size gradient
  14695. * @param gradient defines the gradient to use (between 0 and 1)
  14696. * @param factor defines the size factor to affect to the specified gradient
  14697. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14698. * @returns the current particle system
  14699. */
  14700. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14701. /**
  14702. * Remove a specific size gradient
  14703. * @param gradient defines the gradient to remove
  14704. * @returns the current particle system
  14705. */
  14706. removeSizeGradient(gradient: number): IParticleSystem;
  14707. /**
  14708. * Gets the current list of color gradients.
  14709. * You must use addColorGradient and removeColorGradient to udpate this list
  14710. * @returns the list of color gradients
  14711. */
  14712. getColorGradients(): Nullable<Array<ColorGradient>>;
  14713. /**
  14714. * Gets the current list of size gradients.
  14715. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14716. * @returns the list of size gradients
  14717. */
  14718. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14719. /**
  14720. * Gets the current list of angular speed gradients.
  14721. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14722. * @returns the list of angular speed gradients
  14723. */
  14724. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14725. /**
  14726. * Adds a new angular speed gradient
  14727. * @param gradient defines the gradient to use (between 0 and 1)
  14728. * @param factor defines the angular speed to affect to the specified gradient
  14729. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14730. * @returns the current particle system
  14731. */
  14732. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14733. /**
  14734. * Remove a specific angular speed gradient
  14735. * @param gradient defines the gradient to remove
  14736. * @returns the current particle system
  14737. */
  14738. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14739. /**
  14740. * Gets the current list of velocity gradients.
  14741. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14742. * @returns the list of velocity gradients
  14743. */
  14744. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14745. /**
  14746. * Adds a new velocity gradient
  14747. * @param gradient defines the gradient to use (between 0 and 1)
  14748. * @param factor defines the velocity to affect to the specified gradient
  14749. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14750. * @returns the current particle system
  14751. */
  14752. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14753. /**
  14754. * Remove a specific velocity gradient
  14755. * @param gradient defines the gradient to remove
  14756. * @returns the current particle system
  14757. */
  14758. removeVelocityGradient(gradient: number): IParticleSystem;
  14759. /**
  14760. * Gets the current list of limit velocity gradients.
  14761. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14762. * @returns the list of limit velocity gradients
  14763. */
  14764. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14765. /**
  14766. * Adds a new limit velocity gradient
  14767. * @param gradient defines the gradient to use (between 0 and 1)
  14768. * @param factor defines the limit velocity to affect to the specified gradient
  14769. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14770. * @returns the current particle system
  14771. */
  14772. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14773. /**
  14774. * Remove a specific limit velocity gradient
  14775. * @param gradient defines the gradient to remove
  14776. * @returns the current particle system
  14777. */
  14778. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14779. /**
  14780. * Adds a new drag gradient
  14781. * @param gradient defines the gradient to use (between 0 and 1)
  14782. * @param factor defines the drag to affect to the specified gradient
  14783. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14784. * @returns the current particle system
  14785. */
  14786. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14787. /**
  14788. * Remove a specific drag gradient
  14789. * @param gradient defines the gradient to remove
  14790. * @returns the current particle system
  14791. */
  14792. removeDragGradient(gradient: number): IParticleSystem;
  14793. /**
  14794. * Gets the current list of drag gradients.
  14795. * You must use addDragGradient and removeDragGradient to udpate this list
  14796. * @returns the list of drag gradients
  14797. */
  14798. getDragGradients(): Nullable<Array<FactorGradient>>;
  14799. /**
  14800. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14801. * @param gradient defines the gradient to use (between 0 and 1)
  14802. * @param factor defines the emit rate to affect to the specified gradient
  14803. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14804. * @returns the current particle system
  14805. */
  14806. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14807. /**
  14808. * Remove a specific emit rate gradient
  14809. * @param gradient defines the gradient to remove
  14810. * @returns the current particle system
  14811. */
  14812. removeEmitRateGradient(gradient: number): IParticleSystem;
  14813. /**
  14814. * Gets the current list of emit rate gradients.
  14815. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14816. * @returns the list of emit rate gradients
  14817. */
  14818. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14819. /**
  14820. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14821. * @param gradient defines the gradient to use (between 0 and 1)
  14822. * @param factor defines the start size to affect to the specified gradient
  14823. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14824. * @returns the current particle system
  14825. */
  14826. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14827. /**
  14828. * Remove a specific start size gradient
  14829. * @param gradient defines the gradient to remove
  14830. * @returns the current particle system
  14831. */
  14832. removeStartSizeGradient(gradient: number): IParticleSystem;
  14833. /**
  14834. * Gets the current list of start size gradients.
  14835. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14836. * @returns the list of start size gradients
  14837. */
  14838. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14839. /**
  14840. * Adds a new life time gradient
  14841. * @param gradient defines the gradient to use (between 0 and 1)
  14842. * @param factor defines the life time factor to affect to the specified gradient
  14843. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14844. * @returns the current particle system
  14845. */
  14846. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14847. /**
  14848. * Remove a specific life time gradient
  14849. * @param gradient defines the gradient to remove
  14850. * @returns the current particle system
  14851. */
  14852. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14853. /**
  14854. * Gets the current list of life time gradients.
  14855. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14856. * @returns the list of life time gradients
  14857. */
  14858. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14859. /**
  14860. * Gets the current list of color gradients.
  14861. * You must use addColorGradient and removeColorGradient to udpate this list
  14862. * @returns the list of color gradients
  14863. */
  14864. getColorGradients(): Nullable<Array<ColorGradient>>;
  14865. /**
  14866. * Adds a new ramp gradient used to remap particle colors
  14867. * @param gradient defines the gradient to use (between 0 and 1)
  14868. * @param color defines the color to affect to the specified gradient
  14869. * @returns the current particle system
  14870. */
  14871. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14872. /**
  14873. * Gets the current list of ramp gradients.
  14874. * You must use addRampGradient and removeRampGradient to udpate this list
  14875. * @returns the list of ramp gradients
  14876. */
  14877. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14878. /** Gets or sets a boolean indicating that ramp gradients must be used
  14879. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14880. */
  14881. useRampGradients: boolean;
  14882. /**
  14883. * Adds a new color remap gradient
  14884. * @param gradient defines the gradient to use (between 0 and 1)
  14885. * @param min defines the color remap minimal range
  14886. * @param max defines the color remap maximal range
  14887. * @returns the current particle system
  14888. */
  14889. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14890. /**
  14891. * Gets the current list of color remap gradients.
  14892. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14893. * @returns the list of color remap gradients
  14894. */
  14895. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14896. /**
  14897. * Adds a new alpha remap gradient
  14898. * @param gradient defines the gradient to use (between 0 and 1)
  14899. * @param min defines the alpha remap minimal range
  14900. * @param max defines the alpha remap maximal range
  14901. * @returns the current particle system
  14902. */
  14903. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14904. /**
  14905. * Gets the current list of alpha remap gradients.
  14906. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14907. * @returns the list of alpha remap gradients
  14908. */
  14909. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14910. /**
  14911. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14912. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14913. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14914. * @returns the emitter
  14915. */
  14916. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14917. /**
  14918. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14919. * @param radius The radius of the hemisphere to emit from
  14920. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14921. * @returns the emitter
  14922. */
  14923. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14924. /**
  14925. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14926. * @param radius The radius of the sphere to emit from
  14927. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14928. * @returns the emitter
  14929. */
  14930. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14931. /**
  14932. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14933. * @param radius The radius of the sphere to emit from
  14934. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14935. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14936. * @returns the emitter
  14937. */
  14938. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14939. /**
  14940. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14941. * @param radius The radius of the emission cylinder
  14942. * @param height The height of the emission cylinder
  14943. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14944. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14945. * @returns the emitter
  14946. */
  14947. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14948. /**
  14949. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14950. * @param radius The radius of the cylinder to emit from
  14951. * @param height The height of the emission cylinder
  14952. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14953. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14954. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14955. * @returns the emitter
  14956. */
  14957. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14958. /**
  14959. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14960. * @param radius The radius of the cone to emit from
  14961. * @param angle The base angle of the cone
  14962. * @returns the emitter
  14963. */
  14964. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14965. /**
  14966. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14967. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14968. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14969. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14970. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14971. * @returns the emitter
  14972. */
  14973. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14974. /**
  14975. * Get hosting scene
  14976. * @returns the scene
  14977. */
  14978. getScene(): Nullable<Scene>;
  14979. }
  14980. }
  14981. declare module "babylonjs/Meshes/transformNode" {
  14982. import { DeepImmutable } from "babylonjs/types";
  14983. import { Observable } from "babylonjs/Misc/observable";
  14984. import { Nullable } from "babylonjs/types";
  14985. import { Camera } from "babylonjs/Cameras/camera";
  14986. import { Scene } from "babylonjs/scene";
  14987. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14988. import { Node } from "babylonjs/node";
  14989. import { Bone } from "babylonjs/Bones/bone";
  14990. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14991. import { Space } from "babylonjs/Maths/math.axis";
  14992. /**
  14993. * 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.
  14994. * @see https://doc.babylonjs.com/how_to/transformnode
  14995. */
  14996. export class TransformNode extends Node {
  14997. /**
  14998. * Object will not rotate to face the camera
  14999. */
  15000. static BILLBOARDMODE_NONE: number;
  15001. /**
  15002. * Object will rotate to face the camera but only on the x axis
  15003. */
  15004. static BILLBOARDMODE_X: number;
  15005. /**
  15006. * Object will rotate to face the camera but only on the y axis
  15007. */
  15008. static BILLBOARDMODE_Y: number;
  15009. /**
  15010. * Object will rotate to face the camera but only on the z axis
  15011. */
  15012. static BILLBOARDMODE_Z: number;
  15013. /**
  15014. * Object will rotate to face the camera
  15015. */
  15016. static BILLBOARDMODE_ALL: number;
  15017. /**
  15018. * Object will rotate to face the camera's position instead of orientation
  15019. */
  15020. static BILLBOARDMODE_USE_POSITION: number;
  15021. private static _TmpRotation;
  15022. private static _TmpScaling;
  15023. private static _TmpTranslation;
  15024. private _forward;
  15025. private _forwardInverted;
  15026. private _up;
  15027. private _right;
  15028. private _rightInverted;
  15029. private _position;
  15030. private _rotation;
  15031. private _rotationQuaternion;
  15032. protected _scaling: Vector3;
  15033. protected _isDirty: boolean;
  15034. private _transformToBoneReferal;
  15035. private _isAbsoluteSynced;
  15036. private _billboardMode;
  15037. /**
  15038. * Gets or sets the billboard mode. Default is 0.
  15039. *
  15040. * | Value | Type | Description |
  15041. * | --- | --- | --- |
  15042. * | 0 | BILLBOARDMODE_NONE | |
  15043. * | 1 | BILLBOARDMODE_X | |
  15044. * | 2 | BILLBOARDMODE_Y | |
  15045. * | 4 | BILLBOARDMODE_Z | |
  15046. * | 7 | BILLBOARDMODE_ALL | |
  15047. *
  15048. */
  15049. get billboardMode(): number;
  15050. set billboardMode(value: number);
  15051. private _preserveParentRotationForBillboard;
  15052. /**
  15053. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  15054. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  15055. */
  15056. get preserveParentRotationForBillboard(): boolean;
  15057. set preserveParentRotationForBillboard(value: boolean);
  15058. /**
  15059. * 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
  15060. */
  15061. scalingDeterminant: number;
  15062. private _infiniteDistance;
  15063. /**
  15064. * Gets or sets the distance of the object to max, often used by skybox
  15065. */
  15066. get infiniteDistance(): boolean;
  15067. set infiniteDistance(value: boolean);
  15068. /**
  15069. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  15070. * By default the system will update normals to compensate
  15071. */
  15072. ignoreNonUniformScaling: boolean;
  15073. /**
  15074. * 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
  15075. */
  15076. reIntegrateRotationIntoRotationQuaternion: boolean;
  15077. /** @hidden */
  15078. _poseMatrix: Nullable<Matrix>;
  15079. /** @hidden */
  15080. _localMatrix: Matrix;
  15081. private _usePivotMatrix;
  15082. private _absolutePosition;
  15083. private _absoluteScaling;
  15084. private _absoluteRotationQuaternion;
  15085. private _pivotMatrix;
  15086. private _pivotMatrixInverse;
  15087. protected _postMultiplyPivotMatrix: boolean;
  15088. protected _isWorldMatrixFrozen: boolean;
  15089. /** @hidden */
  15090. _indexInSceneTransformNodesArray: number;
  15091. /**
  15092. * An event triggered after the world matrix is updated
  15093. */
  15094. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  15095. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  15096. /**
  15097. * Gets a string identifying the name of the class
  15098. * @returns "TransformNode" string
  15099. */
  15100. getClassName(): string;
  15101. /**
  15102. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  15103. */
  15104. get position(): Vector3;
  15105. set position(newPosition: Vector3);
  15106. /**
  15107. * 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)).
  15108. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  15109. */
  15110. get rotation(): Vector3;
  15111. set rotation(newRotation: Vector3);
  15112. /**
  15113. * 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)).
  15114. */
  15115. get scaling(): Vector3;
  15116. set scaling(newScaling: Vector3);
  15117. /**
  15118. * 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).
  15119. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  15120. */
  15121. get rotationQuaternion(): Nullable<Quaternion>;
  15122. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  15123. /**
  15124. * The forward direction of that transform in world space.
  15125. */
  15126. get forward(): Vector3;
  15127. /**
  15128. * The up direction of that transform in world space.
  15129. */
  15130. get up(): Vector3;
  15131. /**
  15132. * The right direction of that transform in world space.
  15133. */
  15134. get right(): Vector3;
  15135. /**
  15136. * Copies the parameter passed Matrix into the mesh Pose matrix.
  15137. * @param matrix the matrix to copy the pose from
  15138. * @returns this TransformNode.
  15139. */
  15140. updatePoseMatrix(matrix: Matrix): TransformNode;
  15141. /**
  15142. * Returns the mesh Pose matrix.
  15143. * @returns the pose matrix
  15144. */
  15145. getPoseMatrix(): Matrix;
  15146. /** @hidden */
  15147. _isSynchronized(): boolean;
  15148. /** @hidden */
  15149. _initCache(): void;
  15150. /**
  15151. * Flag the transform node as dirty (Forcing it to update everything)
  15152. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  15153. * @returns this transform node
  15154. */
  15155. markAsDirty(property: string): TransformNode;
  15156. /**
  15157. * Returns the current mesh absolute position.
  15158. * Returns a Vector3.
  15159. */
  15160. get absolutePosition(): Vector3;
  15161. /**
  15162. * Returns the current mesh absolute scaling.
  15163. * Returns a Vector3.
  15164. */
  15165. get absoluteScaling(): Vector3;
  15166. /**
  15167. * Returns the current mesh absolute rotation.
  15168. * Returns a Quaternion.
  15169. */
  15170. get absoluteRotationQuaternion(): Quaternion;
  15171. /**
  15172. * Sets a new matrix to apply before all other transformation
  15173. * @param matrix defines the transform matrix
  15174. * @returns the current TransformNode
  15175. */
  15176. setPreTransformMatrix(matrix: Matrix): TransformNode;
  15177. /**
  15178. * Sets a new pivot matrix to the current node
  15179. * @param matrix defines the new pivot matrix to use
  15180. * @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
  15181. * @returns the current TransformNode
  15182. */
  15183. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  15184. /**
  15185. * Returns the mesh pivot matrix.
  15186. * Default : Identity.
  15187. * @returns the matrix
  15188. */
  15189. getPivotMatrix(): Matrix;
  15190. /**
  15191. * Instantiate (when possible) or clone that node with its hierarchy
  15192. * @param newParent defines the new parent to use for the instance (or clone)
  15193. * @param options defines options to configure how copy is done
  15194. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  15195. * @returns an instance (or a clone) of the current node with its hiearchy
  15196. */
  15197. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  15198. doNotInstantiate: boolean;
  15199. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  15200. /**
  15201. * Prevents the World matrix to be computed any longer
  15202. * @param newWorldMatrix defines an optional matrix to use as world matrix
  15203. * @returns the TransformNode.
  15204. */
  15205. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  15206. /**
  15207. * Allows back the World matrix computation.
  15208. * @returns the TransformNode.
  15209. */
  15210. unfreezeWorldMatrix(): this;
  15211. /**
  15212. * True if the World matrix has been frozen.
  15213. */
  15214. get isWorldMatrixFrozen(): boolean;
  15215. /**
  15216. * Retuns the mesh absolute position in the World.
  15217. * @returns a Vector3.
  15218. */
  15219. getAbsolutePosition(): Vector3;
  15220. /**
  15221. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  15222. * @param absolutePosition the absolute position to set
  15223. * @returns the TransformNode.
  15224. */
  15225. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  15226. /**
  15227. * Sets the mesh position in its local space.
  15228. * @param vector3 the position to set in localspace
  15229. * @returns the TransformNode.
  15230. */
  15231. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  15232. /**
  15233. * Returns the mesh position in the local space from the current World matrix values.
  15234. * @returns a new Vector3.
  15235. */
  15236. getPositionExpressedInLocalSpace(): Vector3;
  15237. /**
  15238. * Translates the mesh along the passed Vector3 in its local space.
  15239. * @param vector3 the distance to translate in localspace
  15240. * @returns the TransformNode.
  15241. */
  15242. locallyTranslate(vector3: Vector3): TransformNode;
  15243. private static _lookAtVectorCache;
  15244. /**
  15245. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  15246. * @param targetPoint the position (must be in same space as current mesh) to look at
  15247. * @param yawCor optional yaw (y-axis) correction in radians
  15248. * @param pitchCor optional pitch (x-axis) correction in radians
  15249. * @param rollCor optional roll (z-axis) correction in radians
  15250. * @param space the choosen space of the target
  15251. * @returns the TransformNode.
  15252. */
  15253. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  15254. /**
  15255. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15256. * This Vector3 is expressed in the World space.
  15257. * @param localAxis axis to rotate
  15258. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15259. */
  15260. getDirection(localAxis: Vector3): Vector3;
  15261. /**
  15262. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  15263. * localAxis is expressed in the mesh local space.
  15264. * result is computed in the Wordl space from the mesh World matrix.
  15265. * @param localAxis axis to rotate
  15266. * @param result the resulting transformnode
  15267. * @returns this TransformNode.
  15268. */
  15269. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  15270. /**
  15271. * Sets this transform node rotation to the given local axis.
  15272. * @param localAxis the axis in local space
  15273. * @param yawCor optional yaw (y-axis) correction in radians
  15274. * @param pitchCor optional pitch (x-axis) correction in radians
  15275. * @param rollCor optional roll (z-axis) correction in radians
  15276. * @returns this TransformNode
  15277. */
  15278. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  15279. /**
  15280. * Sets a new pivot point to the current node
  15281. * @param point defines the new pivot point to use
  15282. * @param space defines if the point is in world or local space (local by default)
  15283. * @returns the current TransformNode
  15284. */
  15285. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  15286. /**
  15287. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  15288. * @returns the pivot point
  15289. */
  15290. getPivotPoint(): Vector3;
  15291. /**
  15292. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  15293. * @param result the vector3 to store the result
  15294. * @returns this TransformNode.
  15295. */
  15296. getPivotPointToRef(result: Vector3): TransformNode;
  15297. /**
  15298. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  15299. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  15300. */
  15301. getAbsolutePivotPoint(): Vector3;
  15302. /**
  15303. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  15304. * @param result vector3 to store the result
  15305. * @returns this TransformNode.
  15306. */
  15307. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  15308. /**
  15309. * Defines the passed node as the parent of the current node.
  15310. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  15311. * @see https://doc.babylonjs.com/how_to/parenting
  15312. * @param node the node ot set as the parent
  15313. * @returns this TransformNode.
  15314. */
  15315. setParent(node: Nullable<Node>): TransformNode;
  15316. private _nonUniformScaling;
  15317. /**
  15318. * True if the scaling property of this object is non uniform eg. (1,2,1)
  15319. */
  15320. get nonUniformScaling(): boolean;
  15321. /** @hidden */
  15322. _updateNonUniformScalingState(value: boolean): boolean;
  15323. /**
  15324. * Attach the current TransformNode to another TransformNode associated with a bone
  15325. * @param bone Bone affecting the TransformNode
  15326. * @param affectedTransformNode TransformNode associated with the bone
  15327. * @returns this object
  15328. */
  15329. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  15330. /**
  15331. * Detach the transform node if its associated with a bone
  15332. * @returns this object
  15333. */
  15334. detachFromBone(): TransformNode;
  15335. private static _rotationAxisCache;
  15336. /**
  15337. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  15338. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15339. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15340. * The passed axis is also normalized.
  15341. * @param axis the axis to rotate around
  15342. * @param amount the amount to rotate in radians
  15343. * @param space Space to rotate in (Default: local)
  15344. * @returns the TransformNode.
  15345. */
  15346. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15347. /**
  15348. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15349. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15350. * The passed axis is also normalized. .
  15351. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15352. * @param point the point to rotate around
  15353. * @param axis the axis to rotate around
  15354. * @param amount the amount to rotate in radians
  15355. * @returns the TransformNode
  15356. */
  15357. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15358. /**
  15359. * Translates the mesh along the axis vector for the passed distance in the given space.
  15360. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15361. * @param axis the axis to translate in
  15362. * @param distance the distance to translate
  15363. * @param space Space to rotate in (Default: local)
  15364. * @returns the TransformNode.
  15365. */
  15366. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15367. /**
  15368. * Adds a rotation step to the mesh current rotation.
  15369. * x, y, z are Euler angles expressed in radians.
  15370. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15371. * This means this rotation is made in the mesh local space only.
  15372. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15373. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15374. * ```javascript
  15375. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15376. * ```
  15377. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15378. * 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.
  15379. * @param x Rotation to add
  15380. * @param y Rotation to add
  15381. * @param z Rotation to add
  15382. * @returns the TransformNode.
  15383. */
  15384. addRotation(x: number, y: number, z: number): TransformNode;
  15385. /**
  15386. * @hidden
  15387. */
  15388. protected _getEffectiveParent(): Nullable<Node>;
  15389. /**
  15390. * Computes the world matrix of the node
  15391. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15392. * @returns the world matrix
  15393. */
  15394. computeWorldMatrix(force?: boolean): Matrix;
  15395. /**
  15396. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15397. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15398. */
  15399. resetLocalMatrix(independentOfChildren?: boolean): void;
  15400. protected _afterComputeWorldMatrix(): void;
  15401. /**
  15402. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15403. * @param func callback function to add
  15404. *
  15405. * @returns the TransformNode.
  15406. */
  15407. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15408. /**
  15409. * Removes a registered callback function.
  15410. * @param func callback function to remove
  15411. * @returns the TransformNode.
  15412. */
  15413. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15414. /**
  15415. * Gets the position of the current mesh in camera space
  15416. * @param camera defines the camera to use
  15417. * @returns a position
  15418. */
  15419. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15420. /**
  15421. * Returns the distance from the mesh to the active camera
  15422. * @param camera defines the camera to use
  15423. * @returns the distance
  15424. */
  15425. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15426. /**
  15427. * Clone the current transform node
  15428. * @param name Name of the new clone
  15429. * @param newParent New parent for the clone
  15430. * @param doNotCloneChildren Do not clone children hierarchy
  15431. * @returns the new transform node
  15432. */
  15433. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15434. /**
  15435. * Serializes the objects information.
  15436. * @param currentSerializationObject defines the object to serialize in
  15437. * @returns the serialized object
  15438. */
  15439. serialize(currentSerializationObject?: any): any;
  15440. /**
  15441. * Returns a new TransformNode object parsed from the source provided.
  15442. * @param parsedTransformNode is the source.
  15443. * @param scene the scne the object belongs to
  15444. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15445. * @returns a new TransformNode object parsed from the source provided.
  15446. */
  15447. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15448. /**
  15449. * Get all child-transformNodes of this node
  15450. * @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
  15451. * @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
  15452. * @returns an array of TransformNode
  15453. */
  15454. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15455. /**
  15456. * Releases resources associated with this transform node.
  15457. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15458. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15459. */
  15460. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15461. /**
  15462. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15463. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15464. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15465. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15466. * @returns the current mesh
  15467. */
  15468. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15469. private _syncAbsoluteScalingAndRotation;
  15470. }
  15471. }
  15472. declare module "babylonjs/Animations/animationPropertiesOverride" {
  15473. /**
  15474. * Class used to override all child animations of a given target
  15475. */
  15476. export class AnimationPropertiesOverride {
  15477. /**
  15478. * Gets or sets a value indicating if animation blending must be used
  15479. */
  15480. enableBlending: boolean;
  15481. /**
  15482. * Gets or sets the blending speed to use when enableBlending is true
  15483. */
  15484. blendingSpeed: number;
  15485. /**
  15486. * Gets or sets the default loop mode to use
  15487. */
  15488. loopMode: number;
  15489. }
  15490. }
  15491. declare module "babylonjs/Bones/bone" {
  15492. import { Skeleton } from "babylonjs/Bones/skeleton";
  15493. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  15494. import { Nullable } from "babylonjs/types";
  15495. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15496. import { TransformNode } from "babylonjs/Meshes/transformNode";
  15497. import { Node } from "babylonjs/node";
  15498. import { Space } from "babylonjs/Maths/math.axis";
  15499. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15500. /**
  15501. * Class used to store bone information
  15502. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15503. */
  15504. export class Bone extends Node {
  15505. /**
  15506. * defines the bone name
  15507. */
  15508. name: string;
  15509. private static _tmpVecs;
  15510. private static _tmpQuat;
  15511. private static _tmpMats;
  15512. /**
  15513. * Gets the list of child bones
  15514. */
  15515. children: Bone[];
  15516. /** Gets the animations associated with this bone */
  15517. animations: import("babylonjs/Animations/animation").Animation[];
  15518. /**
  15519. * Gets or sets bone length
  15520. */
  15521. length: number;
  15522. /**
  15523. * @hidden Internal only
  15524. * Set this value to map this bone to a different index in the transform matrices
  15525. * Set this value to -1 to exclude the bone from the transform matrices
  15526. */
  15527. _index: Nullable<number>;
  15528. private _skeleton;
  15529. private _localMatrix;
  15530. private _restPose;
  15531. private _bindPose;
  15532. private _baseMatrix;
  15533. private _absoluteTransform;
  15534. private _invertedAbsoluteTransform;
  15535. private _parent;
  15536. private _scalingDeterminant;
  15537. private _worldTransform;
  15538. private _localScaling;
  15539. private _localRotation;
  15540. private _localPosition;
  15541. private _needToDecompose;
  15542. private _needToCompose;
  15543. /** @hidden */
  15544. _linkedTransformNode: Nullable<TransformNode>;
  15545. /** @hidden */
  15546. _waitingTransformNodeId: Nullable<string>;
  15547. /** @hidden */
  15548. get _matrix(): Matrix;
  15549. /** @hidden */
  15550. set _matrix(value: Matrix);
  15551. /**
  15552. * Create a new bone
  15553. * @param name defines the bone name
  15554. * @param skeleton defines the parent skeleton
  15555. * @param parentBone defines the parent (can be null if the bone is the root)
  15556. * @param localMatrix defines the local matrix
  15557. * @param restPose defines the rest pose matrix
  15558. * @param baseMatrix defines the base matrix
  15559. * @param index defines index of the bone in the hiearchy
  15560. */
  15561. constructor(
  15562. /**
  15563. * defines the bone name
  15564. */
  15565. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15566. /**
  15567. * Gets the current object class name.
  15568. * @return the class name
  15569. */
  15570. getClassName(): string;
  15571. /**
  15572. * Gets the parent skeleton
  15573. * @returns a skeleton
  15574. */
  15575. getSkeleton(): Skeleton;
  15576. /**
  15577. * Gets parent bone
  15578. * @returns a bone or null if the bone is the root of the bone hierarchy
  15579. */
  15580. getParent(): Nullable<Bone>;
  15581. /**
  15582. * Returns an array containing the root bones
  15583. * @returns an array containing the root bones
  15584. */
  15585. getChildren(): Array<Bone>;
  15586. /**
  15587. * Gets the node index in matrix array generated for rendering
  15588. * @returns the node index
  15589. */
  15590. getIndex(): number;
  15591. /**
  15592. * Sets the parent bone
  15593. * @param parent defines the parent (can be null if the bone is the root)
  15594. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15595. */
  15596. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15597. /**
  15598. * Gets the local matrix
  15599. * @returns a matrix
  15600. */
  15601. getLocalMatrix(): Matrix;
  15602. /**
  15603. * Gets the base matrix (initial matrix which remains unchanged)
  15604. * @returns a matrix
  15605. */
  15606. getBaseMatrix(): Matrix;
  15607. /**
  15608. * Gets the rest pose matrix
  15609. * @returns a matrix
  15610. */
  15611. getRestPose(): Matrix;
  15612. /**
  15613. * Sets the rest pose matrix
  15614. * @param matrix the local-space rest pose to set for this bone
  15615. */
  15616. setRestPose(matrix: Matrix): void;
  15617. /**
  15618. * Gets the bind pose matrix
  15619. * @returns the bind pose matrix
  15620. */
  15621. getBindPose(): Matrix;
  15622. /**
  15623. * Sets the bind pose matrix
  15624. * @param matrix the local-space bind pose to set for this bone
  15625. */
  15626. setBindPose(matrix: Matrix): void;
  15627. /**
  15628. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15629. */
  15630. getWorldMatrix(): Matrix;
  15631. /**
  15632. * Sets the local matrix to rest pose matrix
  15633. */
  15634. returnToRest(): void;
  15635. /**
  15636. * Gets the inverse of the absolute transform matrix.
  15637. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15638. * @returns a matrix
  15639. */
  15640. getInvertedAbsoluteTransform(): Matrix;
  15641. /**
  15642. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15643. * @returns a matrix
  15644. */
  15645. getAbsoluteTransform(): Matrix;
  15646. /**
  15647. * Links with the given transform node.
  15648. * The local matrix of this bone is copied from the transform node every frame.
  15649. * @param transformNode defines the transform node to link to
  15650. */
  15651. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15652. /**
  15653. * Gets the node used to drive the bone's transformation
  15654. * @returns a transform node or null
  15655. */
  15656. getTransformNode(): Nullable<TransformNode>;
  15657. /** Gets or sets current position (in local space) */
  15658. get position(): Vector3;
  15659. set position(newPosition: Vector3);
  15660. /** Gets or sets current rotation (in local space) */
  15661. get rotation(): Vector3;
  15662. set rotation(newRotation: Vector3);
  15663. /** Gets or sets current rotation quaternion (in local space) */
  15664. get rotationQuaternion(): Quaternion;
  15665. set rotationQuaternion(newRotation: Quaternion);
  15666. /** Gets or sets current scaling (in local space) */
  15667. get scaling(): Vector3;
  15668. set scaling(newScaling: Vector3);
  15669. /**
  15670. * Gets the animation properties override
  15671. */
  15672. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15673. private _decompose;
  15674. private _compose;
  15675. /**
  15676. * Update the base and local matrices
  15677. * @param matrix defines the new base or local matrix
  15678. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15679. * @param updateLocalMatrix defines if the local matrix should be updated
  15680. */
  15681. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15682. /** @hidden */
  15683. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15684. /**
  15685. * Flag the bone as dirty (Forcing it to update everything)
  15686. */
  15687. markAsDirty(): void;
  15688. /** @hidden */
  15689. _markAsDirtyAndCompose(): void;
  15690. private _markAsDirtyAndDecompose;
  15691. /**
  15692. * Translate the bone in local or world space
  15693. * @param vec The amount to translate the bone
  15694. * @param space The space that the translation is in
  15695. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15696. */
  15697. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15698. /**
  15699. * Set the postion of the bone in local or world space
  15700. * @param position The position to set the bone
  15701. * @param space The space that the position is in
  15702. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15703. */
  15704. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15705. /**
  15706. * Set the absolute position of the bone (world space)
  15707. * @param position The position to set the bone
  15708. * @param mesh The mesh that this bone is attached to
  15709. */
  15710. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15711. /**
  15712. * Scale the bone on the x, y and z axes (in local space)
  15713. * @param x The amount to scale the bone on the x axis
  15714. * @param y The amount to scale the bone on the y axis
  15715. * @param z The amount to scale the bone on the z axis
  15716. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15717. */
  15718. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15719. /**
  15720. * Set the bone scaling in local space
  15721. * @param scale defines the scaling vector
  15722. */
  15723. setScale(scale: Vector3): void;
  15724. /**
  15725. * Gets the current scaling in local space
  15726. * @returns the current scaling vector
  15727. */
  15728. getScale(): Vector3;
  15729. /**
  15730. * Gets the current scaling in local space and stores it in a target vector
  15731. * @param result defines the target vector
  15732. */
  15733. getScaleToRef(result: Vector3): void;
  15734. /**
  15735. * Set the yaw, pitch, and roll of the bone in local or world space
  15736. * @param yaw The rotation of the bone on the y axis
  15737. * @param pitch The rotation of the bone on the x axis
  15738. * @param roll The rotation of the bone on the z axis
  15739. * @param space The space that the axes of rotation are in
  15740. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15741. */
  15742. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15743. /**
  15744. * Add a rotation to the bone on an axis in local or world space
  15745. * @param axis The axis to rotate the bone on
  15746. * @param amount The amount to rotate the bone
  15747. * @param space The space that the axis is in
  15748. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15749. */
  15750. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15751. /**
  15752. * Set the rotation of the bone to a particular axis angle in local or world space
  15753. * @param axis The axis to rotate the bone on
  15754. * @param angle The angle that the bone should be rotated to
  15755. * @param space The space that the axis is in
  15756. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15757. */
  15758. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15759. /**
  15760. * Set the euler rotation of the bone in local of world space
  15761. * @param rotation The euler rotation that the bone should be set to
  15762. * @param space The space that the rotation is in
  15763. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15764. */
  15765. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15766. /**
  15767. * Set the quaternion rotation of the bone in local of world space
  15768. * @param quat The quaternion rotation that the bone should be set to
  15769. * @param space The space that the rotation is in
  15770. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15771. */
  15772. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15773. /**
  15774. * Set the rotation matrix of the bone in local of world space
  15775. * @param rotMat The rotation matrix that the bone should be set to
  15776. * @param space The space that the rotation is in
  15777. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15778. */
  15779. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15780. private _rotateWithMatrix;
  15781. private _getNegativeRotationToRef;
  15782. /**
  15783. * Get the position of the bone in local or world space
  15784. * @param space The space that the returned position is in
  15785. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15786. * @returns The position of the bone
  15787. */
  15788. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15789. /**
  15790. * Copy the position of the bone to a vector3 in local or world space
  15791. * @param space The space that the returned position is in
  15792. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15793. * @param result The vector3 to copy the position to
  15794. */
  15795. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15796. /**
  15797. * Get the absolute position of the bone (world space)
  15798. * @param mesh The mesh that this bone is attached to
  15799. * @returns The absolute position of the bone
  15800. */
  15801. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15802. /**
  15803. * Copy the absolute position of the bone (world space) to the result param
  15804. * @param mesh The mesh that this bone is attached to
  15805. * @param result The vector3 to copy the absolute position to
  15806. */
  15807. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15808. /**
  15809. * Compute the absolute transforms of this bone and its children
  15810. */
  15811. computeAbsoluteTransforms(): void;
  15812. /**
  15813. * Get the world direction from an axis that is in the local space of the bone
  15814. * @param localAxis The local direction that is used to compute the world direction
  15815. * @param mesh The mesh that this bone is attached to
  15816. * @returns The world direction
  15817. */
  15818. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15819. /**
  15820. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15821. * @param localAxis The local direction that is used to compute the world direction
  15822. * @param mesh The mesh that this bone is attached to
  15823. * @param result The vector3 that the world direction will be copied to
  15824. */
  15825. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15826. /**
  15827. * Get the euler rotation of the bone in local or world space
  15828. * @param space The space that the rotation should be in
  15829. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15830. * @returns The euler rotation
  15831. */
  15832. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15833. /**
  15834. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15835. * @param space The space that the rotation should be in
  15836. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15837. * @param result The vector3 that the rotation should be copied to
  15838. */
  15839. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15840. /**
  15841. * Get the quaternion rotation of the bone in either local or world space
  15842. * @param space The space that the rotation should be in
  15843. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15844. * @returns The quaternion rotation
  15845. */
  15846. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15847. /**
  15848. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15849. * @param space The space that the rotation should be in
  15850. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15851. * @param result The quaternion that the rotation should be copied to
  15852. */
  15853. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15854. /**
  15855. * Get the rotation matrix of the bone in local or world space
  15856. * @param space The space that the rotation should be in
  15857. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15858. * @returns The rotation matrix
  15859. */
  15860. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15861. /**
  15862. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15863. * @param space The space that the rotation should be in
  15864. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15865. * @param result The quaternion that the rotation should be copied to
  15866. */
  15867. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15868. /**
  15869. * Get the world position of a point that is in the local space of the bone
  15870. * @param position The local position
  15871. * @param mesh The mesh that this bone is attached to
  15872. * @returns The world position
  15873. */
  15874. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15875. /**
  15876. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15877. * @param position The local position
  15878. * @param mesh The mesh that this bone is attached to
  15879. * @param result The vector3 that the world position should be copied to
  15880. */
  15881. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15882. /**
  15883. * Get the local position of a point that is in world space
  15884. * @param position The world position
  15885. * @param mesh The mesh that this bone is attached to
  15886. * @returns The local position
  15887. */
  15888. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15889. /**
  15890. * Get the local position of a point that is in world space and copy it to the result param
  15891. * @param position The world position
  15892. * @param mesh The mesh that this bone is attached to
  15893. * @param result The vector3 that the local position should be copied to
  15894. */
  15895. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15896. }
  15897. }
  15898. declare module "babylonjs/Animations/runtimeAnimation" {
  15899. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  15900. import { Animatable } from "babylonjs/Animations/animatable";
  15901. import { Scene } from "babylonjs/scene";
  15902. /**
  15903. * Defines a runtime animation
  15904. */
  15905. export class RuntimeAnimation {
  15906. private _events;
  15907. /**
  15908. * The current frame of the runtime animation
  15909. */
  15910. private _currentFrame;
  15911. /**
  15912. * The animation used by the runtime animation
  15913. */
  15914. private _animation;
  15915. /**
  15916. * The target of the runtime animation
  15917. */
  15918. private _target;
  15919. /**
  15920. * The initiating animatable
  15921. */
  15922. private _host;
  15923. /**
  15924. * The original value of the runtime animation
  15925. */
  15926. private _originalValue;
  15927. /**
  15928. * The original blend value of the runtime animation
  15929. */
  15930. private _originalBlendValue;
  15931. /**
  15932. * The offsets cache of the runtime animation
  15933. */
  15934. private _offsetsCache;
  15935. /**
  15936. * The high limits cache of the runtime animation
  15937. */
  15938. private _highLimitsCache;
  15939. /**
  15940. * Specifies if the runtime animation has been stopped
  15941. */
  15942. private _stopped;
  15943. /**
  15944. * The blending factor of the runtime animation
  15945. */
  15946. private _blendingFactor;
  15947. /**
  15948. * The BabylonJS scene
  15949. */
  15950. private _scene;
  15951. /**
  15952. * The current value of the runtime animation
  15953. */
  15954. private _currentValue;
  15955. /** @hidden */
  15956. _animationState: _IAnimationState;
  15957. /**
  15958. * The active target of the runtime animation
  15959. */
  15960. private _activeTargets;
  15961. private _currentActiveTarget;
  15962. private _directTarget;
  15963. /**
  15964. * The target path of the runtime animation
  15965. */
  15966. private _targetPath;
  15967. /**
  15968. * The weight of the runtime animation
  15969. */
  15970. private _weight;
  15971. /**
  15972. * The ratio offset of the runtime animation
  15973. */
  15974. private _ratioOffset;
  15975. /**
  15976. * The previous delay of the runtime animation
  15977. */
  15978. private _previousDelay;
  15979. /**
  15980. * The previous ratio of the runtime animation
  15981. */
  15982. private _previousRatio;
  15983. private _enableBlending;
  15984. private _keys;
  15985. private _minFrame;
  15986. private _maxFrame;
  15987. private _minValue;
  15988. private _maxValue;
  15989. private _targetIsArray;
  15990. /**
  15991. * Gets the current frame of the runtime animation
  15992. */
  15993. get currentFrame(): number;
  15994. /**
  15995. * Gets the weight of the runtime animation
  15996. */
  15997. get weight(): number;
  15998. /**
  15999. * Gets the current value of the runtime animation
  16000. */
  16001. get currentValue(): any;
  16002. /**
  16003. * Gets the target path of the runtime animation
  16004. */
  16005. get targetPath(): string;
  16006. /**
  16007. * Gets the actual target of the runtime animation
  16008. */
  16009. get target(): any;
  16010. /**
  16011. * Gets the additive state of the runtime animation
  16012. */
  16013. get isAdditive(): boolean;
  16014. /** @hidden */
  16015. _onLoop: () => void;
  16016. /**
  16017. * Create a new RuntimeAnimation object
  16018. * @param target defines the target of the animation
  16019. * @param animation defines the source animation object
  16020. * @param scene defines the hosting scene
  16021. * @param host defines the initiating Animatable
  16022. */
  16023. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  16024. private _preparePath;
  16025. /**
  16026. * Gets the animation from the runtime animation
  16027. */
  16028. get animation(): Animation;
  16029. /**
  16030. * Resets the runtime animation to the beginning
  16031. * @param restoreOriginal defines whether to restore the target property to the original value
  16032. */
  16033. reset(restoreOriginal?: boolean): void;
  16034. /**
  16035. * Specifies if the runtime animation is stopped
  16036. * @returns Boolean specifying if the runtime animation is stopped
  16037. */
  16038. isStopped(): boolean;
  16039. /**
  16040. * Disposes of the runtime animation
  16041. */
  16042. dispose(): void;
  16043. /**
  16044. * Apply the interpolated value to the target
  16045. * @param currentValue defines the value computed by the animation
  16046. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  16047. */
  16048. setValue(currentValue: any, weight: number): void;
  16049. private _getOriginalValues;
  16050. private _setValue;
  16051. /**
  16052. * Gets the loop pmode of the runtime animation
  16053. * @returns Loop Mode
  16054. */
  16055. private _getCorrectLoopMode;
  16056. /**
  16057. * Move the current animation to a given frame
  16058. * @param frame defines the frame to move to
  16059. */
  16060. goToFrame(frame: number): void;
  16061. /**
  16062. * @hidden Internal use only
  16063. */
  16064. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  16065. /**
  16066. * Execute the current animation
  16067. * @param delay defines the delay to add to the current frame
  16068. * @param from defines the lower bound of the animation range
  16069. * @param to defines the upper bound of the animation range
  16070. * @param loop defines if the current animation must loop
  16071. * @param speedRatio defines the current speed ratio
  16072. * @param weight defines the weight of the animation (default is -1 so no weight)
  16073. * @param onLoop optional callback called when animation loops
  16074. * @returns a boolean indicating if the animation is running
  16075. */
  16076. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  16077. }
  16078. }
  16079. declare module "babylonjs/Animations/animatable" {
  16080. import { Animation } from "babylonjs/Animations/animation";
  16081. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  16082. import { Nullable } from "babylonjs/types";
  16083. import { Observable } from "babylonjs/Misc/observable";
  16084. import { Scene } from "babylonjs/scene";
  16085. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  16086. import { Node } from "babylonjs/node";
  16087. /**
  16088. * Class used to store an actual running animation
  16089. */
  16090. export class Animatable {
  16091. /** defines the target object */
  16092. target: any;
  16093. /** defines the starting frame number (default is 0) */
  16094. fromFrame: number;
  16095. /** defines the ending frame number (default is 100) */
  16096. toFrame: number;
  16097. /** defines if the animation must loop (default is false) */
  16098. loopAnimation: boolean;
  16099. /** defines a callback to call when animation ends if it is not looping */
  16100. onAnimationEnd?: (() => void) | null | undefined;
  16101. /** defines a callback to call when animation loops */
  16102. onAnimationLoop?: (() => void) | null | undefined;
  16103. /** defines whether the animation should be evaluated additively */
  16104. isAdditive: boolean;
  16105. private _localDelayOffset;
  16106. private _pausedDelay;
  16107. private _runtimeAnimations;
  16108. private _paused;
  16109. private _scene;
  16110. private _speedRatio;
  16111. private _weight;
  16112. private _syncRoot;
  16113. /**
  16114. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  16115. * This will only apply for non looping animation (default is true)
  16116. */
  16117. disposeOnEnd: boolean;
  16118. /**
  16119. * Gets a boolean indicating if the animation has started
  16120. */
  16121. animationStarted: boolean;
  16122. /**
  16123. * Observer raised when the animation ends
  16124. */
  16125. onAnimationEndObservable: Observable<Animatable>;
  16126. /**
  16127. * Observer raised when the animation loops
  16128. */
  16129. onAnimationLoopObservable: Observable<Animatable>;
  16130. /**
  16131. * Gets the root Animatable used to synchronize and normalize animations
  16132. */
  16133. get syncRoot(): Nullable<Animatable>;
  16134. /**
  16135. * Gets the current frame of the first RuntimeAnimation
  16136. * Used to synchronize Animatables
  16137. */
  16138. get masterFrame(): number;
  16139. /**
  16140. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  16141. */
  16142. get weight(): number;
  16143. set weight(value: number);
  16144. /**
  16145. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  16146. */
  16147. get speedRatio(): number;
  16148. set speedRatio(value: number);
  16149. /**
  16150. * Creates a new Animatable
  16151. * @param scene defines the hosting scene
  16152. * @param target defines the target object
  16153. * @param fromFrame defines the starting frame number (default is 0)
  16154. * @param toFrame defines the ending frame number (default is 100)
  16155. * @param loopAnimation defines if the animation must loop (default is false)
  16156. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  16157. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  16158. * @param animations defines a group of animation to add to the new Animatable
  16159. * @param onAnimationLoop defines a callback to call when animation loops
  16160. * @param isAdditive defines whether the animation should be evaluated additively
  16161. */
  16162. constructor(scene: Scene,
  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, speedRatio?: number,
  16171. /** defines a callback to call when animation ends if it is not looping */
  16172. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  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. /**
  16178. * Synchronize and normalize current Animatable with a source Animatable
  16179. * This is useful when using animation weights and when animations are not of the same length
  16180. * @param root defines the root Animatable to synchronize with
  16181. * @returns the current Animatable
  16182. */
  16183. syncWith(root: Animatable): Animatable;
  16184. /**
  16185. * Gets the list of runtime animations
  16186. * @returns an array of RuntimeAnimation
  16187. */
  16188. getAnimations(): RuntimeAnimation[];
  16189. /**
  16190. * Adds more animations to the current animatable
  16191. * @param target defines the target of the animations
  16192. * @param animations defines the new animations to add
  16193. */
  16194. appendAnimations(target: any, animations: Animation[]): void;
  16195. /**
  16196. * Gets the source animation for a specific property
  16197. * @param property defines the propertyu to look for
  16198. * @returns null or the source animation for the given property
  16199. */
  16200. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  16201. /**
  16202. * Gets the runtime animation for a specific property
  16203. * @param property defines the propertyu to look for
  16204. * @returns null or the runtime animation for the given property
  16205. */
  16206. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  16207. /**
  16208. * Resets the animatable to its original state
  16209. */
  16210. reset(): void;
  16211. /**
  16212. * Allows the animatable to blend with current running animations
  16213. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16214. * @param blendingSpeed defines the blending speed to use
  16215. */
  16216. enableBlending(blendingSpeed: number): void;
  16217. /**
  16218. * Disable animation blending
  16219. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16220. */
  16221. disableBlending(): void;
  16222. /**
  16223. * Jump directly to a given frame
  16224. * @param frame defines the frame to jump to
  16225. */
  16226. goToFrame(frame: number): void;
  16227. /**
  16228. * Pause the animation
  16229. */
  16230. pause(): void;
  16231. /**
  16232. * Restart the animation
  16233. */
  16234. restart(): void;
  16235. private _raiseOnAnimationEnd;
  16236. /**
  16237. * Stop and delete the current animation
  16238. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  16239. * @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)
  16240. */
  16241. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  16242. /**
  16243. * Wait asynchronously for the animation to end
  16244. * @returns a promise which will be fullfilled when the animation ends
  16245. */
  16246. waitAsync(): Promise<Animatable>;
  16247. /** @hidden */
  16248. _animate(delay: number): boolean;
  16249. }
  16250. module "babylonjs/scene" {
  16251. interface Scene {
  16252. /** @hidden */
  16253. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  16254. /** @hidden */
  16255. _processLateAnimationBindingsForMatrices(holder: {
  16256. totalWeight: number;
  16257. totalAdditiveWeight: number;
  16258. animations: RuntimeAnimation[];
  16259. additiveAnimations: RuntimeAnimation[];
  16260. originalValue: Matrix;
  16261. }): any;
  16262. /** @hidden */
  16263. _processLateAnimationBindingsForQuaternions(holder: {
  16264. totalWeight: number;
  16265. totalAdditiveWeight: number;
  16266. animations: RuntimeAnimation[];
  16267. additiveAnimations: RuntimeAnimation[];
  16268. originalValue: Quaternion;
  16269. }, refQuaternion: Quaternion): Quaternion;
  16270. /** @hidden */
  16271. _processLateAnimationBindings(): void;
  16272. /**
  16273. * Will start the animation sequence of a given target
  16274. * @param target defines the target
  16275. * @param from defines from which frame should animation start
  16276. * @param to defines until which frame should animation run.
  16277. * @param weight defines the weight to apply to the animation (1.0 by default)
  16278. * @param loop defines if the animation loops
  16279. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16280. * @param onAnimationEnd defines the function to be executed when the animation ends
  16281. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16282. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16283. * @param onAnimationLoop defines the callback to call when an animation loops
  16284. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16285. * @returns the animatable object created for this animation
  16286. */
  16287. 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;
  16288. /**
  16289. * Will start the animation sequence of a given target
  16290. * @param target defines the target
  16291. * @param from defines from which frame should animation start
  16292. * @param to defines until which frame should animation run.
  16293. * @param loop defines if the animation loops
  16294. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16295. * @param onAnimationEnd defines the function to be executed when the animation ends
  16296. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16297. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16298. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  16299. * @param onAnimationLoop defines the callback to call when an animation loops
  16300. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16301. * @returns the animatable object created for this animation
  16302. */
  16303. 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;
  16304. /**
  16305. * Will start the animation sequence of a given target and its hierarchy
  16306. * @param target defines the target
  16307. * @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.
  16308. * @param from defines from which frame should animation start
  16309. * @param to defines until which frame should animation run.
  16310. * @param loop defines if the animation loops
  16311. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16312. * @param onAnimationEnd defines the function to be executed when the animation ends
  16313. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16314. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16315. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16316. * @param onAnimationLoop defines the callback to call when an animation loops
  16317. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16318. * @returns the list of created animatables
  16319. */
  16320. 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[];
  16321. /**
  16322. * Begin a new animation on a given node
  16323. * @param target defines the target where the animation will take place
  16324. * @param animations defines the list of animations to start
  16325. * @param from defines the initial value
  16326. * @param to defines the final value
  16327. * @param loop defines if you want animation to loop (off by default)
  16328. * @param speedRatio defines the speed ratio to apply to all animations
  16329. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16330. * @param onAnimationLoop defines the callback to call when an animation loops
  16331. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16332. * @returns the list of created animatables
  16333. */
  16334. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16335. /**
  16336. * Begin a new animation on a given node and its hierarchy
  16337. * @param target defines the root node where the animation will take place
  16338. * @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.
  16339. * @param animations defines the list of animations to start
  16340. * @param from defines the initial value
  16341. * @param to defines the final value
  16342. * @param loop defines if you want animation to loop (off by default)
  16343. * @param speedRatio defines the speed ratio to apply to all animations
  16344. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16345. * @param onAnimationLoop defines the callback to call when an animation loops
  16346. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16347. * @returns the list of animatables created for all nodes
  16348. */
  16349. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16350. /**
  16351. * Gets the animatable associated with a specific target
  16352. * @param target defines the target of the animatable
  16353. * @returns the required animatable if found
  16354. */
  16355. getAnimatableByTarget(target: any): Nullable<Animatable>;
  16356. /**
  16357. * Gets all animatables associated with a given target
  16358. * @param target defines the target to look animatables for
  16359. * @returns an array of Animatables
  16360. */
  16361. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16362. /**
  16363. * Stops and removes all animations that have been applied to the scene
  16364. */
  16365. stopAllAnimations(): void;
  16366. /**
  16367. * Gets the current delta time used by animation engine
  16368. */
  16369. deltaTime: number;
  16370. }
  16371. }
  16372. module "babylonjs/Bones/bone" {
  16373. interface Bone {
  16374. /**
  16375. * Copy an animation range from another bone
  16376. * @param source defines the source bone
  16377. * @param rangeName defines the range name to copy
  16378. * @param frameOffset defines the frame offset
  16379. * @param rescaleAsRequired defines if rescaling must be applied if required
  16380. * @param skelDimensionsRatio defines the scaling ratio
  16381. * @returns true if operation was successful
  16382. */
  16383. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16384. }
  16385. }
  16386. }
  16387. declare module "babylonjs/Bones/skeleton" {
  16388. import { Bone } from "babylonjs/Bones/bone";
  16389. import { Observable } from "babylonjs/Misc/observable";
  16390. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16391. import { Scene } from "babylonjs/scene";
  16392. import { Nullable } from "babylonjs/types";
  16393. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16394. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16395. import { Animatable } from "babylonjs/Animations/animatable";
  16396. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  16397. import { Animation } from "babylonjs/Animations/animation";
  16398. import { AnimationRange } from "babylonjs/Animations/animationRange";
  16399. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16400. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  16401. /**
  16402. * Class used to handle skinning animations
  16403. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16404. */
  16405. export class Skeleton implements IAnimatable {
  16406. /** defines the skeleton name */
  16407. name: string;
  16408. /** defines the skeleton Id */
  16409. id: string;
  16410. /**
  16411. * Defines the list of child bones
  16412. */
  16413. bones: Bone[];
  16414. /**
  16415. * Defines an estimate of the dimension of the skeleton at rest
  16416. */
  16417. dimensionsAtRest: Vector3;
  16418. /**
  16419. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16420. */
  16421. needInitialSkinMatrix: boolean;
  16422. /**
  16423. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16424. */
  16425. overrideMesh: Nullable<AbstractMesh>;
  16426. /**
  16427. * Gets the list of animations attached to this skeleton
  16428. */
  16429. animations: Array<Animation>;
  16430. private _scene;
  16431. private _isDirty;
  16432. private _transformMatrices;
  16433. private _transformMatrixTexture;
  16434. private _meshesWithPoseMatrix;
  16435. private _animatables;
  16436. private _identity;
  16437. private _synchronizedWithMesh;
  16438. private _ranges;
  16439. private _lastAbsoluteTransformsUpdateId;
  16440. private _canUseTextureForBones;
  16441. private _uniqueId;
  16442. /** @hidden */
  16443. _numBonesWithLinkedTransformNode: number;
  16444. /** @hidden */
  16445. _hasWaitingData: Nullable<boolean>;
  16446. /**
  16447. * Specifies if the skeleton should be serialized
  16448. */
  16449. doNotSerialize: boolean;
  16450. private _useTextureToStoreBoneMatrices;
  16451. /**
  16452. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16453. * Please note that this option is not available if the hardware does not support it
  16454. */
  16455. get useTextureToStoreBoneMatrices(): boolean;
  16456. set useTextureToStoreBoneMatrices(value: boolean);
  16457. private _animationPropertiesOverride;
  16458. /**
  16459. * Gets or sets the animation properties override
  16460. */
  16461. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16462. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16463. /**
  16464. * List of inspectable custom properties (used by the Inspector)
  16465. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16466. */
  16467. inspectableCustomProperties: IInspectable[];
  16468. /**
  16469. * An observable triggered before computing the skeleton's matrices
  16470. */
  16471. onBeforeComputeObservable: Observable<Skeleton>;
  16472. /**
  16473. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16474. */
  16475. get isUsingTextureForMatrices(): boolean;
  16476. /**
  16477. * Gets the unique ID of this skeleton
  16478. */
  16479. get uniqueId(): number;
  16480. /**
  16481. * Creates a new skeleton
  16482. * @param name defines the skeleton name
  16483. * @param id defines the skeleton Id
  16484. * @param scene defines the hosting scene
  16485. */
  16486. constructor(
  16487. /** defines the skeleton name */
  16488. name: string,
  16489. /** defines the skeleton Id */
  16490. id: string, scene: Scene);
  16491. /**
  16492. * Gets the current object class name.
  16493. * @return the class name
  16494. */
  16495. getClassName(): string;
  16496. /**
  16497. * Returns an array containing the root bones
  16498. * @returns an array containing the root bones
  16499. */
  16500. getChildren(): Array<Bone>;
  16501. /**
  16502. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16503. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16504. * @returns a Float32Array containing matrices data
  16505. */
  16506. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16507. /**
  16508. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16509. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16510. * @returns a raw texture containing the data
  16511. */
  16512. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16513. /**
  16514. * Gets the current hosting scene
  16515. * @returns a scene object
  16516. */
  16517. getScene(): Scene;
  16518. /**
  16519. * Gets a string representing the current skeleton data
  16520. * @param fullDetails defines a boolean indicating if we want a verbose version
  16521. * @returns a string representing the current skeleton data
  16522. */
  16523. toString(fullDetails?: boolean): string;
  16524. /**
  16525. * Get bone's index searching by name
  16526. * @param name defines bone's name to search for
  16527. * @return the indice of the bone. Returns -1 if not found
  16528. */
  16529. getBoneIndexByName(name: string): number;
  16530. /**
  16531. * Creater a new animation range
  16532. * @param name defines the name of the range
  16533. * @param from defines the start key
  16534. * @param to defines the end key
  16535. */
  16536. createAnimationRange(name: string, from: number, to: number): void;
  16537. /**
  16538. * Delete a specific animation range
  16539. * @param name defines the name of the range
  16540. * @param deleteFrames defines if frames must be removed as well
  16541. */
  16542. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16543. /**
  16544. * Gets a specific animation range
  16545. * @param name defines the name of the range to look for
  16546. * @returns the requested animation range or null if not found
  16547. */
  16548. getAnimationRange(name: string): Nullable<AnimationRange>;
  16549. /**
  16550. * Gets the list of all animation ranges defined on this skeleton
  16551. * @returns an array
  16552. */
  16553. getAnimationRanges(): Nullable<AnimationRange>[];
  16554. /**
  16555. * Copy animation range from a source skeleton.
  16556. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16557. * @param source defines the source skeleton
  16558. * @param name defines the name of the range to copy
  16559. * @param rescaleAsRequired defines if rescaling must be applied if required
  16560. * @returns true if operation was successful
  16561. */
  16562. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16563. /**
  16564. * Forces the skeleton to go to rest pose
  16565. */
  16566. returnToRest(): void;
  16567. private _getHighestAnimationFrame;
  16568. /**
  16569. * Begin a specific animation range
  16570. * @param name defines the name of the range to start
  16571. * @param loop defines if looping must be turned on (false by default)
  16572. * @param speedRatio defines the speed ratio to apply (1 by default)
  16573. * @param onAnimationEnd defines a callback which will be called when animation will end
  16574. * @returns a new animatable
  16575. */
  16576. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16577. /**
  16578. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16579. * @param skeleton defines the Skeleton containing the animation range to convert
  16580. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16581. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16582. * @returns the original skeleton
  16583. */
  16584. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16585. /** @hidden */
  16586. _markAsDirty(): void;
  16587. /** @hidden */
  16588. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16589. /** @hidden */
  16590. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16591. private _computeTransformMatrices;
  16592. /**
  16593. * Build all resources required to render a skeleton
  16594. */
  16595. prepare(): void;
  16596. /**
  16597. * Gets the list of animatables currently running for this skeleton
  16598. * @returns an array of animatables
  16599. */
  16600. getAnimatables(): IAnimatable[];
  16601. /**
  16602. * Clone the current skeleton
  16603. * @param name defines the name of the new skeleton
  16604. * @param id defines the id of the new skeleton
  16605. * @returns the new skeleton
  16606. */
  16607. clone(name: string, id?: string): Skeleton;
  16608. /**
  16609. * Enable animation blending for this skeleton
  16610. * @param blendingSpeed defines the blending speed to apply
  16611. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16612. */
  16613. enableBlending(blendingSpeed?: number): void;
  16614. /**
  16615. * Releases all resources associated with the current skeleton
  16616. */
  16617. dispose(): void;
  16618. /**
  16619. * Serialize the skeleton in a JSON object
  16620. * @returns a JSON object
  16621. */
  16622. serialize(): any;
  16623. /**
  16624. * Creates a new skeleton from serialized data
  16625. * @param parsedSkeleton defines the serialized data
  16626. * @param scene defines the hosting scene
  16627. * @returns a new skeleton
  16628. */
  16629. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16630. /**
  16631. * Compute all node absolute transforms
  16632. * @param forceUpdate defines if computation must be done even if cache is up to date
  16633. */
  16634. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16635. /**
  16636. * Gets the root pose matrix
  16637. * @returns a matrix
  16638. */
  16639. getPoseMatrix(): Nullable<Matrix>;
  16640. /**
  16641. * Sorts bones per internal index
  16642. */
  16643. sortBones(): void;
  16644. private _sortBones;
  16645. }
  16646. }
  16647. declare module "babylonjs/Meshes/instancedMesh" {
  16648. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16649. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16650. import { Camera } from "babylonjs/Cameras/camera";
  16651. import { Node } from "babylonjs/node";
  16652. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16653. import { Mesh } from "babylonjs/Meshes/mesh";
  16654. import { Material } from "babylonjs/Materials/material";
  16655. import { Skeleton } from "babylonjs/Bones/skeleton";
  16656. import { Light } from "babylonjs/Lights/light";
  16657. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16658. /**
  16659. * Creates an instance based on a source mesh.
  16660. */
  16661. export class InstancedMesh extends AbstractMesh {
  16662. private _sourceMesh;
  16663. private _currentLOD;
  16664. /** @hidden */
  16665. _indexInSourceMeshInstanceArray: number;
  16666. constructor(name: string, source: Mesh);
  16667. /**
  16668. * Returns the string "InstancedMesh".
  16669. */
  16670. getClassName(): string;
  16671. /** Gets the list of lights affecting that mesh */
  16672. get lightSources(): Light[];
  16673. _resyncLightSources(): void;
  16674. _resyncLightSource(light: Light): void;
  16675. _removeLightSource(light: Light, dispose: boolean): void;
  16676. /**
  16677. * If the source mesh receives shadows
  16678. */
  16679. get receiveShadows(): boolean;
  16680. /**
  16681. * The material of the source mesh
  16682. */
  16683. get material(): Nullable<Material>;
  16684. /**
  16685. * Visibility of the source mesh
  16686. */
  16687. get visibility(): number;
  16688. /**
  16689. * Skeleton of the source mesh
  16690. */
  16691. get skeleton(): Nullable<Skeleton>;
  16692. /**
  16693. * Rendering ground id of the source mesh
  16694. */
  16695. get renderingGroupId(): number;
  16696. set renderingGroupId(value: number);
  16697. /**
  16698. * Returns the total number of vertices (integer).
  16699. */
  16700. getTotalVertices(): number;
  16701. /**
  16702. * Returns a positive integer : the total number of indices in this mesh geometry.
  16703. * @returns the numner of indices or zero if the mesh has no geometry.
  16704. */
  16705. getTotalIndices(): number;
  16706. /**
  16707. * The source mesh of the instance
  16708. */
  16709. get sourceMesh(): Mesh;
  16710. /**
  16711. * Creates a new InstancedMesh object from the mesh model.
  16712. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16713. * @param name defines the name of the new instance
  16714. * @returns a new InstancedMesh
  16715. */
  16716. createInstance(name: string): InstancedMesh;
  16717. /**
  16718. * Is this node ready to be used/rendered
  16719. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16720. * @return {boolean} is it ready
  16721. */
  16722. isReady(completeCheck?: boolean): boolean;
  16723. /**
  16724. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16725. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16726. * @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.
  16727. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16728. */
  16729. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16730. /**
  16731. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16732. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16733. * The `data` are either a numeric array either a Float32Array.
  16734. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16735. * 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).
  16736. * Note that a new underlying VertexBuffer object is created each call.
  16737. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16738. *
  16739. * Possible `kind` values :
  16740. * - VertexBuffer.PositionKind
  16741. * - VertexBuffer.UVKind
  16742. * - VertexBuffer.UV2Kind
  16743. * - VertexBuffer.UV3Kind
  16744. * - VertexBuffer.UV4Kind
  16745. * - VertexBuffer.UV5Kind
  16746. * - VertexBuffer.UV6Kind
  16747. * - VertexBuffer.ColorKind
  16748. * - VertexBuffer.MatricesIndicesKind
  16749. * - VertexBuffer.MatricesIndicesExtraKind
  16750. * - VertexBuffer.MatricesWeightsKind
  16751. * - VertexBuffer.MatricesWeightsExtraKind
  16752. *
  16753. * Returns the Mesh.
  16754. */
  16755. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16756. /**
  16757. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16758. * If the mesh has no geometry, it is simply returned as it is.
  16759. * The `data` are either a numeric array either a Float32Array.
  16760. * No new underlying VertexBuffer object is created.
  16761. * 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.
  16762. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16763. *
  16764. * Possible `kind` values :
  16765. * - VertexBuffer.PositionKind
  16766. * - VertexBuffer.UVKind
  16767. * - VertexBuffer.UV2Kind
  16768. * - VertexBuffer.UV3Kind
  16769. * - VertexBuffer.UV4Kind
  16770. * - VertexBuffer.UV5Kind
  16771. * - VertexBuffer.UV6Kind
  16772. * - VertexBuffer.ColorKind
  16773. * - VertexBuffer.MatricesIndicesKind
  16774. * - VertexBuffer.MatricesIndicesExtraKind
  16775. * - VertexBuffer.MatricesWeightsKind
  16776. * - VertexBuffer.MatricesWeightsExtraKind
  16777. *
  16778. * Returns the Mesh.
  16779. */
  16780. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16781. /**
  16782. * Sets the mesh indices.
  16783. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16784. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16785. * This method creates a new index buffer each call.
  16786. * Returns the Mesh.
  16787. */
  16788. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16789. /**
  16790. * Boolean : True if the mesh owns the requested kind of data.
  16791. */
  16792. isVerticesDataPresent(kind: string): boolean;
  16793. /**
  16794. * Returns an array of indices (IndicesArray).
  16795. */
  16796. getIndices(): Nullable<IndicesArray>;
  16797. get _positions(): Nullable<Vector3[]>;
  16798. /**
  16799. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16800. * This means the mesh underlying bounding box and sphere are recomputed.
  16801. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16802. * @returns the current mesh
  16803. */
  16804. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16805. /** @hidden */
  16806. _preActivate(): InstancedMesh;
  16807. /** @hidden */
  16808. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16809. /** @hidden */
  16810. _postActivate(): void;
  16811. getWorldMatrix(): Matrix;
  16812. get isAnInstance(): boolean;
  16813. /**
  16814. * Returns the current associated LOD AbstractMesh.
  16815. */
  16816. getLOD(camera: Camera): AbstractMesh;
  16817. /** @hidden */
  16818. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16819. /** @hidden */
  16820. _syncSubMeshes(): InstancedMesh;
  16821. /** @hidden */
  16822. _generatePointsArray(): boolean;
  16823. /** @hidden */
  16824. _updateBoundingInfo(): AbstractMesh;
  16825. /**
  16826. * Creates a new InstancedMesh from the current mesh.
  16827. * - name (string) : the cloned mesh name
  16828. * - newParent (optional Node) : the optional Node to parent the clone to.
  16829. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16830. *
  16831. * Returns the clone.
  16832. */
  16833. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16834. /**
  16835. * Disposes the InstancedMesh.
  16836. * Returns nothing.
  16837. */
  16838. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16839. }
  16840. module "babylonjs/Meshes/mesh" {
  16841. interface Mesh {
  16842. /**
  16843. * Register a custom buffer that will be instanced
  16844. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16845. * @param kind defines the buffer kind
  16846. * @param stride defines the stride in floats
  16847. */
  16848. registerInstancedBuffer(kind: string, stride: number): void;
  16849. /**
  16850. * true to use the edge renderer for all instances of this mesh
  16851. */
  16852. edgesShareWithInstances: boolean;
  16853. /** @hidden */
  16854. _userInstancedBuffersStorage: {
  16855. data: {
  16856. [key: string]: Float32Array;
  16857. };
  16858. sizes: {
  16859. [key: string]: number;
  16860. };
  16861. vertexBuffers: {
  16862. [key: string]: Nullable<VertexBuffer>;
  16863. };
  16864. strides: {
  16865. [key: string]: number;
  16866. };
  16867. };
  16868. }
  16869. }
  16870. module "babylonjs/Meshes/abstractMesh" {
  16871. interface AbstractMesh {
  16872. /**
  16873. * Object used to store instanced buffers defined by user
  16874. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16875. */
  16876. instancedBuffers: {
  16877. [key: string]: any;
  16878. };
  16879. }
  16880. }
  16881. }
  16882. declare module "babylonjs/Materials/shaderMaterial" {
  16883. import { Nullable } from "babylonjs/types";
  16884. import { Scene } from "babylonjs/scene";
  16885. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  16886. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16887. import { Mesh } from "babylonjs/Meshes/mesh";
  16888. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16889. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16890. import { Effect } from "babylonjs/Materials/effect";
  16891. import { Material } from "babylonjs/Materials/material";
  16892. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16893. /**
  16894. * Defines the options associated with the creation of a shader material.
  16895. */
  16896. export interface IShaderMaterialOptions {
  16897. /**
  16898. * Does the material work in alpha blend mode
  16899. */
  16900. needAlphaBlending: boolean;
  16901. /**
  16902. * Does the material work in alpha test mode
  16903. */
  16904. needAlphaTesting: boolean;
  16905. /**
  16906. * The list of attribute names used in the shader
  16907. */
  16908. attributes: string[];
  16909. /**
  16910. * The list of unifrom names used in the shader
  16911. */
  16912. uniforms: string[];
  16913. /**
  16914. * The list of UBO names used in the shader
  16915. */
  16916. uniformBuffers: string[];
  16917. /**
  16918. * The list of sampler names used in the shader
  16919. */
  16920. samplers: string[];
  16921. /**
  16922. * The list of defines used in the shader
  16923. */
  16924. defines: string[];
  16925. }
  16926. /**
  16927. * 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.
  16928. *
  16929. * This returned material effects how the mesh will look based on the code in the shaders.
  16930. *
  16931. * @see https://doc.babylonjs.com/how_to/shader_material
  16932. */
  16933. export class ShaderMaterial extends Material {
  16934. private _shaderPath;
  16935. private _options;
  16936. private _textures;
  16937. private _textureArrays;
  16938. private _floats;
  16939. private _ints;
  16940. private _floatsArrays;
  16941. private _colors3;
  16942. private _colors3Arrays;
  16943. private _colors4;
  16944. private _colors4Arrays;
  16945. private _vectors2;
  16946. private _vectors3;
  16947. private _vectors4;
  16948. private _matrices;
  16949. private _matrixArrays;
  16950. private _matrices3x3;
  16951. private _matrices2x2;
  16952. private _vectors2Arrays;
  16953. private _vectors3Arrays;
  16954. private _vectors4Arrays;
  16955. private _cachedWorldViewMatrix;
  16956. private _cachedWorldViewProjectionMatrix;
  16957. private _renderId;
  16958. private _multiview;
  16959. private _cachedDefines;
  16960. /** Define the Url to load snippets */
  16961. static SnippetUrl: string;
  16962. /** Snippet ID if the material was created from the snippet server */
  16963. snippetId: string;
  16964. /**
  16965. * Instantiate a new shader material.
  16966. * 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.
  16967. * This returned material effects how the mesh will look based on the code in the shaders.
  16968. * @see https://doc.babylonjs.com/how_to/shader_material
  16969. * @param name Define the name of the material in the scene
  16970. * @param scene Define the scene the material belongs to
  16971. * @param shaderPath Defines the route to the shader code in one of three ways:
  16972. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16973. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16974. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16975. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16976. * @param options Define the options used to create the shader
  16977. */
  16978. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16979. /**
  16980. * Gets the shader path used to define the shader code
  16981. * It can be modified to trigger a new compilation
  16982. */
  16983. get shaderPath(): any;
  16984. /**
  16985. * Sets the shader path used to define the shader code
  16986. * It can be modified to trigger a new compilation
  16987. */
  16988. set shaderPath(shaderPath: any);
  16989. /**
  16990. * Gets the options used to compile the shader.
  16991. * They can be modified to trigger a new compilation
  16992. */
  16993. get options(): IShaderMaterialOptions;
  16994. /**
  16995. * Gets the current class name of the material e.g. "ShaderMaterial"
  16996. * Mainly use in serialization.
  16997. * @returns the class name
  16998. */
  16999. getClassName(): string;
  17000. /**
  17001. * Specifies if the material will require alpha blending
  17002. * @returns a boolean specifying if alpha blending is needed
  17003. */
  17004. needAlphaBlending(): boolean;
  17005. /**
  17006. * Specifies if this material should be rendered in alpha test mode
  17007. * @returns a boolean specifying if an alpha test is needed.
  17008. */
  17009. needAlphaTesting(): boolean;
  17010. private _checkUniform;
  17011. /**
  17012. * Set a texture in the shader.
  17013. * @param name Define the name of the uniform samplers as defined in the shader
  17014. * @param texture Define the texture to bind to this sampler
  17015. * @return the material itself allowing "fluent" like uniform updates
  17016. */
  17017. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  17018. /**
  17019. * Set a texture array in the shader.
  17020. * @param name Define the name of the uniform sampler array as defined in the shader
  17021. * @param textures Define the list of textures to bind to this sampler
  17022. * @return the material itself allowing "fluent" like uniform updates
  17023. */
  17024. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  17025. /**
  17026. * Set a float in the shader.
  17027. * @param name Define the name of the uniform as defined in the shader
  17028. * @param value Define the value to give to the uniform
  17029. * @return the material itself allowing "fluent" like uniform updates
  17030. */
  17031. setFloat(name: string, value: number): ShaderMaterial;
  17032. /**
  17033. * Set a int in the shader.
  17034. * @param name Define the name of the uniform as defined in the shader
  17035. * @param value Define the value to give to the uniform
  17036. * @return the material itself allowing "fluent" like uniform updates
  17037. */
  17038. setInt(name: string, value: number): ShaderMaterial;
  17039. /**
  17040. * Set an array of floats in the shader.
  17041. * @param name Define the name of the uniform as defined in the shader
  17042. * @param value Define the value to give to the uniform
  17043. * @return the material itself allowing "fluent" like uniform updates
  17044. */
  17045. setFloats(name: string, value: number[]): ShaderMaterial;
  17046. /**
  17047. * Set a vec3 in the shader from a Color3.
  17048. * @param name Define the name of the uniform as defined in the shader
  17049. * @param value Define the value to give to the uniform
  17050. * @return the material itself allowing "fluent" like uniform updates
  17051. */
  17052. setColor3(name: string, value: Color3): ShaderMaterial;
  17053. /**
  17054. * Set a vec3 array in the shader from a Color3 array.
  17055. * @param name Define the name of the uniform as defined in the shader
  17056. * @param value Define the value to give to the uniform
  17057. * @return the material itself allowing "fluent" like uniform updates
  17058. */
  17059. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17060. /**
  17061. * Set a vec4 in the shader from a Color4.
  17062. * @param name Define the name of the uniform as defined in the shader
  17063. * @param value Define the value to give to the uniform
  17064. * @return the material itself allowing "fluent" like uniform updates
  17065. */
  17066. setColor4(name: string, value: Color4): ShaderMaterial;
  17067. /**
  17068. * Set a vec4 array in the shader from a Color4 array.
  17069. * @param name Define the name of the uniform as defined in the shader
  17070. * @param value Define the value to give to the uniform
  17071. * @return the material itself allowing "fluent" like uniform updates
  17072. */
  17073. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  17074. /**
  17075. * Set a vec2 in the shader from a Vector2.
  17076. * @param name Define the name of the uniform as defined in the shader
  17077. * @param value Define the value to give to the uniform
  17078. * @return the material itself allowing "fluent" like uniform updates
  17079. */
  17080. setVector2(name: string, value: Vector2): ShaderMaterial;
  17081. /**
  17082. * Set a vec3 in the shader from a Vector3.
  17083. * @param name Define the name of the uniform as defined in the shader
  17084. * @param value Define the value to give to the uniform
  17085. * @return the material itself allowing "fluent" like uniform updates
  17086. */
  17087. setVector3(name: string, value: Vector3): ShaderMaterial;
  17088. /**
  17089. * Set a vec4 in the shader from a Vector4.
  17090. * @param name Define the name of the uniform as defined in the shader
  17091. * @param value Define the value to give to the uniform
  17092. * @return the material itself allowing "fluent" like uniform updates
  17093. */
  17094. setVector4(name: string, value: Vector4): ShaderMaterial;
  17095. /**
  17096. * Set a mat4 in the shader from a Matrix.
  17097. * @param name Define the name of the uniform as defined in the shader
  17098. * @param value Define the value to give to the uniform
  17099. * @return the material itself allowing "fluent" like uniform updates
  17100. */
  17101. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17102. /**
  17103. * Set a float32Array in the shader from a matrix array.
  17104. * @param name Define the name of the uniform as defined in the shader
  17105. * @param value Define the value to give to the uniform
  17106. * @return the material itself allowing "fluent" like uniform updates
  17107. */
  17108. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  17109. /**
  17110. * Set a mat3 in the shader from a Float32Array.
  17111. * @param name Define the name of the uniform as defined in the shader
  17112. * @param value Define the value to give to the uniform
  17113. * @return the material itself allowing "fluent" like uniform updates
  17114. */
  17115. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  17116. /**
  17117. * Set a mat2 in the shader from a Float32Array.
  17118. * @param name Define the name of the uniform as defined in the shader
  17119. * @param value Define the value to give to the uniform
  17120. * @return the material itself allowing "fluent" like uniform updates
  17121. */
  17122. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  17123. /**
  17124. * Set a vec2 array in the shader from a number array.
  17125. * @param name Define the name of the uniform as defined in the shader
  17126. * @param value Define the value to give to the uniform
  17127. * @return the material itself allowing "fluent" like uniform updates
  17128. */
  17129. setArray2(name: string, value: number[]): ShaderMaterial;
  17130. /**
  17131. * Set a vec3 array in the shader from a number array.
  17132. * @param name Define the name of the uniform as defined in the shader
  17133. * @param value Define the value to give to the uniform
  17134. * @return the material itself allowing "fluent" like uniform updates
  17135. */
  17136. setArray3(name: string, value: number[]): ShaderMaterial;
  17137. /**
  17138. * Set a vec4 array in the shader from a number array.
  17139. * @param name Define the name of the uniform as defined in the shader
  17140. * @param value Define the value to give to the uniform
  17141. * @return the material itself allowing "fluent" like uniform updates
  17142. */
  17143. setArray4(name: string, value: number[]): ShaderMaterial;
  17144. private _checkCache;
  17145. /**
  17146. * Specifies that the submesh is ready to be used
  17147. * @param mesh defines the mesh to check
  17148. * @param subMesh defines which submesh to check
  17149. * @param useInstances specifies that instances should be used
  17150. * @returns a boolean indicating that the submesh is ready or not
  17151. */
  17152. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  17153. /**
  17154. * Checks if the material is ready to render the requested mesh
  17155. * @param mesh Define the mesh to render
  17156. * @param useInstances Define whether or not the material is used with instances
  17157. * @returns true if ready, otherwise false
  17158. */
  17159. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17160. /**
  17161. * Binds the world matrix to the material
  17162. * @param world defines the world transformation matrix
  17163. * @param effectOverride - If provided, use this effect instead of internal effect
  17164. */
  17165. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  17166. /**
  17167. * Binds the submesh to this material by preparing the effect and shader to draw
  17168. * @param world defines the world transformation matrix
  17169. * @param mesh defines the mesh containing the submesh
  17170. * @param subMesh defines the submesh to bind the material to
  17171. */
  17172. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  17173. /**
  17174. * Binds the material to the mesh
  17175. * @param world defines the world transformation matrix
  17176. * @param mesh defines the mesh to bind the material to
  17177. * @param effectOverride - If provided, use this effect instead of internal effect
  17178. */
  17179. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  17180. protected _afterBind(mesh?: Mesh): void;
  17181. /**
  17182. * Gets the active textures from the material
  17183. * @returns an array of textures
  17184. */
  17185. getActiveTextures(): BaseTexture[];
  17186. /**
  17187. * Specifies if the material uses a texture
  17188. * @param texture defines the texture to check against the material
  17189. * @returns a boolean specifying if the material uses the texture
  17190. */
  17191. hasTexture(texture: BaseTexture): boolean;
  17192. /**
  17193. * Makes a duplicate of the material, and gives it a new name
  17194. * @param name defines the new name for the duplicated material
  17195. * @returns the cloned material
  17196. */
  17197. clone(name: string): ShaderMaterial;
  17198. /**
  17199. * Disposes the material
  17200. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17201. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17202. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17203. */
  17204. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17205. /**
  17206. * Serializes this material in a JSON representation
  17207. * @returns the serialized material object
  17208. */
  17209. serialize(): any;
  17210. /**
  17211. * Creates a shader material from parsed shader material data
  17212. * @param source defines the JSON represnetation of the material
  17213. * @param scene defines the hosting scene
  17214. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17215. * @returns a new material
  17216. */
  17217. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17218. /**
  17219. * Creates a new ShaderMaterial from a snippet saved in a remote file
  17220. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  17221. * @param url defines the url to load from
  17222. * @param scene defines the hosting scene
  17223. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17224. * @returns a promise that will resolve to the new ShaderMaterial
  17225. */
  17226. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17227. /**
  17228. * Creates a ShaderMaterial from a snippet saved by the Inspector
  17229. * @param snippetId defines the snippet to load
  17230. * @param scene defines the hosting scene
  17231. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17232. * @returns a promise that will resolve to the new ShaderMaterial
  17233. */
  17234. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17235. }
  17236. }
  17237. declare module "babylonjs/Shaders/color.fragment" {
  17238. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17239. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17240. /** @hidden */
  17241. export var colorPixelShader: {
  17242. name: string;
  17243. shader: string;
  17244. };
  17245. }
  17246. declare module "babylonjs/Shaders/color.vertex" {
  17247. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17248. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17249. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17250. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17251. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17252. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17253. /** @hidden */
  17254. export var colorVertexShader: {
  17255. name: string;
  17256. shader: string;
  17257. };
  17258. }
  17259. declare module "babylonjs/Meshes/linesMesh" {
  17260. import { Nullable } from "babylonjs/types";
  17261. import { Scene } from "babylonjs/scene";
  17262. import { Color3 } from "babylonjs/Maths/math.color";
  17263. import { Node } from "babylonjs/node";
  17264. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17265. import { Mesh } from "babylonjs/Meshes/mesh";
  17266. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17267. import { Effect } from "babylonjs/Materials/effect";
  17268. import { Material } from "babylonjs/Materials/material";
  17269. import "babylonjs/Shaders/color.fragment";
  17270. import "babylonjs/Shaders/color.vertex";
  17271. /**
  17272. * Line mesh
  17273. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17274. */
  17275. export class LinesMesh extends Mesh {
  17276. /**
  17277. * If vertex color should be applied to the mesh
  17278. */
  17279. readonly useVertexColor?: boolean | undefined;
  17280. /**
  17281. * If vertex alpha should be applied to the mesh
  17282. */
  17283. readonly useVertexAlpha?: boolean | undefined;
  17284. /**
  17285. * Color of the line (Default: White)
  17286. */
  17287. color: Color3;
  17288. /**
  17289. * Alpha of the line (Default: 1)
  17290. */
  17291. alpha: number;
  17292. /**
  17293. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17294. * This margin is expressed in world space coordinates, so its value may vary.
  17295. * Default value is 0.1
  17296. */
  17297. intersectionThreshold: number;
  17298. private _colorShader;
  17299. private color4;
  17300. /**
  17301. * Creates a new LinesMesh
  17302. * @param name defines the name
  17303. * @param scene defines the hosting scene
  17304. * @param parent defines the parent mesh if any
  17305. * @param source defines the optional source LinesMesh used to clone data from
  17306. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17307. * When false, achieved by calling a clone(), also passing False.
  17308. * This will make creation of children, recursive.
  17309. * @param useVertexColor defines if this LinesMesh supports vertex color
  17310. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17311. */
  17312. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  17313. /**
  17314. * If vertex color should be applied to the mesh
  17315. */
  17316. useVertexColor?: boolean | undefined,
  17317. /**
  17318. * If vertex alpha should be applied to the mesh
  17319. */
  17320. useVertexAlpha?: boolean | undefined);
  17321. private _addClipPlaneDefine;
  17322. private _removeClipPlaneDefine;
  17323. isReady(): boolean;
  17324. /**
  17325. * Returns the string "LineMesh"
  17326. */
  17327. getClassName(): string;
  17328. /**
  17329. * @hidden
  17330. */
  17331. get material(): Material;
  17332. /**
  17333. * @hidden
  17334. */
  17335. set material(value: Material);
  17336. /**
  17337. * @hidden
  17338. */
  17339. get checkCollisions(): boolean;
  17340. /** @hidden */
  17341. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  17342. /** @hidden */
  17343. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  17344. /**
  17345. * Disposes of the line mesh
  17346. * @param doNotRecurse If children should be disposed
  17347. */
  17348. dispose(doNotRecurse?: boolean): void;
  17349. /**
  17350. * Returns a new LineMesh object cloned from the current one.
  17351. */
  17352. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  17353. /**
  17354. * Creates a new InstancedLinesMesh object from the mesh model.
  17355. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  17356. * @param name defines the name of the new instance
  17357. * @returns a new InstancedLinesMesh
  17358. */
  17359. createInstance(name: string): InstancedLinesMesh;
  17360. }
  17361. /**
  17362. * Creates an instance based on a source LinesMesh
  17363. */
  17364. export class InstancedLinesMesh extends InstancedMesh {
  17365. /**
  17366. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17367. * This margin is expressed in world space coordinates, so its value may vary.
  17368. * Initilized with the intersectionThreshold value of the source LinesMesh
  17369. */
  17370. intersectionThreshold: number;
  17371. constructor(name: string, source: LinesMesh);
  17372. /**
  17373. * Returns the string "InstancedLinesMesh".
  17374. */
  17375. getClassName(): string;
  17376. }
  17377. }
  17378. declare module "babylonjs/Shaders/line.fragment" {
  17379. /** @hidden */
  17380. export var linePixelShader: {
  17381. name: string;
  17382. shader: string;
  17383. };
  17384. }
  17385. declare module "babylonjs/Shaders/line.vertex" {
  17386. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17387. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17388. /** @hidden */
  17389. export var lineVertexShader: {
  17390. name: string;
  17391. shader: string;
  17392. };
  17393. }
  17394. declare module "babylonjs/Rendering/edgesRenderer" {
  17395. import { Nullable } from "babylonjs/types";
  17396. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17397. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17398. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17399. import { IDisposable } from "babylonjs/scene";
  17400. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17401. import "babylonjs/Shaders/line.fragment";
  17402. import "babylonjs/Shaders/line.vertex";
  17403. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  17404. import { SmartArray } from "babylonjs/Misc/smartArray";
  17405. module "babylonjs/scene" {
  17406. interface Scene {
  17407. /** @hidden */
  17408. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  17409. }
  17410. }
  17411. module "babylonjs/Meshes/abstractMesh" {
  17412. interface AbstractMesh {
  17413. /**
  17414. * Gets the edgesRenderer associated with the mesh
  17415. */
  17416. edgesRenderer: Nullable<EdgesRenderer>;
  17417. }
  17418. }
  17419. module "babylonjs/Meshes/linesMesh" {
  17420. interface LinesMesh {
  17421. /**
  17422. * Enables the edge rendering mode on the mesh.
  17423. * This mode makes the mesh edges visible
  17424. * @param epsilon defines the maximal distance between two angles to detect a face
  17425. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17426. * @returns the currentAbstractMesh
  17427. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17428. */
  17429. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17430. }
  17431. }
  17432. module "babylonjs/Meshes/linesMesh" {
  17433. interface InstancedLinesMesh {
  17434. /**
  17435. * Enables the edge rendering mode on the mesh.
  17436. * This mode makes the mesh edges visible
  17437. * @param epsilon defines the maximal distance between two angles to detect a face
  17438. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17439. * @returns the current InstancedLinesMesh
  17440. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17441. */
  17442. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17443. }
  17444. }
  17445. /**
  17446. * Defines the minimum contract an Edges renderer should follow.
  17447. */
  17448. export interface IEdgesRenderer extends IDisposable {
  17449. /**
  17450. * Gets or sets a boolean indicating if the edgesRenderer is active
  17451. */
  17452. isEnabled: boolean;
  17453. /**
  17454. * Renders the edges of the attached mesh,
  17455. */
  17456. render(): void;
  17457. /**
  17458. * Checks wether or not the edges renderer is ready to render.
  17459. * @return true if ready, otherwise false.
  17460. */
  17461. isReady(): boolean;
  17462. /**
  17463. * List of instances to render in case the source mesh has instances
  17464. */
  17465. customInstances: SmartArray<Matrix>;
  17466. }
  17467. /**
  17468. * Defines the additional options of the edges renderer
  17469. */
  17470. export interface IEdgesRendererOptions {
  17471. /**
  17472. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  17473. * If not defined, the default value is true
  17474. */
  17475. useAlternateEdgeFinder?: boolean;
  17476. /**
  17477. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  17478. * If not defined, the default value is true.
  17479. * 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)
  17480. * This option is used only if useAlternateEdgeFinder = true
  17481. */
  17482. useFastVertexMerger?: boolean;
  17483. /**
  17484. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  17485. * The default value is 1e-6
  17486. * This option is used only if useAlternateEdgeFinder = true
  17487. */
  17488. epsilonVertexMerge?: number;
  17489. /**
  17490. * 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
  17491. * 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.
  17492. * This option is used only if useAlternateEdgeFinder = true
  17493. */
  17494. applyTessellation?: boolean;
  17495. /**
  17496. * 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
  17497. * The default value is 1e-6
  17498. * This option is used only if useAlternateEdgeFinder = true
  17499. */
  17500. epsilonVertexAligned?: number;
  17501. }
  17502. /**
  17503. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17504. */
  17505. export class EdgesRenderer implements IEdgesRenderer {
  17506. /**
  17507. * Define the size of the edges with an orthographic camera
  17508. */
  17509. edgesWidthScalerForOrthographic: number;
  17510. /**
  17511. * Define the size of the edges with a perspective camera
  17512. */
  17513. edgesWidthScalerForPerspective: number;
  17514. protected _source: AbstractMesh;
  17515. protected _linesPositions: number[];
  17516. protected _linesNormals: number[];
  17517. protected _linesIndices: number[];
  17518. protected _epsilon: number;
  17519. protected _indicesCount: number;
  17520. protected _lineShader: ShaderMaterial;
  17521. protected _ib: DataBuffer;
  17522. protected _buffers: {
  17523. [key: string]: Nullable<VertexBuffer>;
  17524. };
  17525. protected _buffersForInstances: {
  17526. [key: string]: Nullable<VertexBuffer>;
  17527. };
  17528. protected _checkVerticesInsteadOfIndices: boolean;
  17529. protected _options: Nullable<IEdgesRendererOptions>;
  17530. private _meshRebuildObserver;
  17531. private _meshDisposeObserver;
  17532. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17533. isEnabled: boolean;
  17534. /**
  17535. * List of instances to render in case the source mesh has instances
  17536. */
  17537. customInstances: SmartArray<Matrix>;
  17538. private static GetShader;
  17539. /**
  17540. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17541. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17542. * @param source Mesh used to create edges
  17543. * @param epsilon sum of angles in adjacency to check for edge
  17544. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  17545. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17546. * @param options The options to apply when generating the edges
  17547. */
  17548. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  17549. protected _prepareRessources(): void;
  17550. /** @hidden */
  17551. _rebuild(): void;
  17552. /**
  17553. * Releases the required resources for the edges renderer
  17554. */
  17555. dispose(): void;
  17556. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17557. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17558. /**
  17559. * Checks if the pair of p0 and p1 is en edge
  17560. * @param faceIndex
  17561. * @param edge
  17562. * @param faceNormals
  17563. * @param p0
  17564. * @param p1
  17565. * @private
  17566. */
  17567. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17568. /**
  17569. * push line into the position, normal and index buffer
  17570. * @protected
  17571. */
  17572. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17573. /**
  17574. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  17575. */
  17576. private _tessellateTriangle;
  17577. private _generateEdgesLinesAlternate;
  17578. /**
  17579. * Generates lines edges from adjacencjes
  17580. * @private
  17581. */
  17582. _generateEdgesLines(): void;
  17583. /**
  17584. * Checks wether or not the edges renderer is ready to render.
  17585. * @return true if ready, otherwise false.
  17586. */
  17587. isReady(): boolean;
  17588. /**
  17589. * Renders the edges of the attached mesh,
  17590. */
  17591. render(): void;
  17592. }
  17593. /**
  17594. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17595. */
  17596. export class LineEdgesRenderer extends EdgesRenderer {
  17597. /**
  17598. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17599. * @param source LineMesh used to generate edges
  17600. * @param epsilon not important (specified angle for edge detection)
  17601. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17602. */
  17603. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17604. /**
  17605. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17606. */
  17607. _generateEdgesLines(): void;
  17608. }
  17609. }
  17610. declare module "babylonjs/Rendering/renderingGroup" {
  17611. import { SmartArray, SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  17612. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17613. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17614. import { Nullable } from "babylonjs/types";
  17615. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17616. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17617. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17618. import { Material } from "babylonjs/Materials/material";
  17619. import { Scene } from "babylonjs/scene";
  17620. /**
  17621. * This represents the object necessary to create a rendering group.
  17622. * This is exclusively used and created by the rendering manager.
  17623. * To modify the behavior, you use the available helpers in your scene or meshes.
  17624. * @hidden
  17625. */
  17626. export class RenderingGroup {
  17627. index: number;
  17628. private static _zeroVector;
  17629. private _scene;
  17630. private _opaqueSubMeshes;
  17631. private _transparentSubMeshes;
  17632. private _alphaTestSubMeshes;
  17633. private _depthOnlySubMeshes;
  17634. private _particleSystems;
  17635. private _spriteManagers;
  17636. private _opaqueSortCompareFn;
  17637. private _alphaTestSortCompareFn;
  17638. private _transparentSortCompareFn;
  17639. private _renderOpaque;
  17640. private _renderAlphaTest;
  17641. private _renderTransparent;
  17642. /** @hidden */
  17643. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17644. onBeforeTransparentRendering: () => void;
  17645. /**
  17646. * Set the opaque sort comparison function.
  17647. * If null the sub meshes will be render in the order they were created
  17648. */
  17649. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17650. /**
  17651. * Set the alpha test sort comparison function.
  17652. * If null the sub meshes will be render in the order they were created
  17653. */
  17654. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17655. /**
  17656. * Set the transparent sort comparison function.
  17657. * If null the sub meshes will be render in the order they were created
  17658. */
  17659. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17660. /**
  17661. * Creates a new rendering group.
  17662. * @param index The rendering group index
  17663. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17664. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17665. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17666. */
  17667. 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>);
  17668. /**
  17669. * Render all the sub meshes contained in the group.
  17670. * @param customRenderFunction Used to override the default render behaviour of the group.
  17671. * @returns true if rendered some submeshes.
  17672. */
  17673. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17674. /**
  17675. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17676. * @param subMeshes The submeshes to render
  17677. */
  17678. private renderOpaqueSorted;
  17679. /**
  17680. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17681. * @param subMeshes The submeshes to render
  17682. */
  17683. private renderAlphaTestSorted;
  17684. /**
  17685. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17686. * @param subMeshes The submeshes to render
  17687. */
  17688. private renderTransparentSorted;
  17689. /**
  17690. * Renders the submeshes in a specified order.
  17691. * @param subMeshes The submeshes to sort before render
  17692. * @param sortCompareFn The comparison function use to sort
  17693. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17694. * @param transparent Specifies to activate blending if true
  17695. */
  17696. private static renderSorted;
  17697. /**
  17698. * Renders the submeshes in the order they were dispatched (no sort applied).
  17699. * @param subMeshes The submeshes to render
  17700. */
  17701. private static renderUnsorted;
  17702. /**
  17703. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17704. * are rendered back to front if in the same alpha index.
  17705. *
  17706. * @param a The first submesh
  17707. * @param b The second submesh
  17708. * @returns The result of the comparison
  17709. */
  17710. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17711. /**
  17712. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17713. * are rendered back to front.
  17714. *
  17715. * @param a The first submesh
  17716. * @param b The second submesh
  17717. * @returns The result of the comparison
  17718. */
  17719. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17720. /**
  17721. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17722. * are rendered front to back (prevent overdraw).
  17723. *
  17724. * @param a The first submesh
  17725. * @param b The second submesh
  17726. * @returns The result of the comparison
  17727. */
  17728. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17729. /**
  17730. * Resets the different lists of submeshes to prepare a new frame.
  17731. */
  17732. prepare(): void;
  17733. dispose(): void;
  17734. /**
  17735. * Inserts the submesh in its correct queue depending on its material.
  17736. * @param subMesh The submesh to dispatch
  17737. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17738. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17739. */
  17740. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17741. dispatchSprites(spriteManager: ISpriteManager): void;
  17742. dispatchParticles(particleSystem: IParticleSystem): void;
  17743. private _renderParticles;
  17744. private _renderSprites;
  17745. }
  17746. }
  17747. declare module "babylonjs/Rendering/renderingManager" {
  17748. import { Nullable } from "babylonjs/types";
  17749. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17750. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17751. import { SmartArray } from "babylonjs/Misc/smartArray";
  17752. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17753. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17754. import { Material } from "babylonjs/Materials/material";
  17755. import { Scene } from "babylonjs/scene";
  17756. import { Camera } from "babylonjs/Cameras/camera";
  17757. /**
  17758. * Interface describing the different options available in the rendering manager
  17759. * regarding Auto Clear between groups.
  17760. */
  17761. export interface IRenderingManagerAutoClearSetup {
  17762. /**
  17763. * Defines whether or not autoclear is enable.
  17764. */
  17765. autoClear: boolean;
  17766. /**
  17767. * Defines whether or not to autoclear the depth buffer.
  17768. */
  17769. depth: boolean;
  17770. /**
  17771. * Defines whether or not to autoclear the stencil buffer.
  17772. */
  17773. stencil: boolean;
  17774. }
  17775. /**
  17776. * This class is used by the onRenderingGroupObservable
  17777. */
  17778. export class RenderingGroupInfo {
  17779. /**
  17780. * The Scene that being rendered
  17781. */
  17782. scene: Scene;
  17783. /**
  17784. * The camera currently used for the rendering pass
  17785. */
  17786. camera: Nullable<Camera>;
  17787. /**
  17788. * The ID of the renderingGroup being processed
  17789. */
  17790. renderingGroupId: number;
  17791. }
  17792. /**
  17793. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17794. * It is enable to manage the different groups as well as the different necessary sort functions.
  17795. * This should not be used directly aside of the few static configurations
  17796. */
  17797. export class RenderingManager {
  17798. /**
  17799. * The max id used for rendering groups (not included)
  17800. */
  17801. static MAX_RENDERINGGROUPS: number;
  17802. /**
  17803. * The min id used for rendering groups (included)
  17804. */
  17805. static MIN_RENDERINGGROUPS: number;
  17806. /**
  17807. * Used to globally prevent autoclearing scenes.
  17808. */
  17809. static AUTOCLEAR: boolean;
  17810. /**
  17811. * @hidden
  17812. */
  17813. _useSceneAutoClearSetup: boolean;
  17814. private _scene;
  17815. private _renderingGroups;
  17816. private _depthStencilBufferAlreadyCleaned;
  17817. private _autoClearDepthStencil;
  17818. private _customOpaqueSortCompareFn;
  17819. private _customAlphaTestSortCompareFn;
  17820. private _customTransparentSortCompareFn;
  17821. private _renderingGroupInfo;
  17822. /**
  17823. * Instantiates a new rendering group for a particular scene
  17824. * @param scene Defines the scene the groups belongs to
  17825. */
  17826. constructor(scene: Scene);
  17827. private _clearDepthStencilBuffer;
  17828. /**
  17829. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17830. * @hidden
  17831. */
  17832. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17833. /**
  17834. * Resets the different information of the group to prepare a new frame
  17835. * @hidden
  17836. */
  17837. reset(): void;
  17838. /**
  17839. * Dispose and release the group and its associated resources.
  17840. * @hidden
  17841. */
  17842. dispose(): void;
  17843. /**
  17844. * Clear the info related to rendering groups preventing retention points during dispose.
  17845. */
  17846. freeRenderingGroups(): void;
  17847. private _prepareRenderingGroup;
  17848. /**
  17849. * Add a sprite manager to the rendering manager in order to render it this frame.
  17850. * @param spriteManager Define the sprite manager to render
  17851. */
  17852. dispatchSprites(spriteManager: ISpriteManager): void;
  17853. /**
  17854. * Add a particle system to the rendering manager in order to render it this frame.
  17855. * @param particleSystem Define the particle system to render
  17856. */
  17857. dispatchParticles(particleSystem: IParticleSystem): void;
  17858. /**
  17859. * Add a submesh to the manager in order to render it this frame
  17860. * @param subMesh The submesh to dispatch
  17861. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17862. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17863. */
  17864. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17865. /**
  17866. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17867. * This allowed control for front to back rendering or reversly depending of the special needs.
  17868. *
  17869. * @param renderingGroupId The rendering group id corresponding to its index
  17870. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17871. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17872. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17873. */
  17874. 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;
  17875. /**
  17876. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17877. *
  17878. * @param renderingGroupId The rendering group id corresponding to its index
  17879. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17880. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17881. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17882. */
  17883. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17884. /**
  17885. * Gets the current auto clear configuration for one rendering group of the rendering
  17886. * manager.
  17887. * @param index the rendering group index to get the information for
  17888. * @returns The auto clear setup for the requested rendering group
  17889. */
  17890. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17891. }
  17892. }
  17893. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  17894. import { SmartArray } from "babylonjs/Misc/smartArray";
  17895. import { Nullable } from "babylonjs/types";
  17896. import { Scene } from "babylonjs/scene";
  17897. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  17898. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17899. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17900. import { Mesh } from "babylonjs/Meshes/mesh";
  17901. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  17902. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  17903. import { Effect } from "babylonjs/Materials/effect";
  17904. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17905. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17906. import "babylonjs/Shaders/shadowMap.fragment";
  17907. import "babylonjs/Shaders/shadowMap.vertex";
  17908. import "babylonjs/Shaders/depthBoxBlur.fragment";
  17909. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow";
  17910. import { Observable } from "babylonjs/Misc/observable";
  17911. /**
  17912. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17913. */
  17914. export interface ICustomShaderOptions {
  17915. /**
  17916. * Gets or sets the custom shader name to use
  17917. */
  17918. shaderName: string;
  17919. /**
  17920. * The list of attribute names used in the shader
  17921. */
  17922. attributes?: string[];
  17923. /**
  17924. * The list of unifrom names used in the shader
  17925. */
  17926. uniforms?: string[];
  17927. /**
  17928. * The list of sampler names used in the shader
  17929. */
  17930. samplers?: string[];
  17931. /**
  17932. * The list of defines used in the shader
  17933. */
  17934. defines?: string[];
  17935. }
  17936. /**
  17937. * Interface to implement to create a shadow generator compatible with BJS.
  17938. */
  17939. export interface IShadowGenerator {
  17940. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17941. id: string;
  17942. /**
  17943. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17944. * @returns The render target texture if present otherwise, null
  17945. */
  17946. getShadowMap(): Nullable<RenderTargetTexture>;
  17947. /**
  17948. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17949. * @param subMesh The submesh we want to render in the shadow map
  17950. * @param useInstances Defines wether will draw in the map using instances
  17951. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17952. * @returns true if ready otherwise, false
  17953. */
  17954. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17955. /**
  17956. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17957. * @param defines Defines of the material we want to update
  17958. * @param lightIndex Index of the light in the enabled light list of the material
  17959. */
  17960. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17961. /**
  17962. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17963. * defined in the generator but impacting the effect).
  17964. * It implies the unifroms available on the materials are the standard BJS ones.
  17965. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17966. * @param effect The effect we are binfing the information for
  17967. */
  17968. bindShadowLight(lightIndex: string, effect: Effect): void;
  17969. /**
  17970. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17971. * (eq to shadow prjection matrix * light transform matrix)
  17972. * @returns The transform matrix used to create the shadow map
  17973. */
  17974. getTransformMatrix(): Matrix;
  17975. /**
  17976. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17977. * Cube and 2D textures for instance.
  17978. */
  17979. recreateShadowMap(): void;
  17980. /**
  17981. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17982. * @param onCompiled Callback triggered at the and of the effects compilation
  17983. * @param options Sets of optional options forcing the compilation with different modes
  17984. */
  17985. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17986. useInstances: boolean;
  17987. }>): void;
  17988. /**
  17989. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17990. * @param options Sets of optional options forcing the compilation with different modes
  17991. * @returns A promise that resolves when the compilation completes
  17992. */
  17993. forceCompilationAsync(options?: Partial<{
  17994. useInstances: boolean;
  17995. }>): Promise<void>;
  17996. /**
  17997. * Serializes the shadow generator setup to a json object.
  17998. * @returns The serialized JSON object
  17999. */
  18000. serialize(): any;
  18001. /**
  18002. * Disposes the Shadow map and related Textures and effects.
  18003. */
  18004. dispose(): void;
  18005. }
  18006. /**
  18007. * Default implementation IShadowGenerator.
  18008. * This is the main object responsible of generating shadows in the framework.
  18009. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  18010. */
  18011. export class ShadowGenerator implements IShadowGenerator {
  18012. /**
  18013. * Name of the shadow generator class
  18014. */
  18015. static CLASSNAME: string;
  18016. /**
  18017. * Shadow generator mode None: no filtering applied.
  18018. */
  18019. static readonly FILTER_NONE: number;
  18020. /**
  18021. * Shadow generator mode ESM: Exponential Shadow Mapping.
  18022. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18023. */
  18024. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  18025. /**
  18026. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  18027. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  18028. */
  18029. static readonly FILTER_POISSONSAMPLING: number;
  18030. /**
  18031. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  18032. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18033. */
  18034. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  18035. /**
  18036. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  18037. * edge artifacts on steep falloff.
  18038. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18039. */
  18040. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  18041. /**
  18042. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  18043. * edge artifacts on steep falloff.
  18044. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18045. */
  18046. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  18047. /**
  18048. * Shadow generator mode PCF: Percentage Closer Filtering
  18049. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  18050. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  18051. */
  18052. static readonly FILTER_PCF: number;
  18053. /**
  18054. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  18055. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  18056. * Contact Hardening
  18057. */
  18058. static readonly FILTER_PCSS: number;
  18059. /**
  18060. * Reserved for PCF and PCSS
  18061. * Highest Quality.
  18062. *
  18063. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  18064. *
  18065. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  18066. */
  18067. static readonly QUALITY_HIGH: number;
  18068. /**
  18069. * Reserved for PCF and PCSS
  18070. * Good tradeoff for quality/perf cross devices
  18071. *
  18072. * Execute PCF on a 3*3 kernel.
  18073. *
  18074. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  18075. */
  18076. static readonly QUALITY_MEDIUM: number;
  18077. /**
  18078. * Reserved for PCF and PCSS
  18079. * The lowest quality but the fastest.
  18080. *
  18081. * Execute PCF on a 1*1 kernel.
  18082. *
  18083. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  18084. */
  18085. static readonly QUALITY_LOW: number;
  18086. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  18087. id: string;
  18088. /** Gets or sets the custom shader name to use */
  18089. customShaderOptions: ICustomShaderOptions;
  18090. /**
  18091. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  18092. */
  18093. onBeforeShadowMapRenderObservable: Observable<Effect>;
  18094. /**
  18095. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  18096. */
  18097. onAfterShadowMapRenderObservable: Observable<Effect>;
  18098. /**
  18099. * Observable triggered before a mesh is rendered in the shadow map.
  18100. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  18101. */
  18102. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  18103. /**
  18104. * Observable triggered after a mesh is rendered in the shadow map.
  18105. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  18106. */
  18107. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  18108. protected _bias: number;
  18109. /**
  18110. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  18111. */
  18112. get bias(): number;
  18113. /**
  18114. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  18115. */
  18116. set bias(bias: number);
  18117. protected _normalBias: number;
  18118. /**
  18119. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  18120. */
  18121. get normalBias(): number;
  18122. /**
  18123. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  18124. */
  18125. set normalBias(normalBias: number);
  18126. protected _blurBoxOffset: number;
  18127. /**
  18128. * Gets the blur box offset: offset applied during the blur pass.
  18129. * Only useful if useKernelBlur = false
  18130. */
  18131. get blurBoxOffset(): number;
  18132. /**
  18133. * Sets the blur box offset: offset applied during the blur pass.
  18134. * Only useful if useKernelBlur = false
  18135. */
  18136. set blurBoxOffset(value: number);
  18137. protected _blurScale: number;
  18138. /**
  18139. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  18140. * 2 means half of the size.
  18141. */
  18142. get blurScale(): number;
  18143. /**
  18144. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  18145. * 2 means half of the size.
  18146. */
  18147. set blurScale(value: number);
  18148. protected _blurKernel: number;
  18149. /**
  18150. * Gets the blur kernel: kernel size of the blur pass.
  18151. * Only useful if useKernelBlur = true
  18152. */
  18153. get blurKernel(): number;
  18154. /**
  18155. * Sets the blur kernel: kernel size of the blur pass.
  18156. * Only useful if useKernelBlur = true
  18157. */
  18158. set blurKernel(value: number);
  18159. protected _useKernelBlur: boolean;
  18160. /**
  18161. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  18162. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18163. */
  18164. get useKernelBlur(): boolean;
  18165. /**
  18166. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  18167. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18168. */
  18169. set useKernelBlur(value: boolean);
  18170. protected _depthScale: number;
  18171. /**
  18172. * Gets the depth scale used in ESM mode.
  18173. */
  18174. get depthScale(): number;
  18175. /**
  18176. * Sets the depth scale used in ESM mode.
  18177. * This can override the scale stored on the light.
  18178. */
  18179. set depthScale(value: number);
  18180. protected _validateFilter(filter: number): number;
  18181. protected _filter: number;
  18182. /**
  18183. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  18184. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18185. */
  18186. get filter(): number;
  18187. /**
  18188. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  18189. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18190. */
  18191. set filter(value: number);
  18192. /**
  18193. * Gets if the current filter is set to Poisson Sampling.
  18194. */
  18195. get usePoissonSampling(): boolean;
  18196. /**
  18197. * Sets the current filter to Poisson Sampling.
  18198. */
  18199. set usePoissonSampling(value: boolean);
  18200. /**
  18201. * Gets if the current filter is set to ESM.
  18202. */
  18203. get useExponentialShadowMap(): boolean;
  18204. /**
  18205. * Sets the current filter is to ESM.
  18206. */
  18207. set useExponentialShadowMap(value: boolean);
  18208. /**
  18209. * Gets if the current filter is set to filtered ESM.
  18210. */
  18211. get useBlurExponentialShadowMap(): boolean;
  18212. /**
  18213. * Gets if the current filter is set to filtered ESM.
  18214. */
  18215. set useBlurExponentialShadowMap(value: boolean);
  18216. /**
  18217. * Gets if the current filter is set to "close ESM" (using the inverse of the
  18218. * exponential to prevent steep falloff artifacts).
  18219. */
  18220. get useCloseExponentialShadowMap(): boolean;
  18221. /**
  18222. * Sets the current filter to "close ESM" (using the inverse of the
  18223. * exponential to prevent steep falloff artifacts).
  18224. */
  18225. set useCloseExponentialShadowMap(value: boolean);
  18226. /**
  18227. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  18228. * exponential to prevent steep falloff artifacts).
  18229. */
  18230. get useBlurCloseExponentialShadowMap(): boolean;
  18231. /**
  18232. * Sets the current filter to filtered "close ESM" (using the inverse of the
  18233. * exponential to prevent steep falloff artifacts).
  18234. */
  18235. set useBlurCloseExponentialShadowMap(value: boolean);
  18236. /**
  18237. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  18238. */
  18239. get usePercentageCloserFiltering(): boolean;
  18240. /**
  18241. * Sets the current filter to "PCF" (percentage closer filtering).
  18242. */
  18243. set usePercentageCloserFiltering(value: boolean);
  18244. protected _filteringQuality: number;
  18245. /**
  18246. * Gets the PCF or PCSS Quality.
  18247. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18248. */
  18249. get filteringQuality(): number;
  18250. /**
  18251. * Sets the PCF or PCSS Quality.
  18252. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18253. */
  18254. set filteringQuality(filteringQuality: number);
  18255. /**
  18256. * Gets if the current filter is set to "PCSS" (contact hardening).
  18257. */
  18258. get useContactHardeningShadow(): boolean;
  18259. /**
  18260. * Sets the current filter to "PCSS" (contact hardening).
  18261. */
  18262. set useContactHardeningShadow(value: boolean);
  18263. protected _contactHardeningLightSizeUVRatio: number;
  18264. /**
  18265. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18266. * Using a ratio helps keeping shape stability independently of the map size.
  18267. *
  18268. * It does not account for the light projection as it was having too much
  18269. * instability during the light setup or during light position changes.
  18270. *
  18271. * Only valid if useContactHardeningShadow is true.
  18272. */
  18273. get contactHardeningLightSizeUVRatio(): number;
  18274. /**
  18275. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18276. * Using a ratio helps keeping shape stability independently of the map size.
  18277. *
  18278. * It does not account for the light projection as it was having too much
  18279. * instability during the light setup or during light position changes.
  18280. *
  18281. * Only valid if useContactHardeningShadow is true.
  18282. */
  18283. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  18284. protected _darkness: number;
  18285. /** Gets or sets the actual darkness of a shadow */
  18286. get darkness(): number;
  18287. set darkness(value: number);
  18288. /**
  18289. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  18290. * 0 means strongest and 1 would means no shadow.
  18291. * @returns the darkness.
  18292. */
  18293. getDarkness(): number;
  18294. /**
  18295. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  18296. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  18297. * @returns the shadow generator allowing fluent coding.
  18298. */
  18299. setDarkness(darkness: number): ShadowGenerator;
  18300. protected _transparencyShadow: boolean;
  18301. /** Gets or sets the ability to have transparent shadow */
  18302. get transparencyShadow(): boolean;
  18303. set transparencyShadow(value: boolean);
  18304. /**
  18305. * Sets the ability to have transparent shadow (boolean).
  18306. * @param transparent True if transparent else False
  18307. * @returns the shadow generator allowing fluent coding
  18308. */
  18309. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  18310. /**
  18311. * Enables or disables shadows with varying strength based on the transparency
  18312. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  18313. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  18314. * mesh.visibility * alphaTexture.a
  18315. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  18316. */
  18317. enableSoftTransparentShadow: boolean;
  18318. protected _shadowMap: Nullable<RenderTargetTexture>;
  18319. protected _shadowMap2: Nullable<RenderTargetTexture>;
  18320. /**
  18321. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18322. * @returns The render target texture if present otherwise, null
  18323. */
  18324. getShadowMap(): Nullable<RenderTargetTexture>;
  18325. /**
  18326. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  18327. * @returns The render target texture if the shadow map is present otherwise, null
  18328. */
  18329. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  18330. /**
  18331. * Gets the class name of that object
  18332. * @returns "ShadowGenerator"
  18333. */
  18334. getClassName(): string;
  18335. /**
  18336. * Helper function to add a mesh and its descendants to the list of shadow casters.
  18337. * @param mesh Mesh to add
  18338. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  18339. * @returns the Shadow Generator itself
  18340. */
  18341. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18342. /**
  18343. * Helper function to remove a mesh and its descendants from the list of shadow casters
  18344. * @param mesh Mesh to remove
  18345. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  18346. * @returns the Shadow Generator itself
  18347. */
  18348. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18349. /**
  18350. * Controls the extent to which the shadows fade out at the edge of the frustum
  18351. */
  18352. frustumEdgeFalloff: number;
  18353. protected _light: IShadowLight;
  18354. /**
  18355. * Returns the associated light object.
  18356. * @returns the light generating the shadow
  18357. */
  18358. getLight(): IShadowLight;
  18359. /**
  18360. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  18361. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  18362. * It might on the other hand introduce peter panning.
  18363. */
  18364. forceBackFacesOnly: boolean;
  18365. protected _scene: Scene;
  18366. protected _lightDirection: Vector3;
  18367. protected _effect: Effect;
  18368. protected _viewMatrix: Matrix;
  18369. protected _projectionMatrix: Matrix;
  18370. protected _transformMatrix: Matrix;
  18371. protected _cachedPosition: Vector3;
  18372. protected _cachedDirection: Vector3;
  18373. protected _cachedDefines: string;
  18374. protected _currentRenderID: number;
  18375. protected _boxBlurPostprocess: Nullable<PostProcess>;
  18376. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  18377. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  18378. protected _blurPostProcesses: PostProcess[];
  18379. protected _mapSize: number;
  18380. protected _currentFaceIndex: number;
  18381. protected _currentFaceIndexCache: number;
  18382. protected _textureType: number;
  18383. protected _defaultTextureMatrix: Matrix;
  18384. protected _storedUniqueId: Nullable<number>;
  18385. /** @hidden */
  18386. static _SceneComponentInitialization: (scene: Scene) => void;
  18387. /**
  18388. * Creates a ShadowGenerator object.
  18389. * A ShadowGenerator is the required tool to use the shadows.
  18390. * Each light casting shadows needs to use its own ShadowGenerator.
  18391. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  18392. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  18393. * @param light The light object generating the shadows.
  18394. * @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.
  18395. */
  18396. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  18397. protected _initializeGenerator(): void;
  18398. protected _createTargetRenderTexture(): void;
  18399. protected _initializeShadowMap(): void;
  18400. protected _initializeBlurRTTAndPostProcesses(): void;
  18401. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  18402. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  18403. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  18404. protected _applyFilterValues(): void;
  18405. /**
  18406. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18407. * @param onCompiled Callback triggered at the and of the effects compilation
  18408. * @param options Sets of optional options forcing the compilation with different modes
  18409. */
  18410. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18411. useInstances: boolean;
  18412. }>): void;
  18413. /**
  18414. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18415. * @param options Sets of optional options forcing the compilation with different modes
  18416. * @returns A promise that resolves when the compilation completes
  18417. */
  18418. forceCompilationAsync(options?: Partial<{
  18419. useInstances: boolean;
  18420. }>): Promise<void>;
  18421. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  18422. private _prepareShadowDefines;
  18423. /**
  18424. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18425. * @param subMesh The submesh we want to render in the shadow map
  18426. * @param useInstances Defines wether will draw in the map using instances
  18427. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18428. * @returns true if ready otherwise, false
  18429. */
  18430. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18431. /**
  18432. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18433. * @param defines Defines of the material we want to update
  18434. * @param lightIndex Index of the light in the enabled light list of the material
  18435. */
  18436. prepareDefines(defines: any, lightIndex: number): void;
  18437. /**
  18438. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18439. * defined in the generator but impacting the effect).
  18440. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18441. * @param effect The effect we are binfing the information for
  18442. */
  18443. bindShadowLight(lightIndex: string, effect: Effect): void;
  18444. /**
  18445. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18446. * (eq to shadow prjection matrix * light transform matrix)
  18447. * @returns The transform matrix used to create the shadow map
  18448. */
  18449. getTransformMatrix(): Matrix;
  18450. /**
  18451. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18452. * Cube and 2D textures for instance.
  18453. */
  18454. recreateShadowMap(): void;
  18455. protected _disposeBlurPostProcesses(): void;
  18456. protected _disposeRTTandPostProcesses(): void;
  18457. /**
  18458. * Disposes the ShadowGenerator.
  18459. * Returns nothing.
  18460. */
  18461. dispose(): void;
  18462. /**
  18463. * Serializes the shadow generator setup to a json object.
  18464. * @returns The serialized JSON object
  18465. */
  18466. serialize(): any;
  18467. /**
  18468. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18469. * @param parsedShadowGenerator The JSON object to parse
  18470. * @param scene The scene to create the shadow map for
  18471. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18472. * @returns The parsed shadow generator
  18473. */
  18474. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18475. }
  18476. }
  18477. declare module "babylonjs/Lights/light" {
  18478. import { Nullable } from "babylonjs/types";
  18479. import { Scene } from "babylonjs/scene";
  18480. import { Vector3 } from "babylonjs/Maths/math.vector";
  18481. import { Color3 } from "babylonjs/Maths/math.color";
  18482. import { Node } from "babylonjs/node";
  18483. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18484. import { Effect } from "babylonjs/Materials/effect";
  18485. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  18486. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  18487. /**
  18488. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18489. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18490. * 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.
  18491. */
  18492. export abstract class Light extends Node {
  18493. /**
  18494. * Falloff Default: light is falling off following the material specification:
  18495. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18496. */
  18497. static readonly FALLOFF_DEFAULT: number;
  18498. /**
  18499. * Falloff Physical: light is falling off following the inverse squared distance law.
  18500. */
  18501. static readonly FALLOFF_PHYSICAL: number;
  18502. /**
  18503. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18504. * to enhance interoperability with other engines.
  18505. */
  18506. static readonly FALLOFF_GLTF: number;
  18507. /**
  18508. * Falloff Standard: light is falling off like in the standard material
  18509. * to enhance interoperability with other materials.
  18510. */
  18511. static readonly FALLOFF_STANDARD: number;
  18512. /**
  18513. * If every light affecting the material is in this lightmapMode,
  18514. * material.lightmapTexture adds or multiplies
  18515. * (depends on material.useLightmapAsShadowmap)
  18516. * after every other light calculations.
  18517. */
  18518. static readonly LIGHTMAP_DEFAULT: number;
  18519. /**
  18520. * material.lightmapTexture as only diffuse lighting from this light
  18521. * adds only specular lighting from this light
  18522. * adds dynamic shadows
  18523. */
  18524. static readonly LIGHTMAP_SPECULAR: number;
  18525. /**
  18526. * material.lightmapTexture as only lighting
  18527. * no light calculation from this light
  18528. * only adds dynamic shadows from this light
  18529. */
  18530. static readonly LIGHTMAP_SHADOWSONLY: number;
  18531. /**
  18532. * Each light type uses the default quantity according to its type:
  18533. * point/spot lights use luminous intensity
  18534. * directional lights use illuminance
  18535. */
  18536. static readonly INTENSITYMODE_AUTOMATIC: number;
  18537. /**
  18538. * lumen (lm)
  18539. */
  18540. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18541. /**
  18542. * candela (lm/sr)
  18543. */
  18544. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18545. /**
  18546. * lux (lm/m^2)
  18547. */
  18548. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18549. /**
  18550. * nit (cd/m^2)
  18551. */
  18552. static readonly INTENSITYMODE_LUMINANCE: number;
  18553. /**
  18554. * Light type const id of the point light.
  18555. */
  18556. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18557. /**
  18558. * Light type const id of the directional light.
  18559. */
  18560. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18561. /**
  18562. * Light type const id of the spot light.
  18563. */
  18564. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18565. /**
  18566. * Light type const id of the hemispheric light.
  18567. */
  18568. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18569. /**
  18570. * Diffuse gives the basic color to an object.
  18571. */
  18572. diffuse: Color3;
  18573. /**
  18574. * Specular produces a highlight color on an object.
  18575. * Note: This is note affecting PBR materials.
  18576. */
  18577. specular: Color3;
  18578. /**
  18579. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18580. * falling off base on range or angle.
  18581. * This can be set to any values in Light.FALLOFF_x.
  18582. *
  18583. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18584. * other types of materials.
  18585. */
  18586. falloffType: number;
  18587. /**
  18588. * Strength of the light.
  18589. * Note: By default it is define in the framework own unit.
  18590. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18591. */
  18592. intensity: number;
  18593. private _range;
  18594. protected _inverseSquaredRange: number;
  18595. /**
  18596. * Defines how far from the source the light is impacting in scene units.
  18597. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18598. */
  18599. get range(): number;
  18600. /**
  18601. * Defines how far from the source the light is impacting in scene units.
  18602. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18603. */
  18604. set range(value: number);
  18605. /**
  18606. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18607. * of light.
  18608. */
  18609. private _photometricScale;
  18610. private _intensityMode;
  18611. /**
  18612. * Gets the photometric scale used to interpret the intensity.
  18613. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18614. */
  18615. get intensityMode(): number;
  18616. /**
  18617. * Sets the photometric scale used to interpret the intensity.
  18618. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18619. */
  18620. set intensityMode(value: number);
  18621. private _radius;
  18622. /**
  18623. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18624. */
  18625. get radius(): number;
  18626. /**
  18627. * sets the light radius used by PBR Materials to simulate soft area lights.
  18628. */
  18629. set radius(value: number);
  18630. private _renderPriority;
  18631. /**
  18632. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18633. * exceeding the number allowed of the materials.
  18634. */
  18635. renderPriority: number;
  18636. private _shadowEnabled;
  18637. /**
  18638. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18639. * the current shadow generator.
  18640. */
  18641. get shadowEnabled(): boolean;
  18642. /**
  18643. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18644. * the current shadow generator.
  18645. */
  18646. set shadowEnabled(value: boolean);
  18647. private _includedOnlyMeshes;
  18648. /**
  18649. * Gets the only meshes impacted by this light.
  18650. */
  18651. get includedOnlyMeshes(): AbstractMesh[];
  18652. /**
  18653. * Sets the only meshes impacted by this light.
  18654. */
  18655. set includedOnlyMeshes(value: AbstractMesh[]);
  18656. private _excludedMeshes;
  18657. /**
  18658. * Gets the meshes not impacted by this light.
  18659. */
  18660. get excludedMeshes(): AbstractMesh[];
  18661. /**
  18662. * Sets the meshes not impacted by this light.
  18663. */
  18664. set excludedMeshes(value: AbstractMesh[]);
  18665. private _excludeWithLayerMask;
  18666. /**
  18667. * Gets the layer id use to find what meshes are not impacted by the light.
  18668. * Inactive if 0
  18669. */
  18670. get excludeWithLayerMask(): number;
  18671. /**
  18672. * Sets the layer id use to find what meshes are not impacted by the light.
  18673. * Inactive if 0
  18674. */
  18675. set excludeWithLayerMask(value: number);
  18676. private _includeOnlyWithLayerMask;
  18677. /**
  18678. * Gets the layer id use to find what meshes are impacted by the light.
  18679. * Inactive if 0
  18680. */
  18681. get includeOnlyWithLayerMask(): number;
  18682. /**
  18683. * Sets the layer id use to find what meshes are impacted by the light.
  18684. * Inactive if 0
  18685. */
  18686. set includeOnlyWithLayerMask(value: number);
  18687. private _lightmapMode;
  18688. /**
  18689. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18690. */
  18691. get lightmapMode(): number;
  18692. /**
  18693. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18694. */
  18695. set lightmapMode(value: number);
  18696. /**
  18697. * Shadow generator associted to the light.
  18698. * @hidden Internal use only.
  18699. */
  18700. _shadowGenerator: Nullable<IShadowGenerator>;
  18701. /**
  18702. * @hidden Internal use only.
  18703. */
  18704. _excludedMeshesIds: string[];
  18705. /**
  18706. * @hidden Internal use only.
  18707. */
  18708. _includedOnlyMeshesIds: string[];
  18709. /**
  18710. * The current light unifom buffer.
  18711. * @hidden Internal use only.
  18712. */
  18713. _uniformBuffer: UniformBuffer;
  18714. /** @hidden */
  18715. _renderId: number;
  18716. /**
  18717. * Creates a Light object in the scene.
  18718. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18719. * @param name The firendly name of the light
  18720. * @param scene The scene the light belongs too
  18721. */
  18722. constructor(name: string, scene: Scene);
  18723. protected abstract _buildUniformLayout(): void;
  18724. /**
  18725. * Sets the passed Effect "effect" with the Light information.
  18726. * @param effect The effect to update
  18727. * @param lightIndex The index of the light in the effect to update
  18728. * @returns The light
  18729. */
  18730. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18731. /**
  18732. * Sets the passed Effect "effect" with the Light textures.
  18733. * @param effect The effect to update
  18734. * @param lightIndex The index of the light in the effect to update
  18735. * @returns The light
  18736. */
  18737. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18738. /**
  18739. * Binds the lights information from the scene to the effect for the given mesh.
  18740. * @param lightIndex Light index
  18741. * @param scene The scene where the light belongs to
  18742. * @param effect The effect we are binding the data to
  18743. * @param useSpecular Defines if specular is supported
  18744. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18745. */
  18746. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18747. /**
  18748. * Sets the passed Effect "effect" with the Light information.
  18749. * @param effect The effect to update
  18750. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18751. * @returns The light
  18752. */
  18753. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18754. /**
  18755. * Returns the string "Light".
  18756. * @returns the class name
  18757. */
  18758. getClassName(): string;
  18759. /** @hidden */
  18760. readonly _isLight: boolean;
  18761. /**
  18762. * Converts the light information to a readable string for debug purpose.
  18763. * @param fullDetails Supports for multiple levels of logging within scene loading
  18764. * @returns the human readable light info
  18765. */
  18766. toString(fullDetails?: boolean): string;
  18767. /** @hidden */
  18768. protected _syncParentEnabledState(): void;
  18769. /**
  18770. * Set the enabled state of this node.
  18771. * @param value - the new enabled state
  18772. */
  18773. setEnabled(value: boolean): void;
  18774. /**
  18775. * Returns the Light associated shadow generator if any.
  18776. * @return the associated shadow generator.
  18777. */
  18778. getShadowGenerator(): Nullable<IShadowGenerator>;
  18779. /**
  18780. * Returns a Vector3, the absolute light position in the World.
  18781. * @returns the world space position of the light
  18782. */
  18783. getAbsolutePosition(): Vector3;
  18784. /**
  18785. * Specifies if the light will affect the passed mesh.
  18786. * @param mesh The mesh to test against the light
  18787. * @return true the mesh is affected otherwise, false.
  18788. */
  18789. canAffectMesh(mesh: AbstractMesh): boolean;
  18790. /**
  18791. * Sort function to order lights for rendering.
  18792. * @param a First Light object to compare to second.
  18793. * @param b Second Light object to compare first.
  18794. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18795. */
  18796. static CompareLightsPriority(a: Light, b: Light): number;
  18797. /**
  18798. * Releases resources associated with this node.
  18799. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18800. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18801. */
  18802. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18803. /**
  18804. * Returns the light type ID (integer).
  18805. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18806. */
  18807. getTypeID(): number;
  18808. /**
  18809. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18810. * @returns the scaled intensity in intensity mode unit
  18811. */
  18812. getScaledIntensity(): number;
  18813. /**
  18814. * Returns a new Light object, named "name", from the current one.
  18815. * @param name The name of the cloned light
  18816. * @param newParent The parent of this light, if it has one
  18817. * @returns the new created light
  18818. */
  18819. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18820. /**
  18821. * Serializes the current light into a Serialization object.
  18822. * @returns the serialized object.
  18823. */
  18824. serialize(): any;
  18825. /**
  18826. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18827. * This new light is named "name" and added to the passed scene.
  18828. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18829. * @param name The friendly name of the light
  18830. * @param scene The scene the new light will belong to
  18831. * @returns the constructor function
  18832. */
  18833. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18834. /**
  18835. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18836. * @param parsedLight The JSON representation of the light
  18837. * @param scene The scene to create the parsed light in
  18838. * @returns the created light after parsing
  18839. */
  18840. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18841. private _hookArrayForExcluded;
  18842. private _hookArrayForIncludedOnly;
  18843. private _resyncMeshes;
  18844. /**
  18845. * Forces the meshes to update their light related information in their rendering used effects
  18846. * @hidden Internal Use Only
  18847. */
  18848. _markMeshesAsLightDirty(): void;
  18849. /**
  18850. * Recomputes the cached photometric scale if needed.
  18851. */
  18852. private _computePhotometricScale;
  18853. /**
  18854. * Returns the Photometric Scale according to the light type and intensity mode.
  18855. */
  18856. private _getPhotometricScale;
  18857. /**
  18858. * Reorder the light in the scene according to their defined priority.
  18859. * @hidden Internal Use Only
  18860. */
  18861. _reorderLightsInScene(): void;
  18862. /**
  18863. * Prepares the list of defines specific to the light type.
  18864. * @param defines the list of defines
  18865. * @param lightIndex defines the index of the light for the effect
  18866. */
  18867. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18868. }
  18869. }
  18870. declare module "babylonjs/Cameras/targetCamera" {
  18871. import { Nullable } from "babylonjs/types";
  18872. import { Camera } from "babylonjs/Cameras/camera";
  18873. import { Scene } from "babylonjs/scene";
  18874. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  18875. /**
  18876. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18877. * This is the base of the follow, arc rotate cameras and Free camera
  18878. * @see https://doc.babylonjs.com/features/cameras
  18879. */
  18880. export class TargetCamera extends Camera {
  18881. private static _RigCamTransformMatrix;
  18882. private static _TargetTransformMatrix;
  18883. private static _TargetFocalPoint;
  18884. private _tmpUpVector;
  18885. private _tmpTargetVector;
  18886. /**
  18887. * Define the current direction the camera is moving to
  18888. */
  18889. cameraDirection: Vector3;
  18890. /**
  18891. * Define the current rotation the camera is rotating to
  18892. */
  18893. cameraRotation: Vector2;
  18894. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18895. ignoreParentScaling: boolean;
  18896. /**
  18897. * When set, the up vector of the camera will be updated by the rotation of the camera
  18898. */
  18899. updateUpVectorFromRotation: boolean;
  18900. private _tmpQuaternion;
  18901. /**
  18902. * Define the current rotation of the camera
  18903. */
  18904. rotation: Vector3;
  18905. /**
  18906. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18907. */
  18908. rotationQuaternion: Quaternion;
  18909. /**
  18910. * Define the current speed of the camera
  18911. */
  18912. speed: number;
  18913. /**
  18914. * Add constraint to the camera to prevent it to move freely in all directions and
  18915. * around all axis.
  18916. */
  18917. noRotationConstraint: boolean;
  18918. /**
  18919. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18920. * panning
  18921. */
  18922. invertRotation: boolean;
  18923. /**
  18924. * Speed multiplier for inverse camera panning
  18925. */
  18926. inverseRotationSpeed: number;
  18927. /**
  18928. * Define the current target of the camera as an object or a position.
  18929. */
  18930. lockedTarget: any;
  18931. /** @hidden */
  18932. _currentTarget: Vector3;
  18933. /** @hidden */
  18934. _initialFocalDistance: number;
  18935. /** @hidden */
  18936. _viewMatrix: Matrix;
  18937. /** @hidden */
  18938. _camMatrix: Matrix;
  18939. /** @hidden */
  18940. _cameraTransformMatrix: Matrix;
  18941. /** @hidden */
  18942. _cameraRotationMatrix: Matrix;
  18943. /** @hidden */
  18944. _referencePoint: Vector3;
  18945. /** @hidden */
  18946. _transformedReferencePoint: Vector3;
  18947. /** @hidden */
  18948. _reset: () => void;
  18949. private _defaultUp;
  18950. /**
  18951. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18952. * This is the base of the follow, arc rotate cameras and Free camera
  18953. * @see https://doc.babylonjs.com/features/cameras
  18954. * @param name Defines the name of the camera in the scene
  18955. * @param position Defines the start position of the camera in the scene
  18956. * @param scene Defines the scene the camera belongs to
  18957. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18958. */
  18959. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18960. /**
  18961. * Gets the position in front of the camera at a given distance.
  18962. * @param distance The distance from the camera we want the position to be
  18963. * @returns the position
  18964. */
  18965. getFrontPosition(distance: number): Vector3;
  18966. /** @hidden */
  18967. _getLockedTargetPosition(): Nullable<Vector3>;
  18968. private _storedPosition;
  18969. private _storedRotation;
  18970. private _storedRotationQuaternion;
  18971. /**
  18972. * Store current camera state of the camera (fov, position, rotation, etc..)
  18973. * @returns the camera
  18974. */
  18975. storeState(): Camera;
  18976. /**
  18977. * Restored camera state. You must call storeState() first
  18978. * @returns whether it was successful or not
  18979. * @hidden
  18980. */
  18981. _restoreStateValues(): boolean;
  18982. /** @hidden */
  18983. _initCache(): void;
  18984. /** @hidden */
  18985. _updateCache(ignoreParentClass?: boolean): void;
  18986. /** @hidden */
  18987. _isSynchronizedViewMatrix(): boolean;
  18988. /** @hidden */
  18989. _computeLocalCameraSpeed(): number;
  18990. /**
  18991. * Defines the target the camera should look at.
  18992. * @param target Defines the new target as a Vector or a mesh
  18993. */
  18994. setTarget(target: Vector3): void;
  18995. /**
  18996. * Defines the target point of the camera.
  18997. * The camera looks towards it form the radius distance.
  18998. */
  18999. get target(): Vector3;
  19000. set target(value: Vector3);
  19001. /**
  19002. * Return the current target position of the camera. This value is expressed in local space.
  19003. * @returns the target position
  19004. */
  19005. getTarget(): Vector3;
  19006. /** @hidden */
  19007. _decideIfNeedsToMove(): boolean;
  19008. /** @hidden */
  19009. _updatePosition(): void;
  19010. /** @hidden */
  19011. _checkInputs(): void;
  19012. protected _updateCameraRotationMatrix(): void;
  19013. /**
  19014. * 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)
  19015. * @returns the current camera
  19016. */
  19017. private _rotateUpVectorWithCameraRotationMatrix;
  19018. private _cachedRotationZ;
  19019. private _cachedQuaternionRotationZ;
  19020. /** @hidden */
  19021. _getViewMatrix(): Matrix;
  19022. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  19023. /**
  19024. * @hidden
  19025. */
  19026. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  19027. /**
  19028. * @hidden
  19029. */
  19030. _updateRigCameras(): void;
  19031. private _getRigCamPositionAndTarget;
  19032. /**
  19033. * Gets the current object class name.
  19034. * @return the class name
  19035. */
  19036. getClassName(): string;
  19037. }
  19038. }
  19039. declare module "babylonjs/Events/keyboardEvents" {
  19040. /**
  19041. * Gather the list of keyboard event types as constants.
  19042. */
  19043. export class KeyboardEventTypes {
  19044. /**
  19045. * The keydown event is fired when a key becomes active (pressed).
  19046. */
  19047. static readonly KEYDOWN: number;
  19048. /**
  19049. * The keyup event is fired when a key has been released.
  19050. */
  19051. static readonly KEYUP: number;
  19052. }
  19053. /**
  19054. * This class is used to store keyboard related info for the onKeyboardObservable event.
  19055. */
  19056. export class KeyboardInfo {
  19057. /**
  19058. * Defines the type of event (KeyboardEventTypes)
  19059. */
  19060. type: number;
  19061. /**
  19062. * Defines the related dom event
  19063. */
  19064. event: KeyboardEvent;
  19065. /**
  19066. * Instantiates a new keyboard info.
  19067. * This class is used to store keyboard related info for the onKeyboardObservable event.
  19068. * @param type Defines the type of event (KeyboardEventTypes)
  19069. * @param event Defines the related dom event
  19070. */
  19071. constructor(
  19072. /**
  19073. * Defines the type of event (KeyboardEventTypes)
  19074. */
  19075. type: number,
  19076. /**
  19077. * Defines the related dom event
  19078. */
  19079. event: KeyboardEvent);
  19080. }
  19081. /**
  19082. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  19083. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  19084. */
  19085. export class KeyboardInfoPre extends KeyboardInfo {
  19086. /**
  19087. * Defines the type of event (KeyboardEventTypes)
  19088. */
  19089. type: number;
  19090. /**
  19091. * Defines the related dom event
  19092. */
  19093. event: KeyboardEvent;
  19094. /**
  19095. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  19096. */
  19097. skipOnPointerObservable: boolean;
  19098. /**
  19099. * Instantiates a new keyboard pre info.
  19100. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  19101. * @param type Defines the type of event (KeyboardEventTypes)
  19102. * @param event Defines the related dom event
  19103. */
  19104. constructor(
  19105. /**
  19106. * Defines the type of event (KeyboardEventTypes)
  19107. */
  19108. type: number,
  19109. /**
  19110. * Defines the related dom event
  19111. */
  19112. event: KeyboardEvent);
  19113. }
  19114. }
  19115. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  19116. import { Nullable } from "babylonjs/types";
  19117. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19118. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19119. /**
  19120. * Manage the keyboard inputs to control the movement of a free camera.
  19121. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19122. */
  19123. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  19124. /**
  19125. * Defines the camera the input is attached to.
  19126. */
  19127. camera: FreeCamera;
  19128. /**
  19129. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19130. */
  19131. keysUp: number[];
  19132. /**
  19133. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19134. */
  19135. keysUpward: number[];
  19136. /**
  19137. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19138. */
  19139. keysDown: number[];
  19140. /**
  19141. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19142. */
  19143. keysDownward: number[];
  19144. /**
  19145. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19146. */
  19147. keysLeft: number[];
  19148. /**
  19149. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19150. */
  19151. keysRight: number[];
  19152. private _keys;
  19153. private _onCanvasBlurObserver;
  19154. private _onKeyboardObserver;
  19155. private _engine;
  19156. private _scene;
  19157. /**
  19158. * Attach the input controls to a specific dom element to get the input from.
  19159. * @param element Defines the element the controls should be listened from
  19160. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19161. */
  19162. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19163. /**
  19164. * Detach the current controls from the specified dom element.
  19165. * @param element Defines the element to stop listening the inputs from
  19166. */
  19167. detachControl(element: Nullable<HTMLElement>): void;
  19168. /**
  19169. * Update the current camera state depending on the inputs that have been used this frame.
  19170. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19171. */
  19172. checkInputs(): void;
  19173. /**
  19174. * Gets the class name of the current intput.
  19175. * @returns the class name
  19176. */
  19177. getClassName(): string;
  19178. /** @hidden */
  19179. _onLostFocus(): void;
  19180. /**
  19181. * Get the friendly name associated with the input class.
  19182. * @returns the input friendly name
  19183. */
  19184. getSimpleName(): string;
  19185. }
  19186. }
  19187. declare module "babylonjs/Events/pointerEvents" {
  19188. import { Nullable } from "babylonjs/types";
  19189. import { Vector2 } from "babylonjs/Maths/math.vector";
  19190. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  19191. import { Ray } from "babylonjs/Culling/ray";
  19192. /**
  19193. * Gather the list of pointer event types as constants.
  19194. */
  19195. export class PointerEventTypes {
  19196. /**
  19197. * 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.
  19198. */
  19199. static readonly POINTERDOWN: number;
  19200. /**
  19201. * The pointerup event is fired when a pointer is no longer active.
  19202. */
  19203. static readonly POINTERUP: number;
  19204. /**
  19205. * The pointermove event is fired when a pointer changes coordinates.
  19206. */
  19207. static readonly POINTERMOVE: number;
  19208. /**
  19209. * The pointerwheel event is fired when a mouse wheel has been rotated.
  19210. */
  19211. static readonly POINTERWHEEL: number;
  19212. /**
  19213. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  19214. */
  19215. static readonly POINTERPICK: number;
  19216. /**
  19217. * The pointertap event is fired when a the object has been touched and released without drag.
  19218. */
  19219. static readonly POINTERTAP: number;
  19220. /**
  19221. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  19222. */
  19223. static readonly POINTERDOUBLETAP: number;
  19224. }
  19225. /**
  19226. * Base class of pointer info types.
  19227. */
  19228. export class PointerInfoBase {
  19229. /**
  19230. * Defines the type of event (PointerEventTypes)
  19231. */
  19232. type: number;
  19233. /**
  19234. * Defines the related dom event
  19235. */
  19236. event: PointerEvent | MouseWheelEvent;
  19237. /**
  19238. * Instantiates the base class of pointers info.
  19239. * @param type Defines the type of event (PointerEventTypes)
  19240. * @param event Defines the related dom event
  19241. */
  19242. constructor(
  19243. /**
  19244. * Defines the type of event (PointerEventTypes)
  19245. */
  19246. type: number,
  19247. /**
  19248. * Defines the related dom event
  19249. */
  19250. event: PointerEvent | MouseWheelEvent);
  19251. }
  19252. /**
  19253. * This class is used to store pointer related info for the onPrePointerObservable event.
  19254. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  19255. */
  19256. export class PointerInfoPre extends PointerInfoBase {
  19257. /**
  19258. * Ray from a pointer if availible (eg. 6dof controller)
  19259. */
  19260. ray: Nullable<Ray>;
  19261. /**
  19262. * Defines the local position of the pointer on the canvas.
  19263. */
  19264. localPosition: Vector2;
  19265. /**
  19266. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  19267. */
  19268. skipOnPointerObservable: boolean;
  19269. /**
  19270. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  19271. * @param type Defines the type of event (PointerEventTypes)
  19272. * @param event Defines the related dom event
  19273. * @param localX Defines the local x coordinates of the pointer when the event occured
  19274. * @param localY Defines the local y coordinates of the pointer when the event occured
  19275. */
  19276. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  19277. }
  19278. /**
  19279. * This type contains all the data related to a pointer event in Babylon.js.
  19280. * 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.
  19281. */
  19282. export class PointerInfo extends PointerInfoBase {
  19283. /**
  19284. * Defines the picking info associated to the info (if any)\
  19285. */
  19286. pickInfo: Nullable<PickingInfo>;
  19287. /**
  19288. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  19289. * @param type Defines the type of event (PointerEventTypes)
  19290. * @param event Defines the related dom event
  19291. * @param pickInfo Defines the picking info associated to the info (if any)\
  19292. */
  19293. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  19294. /**
  19295. * Defines the picking info associated to the info (if any)\
  19296. */
  19297. pickInfo: Nullable<PickingInfo>);
  19298. }
  19299. /**
  19300. * Data relating to a touch event on the screen.
  19301. */
  19302. export interface PointerTouch {
  19303. /**
  19304. * X coordinate of touch.
  19305. */
  19306. x: number;
  19307. /**
  19308. * Y coordinate of touch.
  19309. */
  19310. y: number;
  19311. /**
  19312. * Id of touch. Unique for each finger.
  19313. */
  19314. pointerId: number;
  19315. /**
  19316. * Event type passed from DOM.
  19317. */
  19318. type: any;
  19319. }
  19320. }
  19321. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  19322. import { Observable } from "babylonjs/Misc/observable";
  19323. import { Nullable } from "babylonjs/types";
  19324. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19325. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19326. /**
  19327. * Manage the mouse inputs to control the movement of a free camera.
  19328. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19329. */
  19330. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  19331. /**
  19332. * Define if touch is enabled in the mouse input
  19333. */
  19334. touchEnabled: boolean;
  19335. /**
  19336. * Defines the camera the input is attached to.
  19337. */
  19338. camera: FreeCamera;
  19339. /**
  19340. * Defines the buttons associated with the input to handle camera move.
  19341. */
  19342. buttons: number[];
  19343. /**
  19344. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  19345. */
  19346. angularSensibility: number;
  19347. private _pointerInput;
  19348. private _onMouseMove;
  19349. private _observer;
  19350. private previousPosition;
  19351. /**
  19352. * Observable for when a pointer move event occurs containing the move offset
  19353. */
  19354. onPointerMovedObservable: Observable<{
  19355. offsetX: number;
  19356. offsetY: number;
  19357. }>;
  19358. /**
  19359. * @hidden
  19360. * If the camera should be rotated automatically based on pointer movement
  19361. */
  19362. _allowCameraRotation: boolean;
  19363. /**
  19364. * Manage the mouse inputs to control the movement of a free camera.
  19365. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19366. * @param touchEnabled Defines if touch is enabled or not
  19367. */
  19368. constructor(
  19369. /**
  19370. * Define if touch is enabled in the mouse input
  19371. */
  19372. touchEnabled?: boolean);
  19373. /**
  19374. * Attach the input controls to a specific dom element to get the input from.
  19375. * @param element Defines the element the controls should be listened from
  19376. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19377. */
  19378. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19379. /**
  19380. * Called on JS contextmenu event.
  19381. * Override this method to provide functionality.
  19382. */
  19383. protected onContextMenu(evt: PointerEvent): void;
  19384. /**
  19385. * Detach the current controls from the specified dom element.
  19386. * @param element Defines the element to stop listening the inputs from
  19387. */
  19388. detachControl(element: Nullable<HTMLElement>): void;
  19389. /**
  19390. * Gets the class name of the current intput.
  19391. * @returns the class name
  19392. */
  19393. getClassName(): string;
  19394. /**
  19395. * Get the friendly name associated with the input class.
  19396. * @returns the input friendly name
  19397. */
  19398. getSimpleName(): string;
  19399. }
  19400. }
  19401. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  19402. import { Nullable } from "babylonjs/types";
  19403. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19404. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19405. /**
  19406. * Manage the touch inputs to control the movement of a free camera.
  19407. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19408. */
  19409. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19410. /**
  19411. * Defines the camera the input is attached to.
  19412. */
  19413. camera: FreeCamera;
  19414. /**
  19415. * Defines the touch sensibility for rotation.
  19416. * The higher the faster.
  19417. */
  19418. touchAngularSensibility: number;
  19419. /**
  19420. * Defines the touch sensibility for move.
  19421. * The higher the faster.
  19422. */
  19423. touchMoveSensibility: number;
  19424. private _offsetX;
  19425. private _offsetY;
  19426. private _pointerPressed;
  19427. private _pointerInput;
  19428. private _observer;
  19429. private _onLostFocus;
  19430. /**
  19431. * Attach the input controls to a specific dom element to get the input from.
  19432. * @param element Defines the element the controls should be listened from
  19433. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19434. */
  19435. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19436. /**
  19437. * Detach the current controls from the specified dom element.
  19438. * @param element Defines the element to stop listening the inputs from
  19439. */
  19440. detachControl(element: Nullable<HTMLElement>): void;
  19441. /**
  19442. * Update the current camera state depending on the inputs that have been used this frame.
  19443. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19444. */
  19445. checkInputs(): void;
  19446. /**
  19447. * Gets the class name of the current intput.
  19448. * @returns the class name
  19449. */
  19450. getClassName(): string;
  19451. /**
  19452. * Get the friendly name associated with the input class.
  19453. * @returns the input friendly name
  19454. */
  19455. getSimpleName(): string;
  19456. }
  19457. }
  19458. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  19459. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19460. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  19461. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  19462. import { Nullable } from "babylonjs/types";
  19463. /**
  19464. * Default Inputs manager for the FreeCamera.
  19465. * It groups all the default supported inputs for ease of use.
  19466. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19467. */
  19468. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19469. /**
  19470. * @hidden
  19471. */
  19472. _mouseInput: Nullable<FreeCameraMouseInput>;
  19473. /**
  19474. * Instantiates a new FreeCameraInputsManager.
  19475. * @param camera Defines the camera the inputs belong to
  19476. */
  19477. constructor(camera: FreeCamera);
  19478. /**
  19479. * Add keyboard input support to the input manager.
  19480. * @returns the current input manager
  19481. */
  19482. addKeyboard(): FreeCameraInputsManager;
  19483. /**
  19484. * Add mouse input support to the input manager.
  19485. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19486. * @returns the current input manager
  19487. */
  19488. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19489. /**
  19490. * Removes the mouse input support from the manager
  19491. * @returns the current input manager
  19492. */
  19493. removeMouse(): FreeCameraInputsManager;
  19494. /**
  19495. * Add touch input support to the input manager.
  19496. * @returns the current input manager
  19497. */
  19498. addTouch(): FreeCameraInputsManager;
  19499. /**
  19500. * Remove all attached input methods from a camera
  19501. */
  19502. clear(): void;
  19503. }
  19504. }
  19505. declare module "babylonjs/Cameras/freeCamera" {
  19506. import { Vector3 } from "babylonjs/Maths/math.vector";
  19507. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19508. import { Scene } from "babylonjs/scene";
  19509. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19510. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  19511. /**
  19512. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19513. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19514. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19515. */
  19516. export class FreeCamera extends TargetCamera {
  19517. /**
  19518. * Define the collision ellipsoid of the camera.
  19519. * This is helpful to simulate a camera body like the player body around the camera
  19520. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19521. */
  19522. ellipsoid: Vector3;
  19523. /**
  19524. * Define an offset for the position of the ellipsoid around the camera.
  19525. * This can be helpful to determine the center of the body near the gravity center of the body
  19526. * instead of its head.
  19527. */
  19528. ellipsoidOffset: Vector3;
  19529. /**
  19530. * Enable or disable collisions of the camera with the rest of the scene objects.
  19531. */
  19532. checkCollisions: boolean;
  19533. /**
  19534. * Enable or disable gravity on the camera.
  19535. */
  19536. applyGravity: boolean;
  19537. /**
  19538. * Define the input manager associated to the camera.
  19539. */
  19540. inputs: FreeCameraInputsManager;
  19541. /**
  19542. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19543. * Higher values reduce sensitivity.
  19544. */
  19545. get angularSensibility(): number;
  19546. /**
  19547. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19548. * Higher values reduce sensitivity.
  19549. */
  19550. set angularSensibility(value: number);
  19551. /**
  19552. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19553. */
  19554. get keysUp(): number[];
  19555. set keysUp(value: number[]);
  19556. /**
  19557. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19558. */
  19559. get keysUpward(): number[];
  19560. set keysUpward(value: number[]);
  19561. /**
  19562. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19563. */
  19564. get keysDown(): number[];
  19565. set keysDown(value: number[]);
  19566. /**
  19567. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19568. */
  19569. get keysDownward(): number[];
  19570. set keysDownward(value: number[]);
  19571. /**
  19572. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19573. */
  19574. get keysLeft(): number[];
  19575. set keysLeft(value: number[]);
  19576. /**
  19577. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19578. */
  19579. get keysRight(): number[];
  19580. set keysRight(value: number[]);
  19581. /**
  19582. * Event raised when the camera collide with a mesh in the scene.
  19583. */
  19584. onCollide: (collidedMesh: AbstractMesh) => void;
  19585. private _collider;
  19586. private _needMoveForGravity;
  19587. private _oldPosition;
  19588. private _diffPosition;
  19589. private _newPosition;
  19590. /** @hidden */
  19591. _localDirection: Vector3;
  19592. /** @hidden */
  19593. _transformedDirection: Vector3;
  19594. /**
  19595. * Instantiates a Free Camera.
  19596. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19597. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19598. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19599. * @param name Define the name of the camera in the scene
  19600. * @param position Define the start position of the camera in the scene
  19601. * @param scene Define the scene the camera belongs to
  19602. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19603. */
  19604. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19605. /**
  19606. * Attached controls to the current camera.
  19607. * @param element Defines the element the controls should be listened from
  19608. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19609. */
  19610. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19611. /**
  19612. * Detach the current controls from the camera.
  19613. * The camera will stop reacting to inputs.
  19614. * @param element Defines the element to stop listening the inputs from
  19615. */
  19616. detachControl(element: HTMLElement): void;
  19617. private _collisionMask;
  19618. /**
  19619. * Define a collision mask to limit the list of object the camera can collide with
  19620. */
  19621. get collisionMask(): number;
  19622. set collisionMask(mask: number);
  19623. /** @hidden */
  19624. _collideWithWorld(displacement: Vector3): void;
  19625. private _onCollisionPositionChange;
  19626. /** @hidden */
  19627. _checkInputs(): void;
  19628. /** @hidden */
  19629. _decideIfNeedsToMove(): boolean;
  19630. /** @hidden */
  19631. _updatePosition(): void;
  19632. /**
  19633. * Destroy the camera and release the current resources hold by it.
  19634. */
  19635. dispose(): void;
  19636. /**
  19637. * Gets the current object class name.
  19638. * @return the class name
  19639. */
  19640. getClassName(): string;
  19641. }
  19642. }
  19643. declare module "babylonjs/Gamepads/gamepad" {
  19644. import { Observable } from "babylonjs/Misc/observable";
  19645. /**
  19646. * Represents a gamepad control stick position
  19647. */
  19648. export class StickValues {
  19649. /**
  19650. * The x component of the control stick
  19651. */
  19652. x: number;
  19653. /**
  19654. * The y component of the control stick
  19655. */
  19656. y: number;
  19657. /**
  19658. * Initializes the gamepad x and y control stick values
  19659. * @param x The x component of the gamepad control stick value
  19660. * @param y The y component of the gamepad control stick value
  19661. */
  19662. constructor(
  19663. /**
  19664. * The x component of the control stick
  19665. */
  19666. x: number,
  19667. /**
  19668. * The y component of the control stick
  19669. */
  19670. y: number);
  19671. }
  19672. /**
  19673. * An interface which manages callbacks for gamepad button changes
  19674. */
  19675. export interface GamepadButtonChanges {
  19676. /**
  19677. * Called when a gamepad has been changed
  19678. */
  19679. changed: boolean;
  19680. /**
  19681. * Called when a gamepad press event has been triggered
  19682. */
  19683. pressChanged: boolean;
  19684. /**
  19685. * Called when a touch event has been triggered
  19686. */
  19687. touchChanged: boolean;
  19688. /**
  19689. * Called when a value has changed
  19690. */
  19691. valueChanged: boolean;
  19692. }
  19693. /**
  19694. * Represents a gamepad
  19695. */
  19696. export class Gamepad {
  19697. /**
  19698. * The id of the gamepad
  19699. */
  19700. id: string;
  19701. /**
  19702. * The index of the gamepad
  19703. */
  19704. index: number;
  19705. /**
  19706. * The browser gamepad
  19707. */
  19708. browserGamepad: any;
  19709. /**
  19710. * Specifies what type of gamepad this represents
  19711. */
  19712. type: number;
  19713. private _leftStick;
  19714. private _rightStick;
  19715. /** @hidden */
  19716. _isConnected: boolean;
  19717. private _leftStickAxisX;
  19718. private _leftStickAxisY;
  19719. private _rightStickAxisX;
  19720. private _rightStickAxisY;
  19721. /**
  19722. * Triggered when the left control stick has been changed
  19723. */
  19724. private _onleftstickchanged;
  19725. /**
  19726. * Triggered when the right control stick has been changed
  19727. */
  19728. private _onrightstickchanged;
  19729. /**
  19730. * Represents a gamepad controller
  19731. */
  19732. static GAMEPAD: number;
  19733. /**
  19734. * Represents a generic controller
  19735. */
  19736. static GENERIC: number;
  19737. /**
  19738. * Represents an XBox controller
  19739. */
  19740. static XBOX: number;
  19741. /**
  19742. * Represents a pose-enabled controller
  19743. */
  19744. static POSE_ENABLED: number;
  19745. /**
  19746. * Represents an Dual Shock controller
  19747. */
  19748. static DUALSHOCK: number;
  19749. /**
  19750. * Specifies whether the left control stick should be Y-inverted
  19751. */
  19752. protected _invertLeftStickY: boolean;
  19753. /**
  19754. * Specifies if the gamepad has been connected
  19755. */
  19756. get isConnected(): boolean;
  19757. /**
  19758. * Initializes the gamepad
  19759. * @param id The id of the gamepad
  19760. * @param index The index of the gamepad
  19761. * @param browserGamepad The browser gamepad
  19762. * @param leftStickX The x component of the left joystick
  19763. * @param leftStickY The y component of the left joystick
  19764. * @param rightStickX The x component of the right joystick
  19765. * @param rightStickY The y component of the right joystick
  19766. */
  19767. constructor(
  19768. /**
  19769. * The id of the gamepad
  19770. */
  19771. id: string,
  19772. /**
  19773. * The index of the gamepad
  19774. */
  19775. index: number,
  19776. /**
  19777. * The browser gamepad
  19778. */
  19779. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19780. /**
  19781. * Callback triggered when the left joystick has changed
  19782. * @param callback
  19783. */
  19784. onleftstickchanged(callback: (values: StickValues) => void): void;
  19785. /**
  19786. * Callback triggered when the right joystick has changed
  19787. * @param callback
  19788. */
  19789. onrightstickchanged(callback: (values: StickValues) => void): void;
  19790. /**
  19791. * Gets the left joystick
  19792. */
  19793. get leftStick(): StickValues;
  19794. /**
  19795. * Sets the left joystick values
  19796. */
  19797. set leftStick(newValues: StickValues);
  19798. /**
  19799. * Gets the right joystick
  19800. */
  19801. get rightStick(): StickValues;
  19802. /**
  19803. * Sets the right joystick value
  19804. */
  19805. set rightStick(newValues: StickValues);
  19806. /**
  19807. * Updates the gamepad joystick positions
  19808. */
  19809. update(): void;
  19810. /**
  19811. * Disposes the gamepad
  19812. */
  19813. dispose(): void;
  19814. }
  19815. /**
  19816. * Represents a generic gamepad
  19817. */
  19818. export class GenericPad extends Gamepad {
  19819. private _buttons;
  19820. private _onbuttondown;
  19821. private _onbuttonup;
  19822. /**
  19823. * Observable triggered when a button has been pressed
  19824. */
  19825. onButtonDownObservable: Observable<number>;
  19826. /**
  19827. * Observable triggered when a button has been released
  19828. */
  19829. onButtonUpObservable: Observable<number>;
  19830. /**
  19831. * Callback triggered when a button has been pressed
  19832. * @param callback Called when a button has been pressed
  19833. */
  19834. onbuttondown(callback: (buttonPressed: number) => void): void;
  19835. /**
  19836. * Callback triggered when a button has been released
  19837. * @param callback Called when a button has been released
  19838. */
  19839. onbuttonup(callback: (buttonReleased: number) => void): void;
  19840. /**
  19841. * Initializes the generic gamepad
  19842. * @param id The id of the generic gamepad
  19843. * @param index The index of the generic gamepad
  19844. * @param browserGamepad The browser gamepad
  19845. */
  19846. constructor(id: string, index: number, browserGamepad: any);
  19847. private _setButtonValue;
  19848. /**
  19849. * Updates the generic gamepad
  19850. */
  19851. update(): void;
  19852. /**
  19853. * Disposes the generic gamepad
  19854. */
  19855. dispose(): void;
  19856. }
  19857. }
  19858. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  19859. import { Observable } from "babylonjs/Misc/observable";
  19860. import { Nullable } from "babylonjs/types";
  19861. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19862. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19863. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19864. import { Ray } from "babylonjs/Culling/ray";
  19865. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  19866. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  19867. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19868. /**
  19869. * Defines the types of pose enabled controllers that are supported
  19870. */
  19871. export enum PoseEnabledControllerType {
  19872. /**
  19873. * HTC Vive
  19874. */
  19875. VIVE = 0,
  19876. /**
  19877. * Oculus Rift
  19878. */
  19879. OCULUS = 1,
  19880. /**
  19881. * Windows mixed reality
  19882. */
  19883. WINDOWS = 2,
  19884. /**
  19885. * Samsung gear VR
  19886. */
  19887. GEAR_VR = 3,
  19888. /**
  19889. * Google Daydream
  19890. */
  19891. DAYDREAM = 4,
  19892. /**
  19893. * Generic
  19894. */
  19895. GENERIC = 5
  19896. }
  19897. /**
  19898. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19899. */
  19900. export interface MutableGamepadButton {
  19901. /**
  19902. * Value of the button/trigger
  19903. */
  19904. value: number;
  19905. /**
  19906. * If the button/trigger is currently touched
  19907. */
  19908. touched: boolean;
  19909. /**
  19910. * If the button/trigger is currently pressed
  19911. */
  19912. pressed: boolean;
  19913. }
  19914. /**
  19915. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19916. * @hidden
  19917. */
  19918. export interface ExtendedGamepadButton extends GamepadButton {
  19919. /**
  19920. * If the button/trigger is currently pressed
  19921. */
  19922. readonly pressed: boolean;
  19923. /**
  19924. * If the button/trigger is currently touched
  19925. */
  19926. readonly touched: boolean;
  19927. /**
  19928. * Value of the button/trigger
  19929. */
  19930. readonly value: number;
  19931. }
  19932. /** @hidden */
  19933. export interface _GamePadFactory {
  19934. /**
  19935. * Returns whether or not the current gamepad can be created for this type of controller.
  19936. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19937. * @returns true if it can be created, otherwise false
  19938. */
  19939. canCreate(gamepadInfo: any): boolean;
  19940. /**
  19941. * Creates a new instance of the Gamepad.
  19942. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19943. * @returns the new gamepad instance
  19944. */
  19945. create(gamepadInfo: any): Gamepad;
  19946. }
  19947. /**
  19948. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19949. */
  19950. export class PoseEnabledControllerHelper {
  19951. /** @hidden */
  19952. static _ControllerFactories: _GamePadFactory[];
  19953. /** @hidden */
  19954. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19955. /**
  19956. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19957. * @param vrGamepad the gamepad to initialized
  19958. * @returns a vr controller of the type the gamepad identified as
  19959. */
  19960. static InitiateController(vrGamepad: any): Gamepad;
  19961. }
  19962. /**
  19963. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19964. */
  19965. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19966. /**
  19967. * If the controller is used in a webXR session
  19968. */
  19969. isXR: boolean;
  19970. private _deviceRoomPosition;
  19971. private _deviceRoomRotationQuaternion;
  19972. /**
  19973. * The device position in babylon space
  19974. */
  19975. devicePosition: Vector3;
  19976. /**
  19977. * The device rotation in babylon space
  19978. */
  19979. deviceRotationQuaternion: Quaternion;
  19980. /**
  19981. * The scale factor of the device in babylon space
  19982. */
  19983. deviceScaleFactor: number;
  19984. /**
  19985. * (Likely devicePosition should be used instead) The device position in its room space
  19986. */
  19987. position: Vector3;
  19988. /**
  19989. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19990. */
  19991. rotationQuaternion: Quaternion;
  19992. /**
  19993. * The type of controller (Eg. Windows mixed reality)
  19994. */
  19995. controllerType: PoseEnabledControllerType;
  19996. protected _calculatedPosition: Vector3;
  19997. private _calculatedRotation;
  19998. /**
  19999. * The raw pose from the device
  20000. */
  20001. rawPose: DevicePose;
  20002. private _trackPosition;
  20003. private _maxRotationDistFromHeadset;
  20004. private _draggedRoomRotation;
  20005. /**
  20006. * @hidden
  20007. */
  20008. _disableTrackPosition(fixedPosition: Vector3): void;
  20009. /**
  20010. * Internal, the mesh attached to the controller
  20011. * @hidden
  20012. */
  20013. _mesh: Nullable<AbstractMesh>;
  20014. private _poseControlledCamera;
  20015. private _leftHandSystemQuaternion;
  20016. /**
  20017. * Internal, matrix used to convert room space to babylon space
  20018. * @hidden
  20019. */
  20020. _deviceToWorld: Matrix;
  20021. /**
  20022. * Node to be used when casting a ray from the controller
  20023. * @hidden
  20024. */
  20025. _pointingPoseNode: Nullable<TransformNode>;
  20026. /**
  20027. * Name of the child mesh that can be used to cast a ray from the controller
  20028. */
  20029. static readonly POINTING_POSE: string;
  20030. /**
  20031. * Creates a new PoseEnabledController from a gamepad
  20032. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  20033. */
  20034. constructor(browserGamepad: any);
  20035. private _workingMatrix;
  20036. /**
  20037. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  20038. */
  20039. update(): void;
  20040. /**
  20041. * Updates only the pose device and mesh without doing any button event checking
  20042. */
  20043. protected _updatePoseAndMesh(): void;
  20044. /**
  20045. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  20046. * @param poseData raw pose fromthe device
  20047. */
  20048. updateFromDevice(poseData: DevicePose): void;
  20049. /**
  20050. * @hidden
  20051. */
  20052. _meshAttachedObservable: Observable<AbstractMesh>;
  20053. /**
  20054. * Attaches a mesh to the controller
  20055. * @param mesh the mesh to be attached
  20056. */
  20057. attachToMesh(mesh: AbstractMesh): void;
  20058. /**
  20059. * Attaches the controllers mesh to a camera
  20060. * @param camera the camera the mesh should be attached to
  20061. */
  20062. attachToPoseControlledCamera(camera: TargetCamera): void;
  20063. /**
  20064. * Disposes of the controller
  20065. */
  20066. dispose(): void;
  20067. /**
  20068. * The mesh that is attached to the controller
  20069. */
  20070. get mesh(): Nullable<AbstractMesh>;
  20071. /**
  20072. * Gets the ray of the controller in the direction the controller is pointing
  20073. * @param length the length the resulting ray should be
  20074. * @returns a ray in the direction the controller is pointing
  20075. */
  20076. getForwardRay(length?: number): Ray;
  20077. }
  20078. }
  20079. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  20080. import { Observable } from "babylonjs/Misc/observable";
  20081. import { Scene } from "babylonjs/scene";
  20082. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20083. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  20084. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  20085. import { Nullable } from "babylonjs/types";
  20086. /**
  20087. * Defines the WebVRController object that represents controllers tracked in 3D space
  20088. */
  20089. export abstract class WebVRController extends PoseEnabledController {
  20090. /**
  20091. * Internal, the default controller model for the controller
  20092. */
  20093. protected _defaultModel: Nullable<AbstractMesh>;
  20094. /**
  20095. * Fired when the trigger state has changed
  20096. */
  20097. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  20098. /**
  20099. * Fired when the main button state has changed
  20100. */
  20101. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  20102. /**
  20103. * Fired when the secondary button state has changed
  20104. */
  20105. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  20106. /**
  20107. * Fired when the pad state has changed
  20108. */
  20109. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  20110. /**
  20111. * Fired when controllers stick values have changed
  20112. */
  20113. onPadValuesChangedObservable: Observable<StickValues>;
  20114. /**
  20115. * Array of button availible on the controller
  20116. */
  20117. protected _buttons: Array<MutableGamepadButton>;
  20118. private _onButtonStateChange;
  20119. /**
  20120. * Fired when a controller button's state has changed
  20121. * @param callback the callback containing the button that was modified
  20122. */
  20123. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  20124. /**
  20125. * X and Y axis corresponding to the controllers joystick
  20126. */
  20127. pad: StickValues;
  20128. /**
  20129. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  20130. */
  20131. hand: string;
  20132. /**
  20133. * The default controller model for the controller
  20134. */
  20135. get defaultModel(): Nullable<AbstractMesh>;
  20136. /**
  20137. * Creates a new WebVRController from a gamepad
  20138. * @param vrGamepad the gamepad that the WebVRController should be created from
  20139. */
  20140. constructor(vrGamepad: any);
  20141. /**
  20142. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  20143. */
  20144. update(): void;
  20145. /**
  20146. * Function to be called when a button is modified
  20147. */
  20148. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  20149. /**
  20150. * Loads a mesh and attaches it to the controller
  20151. * @param scene the scene the mesh should be added to
  20152. * @param meshLoaded callback for when the mesh has been loaded
  20153. */
  20154. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  20155. private _setButtonValue;
  20156. private _changes;
  20157. private _checkChanges;
  20158. /**
  20159. * Disposes of th webVRCOntroller
  20160. */
  20161. dispose(): void;
  20162. }
  20163. }
  20164. declare module "babylonjs/Lights/hemisphericLight" {
  20165. import { Nullable } from "babylonjs/types";
  20166. import { Scene } from "babylonjs/scene";
  20167. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20168. import { Color3 } from "babylonjs/Maths/math.color";
  20169. import { Effect } from "babylonjs/Materials/effect";
  20170. import { Light } from "babylonjs/Lights/light";
  20171. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  20172. /**
  20173. * The HemisphericLight simulates the ambient environment light,
  20174. * so the passed direction is the light reflection direction, not the incoming direction.
  20175. */
  20176. export class HemisphericLight extends Light {
  20177. /**
  20178. * The groundColor is the light in the opposite direction to the one specified during creation.
  20179. * 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.
  20180. */
  20181. groundColor: Color3;
  20182. /**
  20183. * The light reflection direction, not the incoming direction.
  20184. */
  20185. direction: Vector3;
  20186. /**
  20187. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  20188. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  20189. * The HemisphericLight can't cast shadows.
  20190. * Documentation : https://doc.babylonjs.com/babylon101/lights
  20191. * @param name The friendly name of the light
  20192. * @param direction The direction of the light reflection
  20193. * @param scene The scene the light belongs to
  20194. */
  20195. constructor(name: string, direction: Vector3, scene: Scene);
  20196. protected _buildUniformLayout(): void;
  20197. /**
  20198. * Returns the string "HemisphericLight".
  20199. * @return The class name
  20200. */
  20201. getClassName(): string;
  20202. /**
  20203. * Sets the HemisphericLight direction towards the passed target (Vector3).
  20204. * Returns the updated direction.
  20205. * @param target The target the direction should point to
  20206. * @return The computed direction
  20207. */
  20208. setDirectionToTarget(target: Vector3): Vector3;
  20209. /**
  20210. * Returns the shadow generator associated to the light.
  20211. * @returns Always null for hemispheric lights because it does not support shadows.
  20212. */
  20213. getShadowGenerator(): Nullable<IShadowGenerator>;
  20214. /**
  20215. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  20216. * @param effect The effect to update
  20217. * @param lightIndex The index of the light in the effect to update
  20218. * @returns The hemispheric light
  20219. */
  20220. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  20221. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  20222. /**
  20223. * Computes the world matrix of the node
  20224. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  20225. * @param useWasUpdatedFlag defines a reserved property
  20226. * @returns the world matrix
  20227. */
  20228. computeWorldMatrix(): Matrix;
  20229. /**
  20230. * Returns the integer 3.
  20231. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  20232. */
  20233. getTypeID(): number;
  20234. /**
  20235. * Prepares the list of defines specific to the light type.
  20236. * @param defines the list of defines
  20237. * @param lightIndex defines the index of the light for the effect
  20238. */
  20239. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  20240. }
  20241. }
  20242. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  20243. /** @hidden */
  20244. export var vrMultiviewToSingleviewPixelShader: {
  20245. name: string;
  20246. shader: string;
  20247. };
  20248. }
  20249. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  20250. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20251. import { Scene } from "babylonjs/scene";
  20252. /**
  20253. * Renders to multiple views with a single draw call
  20254. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  20255. */
  20256. export class MultiviewRenderTarget extends RenderTargetTexture {
  20257. /**
  20258. * Creates a multiview render target
  20259. * @param scene scene used with the render target
  20260. * @param size the size of the render target (used for each view)
  20261. */
  20262. constructor(scene: Scene, size?: number | {
  20263. width: number;
  20264. height: number;
  20265. } | {
  20266. ratio: number;
  20267. });
  20268. /**
  20269. * @hidden
  20270. * @param faceIndex the face index, if its a cube texture
  20271. */
  20272. _bindFrameBuffer(faceIndex?: number): void;
  20273. /**
  20274. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20275. * @returns the view count
  20276. */
  20277. getViewCount(): number;
  20278. }
  20279. }
  20280. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  20281. import { Camera } from "babylonjs/Cameras/camera";
  20282. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20283. import { Nullable } from "babylonjs/types";
  20284. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20285. import { Matrix } from "babylonjs/Maths/math.vector";
  20286. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20287. module "babylonjs/Engines/engine" {
  20288. interface Engine {
  20289. /**
  20290. * Creates a new multiview render target
  20291. * @param width defines the width of the texture
  20292. * @param height defines the height of the texture
  20293. * @returns the created multiview texture
  20294. */
  20295. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  20296. /**
  20297. * Binds a multiview framebuffer to be drawn to
  20298. * @param multiviewTexture texture to bind
  20299. */
  20300. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  20301. }
  20302. }
  20303. module "babylonjs/Cameras/camera" {
  20304. interface Camera {
  20305. /**
  20306. * @hidden
  20307. * 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)
  20308. */
  20309. _useMultiviewToSingleView: boolean;
  20310. /**
  20311. * @hidden
  20312. * 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)
  20313. */
  20314. _multiviewTexture: Nullable<RenderTargetTexture>;
  20315. /**
  20316. * @hidden
  20317. * ensures the multiview texture of the camera exists and has the specified width/height
  20318. * @param width height to set on the multiview texture
  20319. * @param height width to set on the multiview texture
  20320. */
  20321. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  20322. }
  20323. }
  20324. module "babylonjs/scene" {
  20325. interface Scene {
  20326. /** @hidden */
  20327. _transformMatrixR: Matrix;
  20328. /** @hidden */
  20329. _multiviewSceneUbo: Nullable<UniformBuffer>;
  20330. /** @hidden */
  20331. _createMultiviewUbo(): void;
  20332. /** @hidden */
  20333. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  20334. /** @hidden */
  20335. _renderMultiviewToSingleView(camera: Camera): void;
  20336. }
  20337. }
  20338. }
  20339. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  20340. import { Camera } from "babylonjs/Cameras/camera";
  20341. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20342. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  20343. import "babylonjs/Engines/Extensions/engine.multiview";
  20344. /**
  20345. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  20346. * This will not be used for webXR as it supports displaying texture arrays directly
  20347. */
  20348. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  20349. /**
  20350. * Gets a string identifying the name of the class
  20351. * @returns "VRMultiviewToSingleviewPostProcess" string
  20352. */
  20353. getClassName(): string;
  20354. /**
  20355. * Initializes a VRMultiviewToSingleview
  20356. * @param name name of the post process
  20357. * @param camera camera to be applied to
  20358. * @param scaleFactor scaling factor to the size of the output texture
  20359. */
  20360. constructor(name: string, camera: Camera, scaleFactor: number);
  20361. }
  20362. }
  20363. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  20364. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  20365. import { Nullable } from "babylonjs/types";
  20366. import { Size } from "babylonjs/Maths/math.size";
  20367. import { Observable } from "babylonjs/Misc/observable";
  20368. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  20369. /**
  20370. * Interface used to define additional presentation attributes
  20371. */
  20372. export interface IVRPresentationAttributes {
  20373. /**
  20374. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  20375. */
  20376. highRefreshRate: boolean;
  20377. /**
  20378. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  20379. */
  20380. foveationLevel: number;
  20381. }
  20382. module "babylonjs/Engines/engine" {
  20383. interface Engine {
  20384. /** @hidden */
  20385. _vrDisplay: any;
  20386. /** @hidden */
  20387. _vrSupported: boolean;
  20388. /** @hidden */
  20389. _oldSize: Size;
  20390. /** @hidden */
  20391. _oldHardwareScaleFactor: number;
  20392. /** @hidden */
  20393. _vrExclusivePointerMode: boolean;
  20394. /** @hidden */
  20395. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  20396. /** @hidden */
  20397. _onVRDisplayPointerRestricted: () => void;
  20398. /** @hidden */
  20399. _onVRDisplayPointerUnrestricted: () => void;
  20400. /** @hidden */
  20401. _onVrDisplayConnect: Nullable<(display: any) => void>;
  20402. /** @hidden */
  20403. _onVrDisplayDisconnect: Nullable<() => void>;
  20404. /** @hidden */
  20405. _onVrDisplayPresentChange: Nullable<() => void>;
  20406. /**
  20407. * Observable signaled when VR display mode changes
  20408. */
  20409. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  20410. /**
  20411. * Observable signaled when VR request present is complete
  20412. */
  20413. onVRRequestPresentComplete: Observable<boolean>;
  20414. /**
  20415. * Observable signaled when VR request present starts
  20416. */
  20417. onVRRequestPresentStart: Observable<Engine>;
  20418. /**
  20419. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  20420. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  20421. */
  20422. isInVRExclusivePointerMode: boolean;
  20423. /**
  20424. * Gets a boolean indicating if a webVR device was detected
  20425. * @returns true if a webVR device was detected
  20426. */
  20427. isVRDevicePresent(): boolean;
  20428. /**
  20429. * Gets the current webVR device
  20430. * @returns the current webVR device (or null)
  20431. */
  20432. getVRDevice(): any;
  20433. /**
  20434. * Initializes a webVR display and starts listening to display change events
  20435. * The onVRDisplayChangedObservable will be notified upon these changes
  20436. * @returns A promise containing a VRDisplay and if vr is supported
  20437. */
  20438. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20439. /** @hidden */
  20440. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20441. /**
  20442. * Gets or sets the presentation attributes used to configure VR rendering
  20443. */
  20444. vrPresentationAttributes?: IVRPresentationAttributes;
  20445. /**
  20446. * Call this function to switch to webVR mode
  20447. * Will do nothing if webVR is not supported or if there is no webVR device
  20448. * @param options the webvr options provided to the camera. mainly used for multiview
  20449. * @see https://doc.babylonjs.com/how_to/webvr_camera
  20450. */
  20451. enableVR(options: WebVROptions): void;
  20452. /** @hidden */
  20453. _onVRFullScreenTriggered(): void;
  20454. }
  20455. }
  20456. }
  20457. declare module "babylonjs/Cameras/VR/webVRCamera" {
  20458. import { Nullable } from "babylonjs/types";
  20459. import { Observable } from "babylonjs/Misc/observable";
  20460. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  20461. import { Scene } from "babylonjs/scene";
  20462. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20463. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  20464. import { Node } from "babylonjs/node";
  20465. import { Ray } from "babylonjs/Culling/ray";
  20466. import "babylonjs/Cameras/RigModes/webVRRigMode";
  20467. import "babylonjs/Engines/Extensions/engine.webVR";
  20468. /**
  20469. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20470. * IMPORTANT!! The data is right-hand data.
  20471. * @export
  20472. * @interface DevicePose
  20473. */
  20474. export interface DevicePose {
  20475. /**
  20476. * The position of the device, values in array are [x,y,z].
  20477. */
  20478. readonly position: Nullable<Float32Array>;
  20479. /**
  20480. * The linearVelocity of the device, values in array are [x,y,z].
  20481. */
  20482. readonly linearVelocity: Nullable<Float32Array>;
  20483. /**
  20484. * The linearAcceleration of the device, values in array are [x,y,z].
  20485. */
  20486. readonly linearAcceleration: Nullable<Float32Array>;
  20487. /**
  20488. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20489. */
  20490. readonly orientation: Nullable<Float32Array>;
  20491. /**
  20492. * The angularVelocity of the device, values in array are [x,y,z].
  20493. */
  20494. readonly angularVelocity: Nullable<Float32Array>;
  20495. /**
  20496. * The angularAcceleration of the device, values in array are [x,y,z].
  20497. */
  20498. readonly angularAcceleration: Nullable<Float32Array>;
  20499. }
  20500. /**
  20501. * Interface representing a pose controlled object in Babylon.
  20502. * A pose controlled object has both regular pose values as well as pose values
  20503. * from an external device such as a VR head mounted display
  20504. */
  20505. export interface PoseControlled {
  20506. /**
  20507. * The position of the object in babylon space.
  20508. */
  20509. position: Vector3;
  20510. /**
  20511. * The rotation quaternion of the object in babylon space.
  20512. */
  20513. rotationQuaternion: Quaternion;
  20514. /**
  20515. * The position of the device in babylon space.
  20516. */
  20517. devicePosition?: Vector3;
  20518. /**
  20519. * The rotation quaternion of the device in babylon space.
  20520. */
  20521. deviceRotationQuaternion: Quaternion;
  20522. /**
  20523. * The raw pose coming from the device.
  20524. */
  20525. rawPose: Nullable<DevicePose>;
  20526. /**
  20527. * The scale of the device to be used when translating from device space to babylon space.
  20528. */
  20529. deviceScaleFactor: number;
  20530. /**
  20531. * Updates the poseControlled values based on the input device pose.
  20532. * @param poseData the pose data to update the object with
  20533. */
  20534. updateFromDevice(poseData: DevicePose): void;
  20535. }
  20536. /**
  20537. * Set of options to customize the webVRCamera
  20538. */
  20539. export interface WebVROptions {
  20540. /**
  20541. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20542. */
  20543. trackPosition?: boolean;
  20544. /**
  20545. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20546. */
  20547. positionScale?: number;
  20548. /**
  20549. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20550. */
  20551. displayName?: string;
  20552. /**
  20553. * Should the native controller meshes be initialized. (default: true)
  20554. */
  20555. controllerMeshes?: boolean;
  20556. /**
  20557. * Creating a default HemiLight only on controllers. (default: true)
  20558. */
  20559. defaultLightingOnControllers?: boolean;
  20560. /**
  20561. * If you don't want to use the default VR button of the helper. (default: false)
  20562. */
  20563. useCustomVRButton?: boolean;
  20564. /**
  20565. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20566. */
  20567. customVRButton?: HTMLButtonElement;
  20568. /**
  20569. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20570. */
  20571. rayLength?: number;
  20572. /**
  20573. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20574. */
  20575. defaultHeight?: number;
  20576. /**
  20577. * If multiview should be used if availible (default: false)
  20578. */
  20579. useMultiview?: boolean;
  20580. }
  20581. /**
  20582. * This represents a WebVR camera.
  20583. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20584. * @example https://doc.babylonjs.com/how_to/webvr_camera
  20585. */
  20586. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20587. private webVROptions;
  20588. /**
  20589. * @hidden
  20590. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20591. */
  20592. _vrDevice: any;
  20593. /**
  20594. * The rawPose of the vrDevice.
  20595. */
  20596. rawPose: Nullable<DevicePose>;
  20597. private _onVREnabled;
  20598. private _specsVersion;
  20599. private _attached;
  20600. private _frameData;
  20601. protected _descendants: Array<Node>;
  20602. private _deviceRoomPosition;
  20603. /** @hidden */
  20604. _deviceRoomRotationQuaternion: Quaternion;
  20605. private _standingMatrix;
  20606. /**
  20607. * Represents device position in babylon space.
  20608. */
  20609. devicePosition: Vector3;
  20610. /**
  20611. * Represents device rotation in babylon space.
  20612. */
  20613. deviceRotationQuaternion: Quaternion;
  20614. /**
  20615. * The scale of the device to be used when translating from device space to babylon space.
  20616. */
  20617. deviceScaleFactor: number;
  20618. private _deviceToWorld;
  20619. private _worldToDevice;
  20620. /**
  20621. * References to the webVR controllers for the vrDevice.
  20622. */
  20623. controllers: Array<WebVRController>;
  20624. /**
  20625. * Emits an event when a controller is attached.
  20626. */
  20627. onControllersAttachedObservable: Observable<WebVRController[]>;
  20628. /**
  20629. * Emits an event when a controller's mesh has been loaded;
  20630. */
  20631. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20632. /**
  20633. * Emits an event when the HMD's pose has been updated.
  20634. */
  20635. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20636. private _poseSet;
  20637. /**
  20638. * If the rig cameras be used as parent instead of this camera.
  20639. */
  20640. rigParenting: boolean;
  20641. private _lightOnControllers;
  20642. private _defaultHeight?;
  20643. /**
  20644. * Instantiates a WebVRFreeCamera.
  20645. * @param name The name of the WebVRFreeCamera
  20646. * @param position The starting anchor position for the camera
  20647. * @param scene The scene the camera belongs to
  20648. * @param webVROptions a set of customizable options for the webVRCamera
  20649. */
  20650. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20651. /**
  20652. * Gets the device distance from the ground in meters.
  20653. * @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.
  20654. */
  20655. deviceDistanceToRoomGround(): number;
  20656. /**
  20657. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20658. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20659. */
  20660. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20661. /**
  20662. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20663. * @returns A promise with a boolean set to if the standing matrix is supported.
  20664. */
  20665. useStandingMatrixAsync(): Promise<boolean>;
  20666. /**
  20667. * Disposes the camera
  20668. */
  20669. dispose(): void;
  20670. /**
  20671. * Gets a vrController by name.
  20672. * @param name The name of the controller to retreive
  20673. * @returns the controller matching the name specified or null if not found
  20674. */
  20675. getControllerByName(name: string): Nullable<WebVRController>;
  20676. private _leftController;
  20677. /**
  20678. * The controller corresponding to the users left hand.
  20679. */
  20680. get leftController(): Nullable<WebVRController>;
  20681. private _rightController;
  20682. /**
  20683. * The controller corresponding to the users right hand.
  20684. */
  20685. get rightController(): Nullable<WebVRController>;
  20686. /**
  20687. * Casts a ray forward from the vrCamera's gaze.
  20688. * @param length Length of the ray (default: 100)
  20689. * @returns the ray corresponding to the gaze
  20690. */
  20691. getForwardRay(length?: number): Ray;
  20692. /**
  20693. * @hidden
  20694. * Updates the camera based on device's frame data
  20695. */
  20696. _checkInputs(): void;
  20697. /**
  20698. * Updates the poseControlled values based on the input device pose.
  20699. * @param poseData Pose coming from the device
  20700. */
  20701. updateFromDevice(poseData: DevicePose): void;
  20702. private _htmlElementAttached;
  20703. private _detachIfAttached;
  20704. /**
  20705. * WebVR's attach control will start broadcasting frames to the device.
  20706. * Note that in certain browsers (chrome for example) this function must be called
  20707. * within a user-interaction callback. Example:
  20708. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20709. *
  20710. * @param element html element to attach the vrDevice to
  20711. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20712. */
  20713. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20714. /**
  20715. * Detaches the camera from the html element and disables VR
  20716. *
  20717. * @param element html element to detach from
  20718. */
  20719. detachControl(element: HTMLElement): void;
  20720. /**
  20721. * @returns the name of this class
  20722. */
  20723. getClassName(): string;
  20724. /**
  20725. * Calls resetPose on the vrDisplay
  20726. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20727. */
  20728. resetToCurrentRotation(): void;
  20729. /**
  20730. * @hidden
  20731. * Updates the rig cameras (left and right eye)
  20732. */
  20733. _updateRigCameras(): void;
  20734. private _workingVector;
  20735. private _oneVector;
  20736. private _workingMatrix;
  20737. private updateCacheCalled;
  20738. private _correctPositionIfNotTrackPosition;
  20739. /**
  20740. * @hidden
  20741. * Updates the cached values of the camera
  20742. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20743. */
  20744. _updateCache(ignoreParentClass?: boolean): void;
  20745. /**
  20746. * @hidden
  20747. * Get current device position in babylon world
  20748. */
  20749. _computeDevicePosition(): void;
  20750. /**
  20751. * Updates the current device position and rotation in the babylon world
  20752. */
  20753. update(): void;
  20754. /**
  20755. * @hidden
  20756. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20757. * @returns an identity matrix
  20758. */
  20759. _getViewMatrix(): Matrix;
  20760. private _tmpMatrix;
  20761. /**
  20762. * This function is called by the two RIG cameras.
  20763. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20764. * @hidden
  20765. */
  20766. _getWebVRViewMatrix(): Matrix;
  20767. /** @hidden */
  20768. _getWebVRProjectionMatrix(): Matrix;
  20769. private _onGamepadConnectedObserver;
  20770. private _onGamepadDisconnectedObserver;
  20771. private _updateCacheWhenTrackingDisabledObserver;
  20772. /**
  20773. * Initializes the controllers and their meshes
  20774. */
  20775. initControllers(): void;
  20776. }
  20777. }
  20778. declare module "babylonjs/Materials/materialHelper" {
  20779. import { Nullable } from "babylonjs/types";
  20780. import { Scene } from "babylonjs/scene";
  20781. import { Engine } from "babylonjs/Engines/engine";
  20782. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20783. import { Light } from "babylonjs/Lights/light";
  20784. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20785. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  20786. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20787. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20788. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20789. /**
  20790. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  20791. *
  20792. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20793. *
  20794. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20795. */
  20796. export class MaterialHelper {
  20797. /**
  20798. * Bind the current view position to an effect.
  20799. * @param effect The effect to be bound
  20800. * @param scene The scene the eyes position is used from
  20801. * @param variableName name of the shader variable that will hold the eye position
  20802. */
  20803. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20804. /**
  20805. * Helps preparing the defines values about the UVs in used in the effect.
  20806. * UVs are shared as much as we can accross channels in the shaders.
  20807. * @param texture The texture we are preparing the UVs for
  20808. * @param defines The defines to update
  20809. * @param key The channel key "diffuse", "specular"... used in the shader
  20810. */
  20811. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20812. /**
  20813. * Binds a texture matrix value to its corrsponding uniform
  20814. * @param texture The texture to bind the matrix for
  20815. * @param uniformBuffer The uniform buffer receivin the data
  20816. * @param key The channel key "diffuse", "specular"... used in the shader
  20817. */
  20818. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20819. /**
  20820. * Gets the current status of the fog (should it be enabled?)
  20821. * @param mesh defines the mesh to evaluate for fog support
  20822. * @param scene defines the hosting scene
  20823. * @returns true if fog must be enabled
  20824. */
  20825. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20826. /**
  20827. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20828. * @param mesh defines the current mesh
  20829. * @param scene defines the current scene
  20830. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20831. * @param pointsCloud defines if point cloud rendering has to be turned on
  20832. * @param fogEnabled defines if fog has to be turned on
  20833. * @param alphaTest defines if alpha testing has to be turned on
  20834. * @param defines defines the current list of defines
  20835. */
  20836. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20837. /**
  20838. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20839. * @param scene defines the current scene
  20840. * @param engine defines the current engine
  20841. * @param defines specifies the list of active defines
  20842. * @param useInstances defines if instances have to be turned on
  20843. * @param useClipPlane defines if clip plane have to be turned on
  20844. * @param useInstances defines if instances have to be turned on
  20845. * @param useThinInstances defines if thin instances have to be turned on
  20846. */
  20847. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20848. /**
  20849. * Prepares the defines for bones
  20850. * @param mesh The mesh containing the geometry data we will draw
  20851. * @param defines The defines to update
  20852. */
  20853. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20854. /**
  20855. * Prepares the defines for morph targets
  20856. * @param mesh The mesh containing the geometry data we will draw
  20857. * @param defines The defines to update
  20858. */
  20859. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20860. /**
  20861. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20862. * @param mesh The mesh containing the geometry data we will draw
  20863. * @param defines The defines to update
  20864. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20865. * @param useBones Precise whether bones should be used or not (override mesh info)
  20866. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20867. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20868. * @returns false if defines are considered not dirty and have not been checked
  20869. */
  20870. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20871. /**
  20872. * Prepares the defines related to multiview
  20873. * @param scene The scene we are intending to draw
  20874. * @param defines The defines to update
  20875. */
  20876. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20877. /**
  20878. * Prepares the defines related to the prepass
  20879. * @param scene The scene we are intending to draw
  20880. * @param defines The defines to update
  20881. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  20882. */
  20883. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  20884. /**
  20885. * Prepares the defines related to the light information passed in parameter
  20886. * @param scene The scene we are intending to draw
  20887. * @param mesh The mesh the effect is compiling for
  20888. * @param light The light the effect is compiling for
  20889. * @param lightIndex The index of the light
  20890. * @param defines The defines to update
  20891. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20892. * @param state Defines the current state regarding what is needed (normals, etc...)
  20893. */
  20894. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20895. needNormals: boolean;
  20896. needRebuild: boolean;
  20897. shadowEnabled: boolean;
  20898. specularEnabled: boolean;
  20899. lightmapMode: boolean;
  20900. }): void;
  20901. /**
  20902. * Prepares the defines related to the light information passed in parameter
  20903. * @param scene The scene we are intending to draw
  20904. * @param mesh The mesh the effect is compiling for
  20905. * @param defines The defines to update
  20906. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20907. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20908. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20909. * @returns true if normals will be required for the rest of the effect
  20910. */
  20911. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20912. /**
  20913. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20914. * @param lightIndex defines the light index
  20915. * @param uniformsList The uniform list
  20916. * @param samplersList The sampler list
  20917. * @param projectedLightTexture defines if projected texture must be used
  20918. * @param uniformBuffersList defines an optional list of uniform buffers
  20919. */
  20920. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20921. /**
  20922. * Prepares the uniforms and samplers list to be used in the effect
  20923. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20924. * @param samplersList The sampler list
  20925. * @param defines The defines helping in the list generation
  20926. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20927. */
  20928. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20929. /**
  20930. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20931. * @param defines The defines to update while falling back
  20932. * @param fallbacks The authorized effect fallbacks
  20933. * @param maxSimultaneousLights The maximum number of lights allowed
  20934. * @param rank the current rank of the Effect
  20935. * @returns The newly affected rank
  20936. */
  20937. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20938. private static _TmpMorphInfluencers;
  20939. /**
  20940. * Prepares the list of attributes required for morph targets according to the effect defines.
  20941. * @param attribs The current list of supported attribs
  20942. * @param mesh The mesh to prepare the morph targets attributes for
  20943. * @param influencers The number of influencers
  20944. */
  20945. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20946. /**
  20947. * Prepares the list of attributes required for morph targets according to the effect defines.
  20948. * @param attribs The current list of supported attribs
  20949. * @param mesh The mesh to prepare the morph targets attributes for
  20950. * @param defines The current Defines of the effect
  20951. */
  20952. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20953. /**
  20954. * Prepares the list of attributes required for bones according to the effect defines.
  20955. * @param attribs The current list of supported attribs
  20956. * @param mesh The mesh to prepare the bones attributes for
  20957. * @param defines The current Defines of the effect
  20958. * @param fallbacks The current efffect fallback strategy
  20959. */
  20960. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20961. /**
  20962. * Check and prepare the list of attributes required for instances according to the effect defines.
  20963. * @param attribs The current list of supported attribs
  20964. * @param defines The current MaterialDefines of the effect
  20965. */
  20966. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20967. /**
  20968. * Add the list of attributes required for instances to the attribs array.
  20969. * @param attribs The current list of supported attribs
  20970. */
  20971. static PushAttributesForInstances(attribs: string[]): void;
  20972. /**
  20973. * Binds the light information to the effect.
  20974. * @param light The light containing the generator
  20975. * @param effect The effect we are binding the data to
  20976. * @param lightIndex The light index in the effect used to render
  20977. */
  20978. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20979. /**
  20980. * Binds the lights information from the scene to the effect for the given mesh.
  20981. * @param light Light to bind
  20982. * @param lightIndex Light index
  20983. * @param scene The scene where the light belongs to
  20984. * @param effect The effect we are binding the data to
  20985. * @param useSpecular Defines if specular is supported
  20986. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20987. */
  20988. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20989. /**
  20990. * Binds the lights information from the scene to the effect for the given mesh.
  20991. * @param scene The scene the lights belongs to
  20992. * @param mesh The mesh we are binding the information to render
  20993. * @param effect The effect we are binding the data to
  20994. * @param defines The generated defines for the effect
  20995. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20996. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20997. */
  20998. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20999. private static _tempFogColor;
  21000. /**
  21001. * Binds the fog information from the scene to the effect for the given mesh.
  21002. * @param scene The scene the lights belongs to
  21003. * @param mesh The mesh we are binding the information to render
  21004. * @param effect The effect we are binding the data to
  21005. * @param linearSpace Defines if the fog effect is applied in linear space
  21006. */
  21007. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  21008. /**
  21009. * Binds the bones information from the mesh to the effect.
  21010. * @param mesh The mesh we are binding the information to render
  21011. * @param effect The effect we are binding the data to
  21012. */
  21013. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  21014. /**
  21015. * Binds the morph targets information from the mesh to the effect.
  21016. * @param abstractMesh The mesh we are binding the information to render
  21017. * @param effect The effect we are binding the data to
  21018. */
  21019. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  21020. /**
  21021. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  21022. * @param defines The generated defines used in the effect
  21023. * @param effect The effect we are binding the data to
  21024. * @param scene The scene we are willing to render with logarithmic scale for
  21025. */
  21026. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  21027. /**
  21028. * Binds the clip plane information from the scene to the effect.
  21029. * @param scene The scene the clip plane information are extracted from
  21030. * @param effect The effect we are binding the data to
  21031. */
  21032. static BindClipPlane(effect: Effect, scene: Scene): void;
  21033. }
  21034. }
  21035. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  21036. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21037. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21038. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  21039. import { Nullable } from "babylonjs/types";
  21040. import { Effect } from "babylonjs/Materials/effect";
  21041. import { Matrix } from "babylonjs/Maths/math.vector";
  21042. import { Scene } from "babylonjs/scene";
  21043. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21044. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21045. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21046. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  21047. import { Observable } from "babylonjs/Misc/observable";
  21048. /**
  21049. * Block used to expose an input value
  21050. */
  21051. export class InputBlock extends NodeMaterialBlock {
  21052. private _mode;
  21053. private _associatedVariableName;
  21054. private _storedValue;
  21055. private _valueCallback;
  21056. private _type;
  21057. private _animationType;
  21058. /** Gets or set a value used to limit the range of float values */
  21059. min: number;
  21060. /** Gets or set a value used to limit the range of float values */
  21061. max: number;
  21062. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  21063. isBoolean: boolean;
  21064. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  21065. matrixMode: number;
  21066. /** @hidden */
  21067. _systemValue: Nullable<NodeMaterialSystemValues>;
  21068. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  21069. visibleInInspector: boolean;
  21070. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  21071. isConstant: boolean;
  21072. /** Gets or sets the group to use to display this block in the Inspector */
  21073. groupInInspector: string;
  21074. /** Gets an observable raised when the value is changed */
  21075. onValueChangedObservable: Observable<InputBlock>;
  21076. /**
  21077. * Gets or sets the connection point type (default is float)
  21078. */
  21079. get type(): NodeMaterialBlockConnectionPointTypes;
  21080. /**
  21081. * Creates a new InputBlock
  21082. * @param name defines the block name
  21083. * @param target defines the target of that block (Vertex by default)
  21084. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  21085. */
  21086. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  21087. /**
  21088. * Validates if a name is a reserve word.
  21089. * @param newName the new name to be given to the node.
  21090. * @returns false if the name is a reserve word, else true.
  21091. */
  21092. validateBlockName(newName: string): boolean;
  21093. /**
  21094. * Gets the output component
  21095. */
  21096. get output(): NodeMaterialConnectionPoint;
  21097. /**
  21098. * Set the source of this connection point to a vertex attribute
  21099. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  21100. * @returns the current connection point
  21101. */
  21102. setAsAttribute(attributeName?: string): InputBlock;
  21103. /**
  21104. * Set the source of this connection point to a system value
  21105. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  21106. * @returns the current connection point
  21107. */
  21108. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  21109. /**
  21110. * Gets or sets the value of that point.
  21111. * Please note that this value will be ignored if valueCallback is defined
  21112. */
  21113. get value(): any;
  21114. set value(value: any);
  21115. /**
  21116. * Gets or sets a callback used to get the value of that point.
  21117. * Please note that setting this value will force the connection point to ignore the value property
  21118. */
  21119. get valueCallback(): () => any;
  21120. set valueCallback(value: () => any);
  21121. /**
  21122. * Gets or sets the associated variable name in the shader
  21123. */
  21124. get associatedVariableName(): string;
  21125. set associatedVariableName(value: string);
  21126. /** Gets or sets the type of animation applied to the input */
  21127. get animationType(): AnimatedInputBlockTypes;
  21128. set animationType(value: AnimatedInputBlockTypes);
  21129. /**
  21130. * Gets a boolean indicating that this connection point not defined yet
  21131. */
  21132. get isUndefined(): boolean;
  21133. /**
  21134. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  21135. * In this case the connection point name must be the name of the uniform to use.
  21136. * Can only be set on inputs
  21137. */
  21138. get isUniform(): boolean;
  21139. set isUniform(value: boolean);
  21140. /**
  21141. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  21142. * In this case the connection point name must be the name of the attribute to use
  21143. * Can only be set on inputs
  21144. */
  21145. get isAttribute(): boolean;
  21146. set isAttribute(value: boolean);
  21147. /**
  21148. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  21149. * Can only be set on exit points
  21150. */
  21151. get isVarying(): boolean;
  21152. set isVarying(value: boolean);
  21153. /**
  21154. * Gets a boolean indicating that the current connection point is a system value
  21155. */
  21156. get isSystemValue(): boolean;
  21157. /**
  21158. * Gets or sets the current well known value or null if not defined as a system value
  21159. */
  21160. get systemValue(): Nullable<NodeMaterialSystemValues>;
  21161. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  21162. /**
  21163. * Gets the current class name
  21164. * @returns the class name
  21165. */
  21166. getClassName(): string;
  21167. /**
  21168. * Animate the input if animationType !== None
  21169. * @param scene defines the rendering scene
  21170. */
  21171. animate(scene: Scene): void;
  21172. private _emitDefine;
  21173. initialize(state: NodeMaterialBuildState): void;
  21174. /**
  21175. * Set the input block to its default value (based on its type)
  21176. */
  21177. setDefaultValue(): void;
  21178. private _emitConstant;
  21179. /** @hidden */
  21180. get _noContextSwitch(): boolean;
  21181. private _emit;
  21182. /** @hidden */
  21183. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  21184. /** @hidden */
  21185. _transmit(effect: Effect, scene: Scene): void;
  21186. protected _buildBlock(state: NodeMaterialBuildState): void;
  21187. protected _dumpPropertiesCode(): string;
  21188. dispose(): void;
  21189. serialize(): any;
  21190. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21191. }
  21192. }
  21193. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  21194. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21195. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21196. import { Nullable } from "babylonjs/types";
  21197. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  21198. import { Observable } from "babylonjs/Misc/observable";
  21199. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21200. /**
  21201. * Enum used to define the compatibility state between two connection points
  21202. */
  21203. export enum NodeMaterialConnectionPointCompatibilityStates {
  21204. /** Points are compatibles */
  21205. Compatible = 0,
  21206. /** Points are incompatible because of their types */
  21207. TypeIncompatible = 1,
  21208. /** Points are incompatible because of their targets (vertex vs fragment) */
  21209. TargetIncompatible = 2
  21210. }
  21211. /**
  21212. * Defines the direction of a connection point
  21213. */
  21214. export enum NodeMaterialConnectionPointDirection {
  21215. /** Input */
  21216. Input = 0,
  21217. /** Output */
  21218. Output = 1
  21219. }
  21220. /**
  21221. * Defines a connection point for a block
  21222. */
  21223. export class NodeMaterialConnectionPoint {
  21224. /** @hidden */
  21225. _ownerBlock: NodeMaterialBlock;
  21226. /** @hidden */
  21227. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  21228. private _endpoints;
  21229. private _associatedVariableName;
  21230. private _direction;
  21231. /** @hidden */
  21232. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21233. /** @hidden */
  21234. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21235. private _type;
  21236. /** @hidden */
  21237. _enforceAssociatedVariableName: boolean;
  21238. /** Gets the direction of the point */
  21239. get direction(): NodeMaterialConnectionPointDirection;
  21240. /** Indicates that this connection point needs dual validation before being connected to another point */
  21241. needDualDirectionValidation: boolean;
  21242. /**
  21243. * Gets or sets the additional types supported by this connection point
  21244. */
  21245. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21246. /**
  21247. * Gets or sets the additional types excluded by this connection point
  21248. */
  21249. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21250. /**
  21251. * Observable triggered when this point is connected
  21252. */
  21253. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  21254. /**
  21255. * Gets or sets the associated variable name in the shader
  21256. */
  21257. get associatedVariableName(): string;
  21258. set associatedVariableName(value: string);
  21259. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  21260. get innerType(): NodeMaterialBlockConnectionPointTypes;
  21261. /**
  21262. * Gets or sets the connection point type (default is float)
  21263. */
  21264. get type(): NodeMaterialBlockConnectionPointTypes;
  21265. set type(value: NodeMaterialBlockConnectionPointTypes);
  21266. /**
  21267. * Gets or sets the connection point name
  21268. */
  21269. name: string;
  21270. /**
  21271. * Gets or sets the connection point name
  21272. */
  21273. displayName: string;
  21274. /**
  21275. * Gets or sets a boolean indicating that this connection point can be omitted
  21276. */
  21277. isOptional: boolean;
  21278. /**
  21279. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  21280. */
  21281. isExposedOnFrame: boolean;
  21282. /**
  21283. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  21284. */
  21285. define: string;
  21286. /** @hidden */
  21287. _prioritizeVertex: boolean;
  21288. private _target;
  21289. /** Gets or sets the target of that connection point */
  21290. get target(): NodeMaterialBlockTargets;
  21291. set target(value: NodeMaterialBlockTargets);
  21292. /**
  21293. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  21294. */
  21295. get isConnected(): boolean;
  21296. /**
  21297. * Gets a boolean indicating that the current point is connected to an input block
  21298. */
  21299. get isConnectedToInputBlock(): boolean;
  21300. /**
  21301. * Gets a the connected input block (if any)
  21302. */
  21303. get connectInputBlock(): Nullable<InputBlock>;
  21304. /** Get the other side of the connection (if any) */
  21305. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  21306. /** Get the block that owns this connection point */
  21307. get ownerBlock(): NodeMaterialBlock;
  21308. /** Get the block connected on the other side of this connection (if any) */
  21309. get sourceBlock(): Nullable<NodeMaterialBlock>;
  21310. /** Get the block connected on the endpoints of this connection (if any) */
  21311. get connectedBlocks(): Array<NodeMaterialBlock>;
  21312. /** Gets the list of connected endpoints */
  21313. get endpoints(): NodeMaterialConnectionPoint[];
  21314. /** Gets a boolean indicating if that output point is connected to at least one input */
  21315. get hasEndpoints(): boolean;
  21316. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  21317. get isConnectedInVertexShader(): boolean;
  21318. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  21319. get isConnectedInFragmentShader(): boolean;
  21320. /**
  21321. * Creates a block suitable to be used as an input for this input point.
  21322. * If null is returned, a block based on the point type will be created.
  21323. * @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
  21324. */
  21325. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21326. /**
  21327. * Creates a new connection point
  21328. * @param name defines the connection point name
  21329. * @param ownerBlock defines the block hosting this connection point
  21330. * @param direction defines the direction of the connection point
  21331. */
  21332. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  21333. /**
  21334. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  21335. * @returns the class name
  21336. */
  21337. getClassName(): string;
  21338. /**
  21339. * Gets a boolean indicating if the current point can be connected to another point
  21340. * @param connectionPoint defines the other connection point
  21341. * @returns a boolean
  21342. */
  21343. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  21344. /**
  21345. * Gets a number indicating if the current point can be connected to another point
  21346. * @param connectionPoint defines the other connection point
  21347. * @returns a number defining the compatibility state
  21348. */
  21349. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21350. /**
  21351. * Connect this point to another connection point
  21352. * @param connectionPoint defines the other connection point
  21353. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  21354. * @returns the current connection point
  21355. */
  21356. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  21357. /**
  21358. * Disconnect this point from one of his endpoint
  21359. * @param endpoint defines the other connection point
  21360. * @returns the current connection point
  21361. */
  21362. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  21363. /**
  21364. * Serializes this point in a JSON representation
  21365. * @param isInput defines if the connection point is an input (default is true)
  21366. * @returns the serialized point object
  21367. */
  21368. serialize(isInput?: boolean): any;
  21369. /**
  21370. * Release resources
  21371. */
  21372. dispose(): void;
  21373. }
  21374. }
  21375. declare module "babylonjs/Materials/Node/Enums/nodeMaterialModes" {
  21376. /**
  21377. * Enum used to define the material modes
  21378. */
  21379. export enum NodeMaterialModes {
  21380. /** Regular material */
  21381. Material = 0,
  21382. /** For post process */
  21383. PostProcess = 1,
  21384. /** For particle system */
  21385. Particle = 2
  21386. }
  21387. }
  21388. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  21389. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21390. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21391. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21392. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21393. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21394. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21395. import { Effect } from "babylonjs/Materials/effect";
  21396. import { Mesh } from "babylonjs/Meshes/mesh";
  21397. import { Nullable } from "babylonjs/types";
  21398. import { Texture } from "babylonjs/Materials/Textures/texture";
  21399. import { Scene } from "babylonjs/scene";
  21400. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  21401. /**
  21402. * Block used to read a texture from a sampler
  21403. */
  21404. export class TextureBlock extends NodeMaterialBlock {
  21405. private _defineName;
  21406. private _linearDefineName;
  21407. private _gammaDefineName;
  21408. private _tempTextureRead;
  21409. private _samplerName;
  21410. private _transformedUVName;
  21411. private _textureTransformName;
  21412. private _textureInfoName;
  21413. private _mainUVName;
  21414. private _mainUVDefineName;
  21415. private _fragmentOnly;
  21416. /**
  21417. * Gets or sets the texture associated with the node
  21418. */
  21419. texture: Nullable<Texture>;
  21420. /**
  21421. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21422. */
  21423. convertToGammaSpace: boolean;
  21424. /**
  21425. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21426. */
  21427. convertToLinearSpace: boolean;
  21428. /**
  21429. * Create a new TextureBlock
  21430. * @param name defines the block name
  21431. */
  21432. constructor(name: string, fragmentOnly?: boolean);
  21433. /**
  21434. * Gets the current class name
  21435. * @returns the class name
  21436. */
  21437. getClassName(): string;
  21438. /**
  21439. * Gets the uv input component
  21440. */
  21441. get uv(): NodeMaterialConnectionPoint;
  21442. /**
  21443. * Gets the rgba output component
  21444. */
  21445. get rgba(): NodeMaterialConnectionPoint;
  21446. /**
  21447. * Gets the rgb output component
  21448. */
  21449. get rgb(): NodeMaterialConnectionPoint;
  21450. /**
  21451. * Gets the r output component
  21452. */
  21453. get r(): NodeMaterialConnectionPoint;
  21454. /**
  21455. * Gets the g output component
  21456. */
  21457. get g(): NodeMaterialConnectionPoint;
  21458. /**
  21459. * Gets the b output component
  21460. */
  21461. get b(): NodeMaterialConnectionPoint;
  21462. /**
  21463. * Gets the a output component
  21464. */
  21465. get a(): NodeMaterialConnectionPoint;
  21466. get target(): NodeMaterialBlockTargets;
  21467. autoConfigure(material: NodeMaterial): void;
  21468. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21469. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21470. isReady(): boolean;
  21471. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21472. private get _isMixed();
  21473. private _injectVertexCode;
  21474. private _writeTextureRead;
  21475. private _writeOutput;
  21476. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21477. protected _dumpPropertiesCode(): string;
  21478. serialize(): any;
  21479. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21480. }
  21481. }
  21482. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  21483. /** @hidden */
  21484. export var reflectionFunction: {
  21485. name: string;
  21486. shader: string;
  21487. };
  21488. }
  21489. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  21490. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21491. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21492. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21493. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21494. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21495. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21496. import { Effect } from "babylonjs/Materials/effect";
  21497. import { Mesh } from "babylonjs/Meshes/mesh";
  21498. import { Nullable } from "babylonjs/types";
  21499. import { Scene } from "babylonjs/scene";
  21500. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  21501. /**
  21502. * Base block used to read a reflection texture from a sampler
  21503. */
  21504. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  21505. /** @hidden */
  21506. _define3DName: string;
  21507. /** @hidden */
  21508. _defineCubicName: string;
  21509. /** @hidden */
  21510. _defineExplicitName: string;
  21511. /** @hidden */
  21512. _defineProjectionName: string;
  21513. /** @hidden */
  21514. _defineLocalCubicName: string;
  21515. /** @hidden */
  21516. _defineSphericalName: string;
  21517. /** @hidden */
  21518. _definePlanarName: string;
  21519. /** @hidden */
  21520. _defineEquirectangularName: string;
  21521. /** @hidden */
  21522. _defineMirroredEquirectangularFixedName: string;
  21523. /** @hidden */
  21524. _defineEquirectangularFixedName: string;
  21525. /** @hidden */
  21526. _defineSkyboxName: string;
  21527. /** @hidden */
  21528. _defineOppositeZ: string;
  21529. /** @hidden */
  21530. _cubeSamplerName: string;
  21531. /** @hidden */
  21532. _2DSamplerName: string;
  21533. protected _positionUVWName: string;
  21534. protected _directionWName: string;
  21535. protected _reflectionVectorName: string;
  21536. /** @hidden */
  21537. _reflectionCoordsName: string;
  21538. /** @hidden */
  21539. _reflectionMatrixName: string;
  21540. protected _reflectionColorName: string;
  21541. /**
  21542. * Gets or sets the texture associated with the node
  21543. */
  21544. texture: Nullable<BaseTexture>;
  21545. /**
  21546. * Create a new ReflectionTextureBaseBlock
  21547. * @param name defines the block name
  21548. */
  21549. constructor(name: string);
  21550. /**
  21551. * Gets the current class name
  21552. * @returns the class name
  21553. */
  21554. getClassName(): string;
  21555. /**
  21556. * Gets the world position input component
  21557. */
  21558. abstract get position(): NodeMaterialConnectionPoint;
  21559. /**
  21560. * Gets the world position input component
  21561. */
  21562. abstract get worldPosition(): NodeMaterialConnectionPoint;
  21563. /**
  21564. * Gets the world normal input component
  21565. */
  21566. abstract get worldNormal(): NodeMaterialConnectionPoint;
  21567. /**
  21568. * Gets the world input component
  21569. */
  21570. abstract get world(): NodeMaterialConnectionPoint;
  21571. /**
  21572. * Gets the camera (or eye) position component
  21573. */
  21574. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  21575. /**
  21576. * Gets the view input component
  21577. */
  21578. abstract get view(): NodeMaterialConnectionPoint;
  21579. protected _getTexture(): Nullable<BaseTexture>;
  21580. autoConfigure(material: NodeMaterial): void;
  21581. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21582. isReady(): boolean;
  21583. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21584. /**
  21585. * Gets the code to inject in the vertex shader
  21586. * @param state current state of the node material building
  21587. * @returns the shader code
  21588. */
  21589. handleVertexSide(state: NodeMaterialBuildState): string;
  21590. /**
  21591. * Handles the inits for the fragment code path
  21592. * @param state node material build state
  21593. */
  21594. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  21595. /**
  21596. * Generates the reflection coords code for the fragment code path
  21597. * @param worldNormalVarName name of the world normal variable
  21598. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  21599. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  21600. * @returns the shader code
  21601. */
  21602. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  21603. /**
  21604. * Generates the reflection color code for the fragment code path
  21605. * @param lodVarName name of the lod variable
  21606. * @param swizzleLookupTexture swizzle to use for the final color variable
  21607. * @returns the shader code
  21608. */
  21609. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21610. /**
  21611. * Generates the code corresponding to the connected output points
  21612. * @param state node material build state
  21613. * @param varName name of the variable to output
  21614. * @returns the shader code
  21615. */
  21616. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21617. protected _buildBlock(state: NodeMaterialBuildState): this;
  21618. protected _dumpPropertiesCode(): string;
  21619. serialize(): any;
  21620. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21621. }
  21622. }
  21623. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  21624. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21625. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21626. import { Nullable } from "babylonjs/types";
  21627. /**
  21628. * Defines a connection point to be used for points with a custom object type
  21629. */
  21630. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21631. private _blockType;
  21632. private _blockName;
  21633. private _nameForCheking?;
  21634. /**
  21635. * Creates a new connection point
  21636. * @param name defines the connection point name
  21637. * @param ownerBlock defines the block hosting this connection point
  21638. * @param direction defines the direction of the connection point
  21639. */
  21640. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21641. /**
  21642. * Gets a number indicating if the current point can be connected to another point
  21643. * @param connectionPoint defines the other connection point
  21644. * @returns a number defining the compatibility state
  21645. */
  21646. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21647. /**
  21648. * Creates a block suitable to be used as an input for this input point.
  21649. * If null is returned, a block based on the point type will be created.
  21650. * @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
  21651. */
  21652. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21653. }
  21654. }
  21655. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  21656. /**
  21657. * Enum defining the type of properties that can be edited in the property pages in the NME
  21658. */
  21659. export enum PropertyTypeForEdition {
  21660. /** property is a boolean */
  21661. Boolean = 0,
  21662. /** property is a float */
  21663. Float = 1,
  21664. /** property is a Vector2 */
  21665. Vector2 = 2,
  21666. /** property is a list of values */
  21667. List = 3
  21668. }
  21669. /**
  21670. * Interface that defines an option in a variable of type list
  21671. */
  21672. export interface IEditablePropertyListOption {
  21673. /** label of the option */
  21674. "label": string;
  21675. /** value of the option */
  21676. "value": number;
  21677. }
  21678. /**
  21679. * Interface that defines the options available for an editable property
  21680. */
  21681. export interface IEditablePropertyOption {
  21682. /** min value */
  21683. "min"?: number;
  21684. /** max value */
  21685. "max"?: number;
  21686. /** notifiers: indicates which actions to take when the property is changed */
  21687. "notifiers"?: {
  21688. /** the material should be rebuilt */
  21689. "rebuild"?: boolean;
  21690. /** the preview should be updated */
  21691. "update"?: boolean;
  21692. };
  21693. /** list of the options for a variable of type list */
  21694. "options"?: IEditablePropertyListOption[];
  21695. }
  21696. /**
  21697. * Interface that describes an editable property
  21698. */
  21699. export interface IPropertyDescriptionForEdition {
  21700. /** name of the property */
  21701. "propertyName": string;
  21702. /** display name of the property */
  21703. "displayName": string;
  21704. /** type of the property */
  21705. "type": PropertyTypeForEdition;
  21706. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21707. "groupName": string;
  21708. /** options for the property */
  21709. "options": IEditablePropertyOption;
  21710. }
  21711. /**
  21712. * Decorator that flags a property in a node material block as being editable
  21713. */
  21714. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21715. }
  21716. declare module "babylonjs/Materials/Node/Blocks/PBR/refractionBlock" {
  21717. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21718. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21719. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21720. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21721. import { Nullable } from "babylonjs/types";
  21722. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21723. import { Mesh } from "babylonjs/Meshes/mesh";
  21724. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21725. import { Effect } from "babylonjs/Materials/effect";
  21726. import { Scene } from "babylonjs/scene";
  21727. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21728. /**
  21729. * Block used to implement the refraction part of the sub surface module of the PBR material
  21730. */
  21731. export class RefractionBlock extends NodeMaterialBlock {
  21732. /** @hidden */
  21733. _define3DName: string;
  21734. /** @hidden */
  21735. _refractionMatrixName: string;
  21736. /** @hidden */
  21737. _defineLODRefractionAlpha: string;
  21738. /** @hidden */
  21739. _defineLinearSpecularRefraction: string;
  21740. /** @hidden */
  21741. _defineOppositeZ: string;
  21742. /** @hidden */
  21743. _cubeSamplerName: string;
  21744. /** @hidden */
  21745. _2DSamplerName: string;
  21746. /** @hidden */
  21747. _vRefractionMicrosurfaceInfosName: string;
  21748. /** @hidden */
  21749. _vRefractionInfosName: string;
  21750. private _scene;
  21751. /**
  21752. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21753. * Materials half opaque for instance using refraction could benefit from this control.
  21754. */
  21755. linkRefractionWithTransparency: boolean;
  21756. /**
  21757. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21758. */
  21759. invertRefractionY: boolean;
  21760. /**
  21761. * Gets or sets the texture associated with the node
  21762. */
  21763. texture: Nullable<BaseTexture>;
  21764. /**
  21765. * Create a new RefractionBlock
  21766. * @param name defines the block name
  21767. */
  21768. constructor(name: string);
  21769. /**
  21770. * Gets the current class name
  21771. * @returns the class name
  21772. */
  21773. getClassName(): string;
  21774. /**
  21775. * Gets the intensity input component
  21776. */
  21777. get intensity(): NodeMaterialConnectionPoint;
  21778. /**
  21779. * Gets the index of refraction input component
  21780. */
  21781. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21782. /**
  21783. * Gets the tint at distance input component
  21784. */
  21785. get tintAtDistance(): NodeMaterialConnectionPoint;
  21786. /**
  21787. * Gets the view input component
  21788. */
  21789. get view(): NodeMaterialConnectionPoint;
  21790. /**
  21791. * Gets the refraction object output component
  21792. */
  21793. get refraction(): NodeMaterialConnectionPoint;
  21794. /**
  21795. * Returns true if the block has a texture
  21796. */
  21797. get hasTexture(): boolean;
  21798. protected _getTexture(): Nullable<BaseTexture>;
  21799. autoConfigure(material: NodeMaterial): void;
  21800. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21801. isReady(): boolean;
  21802. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21803. /**
  21804. * Gets the main code of the block (fragment side)
  21805. * @param state current state of the node material building
  21806. * @returns the shader code
  21807. */
  21808. getCode(state: NodeMaterialBuildState): string;
  21809. protected _buildBlock(state: NodeMaterialBuildState): this;
  21810. protected _dumpPropertiesCode(): string;
  21811. serialize(): any;
  21812. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21813. }
  21814. }
  21815. declare module "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock" {
  21816. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21817. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21818. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21819. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21820. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21821. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21822. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21823. import { Nullable } from "babylonjs/types";
  21824. import { Scene } from "babylonjs/scene";
  21825. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21826. /**
  21827. * Base block used as input for post process
  21828. */
  21829. export class CurrentScreenBlock extends NodeMaterialBlock {
  21830. private _samplerName;
  21831. private _linearDefineName;
  21832. private _gammaDefineName;
  21833. private _mainUVName;
  21834. private _tempTextureRead;
  21835. /**
  21836. * Gets or sets the texture associated with the node
  21837. */
  21838. texture: Nullable<BaseTexture>;
  21839. /**
  21840. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21841. */
  21842. convertToGammaSpace: boolean;
  21843. /**
  21844. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21845. */
  21846. convertToLinearSpace: boolean;
  21847. /**
  21848. * Create a new CurrentScreenBlock
  21849. * @param name defines the block name
  21850. */
  21851. constructor(name: string);
  21852. /**
  21853. * Gets the current class name
  21854. * @returns the class name
  21855. */
  21856. getClassName(): string;
  21857. /**
  21858. * Gets the uv input component
  21859. */
  21860. get uv(): NodeMaterialConnectionPoint;
  21861. /**
  21862. * Gets the rgba output component
  21863. */
  21864. get rgba(): NodeMaterialConnectionPoint;
  21865. /**
  21866. * Gets the rgb output component
  21867. */
  21868. get rgb(): NodeMaterialConnectionPoint;
  21869. /**
  21870. * Gets the r output component
  21871. */
  21872. get r(): NodeMaterialConnectionPoint;
  21873. /**
  21874. * Gets the g output component
  21875. */
  21876. get g(): NodeMaterialConnectionPoint;
  21877. /**
  21878. * Gets the b output component
  21879. */
  21880. get b(): NodeMaterialConnectionPoint;
  21881. /**
  21882. * Gets the a output component
  21883. */
  21884. get a(): NodeMaterialConnectionPoint;
  21885. /**
  21886. * Initialize the block and prepare the context for build
  21887. * @param state defines the state that will be used for the build
  21888. */
  21889. initialize(state: NodeMaterialBuildState): void;
  21890. get target(): NodeMaterialBlockTargets;
  21891. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21892. isReady(): boolean;
  21893. private _injectVertexCode;
  21894. private _writeTextureRead;
  21895. private _writeOutput;
  21896. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21897. serialize(): any;
  21898. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21899. }
  21900. }
  21901. declare module "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock" {
  21902. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21903. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21904. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21905. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21906. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21907. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21908. import { Nullable } from "babylonjs/types";
  21909. import { Scene } from "babylonjs/scene";
  21910. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21911. /**
  21912. * Base block used for the particle texture
  21913. */
  21914. export class ParticleTextureBlock extends NodeMaterialBlock {
  21915. private _samplerName;
  21916. private _linearDefineName;
  21917. private _gammaDefineName;
  21918. private _tempTextureRead;
  21919. /**
  21920. * Gets or sets the texture associated with the node
  21921. */
  21922. texture: Nullable<BaseTexture>;
  21923. /**
  21924. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21925. */
  21926. convertToGammaSpace: boolean;
  21927. /**
  21928. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21929. */
  21930. convertToLinearSpace: boolean;
  21931. /**
  21932. * Create a new ParticleTextureBlock
  21933. * @param name defines the block name
  21934. */
  21935. constructor(name: string);
  21936. /**
  21937. * Gets the current class name
  21938. * @returns the class name
  21939. */
  21940. getClassName(): string;
  21941. /**
  21942. * Gets the uv input component
  21943. */
  21944. get uv(): NodeMaterialConnectionPoint;
  21945. /**
  21946. * Gets the rgba output component
  21947. */
  21948. get rgba(): NodeMaterialConnectionPoint;
  21949. /**
  21950. * Gets the rgb output component
  21951. */
  21952. get rgb(): NodeMaterialConnectionPoint;
  21953. /**
  21954. * Gets the r output component
  21955. */
  21956. get r(): NodeMaterialConnectionPoint;
  21957. /**
  21958. * Gets the g output component
  21959. */
  21960. get g(): NodeMaterialConnectionPoint;
  21961. /**
  21962. * Gets the b output component
  21963. */
  21964. get b(): NodeMaterialConnectionPoint;
  21965. /**
  21966. * Gets the a output component
  21967. */
  21968. get a(): NodeMaterialConnectionPoint;
  21969. /**
  21970. * Initialize the block and prepare the context for build
  21971. * @param state defines the state that will be used for the build
  21972. */
  21973. initialize(state: NodeMaterialBuildState): void;
  21974. autoConfigure(material: NodeMaterial): void;
  21975. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21976. isReady(): boolean;
  21977. private _writeOutput;
  21978. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21979. serialize(): any;
  21980. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21981. }
  21982. }
  21983. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  21984. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21985. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21986. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  21987. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  21988. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  21989. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  21990. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  21991. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  21992. import { Scene } from "babylonjs/scene";
  21993. /**
  21994. * Class used to store shared data between 2 NodeMaterialBuildState
  21995. */
  21996. export class NodeMaterialBuildStateSharedData {
  21997. /**
  21998. * Gets the list of emitted varyings
  21999. */
  22000. temps: string[];
  22001. /**
  22002. * Gets the list of emitted varyings
  22003. */
  22004. varyings: string[];
  22005. /**
  22006. * Gets the varying declaration string
  22007. */
  22008. varyingDeclaration: string;
  22009. /**
  22010. * Input blocks
  22011. */
  22012. inputBlocks: InputBlock[];
  22013. /**
  22014. * Input blocks
  22015. */
  22016. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22017. /**
  22018. * Bindable blocks (Blocks that need to set data to the effect)
  22019. */
  22020. bindableBlocks: NodeMaterialBlock[];
  22021. /**
  22022. * List of blocks that can provide a compilation fallback
  22023. */
  22024. blocksWithFallbacks: NodeMaterialBlock[];
  22025. /**
  22026. * List of blocks that can provide a define update
  22027. */
  22028. blocksWithDefines: NodeMaterialBlock[];
  22029. /**
  22030. * List of blocks that can provide a repeatable content
  22031. */
  22032. repeatableContentBlocks: NodeMaterialBlock[];
  22033. /**
  22034. * List of blocks that can provide a dynamic list of uniforms
  22035. */
  22036. dynamicUniformBlocks: NodeMaterialBlock[];
  22037. /**
  22038. * List of blocks that can block the isReady function for the material
  22039. */
  22040. blockingBlocks: NodeMaterialBlock[];
  22041. /**
  22042. * Gets the list of animated inputs
  22043. */
  22044. animatedInputs: InputBlock[];
  22045. /**
  22046. * Build Id used to avoid multiple recompilations
  22047. */
  22048. buildId: number;
  22049. /** List of emitted variables */
  22050. variableNames: {
  22051. [key: string]: number;
  22052. };
  22053. /** List of emitted defines */
  22054. defineNames: {
  22055. [key: string]: number;
  22056. };
  22057. /** Should emit comments? */
  22058. emitComments: boolean;
  22059. /** Emit build activity */
  22060. verbose: boolean;
  22061. /** Gets or sets the hosting scene */
  22062. scene: Scene;
  22063. /**
  22064. * Gets the compilation hints emitted at compilation time
  22065. */
  22066. hints: {
  22067. needWorldViewMatrix: boolean;
  22068. needWorldViewProjectionMatrix: boolean;
  22069. needAlphaBlending: boolean;
  22070. needAlphaTesting: boolean;
  22071. };
  22072. /**
  22073. * List of compilation checks
  22074. */
  22075. checks: {
  22076. emitVertex: boolean;
  22077. emitFragment: boolean;
  22078. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  22079. };
  22080. /**
  22081. * Is vertex program allowed to be empty?
  22082. */
  22083. allowEmptyVertexProgram: boolean;
  22084. /** Creates a new shared data */
  22085. constructor();
  22086. /**
  22087. * Emits console errors and exceptions if there is a failing check
  22088. */
  22089. emitErrors(): void;
  22090. }
  22091. }
  22092. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  22093. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22094. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22095. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  22096. /**
  22097. * Class used to store node based material build state
  22098. */
  22099. export class NodeMaterialBuildState {
  22100. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  22101. supportUniformBuffers: boolean;
  22102. /**
  22103. * Gets the list of emitted attributes
  22104. */
  22105. attributes: string[];
  22106. /**
  22107. * Gets the list of emitted uniforms
  22108. */
  22109. uniforms: string[];
  22110. /**
  22111. * Gets the list of emitted constants
  22112. */
  22113. constants: string[];
  22114. /**
  22115. * Gets the list of emitted samplers
  22116. */
  22117. samplers: string[];
  22118. /**
  22119. * Gets the list of emitted functions
  22120. */
  22121. functions: {
  22122. [key: string]: string;
  22123. };
  22124. /**
  22125. * Gets the list of emitted extensions
  22126. */
  22127. extensions: {
  22128. [key: string]: string;
  22129. };
  22130. /**
  22131. * Gets the target of the compilation state
  22132. */
  22133. target: NodeMaterialBlockTargets;
  22134. /**
  22135. * Gets the list of emitted counters
  22136. */
  22137. counters: {
  22138. [key: string]: number;
  22139. };
  22140. /**
  22141. * Shared data between multiple NodeMaterialBuildState instances
  22142. */
  22143. sharedData: NodeMaterialBuildStateSharedData;
  22144. /** @hidden */
  22145. _vertexState: NodeMaterialBuildState;
  22146. /** @hidden */
  22147. _attributeDeclaration: string;
  22148. /** @hidden */
  22149. _uniformDeclaration: string;
  22150. /** @hidden */
  22151. _constantDeclaration: string;
  22152. /** @hidden */
  22153. _samplerDeclaration: string;
  22154. /** @hidden */
  22155. _varyingTransfer: string;
  22156. /** @hidden */
  22157. _injectAtEnd: string;
  22158. private _repeatableContentAnchorIndex;
  22159. /** @hidden */
  22160. _builtCompilationString: string;
  22161. /**
  22162. * Gets the emitted compilation strings
  22163. */
  22164. compilationString: string;
  22165. /**
  22166. * Finalize the compilation strings
  22167. * @param state defines the current compilation state
  22168. */
  22169. finalize(state: NodeMaterialBuildState): void;
  22170. /** @hidden */
  22171. get _repeatableContentAnchor(): string;
  22172. /** @hidden */
  22173. _getFreeVariableName(prefix: string): string;
  22174. /** @hidden */
  22175. _getFreeDefineName(prefix: string): string;
  22176. /** @hidden */
  22177. _excludeVariableName(name: string): void;
  22178. /** @hidden */
  22179. _emit2DSampler(name: string): void;
  22180. /** @hidden */
  22181. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  22182. /** @hidden */
  22183. _emitExtension(name: string, extension: string, define?: string): void;
  22184. /** @hidden */
  22185. _emitFunction(name: string, code: string, comments: string): void;
  22186. /** @hidden */
  22187. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  22188. replaceStrings?: {
  22189. search: RegExp;
  22190. replace: string;
  22191. }[];
  22192. repeatKey?: string;
  22193. }): string;
  22194. /** @hidden */
  22195. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  22196. repeatKey?: string;
  22197. removeAttributes?: boolean;
  22198. removeUniforms?: boolean;
  22199. removeVaryings?: boolean;
  22200. removeIfDef?: boolean;
  22201. replaceStrings?: {
  22202. search: RegExp;
  22203. replace: string;
  22204. }[];
  22205. }, storeKey?: string): void;
  22206. /** @hidden */
  22207. _registerTempVariable(name: string): boolean;
  22208. /** @hidden */
  22209. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  22210. /** @hidden */
  22211. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  22212. /** @hidden */
  22213. _emitFloat(value: number): string;
  22214. }
  22215. }
  22216. declare module "babylonjs/Misc/uniqueIdGenerator" {
  22217. /**
  22218. * Helper class used to generate session unique ID
  22219. */
  22220. export class UniqueIdGenerator {
  22221. private static _UniqueIdCounter;
  22222. /**
  22223. * Gets an unique (relatively to the current scene) Id
  22224. */
  22225. static get UniqueId(): number;
  22226. }
  22227. }
  22228. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  22229. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22230. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22231. import { Nullable } from "babylonjs/types";
  22232. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22233. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22234. import { Effect } from "babylonjs/Materials/effect";
  22235. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22236. import { Mesh } from "babylonjs/Meshes/mesh";
  22237. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22238. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22239. import { Scene } from "babylonjs/scene";
  22240. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  22241. /**
  22242. * Defines a block that can be used inside a node based material
  22243. */
  22244. export class NodeMaterialBlock {
  22245. private _buildId;
  22246. private _buildTarget;
  22247. private _target;
  22248. private _isFinalMerger;
  22249. private _isInput;
  22250. private _name;
  22251. protected _isUnique: boolean;
  22252. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  22253. inputsAreExclusive: boolean;
  22254. /** @hidden */
  22255. _codeVariableName: string;
  22256. /** @hidden */
  22257. _inputs: NodeMaterialConnectionPoint[];
  22258. /** @hidden */
  22259. _outputs: NodeMaterialConnectionPoint[];
  22260. /** @hidden */
  22261. _preparationId: number;
  22262. /**
  22263. * Gets the name of the block
  22264. */
  22265. get name(): string;
  22266. /**
  22267. * Sets the name of the block. Will check if the name is valid.
  22268. */
  22269. set name(newName: string);
  22270. /**
  22271. * Gets or sets the unique id of the node
  22272. */
  22273. uniqueId: number;
  22274. /**
  22275. * Gets or sets the comments associated with this block
  22276. */
  22277. comments: string;
  22278. /**
  22279. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  22280. */
  22281. get isUnique(): boolean;
  22282. /**
  22283. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  22284. */
  22285. get isFinalMerger(): boolean;
  22286. /**
  22287. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  22288. */
  22289. get isInput(): boolean;
  22290. /**
  22291. * Gets or sets the build Id
  22292. */
  22293. get buildId(): number;
  22294. set buildId(value: number);
  22295. /**
  22296. * Gets or sets the target of the block
  22297. */
  22298. get target(): NodeMaterialBlockTargets;
  22299. set target(value: NodeMaterialBlockTargets);
  22300. /**
  22301. * Gets the list of input points
  22302. */
  22303. get inputs(): NodeMaterialConnectionPoint[];
  22304. /** Gets the list of output points */
  22305. get outputs(): NodeMaterialConnectionPoint[];
  22306. /**
  22307. * Find an input by its name
  22308. * @param name defines the name of the input to look for
  22309. * @returns the input or null if not found
  22310. */
  22311. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22312. /**
  22313. * Find an output by its name
  22314. * @param name defines the name of the outputto look for
  22315. * @returns the output or null if not found
  22316. */
  22317. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22318. /**
  22319. * Creates a new NodeMaterialBlock
  22320. * @param name defines the block name
  22321. * @param target defines the target of that block (Vertex by default)
  22322. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  22323. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  22324. */
  22325. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  22326. /**
  22327. * Initialize the block and prepare the context for build
  22328. * @param state defines the state that will be used for the build
  22329. */
  22330. initialize(state: NodeMaterialBuildState): void;
  22331. /**
  22332. * Bind data to effect. Will only be called for blocks with isBindable === true
  22333. * @param effect defines the effect to bind data to
  22334. * @param nodeMaterial defines the hosting NodeMaterial
  22335. * @param mesh defines the mesh that will be rendered
  22336. * @param subMesh defines the submesh that will be rendered
  22337. */
  22338. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  22339. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  22340. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  22341. protected _writeFloat(value: number): string;
  22342. /**
  22343. * Gets the current class name e.g. "NodeMaterialBlock"
  22344. * @returns the class name
  22345. */
  22346. getClassName(): string;
  22347. /**
  22348. * Register a new input. Must be called inside a block constructor
  22349. * @param name defines the connection point name
  22350. * @param type defines the connection point type
  22351. * @param isOptional defines a boolean indicating that this input can be omitted
  22352. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22353. * @param point an already created connection point. If not provided, create a new one
  22354. * @returns the current block
  22355. */
  22356. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22357. /**
  22358. * Register a new output. Must be called inside a block constructor
  22359. * @param name defines the connection point name
  22360. * @param type defines the connection point type
  22361. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22362. * @param point an already created connection point. If not provided, create a new one
  22363. * @returns the current block
  22364. */
  22365. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22366. /**
  22367. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  22368. * @param forOutput defines an optional connection point to check compatibility with
  22369. * @returns the first available input or null
  22370. */
  22371. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  22372. /**
  22373. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  22374. * @param forBlock defines an optional block to check compatibility with
  22375. * @returns the first available input or null
  22376. */
  22377. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  22378. /**
  22379. * Gets the sibling of the given output
  22380. * @param current defines the current output
  22381. * @returns the next output in the list or null
  22382. */
  22383. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  22384. /**
  22385. * Connect current block with another block
  22386. * @param other defines the block to connect with
  22387. * @param options define the various options to help pick the right connections
  22388. * @returns the current block
  22389. */
  22390. connectTo(other: NodeMaterialBlock, options?: {
  22391. input?: string;
  22392. output?: string;
  22393. outputSwizzle?: string;
  22394. }): this | undefined;
  22395. protected _buildBlock(state: NodeMaterialBuildState): void;
  22396. /**
  22397. * Add uniforms, samplers and uniform buffers at compilation time
  22398. * @param state defines the state to update
  22399. * @param nodeMaterial defines the node material requesting the update
  22400. * @param defines defines the material defines to update
  22401. * @param uniformBuffers defines the list of uniform buffer names
  22402. */
  22403. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  22404. /**
  22405. * Add potential fallbacks if shader compilation fails
  22406. * @param mesh defines the mesh to be rendered
  22407. * @param fallbacks defines the current prioritized list of fallbacks
  22408. */
  22409. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  22410. /**
  22411. * Initialize defines for shader compilation
  22412. * @param mesh defines the mesh to be rendered
  22413. * @param nodeMaterial defines the node material requesting the update
  22414. * @param defines defines the material defines to update
  22415. * @param useInstances specifies that instances should be used
  22416. */
  22417. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  22418. /**
  22419. * Update defines for shader compilation
  22420. * @param mesh defines the mesh to be rendered
  22421. * @param nodeMaterial defines the node material requesting the update
  22422. * @param defines defines the material defines to update
  22423. * @param useInstances specifies that instances should be used
  22424. * @param subMesh defines which submesh to render
  22425. */
  22426. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22427. /**
  22428. * Lets the block try to connect some inputs automatically
  22429. * @param material defines the hosting NodeMaterial
  22430. */
  22431. autoConfigure(material: NodeMaterial): void;
  22432. /**
  22433. * Function called when a block is declared as repeatable content generator
  22434. * @param vertexShaderState defines the current compilation state for the vertex shader
  22435. * @param fragmentShaderState defines the current compilation state for the fragment shader
  22436. * @param mesh defines the mesh to be rendered
  22437. * @param defines defines the material defines to update
  22438. */
  22439. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  22440. /**
  22441. * Checks if the block is ready
  22442. * @param mesh defines the mesh to be rendered
  22443. * @param nodeMaterial defines the node material requesting the update
  22444. * @param defines defines the material defines to update
  22445. * @param useInstances specifies that instances should be used
  22446. * @returns true if the block is ready
  22447. */
  22448. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  22449. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  22450. private _processBuild;
  22451. /**
  22452. * Validates the new name for the block node.
  22453. * @param newName the new name to be given to the node.
  22454. * @returns false if the name is a reserve word, else true.
  22455. */
  22456. validateBlockName(newName: string): boolean;
  22457. /**
  22458. * Compile the current node and generate the shader code
  22459. * @param state defines the current compilation state (uniforms, samplers, current string)
  22460. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  22461. * @returns true if already built
  22462. */
  22463. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  22464. protected _inputRename(name: string): string;
  22465. protected _outputRename(name: string): string;
  22466. protected _dumpPropertiesCode(): string;
  22467. /** @hidden */
  22468. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  22469. /** @hidden */
  22470. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  22471. /**
  22472. * Clone the current block to a new identical block
  22473. * @param scene defines the hosting scene
  22474. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22475. * @returns a copy of the current block
  22476. */
  22477. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  22478. /**
  22479. * Serializes this block in a JSON representation
  22480. * @returns the serialized block object
  22481. */
  22482. serialize(): any;
  22483. /** @hidden */
  22484. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22485. private _deserializePortDisplayNamesAndExposedOnFrame;
  22486. /**
  22487. * Release resources
  22488. */
  22489. dispose(): void;
  22490. }
  22491. }
  22492. declare module "babylonjs/Materials/pushMaterial" {
  22493. import { Nullable } from "babylonjs/types";
  22494. import { Scene } from "babylonjs/scene";
  22495. import { Matrix } from "babylonjs/Maths/math.vector";
  22496. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22497. import { Mesh } from "babylonjs/Meshes/mesh";
  22498. import { Material } from "babylonjs/Materials/material";
  22499. import { Effect } from "babylonjs/Materials/effect";
  22500. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22501. /**
  22502. * Base class of materials working in push mode in babylon JS
  22503. * @hidden
  22504. */
  22505. export class PushMaterial extends Material {
  22506. protected _activeEffect: Effect;
  22507. protected _normalMatrix: Matrix;
  22508. constructor(name: string, scene: Scene);
  22509. getEffect(): Effect;
  22510. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22511. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  22512. /**
  22513. * Binds the given world matrix to the active effect
  22514. *
  22515. * @param world the matrix to bind
  22516. */
  22517. bindOnlyWorldMatrix(world: Matrix): void;
  22518. /**
  22519. * Binds the given normal matrix to the active effect
  22520. *
  22521. * @param normalMatrix the matrix to bind
  22522. */
  22523. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  22524. bind(world: Matrix, mesh?: Mesh): void;
  22525. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  22526. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  22527. }
  22528. }
  22529. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  22530. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22531. /**
  22532. * Root class for all node material optimizers
  22533. */
  22534. export class NodeMaterialOptimizer {
  22535. /**
  22536. * Function used to optimize a NodeMaterial graph
  22537. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  22538. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  22539. */
  22540. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  22541. }
  22542. }
  22543. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  22544. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22545. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22546. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22547. import { Scene } from "babylonjs/scene";
  22548. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22549. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22550. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22551. /**
  22552. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  22553. */
  22554. export class TransformBlock extends NodeMaterialBlock {
  22555. /**
  22556. * Defines the value to use to complement W value to transform it to a Vector4
  22557. */
  22558. complementW: number;
  22559. /**
  22560. * Defines the value to use to complement z value to transform it to a Vector4
  22561. */
  22562. complementZ: number;
  22563. /**
  22564. * Creates a new TransformBlock
  22565. * @param name defines the block name
  22566. */
  22567. constructor(name: string);
  22568. /**
  22569. * Gets the current class name
  22570. * @returns the class name
  22571. */
  22572. getClassName(): string;
  22573. /**
  22574. * Gets the vector input
  22575. */
  22576. get vector(): NodeMaterialConnectionPoint;
  22577. /**
  22578. * Gets the output component
  22579. */
  22580. get output(): NodeMaterialConnectionPoint;
  22581. /**
  22582. * Gets the xyz output component
  22583. */
  22584. get xyz(): NodeMaterialConnectionPoint;
  22585. /**
  22586. * Gets the matrix transform input
  22587. */
  22588. get transform(): NodeMaterialConnectionPoint;
  22589. protected _buildBlock(state: NodeMaterialBuildState): this;
  22590. /**
  22591. * Update defines for shader compilation
  22592. * @param mesh defines the mesh to be rendered
  22593. * @param nodeMaterial defines the node material requesting the update
  22594. * @param defines defines the material defines to update
  22595. * @param useInstances specifies that instances should be used
  22596. * @param subMesh defines which submesh to render
  22597. */
  22598. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22599. serialize(): any;
  22600. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22601. protected _dumpPropertiesCode(): string;
  22602. }
  22603. }
  22604. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  22605. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22606. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22607. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22608. /**
  22609. * Block used to output the vertex position
  22610. */
  22611. export class VertexOutputBlock extends NodeMaterialBlock {
  22612. /**
  22613. * Creates a new VertexOutputBlock
  22614. * @param name defines the block name
  22615. */
  22616. constructor(name: string);
  22617. /**
  22618. * Gets the current class name
  22619. * @returns the class name
  22620. */
  22621. getClassName(): string;
  22622. /**
  22623. * Gets the vector input component
  22624. */
  22625. get vector(): NodeMaterialConnectionPoint;
  22626. protected _buildBlock(state: NodeMaterialBuildState): this;
  22627. }
  22628. }
  22629. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  22630. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22631. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22632. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22633. /**
  22634. * Block used to output the final color
  22635. */
  22636. export class FragmentOutputBlock extends NodeMaterialBlock {
  22637. /**
  22638. * Create a new FragmentOutputBlock
  22639. * @param name defines the block name
  22640. */
  22641. constructor(name: string);
  22642. /**
  22643. * Gets the current class name
  22644. * @returns the class name
  22645. */
  22646. getClassName(): string;
  22647. /**
  22648. * Gets the rgba input component
  22649. */
  22650. get rgba(): NodeMaterialConnectionPoint;
  22651. /**
  22652. * Gets the rgb input component
  22653. */
  22654. get rgb(): NodeMaterialConnectionPoint;
  22655. /**
  22656. * Gets the a input component
  22657. */
  22658. get a(): NodeMaterialConnectionPoint;
  22659. protected _buildBlock(state: NodeMaterialBuildState): this;
  22660. }
  22661. }
  22662. declare module "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock" {
  22663. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22664. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22665. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22666. /**
  22667. * Block used for the particle ramp gradient section
  22668. */
  22669. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  22670. /**
  22671. * Create a new ParticleRampGradientBlock
  22672. * @param name defines the block name
  22673. */
  22674. constructor(name: string);
  22675. /**
  22676. * Gets the current class name
  22677. * @returns the class name
  22678. */
  22679. getClassName(): string;
  22680. /**
  22681. * Gets the color input component
  22682. */
  22683. get color(): NodeMaterialConnectionPoint;
  22684. /**
  22685. * Gets the rampColor output component
  22686. */
  22687. get rampColor(): NodeMaterialConnectionPoint;
  22688. /**
  22689. * Initialize the block and prepare the context for build
  22690. * @param state defines the state that will be used for the build
  22691. */
  22692. initialize(state: NodeMaterialBuildState): void;
  22693. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22694. }
  22695. }
  22696. declare module "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock" {
  22697. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22698. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22699. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22700. /**
  22701. * Block used for the particle blend multiply section
  22702. */
  22703. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22704. /**
  22705. * Create a new ParticleBlendMultiplyBlock
  22706. * @param name defines the block name
  22707. */
  22708. constructor(name: string);
  22709. /**
  22710. * Gets the current class name
  22711. * @returns the class name
  22712. */
  22713. getClassName(): string;
  22714. /**
  22715. * Gets the color input component
  22716. */
  22717. get color(): NodeMaterialConnectionPoint;
  22718. /**
  22719. * Gets the alphaTexture input component
  22720. */
  22721. get alphaTexture(): NodeMaterialConnectionPoint;
  22722. /**
  22723. * Gets the alphaColor input component
  22724. */
  22725. get alphaColor(): NodeMaterialConnectionPoint;
  22726. /**
  22727. * Gets the blendColor output component
  22728. */
  22729. get blendColor(): NodeMaterialConnectionPoint;
  22730. /**
  22731. * Initialize the block and prepare the context for build
  22732. * @param state defines the state that will be used for the build
  22733. */
  22734. initialize(state: NodeMaterialBuildState): void;
  22735. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22736. }
  22737. }
  22738. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  22739. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22740. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22741. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22742. /**
  22743. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22744. */
  22745. export class VectorMergerBlock extends NodeMaterialBlock {
  22746. /**
  22747. * Create a new VectorMergerBlock
  22748. * @param name defines the block name
  22749. */
  22750. constructor(name: string);
  22751. /**
  22752. * Gets the current class name
  22753. * @returns the class name
  22754. */
  22755. getClassName(): string;
  22756. /**
  22757. * Gets the xyz component (input)
  22758. */
  22759. get xyzIn(): NodeMaterialConnectionPoint;
  22760. /**
  22761. * Gets the xy component (input)
  22762. */
  22763. get xyIn(): NodeMaterialConnectionPoint;
  22764. /**
  22765. * Gets the x component (input)
  22766. */
  22767. get x(): NodeMaterialConnectionPoint;
  22768. /**
  22769. * Gets the y component (input)
  22770. */
  22771. get y(): NodeMaterialConnectionPoint;
  22772. /**
  22773. * Gets the z component (input)
  22774. */
  22775. get z(): NodeMaterialConnectionPoint;
  22776. /**
  22777. * Gets the w component (input)
  22778. */
  22779. get w(): NodeMaterialConnectionPoint;
  22780. /**
  22781. * Gets the xyzw component (output)
  22782. */
  22783. get xyzw(): NodeMaterialConnectionPoint;
  22784. /**
  22785. * Gets the xyz component (output)
  22786. */
  22787. get xyzOut(): NodeMaterialConnectionPoint;
  22788. /**
  22789. * Gets the xy component (output)
  22790. */
  22791. get xyOut(): NodeMaterialConnectionPoint;
  22792. /**
  22793. * Gets the xy component (output)
  22794. * @deprecated Please use xyOut instead.
  22795. */
  22796. get xy(): NodeMaterialConnectionPoint;
  22797. /**
  22798. * Gets the xyz component (output)
  22799. * @deprecated Please use xyzOut instead.
  22800. */
  22801. get xyz(): NodeMaterialConnectionPoint;
  22802. protected _buildBlock(state: NodeMaterialBuildState): this;
  22803. }
  22804. }
  22805. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  22806. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22807. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22808. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22809. import { Vector2 } from "babylonjs/Maths/math.vector";
  22810. import { Scene } from "babylonjs/scene";
  22811. /**
  22812. * Block used to remap a float from a range to a new one
  22813. */
  22814. export class RemapBlock extends NodeMaterialBlock {
  22815. /**
  22816. * Gets or sets the source range
  22817. */
  22818. sourceRange: Vector2;
  22819. /**
  22820. * Gets or sets the target range
  22821. */
  22822. targetRange: Vector2;
  22823. /**
  22824. * Creates a new RemapBlock
  22825. * @param name defines the block name
  22826. */
  22827. constructor(name: string);
  22828. /**
  22829. * Gets the current class name
  22830. * @returns the class name
  22831. */
  22832. getClassName(): string;
  22833. /**
  22834. * Gets the input component
  22835. */
  22836. get input(): NodeMaterialConnectionPoint;
  22837. /**
  22838. * Gets the source min input component
  22839. */
  22840. get sourceMin(): NodeMaterialConnectionPoint;
  22841. /**
  22842. * Gets the source max input component
  22843. */
  22844. get sourceMax(): NodeMaterialConnectionPoint;
  22845. /**
  22846. * Gets the target min input component
  22847. */
  22848. get targetMin(): NodeMaterialConnectionPoint;
  22849. /**
  22850. * Gets the target max input component
  22851. */
  22852. get targetMax(): NodeMaterialConnectionPoint;
  22853. /**
  22854. * Gets the output component
  22855. */
  22856. get output(): NodeMaterialConnectionPoint;
  22857. protected _buildBlock(state: NodeMaterialBuildState): this;
  22858. protected _dumpPropertiesCode(): string;
  22859. serialize(): any;
  22860. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22861. }
  22862. }
  22863. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  22864. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22865. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22866. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22867. /**
  22868. * Block used to multiply 2 values
  22869. */
  22870. export class MultiplyBlock extends NodeMaterialBlock {
  22871. /**
  22872. * Creates a new MultiplyBlock
  22873. * @param name defines the block name
  22874. */
  22875. constructor(name: string);
  22876. /**
  22877. * Gets the current class name
  22878. * @returns the class name
  22879. */
  22880. getClassName(): string;
  22881. /**
  22882. * Gets the left operand input component
  22883. */
  22884. get left(): NodeMaterialConnectionPoint;
  22885. /**
  22886. * Gets the right operand input component
  22887. */
  22888. get right(): NodeMaterialConnectionPoint;
  22889. /**
  22890. * Gets the output component
  22891. */
  22892. get output(): NodeMaterialConnectionPoint;
  22893. protected _buildBlock(state: NodeMaterialBuildState): this;
  22894. }
  22895. }
  22896. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  22897. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22898. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22899. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22900. /**
  22901. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  22902. */
  22903. export class ColorSplitterBlock extends NodeMaterialBlock {
  22904. /**
  22905. * Create a new ColorSplitterBlock
  22906. * @param name defines the block name
  22907. */
  22908. constructor(name: string);
  22909. /**
  22910. * Gets the current class name
  22911. * @returns the class name
  22912. */
  22913. getClassName(): string;
  22914. /**
  22915. * Gets the rgba component (input)
  22916. */
  22917. get rgba(): NodeMaterialConnectionPoint;
  22918. /**
  22919. * Gets the rgb component (input)
  22920. */
  22921. get rgbIn(): NodeMaterialConnectionPoint;
  22922. /**
  22923. * Gets the rgb component (output)
  22924. */
  22925. get rgbOut(): NodeMaterialConnectionPoint;
  22926. /**
  22927. * Gets the r component (output)
  22928. */
  22929. get r(): NodeMaterialConnectionPoint;
  22930. /**
  22931. * Gets the g component (output)
  22932. */
  22933. get g(): NodeMaterialConnectionPoint;
  22934. /**
  22935. * Gets the b component (output)
  22936. */
  22937. get b(): NodeMaterialConnectionPoint;
  22938. /**
  22939. * Gets the a component (output)
  22940. */
  22941. get a(): NodeMaterialConnectionPoint;
  22942. protected _inputRename(name: string): string;
  22943. protected _outputRename(name: string): string;
  22944. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22945. }
  22946. }
  22947. declare module "babylonjs/Materials/Node/nodeMaterial" {
  22948. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22949. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  22950. import { Scene } from "babylonjs/scene";
  22951. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22952. import { Matrix } from "babylonjs/Maths/math.vector";
  22953. import { Mesh } from "babylonjs/Meshes/mesh";
  22954. import { Engine } from "babylonjs/Engines/engine";
  22955. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22956. import { Observable } from "babylonjs/Misc/observable";
  22957. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22958. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22959. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  22960. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  22961. import { Nullable } from "babylonjs/types";
  22962. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  22963. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  22964. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  22965. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  22966. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  22967. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  22968. import { Effect } from "babylonjs/Materials/effect";
  22969. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  22970. import { Camera } from "babylonjs/Cameras/camera";
  22971. import { NodeMaterialModes } from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  22972. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  22973. /**
  22974. * Interface used to configure the node material editor
  22975. */
  22976. export interface INodeMaterialEditorOptions {
  22977. /** Define the URl to load node editor script */
  22978. editorURL?: string;
  22979. }
  22980. /** @hidden */
  22981. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  22982. NORMAL: boolean;
  22983. TANGENT: boolean;
  22984. UV1: boolean;
  22985. /** BONES */
  22986. NUM_BONE_INFLUENCERS: number;
  22987. BonesPerMesh: number;
  22988. BONETEXTURE: boolean;
  22989. /** MORPH TARGETS */
  22990. MORPHTARGETS: boolean;
  22991. MORPHTARGETS_NORMAL: boolean;
  22992. MORPHTARGETS_TANGENT: boolean;
  22993. MORPHTARGETS_UV: boolean;
  22994. NUM_MORPH_INFLUENCERS: number;
  22995. /** IMAGE PROCESSING */
  22996. IMAGEPROCESSING: boolean;
  22997. VIGNETTE: boolean;
  22998. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22999. VIGNETTEBLENDMODEOPAQUE: boolean;
  23000. TONEMAPPING: boolean;
  23001. TONEMAPPING_ACES: boolean;
  23002. CONTRAST: boolean;
  23003. EXPOSURE: boolean;
  23004. COLORCURVES: boolean;
  23005. COLORGRADING: boolean;
  23006. COLORGRADING3D: boolean;
  23007. SAMPLER3DGREENDEPTH: boolean;
  23008. SAMPLER3DBGRMAP: boolean;
  23009. IMAGEPROCESSINGPOSTPROCESS: boolean;
  23010. /** MISC. */
  23011. BUMPDIRECTUV: number;
  23012. constructor();
  23013. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  23014. }
  23015. /**
  23016. * Class used to configure NodeMaterial
  23017. */
  23018. export interface INodeMaterialOptions {
  23019. /**
  23020. * Defines if blocks should emit comments
  23021. */
  23022. emitComments: boolean;
  23023. }
  23024. /**
  23025. * Class used to create a node based material built by assembling shader blocks
  23026. */
  23027. export class NodeMaterial extends PushMaterial {
  23028. private static _BuildIdGenerator;
  23029. private _options;
  23030. private _vertexCompilationState;
  23031. private _fragmentCompilationState;
  23032. private _sharedData;
  23033. private _buildId;
  23034. private _buildWasSuccessful;
  23035. private _cachedWorldViewMatrix;
  23036. private _cachedWorldViewProjectionMatrix;
  23037. private _optimizers;
  23038. private _animationFrame;
  23039. /** Define the Url to load node editor script */
  23040. static EditorURL: string;
  23041. /** Define the Url to load snippets */
  23042. static SnippetUrl: string;
  23043. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  23044. static IgnoreTexturesAtLoadTime: boolean;
  23045. private BJSNODEMATERIALEDITOR;
  23046. /** Get the inspector from bundle or global */
  23047. private _getGlobalNodeMaterialEditor;
  23048. /**
  23049. * Snippet ID if the material was created from the snippet server
  23050. */
  23051. snippetId: string;
  23052. /**
  23053. * Gets or sets data used by visual editor
  23054. * @see https://nme.babylonjs.com
  23055. */
  23056. editorData: any;
  23057. /**
  23058. * 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)
  23059. */
  23060. ignoreAlpha: boolean;
  23061. /**
  23062. * Defines the maximum number of lights that can be used in the material
  23063. */
  23064. maxSimultaneousLights: number;
  23065. /**
  23066. * Observable raised when the material is built
  23067. */
  23068. onBuildObservable: Observable<NodeMaterial>;
  23069. /**
  23070. * Gets or sets the root nodes of the material vertex shader
  23071. */
  23072. _vertexOutputNodes: NodeMaterialBlock[];
  23073. /**
  23074. * Gets or sets the root nodes of the material fragment (pixel) shader
  23075. */
  23076. _fragmentOutputNodes: NodeMaterialBlock[];
  23077. /** Gets or sets options to control the node material overall behavior */
  23078. get options(): INodeMaterialOptions;
  23079. set options(options: INodeMaterialOptions);
  23080. /**
  23081. * Default configuration related to image processing available in the standard Material.
  23082. */
  23083. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23084. /**
  23085. * Gets the image processing configuration used either in this material.
  23086. */
  23087. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23088. /**
  23089. * Sets the Default image processing configuration used either in the this material.
  23090. *
  23091. * If sets to null, the scene one is in use.
  23092. */
  23093. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23094. /**
  23095. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  23096. */
  23097. attachedBlocks: NodeMaterialBlock[];
  23098. /**
  23099. * Specifies the mode of the node material
  23100. * @hidden
  23101. */
  23102. _mode: NodeMaterialModes;
  23103. /**
  23104. * Gets the mode property
  23105. */
  23106. get mode(): NodeMaterialModes;
  23107. /**
  23108. * Create a new node based material
  23109. * @param name defines the material name
  23110. * @param scene defines the hosting scene
  23111. * @param options defines creation option
  23112. */
  23113. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  23114. /**
  23115. * Gets the current class name of the material e.g. "NodeMaterial"
  23116. * @returns the class name
  23117. */
  23118. getClassName(): string;
  23119. /**
  23120. * Keep track of the image processing observer to allow dispose and replace.
  23121. */
  23122. private _imageProcessingObserver;
  23123. /**
  23124. * Attaches a new image processing configuration to the Standard Material.
  23125. * @param configuration
  23126. */
  23127. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  23128. /**
  23129. * Get a block by its name
  23130. * @param name defines the name of the block to retrieve
  23131. * @returns the required block or null if not found
  23132. */
  23133. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  23134. /**
  23135. * Get a block by its name
  23136. * @param predicate defines the predicate used to find the good candidate
  23137. * @returns the required block or null if not found
  23138. */
  23139. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  23140. /**
  23141. * Get an input block by its name
  23142. * @param predicate defines the predicate used to find the good candidate
  23143. * @returns the required input block or null if not found
  23144. */
  23145. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  23146. /**
  23147. * Gets the list of input blocks attached to this material
  23148. * @returns an array of InputBlocks
  23149. */
  23150. getInputBlocks(): InputBlock[];
  23151. /**
  23152. * Adds a new optimizer to the list of optimizers
  23153. * @param optimizer defines the optimizers to add
  23154. * @returns the current material
  23155. */
  23156. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23157. /**
  23158. * Remove an optimizer from the list of optimizers
  23159. * @param optimizer defines the optimizers to remove
  23160. * @returns the current material
  23161. */
  23162. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23163. /**
  23164. * Add a new block to the list of output nodes
  23165. * @param node defines the node to add
  23166. * @returns the current material
  23167. */
  23168. addOutputNode(node: NodeMaterialBlock): this;
  23169. /**
  23170. * Remove a block from the list of root nodes
  23171. * @param node defines the node to remove
  23172. * @returns the current material
  23173. */
  23174. removeOutputNode(node: NodeMaterialBlock): this;
  23175. private _addVertexOutputNode;
  23176. private _removeVertexOutputNode;
  23177. private _addFragmentOutputNode;
  23178. private _removeFragmentOutputNode;
  23179. /**
  23180. * Specifies if the material will require alpha blending
  23181. * @returns a boolean specifying if alpha blending is needed
  23182. */
  23183. needAlphaBlending(): boolean;
  23184. /**
  23185. * Specifies if this material should be rendered in alpha test mode
  23186. * @returns a boolean specifying if an alpha test is needed.
  23187. */
  23188. needAlphaTesting(): boolean;
  23189. private _initializeBlock;
  23190. private _resetDualBlocks;
  23191. /**
  23192. * Remove a block from the current node material
  23193. * @param block defines the block to remove
  23194. */
  23195. removeBlock(block: NodeMaterialBlock): void;
  23196. /**
  23197. * Build the material and generates the inner effect
  23198. * @param verbose defines if the build should log activity
  23199. */
  23200. build(verbose?: boolean): void;
  23201. /**
  23202. * Runs an otpimization phase to try to improve the shader code
  23203. */
  23204. optimize(): void;
  23205. private _prepareDefinesForAttributes;
  23206. /**
  23207. * Create a post process from the material
  23208. * @param camera The camera to apply the render pass to.
  23209. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23210. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23211. * @param engine The engine which the post process will be applied. (default: current engine)
  23212. * @param reusable If the post process can be reused on the same frame. (default: false)
  23213. * @param textureType Type of textures used when performing the post process. (default: 0)
  23214. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23215. * @returns the post process created
  23216. */
  23217. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  23218. /**
  23219. * Create the post process effect from the material
  23220. * @param postProcess The post process to create the effect for
  23221. */
  23222. createEffectForPostProcess(postProcess: PostProcess): void;
  23223. private _createEffectOrPostProcess;
  23224. private _createEffectForParticles;
  23225. /**
  23226. * Create the effect to be used as the custom effect for a particle system
  23227. * @param particleSystem Particle system to create the effect for
  23228. * @param onCompiled defines a function to call when the effect creation is successful
  23229. * @param onError defines a function to call when the effect creation has failed
  23230. */
  23231. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23232. private _processDefines;
  23233. /**
  23234. * Get if the submesh is ready to be used and all its information available.
  23235. * Child classes can use it to update shaders
  23236. * @param mesh defines the mesh to check
  23237. * @param subMesh defines which submesh to check
  23238. * @param useInstances specifies that instances should be used
  23239. * @returns a boolean indicating that the submesh is ready or not
  23240. */
  23241. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  23242. /**
  23243. * Get a string representing the shaders built by the current node graph
  23244. */
  23245. get compiledShaders(): string;
  23246. /**
  23247. * Binds the world matrix to the material
  23248. * @param world defines the world transformation matrix
  23249. */
  23250. bindOnlyWorldMatrix(world: Matrix): void;
  23251. /**
  23252. * Binds the submesh to this material by preparing the effect and shader to draw
  23253. * @param world defines the world transformation matrix
  23254. * @param mesh defines the mesh containing the submesh
  23255. * @param subMesh defines the submesh to bind the material to
  23256. */
  23257. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23258. /**
  23259. * Gets the active textures from the material
  23260. * @returns an array of textures
  23261. */
  23262. getActiveTextures(): BaseTexture[];
  23263. /**
  23264. * Gets the list of texture blocks
  23265. * @returns an array of texture blocks
  23266. */
  23267. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  23268. /**
  23269. * Specifies if the material uses a texture
  23270. * @param texture defines the texture to check against the material
  23271. * @returns a boolean specifying if the material uses the texture
  23272. */
  23273. hasTexture(texture: BaseTexture): boolean;
  23274. /**
  23275. * Disposes the material
  23276. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23277. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23278. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23279. */
  23280. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23281. /** Creates the node editor window. */
  23282. private _createNodeEditor;
  23283. /**
  23284. * Launch the node material editor
  23285. * @param config Define the configuration of the editor
  23286. * @return a promise fulfilled when the node editor is visible
  23287. */
  23288. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  23289. /**
  23290. * Clear the current material
  23291. */
  23292. clear(): void;
  23293. /**
  23294. * Clear the current material and set it to a default state
  23295. */
  23296. setToDefault(): void;
  23297. /**
  23298. * Clear the current material and set it to a default state for post process
  23299. */
  23300. setToDefaultPostProcess(): void;
  23301. /**
  23302. * Clear the current material and set it to a default state for particle
  23303. */
  23304. setToDefaultParticle(): void;
  23305. /**
  23306. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  23307. * @param url defines the url to load from
  23308. * @returns a promise that will fullfil when the material is fully loaded
  23309. */
  23310. loadAsync(url: string): Promise<void>;
  23311. private _gatherBlocks;
  23312. /**
  23313. * Generate a string containing the code declaration required to create an equivalent of this material
  23314. * @returns a string
  23315. */
  23316. generateCode(): string;
  23317. /**
  23318. * Serializes this material in a JSON representation
  23319. * @returns the serialized material object
  23320. */
  23321. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  23322. private _restoreConnections;
  23323. /**
  23324. * Clear the current graph and load a new one from a serialization object
  23325. * @param source defines the JSON representation of the material
  23326. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23327. * @param merge defines whether or not the source must be merged or replace the current content
  23328. */
  23329. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  23330. /**
  23331. * Makes a duplicate of the current material.
  23332. * @param name - name to use for the new material.
  23333. */
  23334. clone(name: string): NodeMaterial;
  23335. /**
  23336. * Creates a node material from parsed material data
  23337. * @param source defines the JSON representation of the material
  23338. * @param scene defines the hosting scene
  23339. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23340. * @returns a new node material
  23341. */
  23342. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  23343. /**
  23344. * Creates a node material from a snippet saved in a remote file
  23345. * @param name defines the name of the material to create
  23346. * @param url defines the url to load from
  23347. * @param scene defines the hosting scene
  23348. * @returns a promise that will resolve to the new node material
  23349. */
  23350. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  23351. /**
  23352. * Creates a node material from a snippet saved by the node material editor
  23353. * @param snippetId defines the snippet to load
  23354. * @param scene defines the hosting scene
  23355. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23356. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  23357. * @returns a promise that will resolve to the new node material
  23358. */
  23359. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  23360. /**
  23361. * Creates a new node material set to default basic configuration
  23362. * @param name defines the name of the material
  23363. * @param scene defines the hosting scene
  23364. * @returns a new NodeMaterial
  23365. */
  23366. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  23367. }
  23368. }
  23369. declare module "babylonjs/PostProcesses/postProcess" {
  23370. import { Nullable } from "babylonjs/types";
  23371. import { SmartArray } from "babylonjs/Misc/smartArray";
  23372. import { Observable } from "babylonjs/Misc/observable";
  23373. import { Vector2 } from "babylonjs/Maths/math.vector";
  23374. import { Camera } from "babylonjs/Cameras/camera";
  23375. import { Effect } from "babylonjs/Materials/effect";
  23376. import "babylonjs/Shaders/postprocess.vertex";
  23377. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23378. import { Engine } from "babylonjs/Engines/engine";
  23379. import { Color4 } from "babylonjs/Maths/math.color";
  23380. import "babylonjs/Engines/Extensions/engine.renderTarget";
  23381. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  23382. import { Scene } from "babylonjs/scene";
  23383. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23384. /**
  23385. * Size options for a post process
  23386. */
  23387. export type PostProcessOptions = {
  23388. width: number;
  23389. height: number;
  23390. };
  23391. /**
  23392. * PostProcess can be used to apply a shader to a texture after it has been rendered
  23393. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23394. */
  23395. export class PostProcess {
  23396. /**
  23397. * Gets or sets the unique id of the post process
  23398. */
  23399. uniqueId: number;
  23400. /** Name of the PostProcess. */
  23401. name: string;
  23402. /**
  23403. * Width of the texture to apply the post process on
  23404. */
  23405. width: number;
  23406. /**
  23407. * Height of the texture to apply the post process on
  23408. */
  23409. height: number;
  23410. /**
  23411. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  23412. */
  23413. nodeMaterialSource: Nullable<NodeMaterial>;
  23414. /**
  23415. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  23416. * @hidden
  23417. */
  23418. _outputTexture: Nullable<InternalTexture>;
  23419. /**
  23420. * Sampling mode used by the shader
  23421. * See https://doc.babylonjs.com/classes/3.1/texture
  23422. */
  23423. renderTargetSamplingMode: number;
  23424. /**
  23425. * Clear color to use when screen clearing
  23426. */
  23427. clearColor: Color4;
  23428. /**
  23429. * If the buffer needs to be cleared before applying the post process. (default: true)
  23430. * Should be set to false if shader will overwrite all previous pixels.
  23431. */
  23432. autoClear: boolean;
  23433. /**
  23434. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  23435. */
  23436. alphaMode: number;
  23437. /**
  23438. * Sets the setAlphaBlendConstants of the babylon engine
  23439. */
  23440. alphaConstants: Color4;
  23441. /**
  23442. * Animations to be used for the post processing
  23443. */
  23444. animations: import("babylonjs/Animations/animation").Animation[];
  23445. /**
  23446. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  23447. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  23448. */
  23449. enablePixelPerfectMode: boolean;
  23450. /**
  23451. * Force the postprocess to be applied without taking in account viewport
  23452. */
  23453. forceFullscreenViewport: boolean;
  23454. /**
  23455. * List of inspectable custom properties (used by the Inspector)
  23456. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23457. */
  23458. inspectableCustomProperties: IInspectable[];
  23459. /**
  23460. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  23461. *
  23462. * | Value | Type | Description |
  23463. * | ----- | ----------------------------------- | ----------- |
  23464. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  23465. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  23466. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  23467. *
  23468. */
  23469. scaleMode: number;
  23470. /**
  23471. * Force textures to be a power of two (default: false)
  23472. */
  23473. alwaysForcePOT: boolean;
  23474. private _samples;
  23475. /**
  23476. * Number of sample textures (default: 1)
  23477. */
  23478. get samples(): number;
  23479. set samples(n: number);
  23480. /**
  23481. * Modify the scale of the post process to be the same as the viewport (default: false)
  23482. */
  23483. adaptScaleToCurrentViewport: boolean;
  23484. private _camera;
  23485. protected _scene: Scene;
  23486. private _engine;
  23487. private _options;
  23488. private _reusable;
  23489. private _textureType;
  23490. private _textureFormat;
  23491. /**
  23492. * Smart array of input and output textures for the post process.
  23493. * @hidden
  23494. */
  23495. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  23496. /**
  23497. * The index in _textures that corresponds to the output texture.
  23498. * @hidden
  23499. */
  23500. _currentRenderTextureInd: number;
  23501. private _effect;
  23502. private _samplers;
  23503. private _fragmentUrl;
  23504. private _vertexUrl;
  23505. private _parameters;
  23506. private _scaleRatio;
  23507. protected _indexParameters: any;
  23508. private _shareOutputWithPostProcess;
  23509. private _texelSize;
  23510. private _forcedOutputTexture;
  23511. /**
  23512. * Returns the fragment url or shader name used in the post process.
  23513. * @returns the fragment url or name in the shader store.
  23514. */
  23515. getEffectName(): string;
  23516. /**
  23517. * An event triggered when the postprocess is activated.
  23518. */
  23519. onActivateObservable: Observable<Camera>;
  23520. private _onActivateObserver;
  23521. /**
  23522. * A function that is added to the onActivateObservable
  23523. */
  23524. set onActivate(callback: Nullable<(camera: Camera) => void>);
  23525. /**
  23526. * An event triggered when the postprocess changes its size.
  23527. */
  23528. onSizeChangedObservable: Observable<PostProcess>;
  23529. private _onSizeChangedObserver;
  23530. /**
  23531. * A function that is added to the onSizeChangedObservable
  23532. */
  23533. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  23534. /**
  23535. * An event triggered when the postprocess applies its effect.
  23536. */
  23537. onApplyObservable: Observable<Effect>;
  23538. private _onApplyObserver;
  23539. /**
  23540. * A function that is added to the onApplyObservable
  23541. */
  23542. set onApply(callback: (effect: Effect) => void);
  23543. /**
  23544. * An event triggered before rendering the postprocess
  23545. */
  23546. onBeforeRenderObservable: Observable<Effect>;
  23547. private _onBeforeRenderObserver;
  23548. /**
  23549. * A function that is added to the onBeforeRenderObservable
  23550. */
  23551. set onBeforeRender(callback: (effect: Effect) => void);
  23552. /**
  23553. * An event triggered after rendering the postprocess
  23554. */
  23555. onAfterRenderObservable: Observable<Effect>;
  23556. private _onAfterRenderObserver;
  23557. /**
  23558. * A function that is added to the onAfterRenderObservable
  23559. */
  23560. set onAfterRender(callback: (efect: Effect) => void);
  23561. /**
  23562. * 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
  23563. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  23564. */
  23565. get inputTexture(): InternalTexture;
  23566. set inputTexture(value: InternalTexture);
  23567. /**
  23568. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  23569. * the only way to unset it is to use this function to restore its internal state
  23570. */
  23571. restoreDefaultInputTexture(): void;
  23572. /**
  23573. * Gets the camera which post process is applied to.
  23574. * @returns The camera the post process is applied to.
  23575. */
  23576. getCamera(): Camera;
  23577. /**
  23578. * Gets the texel size of the postprocess.
  23579. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  23580. */
  23581. get texelSize(): Vector2;
  23582. /**
  23583. * Creates a new instance PostProcess
  23584. * @param name The name of the PostProcess.
  23585. * @param fragmentUrl The url of the fragment shader to be used.
  23586. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  23587. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  23588. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23589. * @param camera The camera to apply the render pass to.
  23590. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23591. * @param engine The engine which the post process will be applied. (default: current engine)
  23592. * @param reusable If the post process can be reused on the same frame. (default: false)
  23593. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  23594. * @param textureType Type of textures used when performing the post process. (default: 0)
  23595. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  23596. * @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
  23597. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  23598. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23599. */
  23600. 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);
  23601. /**
  23602. * Gets a string identifying the name of the class
  23603. * @returns "PostProcess" string
  23604. */
  23605. getClassName(): string;
  23606. /**
  23607. * Gets the engine which this post process belongs to.
  23608. * @returns The engine the post process was enabled with.
  23609. */
  23610. getEngine(): Engine;
  23611. /**
  23612. * The effect that is created when initializing the post process.
  23613. * @returns The created effect corresponding the the postprocess.
  23614. */
  23615. getEffect(): Effect;
  23616. /**
  23617. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  23618. * @param postProcess The post process to share the output with.
  23619. * @returns This post process.
  23620. */
  23621. shareOutputWith(postProcess: PostProcess): PostProcess;
  23622. /**
  23623. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  23624. * This should be called if the post process that shares output with this post process is disabled/disposed.
  23625. */
  23626. useOwnOutput(): void;
  23627. /**
  23628. * Updates the effect with the current post process compile time values and recompiles the shader.
  23629. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23630. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23631. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23632. * @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
  23633. * @param onCompiled Called when the shader has been compiled.
  23634. * @param onError Called if there is an error when compiling a shader.
  23635. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  23636. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  23637. */
  23638. 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;
  23639. /**
  23640. * The post process is reusable if it can be used multiple times within one frame.
  23641. * @returns If the post process is reusable
  23642. */
  23643. isReusable(): boolean;
  23644. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  23645. markTextureDirty(): void;
  23646. /**
  23647. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  23648. * 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.
  23649. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  23650. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  23651. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  23652. * @returns The target texture that was bound to be written to.
  23653. */
  23654. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  23655. /**
  23656. * If the post process is supported.
  23657. */
  23658. get isSupported(): boolean;
  23659. /**
  23660. * The aspect ratio of the output texture.
  23661. */
  23662. get aspectRatio(): number;
  23663. /**
  23664. * Get a value indicating if the post-process is ready to be used
  23665. * @returns true if the post-process is ready (shader is compiled)
  23666. */
  23667. isReady(): boolean;
  23668. /**
  23669. * Binds all textures and uniforms to the shader, this will be run on every pass.
  23670. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  23671. */
  23672. apply(): Nullable<Effect>;
  23673. private _disposeTextures;
  23674. /**
  23675. * Disposes the post process.
  23676. * @param camera The camera to dispose the post process on.
  23677. */
  23678. dispose(camera?: Camera): void;
  23679. /**
  23680. * Serializes the particle system to a JSON object
  23681. * @returns the JSON object
  23682. */
  23683. serialize(): any;
  23684. /**
  23685. * Creates a material from parsed material data
  23686. * @param parsedPostProcess defines parsed post process data
  23687. * @param scene defines the hosting scene
  23688. * @param rootUrl defines the root URL to use to load textures
  23689. * @returns a new post process
  23690. */
  23691. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  23692. }
  23693. }
  23694. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  23695. /** @hidden */
  23696. export var kernelBlurVaryingDeclaration: {
  23697. name: string;
  23698. shader: string;
  23699. };
  23700. }
  23701. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  23702. /** @hidden */
  23703. export var kernelBlurFragment: {
  23704. name: string;
  23705. shader: string;
  23706. };
  23707. }
  23708. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  23709. /** @hidden */
  23710. export var kernelBlurFragment2: {
  23711. name: string;
  23712. shader: string;
  23713. };
  23714. }
  23715. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  23716. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23717. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  23718. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  23719. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  23720. /** @hidden */
  23721. export var kernelBlurPixelShader: {
  23722. name: string;
  23723. shader: string;
  23724. };
  23725. }
  23726. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  23727. /** @hidden */
  23728. export var kernelBlurVertex: {
  23729. name: string;
  23730. shader: string;
  23731. };
  23732. }
  23733. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  23734. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23735. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  23736. /** @hidden */
  23737. export var kernelBlurVertexShader: {
  23738. name: string;
  23739. shader: string;
  23740. };
  23741. }
  23742. declare module "babylonjs/PostProcesses/blurPostProcess" {
  23743. import { Vector2 } from "babylonjs/Maths/math.vector";
  23744. import { Nullable } from "babylonjs/types";
  23745. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23746. import { Camera } from "babylonjs/Cameras/camera";
  23747. import { Effect } from "babylonjs/Materials/effect";
  23748. import { Engine } from "babylonjs/Engines/engine";
  23749. import "babylonjs/Shaders/kernelBlur.fragment";
  23750. import "babylonjs/Shaders/kernelBlur.vertex";
  23751. import { Scene } from "babylonjs/scene";
  23752. /**
  23753. * The Blur Post Process which blurs an image based on a kernel and direction.
  23754. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  23755. */
  23756. export class BlurPostProcess extends PostProcess {
  23757. private blockCompilation;
  23758. protected _kernel: number;
  23759. protected _idealKernel: number;
  23760. protected _packedFloat: boolean;
  23761. private _staticDefines;
  23762. /** The direction in which to blur the image. */
  23763. direction: Vector2;
  23764. /**
  23765. * Sets the length in pixels of the blur sample region
  23766. */
  23767. set kernel(v: number);
  23768. /**
  23769. * Gets the length in pixels of the blur sample region
  23770. */
  23771. get kernel(): number;
  23772. /**
  23773. * Sets wether or not the blur needs to unpack/repack floats
  23774. */
  23775. set packedFloat(v: boolean);
  23776. /**
  23777. * Gets wether or not the blur is unpacking/repacking floats
  23778. */
  23779. get packedFloat(): boolean;
  23780. /**
  23781. * Gets a string identifying the name of the class
  23782. * @returns "BlurPostProcess" string
  23783. */
  23784. getClassName(): string;
  23785. /**
  23786. * Creates a new instance BlurPostProcess
  23787. * @param name The name of the effect.
  23788. * @param direction The direction in which to blur the image.
  23789. * @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.
  23790. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23791. * @param camera The camera to apply the render pass to.
  23792. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23793. * @param engine The engine which the post process will be applied. (default: current engine)
  23794. * @param reusable If the post process can be reused on the same frame. (default: false)
  23795. * @param textureType Type of textures used when performing the post process. (default: 0)
  23796. * @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)
  23797. */
  23798. 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);
  23799. /**
  23800. * Updates the effect with the current post process compile time values and recompiles the shader.
  23801. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23802. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23803. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23804. * @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
  23805. * @param onCompiled Called when the shader has been compiled.
  23806. * @param onError Called if there is an error when compiling a shader.
  23807. */
  23808. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23809. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23810. /**
  23811. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  23812. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  23813. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  23814. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  23815. * The gaps between physical kernels are compensated for in the weighting of the samples
  23816. * @param idealKernel Ideal blur kernel.
  23817. * @return Nearest best kernel.
  23818. */
  23819. protected _nearestBestKernel(idealKernel: number): number;
  23820. /**
  23821. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  23822. * @param x The point on the Gaussian distribution to sample.
  23823. * @return the value of the Gaussian function at x.
  23824. */
  23825. protected _gaussianWeight(x: number): number;
  23826. /**
  23827. * Generates a string that can be used as a floating point number in GLSL.
  23828. * @param x Value to print.
  23829. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  23830. * @return GLSL float string.
  23831. */
  23832. protected _glslFloat(x: number, decimalFigures?: number): string;
  23833. /** @hidden */
  23834. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  23835. }
  23836. }
  23837. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  23838. import { Scene } from "babylonjs/scene";
  23839. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23840. import { Plane } from "babylonjs/Maths/math.plane";
  23841. /**
  23842. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23843. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23844. * You can then easily use it as a reflectionTexture on a flat surface.
  23845. * In case the surface is not a plane, please consider relying on reflection probes.
  23846. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23847. */
  23848. export class MirrorTexture extends RenderTargetTexture {
  23849. private scene;
  23850. /**
  23851. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  23852. * 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.
  23853. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23854. */
  23855. mirrorPlane: Plane;
  23856. /**
  23857. * Define the blur ratio used to blur the reflection if needed.
  23858. */
  23859. set blurRatio(value: number);
  23860. get blurRatio(): number;
  23861. /**
  23862. * Define the adaptive blur kernel used to blur the reflection if needed.
  23863. * This will autocompute the closest best match for the `blurKernel`
  23864. */
  23865. set adaptiveBlurKernel(value: number);
  23866. /**
  23867. * Define the blur kernel used to blur the reflection if needed.
  23868. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23869. */
  23870. set blurKernel(value: number);
  23871. /**
  23872. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  23873. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23874. */
  23875. set blurKernelX(value: number);
  23876. get blurKernelX(): number;
  23877. /**
  23878. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  23879. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23880. */
  23881. set blurKernelY(value: number);
  23882. get blurKernelY(): number;
  23883. private _autoComputeBlurKernel;
  23884. protected _onRatioRescale(): void;
  23885. private _updateGammaSpace;
  23886. private _imageProcessingConfigChangeObserver;
  23887. private _transformMatrix;
  23888. private _mirrorMatrix;
  23889. private _savedViewMatrix;
  23890. private _blurX;
  23891. private _blurY;
  23892. private _adaptiveBlurKernel;
  23893. private _blurKernelX;
  23894. private _blurKernelY;
  23895. private _blurRatio;
  23896. /**
  23897. * Instantiates a Mirror Texture.
  23898. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23899. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23900. * You can then easily use it as a reflectionTexture on a flat surface.
  23901. * In case the surface is not a plane, please consider relying on reflection probes.
  23902. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23903. * @param name
  23904. * @param size
  23905. * @param scene
  23906. * @param generateMipMaps
  23907. * @param type
  23908. * @param samplingMode
  23909. * @param generateDepthBuffer
  23910. */
  23911. constructor(name: string, size: number | {
  23912. width: number;
  23913. height: number;
  23914. } | {
  23915. ratio: number;
  23916. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  23917. private _preparePostProcesses;
  23918. /**
  23919. * Clone the mirror texture.
  23920. * @returns the cloned texture
  23921. */
  23922. clone(): MirrorTexture;
  23923. /**
  23924. * Serialize the texture to a JSON representation you could use in Parse later on
  23925. * @returns the serialized JSON representation
  23926. */
  23927. serialize(): any;
  23928. /**
  23929. * Dispose the texture and release its associated resources.
  23930. */
  23931. dispose(): void;
  23932. }
  23933. }
  23934. declare module "babylonjs/Materials/Textures/texture" {
  23935. import { Observable } from "babylonjs/Misc/observable";
  23936. import { Nullable } from "babylonjs/types";
  23937. import { Matrix } from "babylonjs/Maths/math.vector";
  23938. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23939. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23940. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  23941. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  23942. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  23943. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23944. import { Scene } from "babylonjs/scene";
  23945. /**
  23946. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23947. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23948. */
  23949. export class Texture extends BaseTexture {
  23950. /**
  23951. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  23952. */
  23953. static SerializeBuffers: boolean;
  23954. /** @hidden */
  23955. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  23956. /** @hidden */
  23957. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  23958. /** @hidden */
  23959. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  23960. /** nearest is mag = nearest and min = nearest and mip = linear */
  23961. static readonly NEAREST_SAMPLINGMODE: number;
  23962. /** nearest is mag = nearest and min = nearest and mip = linear */
  23963. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  23964. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23965. static readonly BILINEAR_SAMPLINGMODE: number;
  23966. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23967. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  23968. /** Trilinear is mag = linear and min = linear and mip = linear */
  23969. static readonly TRILINEAR_SAMPLINGMODE: number;
  23970. /** Trilinear is mag = linear and min = linear and mip = linear */
  23971. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  23972. /** mag = nearest and min = nearest and mip = nearest */
  23973. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  23974. /** mag = nearest and min = linear and mip = nearest */
  23975. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  23976. /** mag = nearest and min = linear and mip = linear */
  23977. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  23978. /** mag = nearest and min = linear and mip = none */
  23979. static readonly NEAREST_LINEAR: number;
  23980. /** mag = nearest and min = nearest and mip = none */
  23981. static readonly NEAREST_NEAREST: number;
  23982. /** mag = linear and min = nearest and mip = nearest */
  23983. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  23984. /** mag = linear and min = nearest and mip = linear */
  23985. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  23986. /** mag = linear and min = linear and mip = none */
  23987. static readonly LINEAR_LINEAR: number;
  23988. /** mag = linear and min = nearest and mip = none */
  23989. static readonly LINEAR_NEAREST: number;
  23990. /** Explicit coordinates mode */
  23991. static readonly EXPLICIT_MODE: number;
  23992. /** Spherical coordinates mode */
  23993. static readonly SPHERICAL_MODE: number;
  23994. /** Planar coordinates mode */
  23995. static readonly PLANAR_MODE: number;
  23996. /** Cubic coordinates mode */
  23997. static readonly CUBIC_MODE: number;
  23998. /** Projection coordinates mode */
  23999. static readonly PROJECTION_MODE: number;
  24000. /** Inverse Cubic coordinates mode */
  24001. static readonly SKYBOX_MODE: number;
  24002. /** Inverse Cubic coordinates mode */
  24003. static readonly INVCUBIC_MODE: number;
  24004. /** Equirectangular coordinates mode */
  24005. static readonly EQUIRECTANGULAR_MODE: number;
  24006. /** Equirectangular Fixed coordinates mode */
  24007. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  24008. /** Equirectangular Fixed Mirrored coordinates mode */
  24009. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  24010. /** Texture is not repeating outside of 0..1 UVs */
  24011. static readonly CLAMP_ADDRESSMODE: number;
  24012. /** Texture is repeating outside of 0..1 UVs */
  24013. static readonly WRAP_ADDRESSMODE: number;
  24014. /** Texture is repeating and mirrored */
  24015. static readonly MIRROR_ADDRESSMODE: number;
  24016. /**
  24017. * 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
  24018. */
  24019. static UseSerializedUrlIfAny: boolean;
  24020. /**
  24021. * Define the url of the texture.
  24022. */
  24023. url: Nullable<string>;
  24024. /**
  24025. * Define an offset on the texture to offset the u coordinates of the UVs
  24026. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  24027. */
  24028. uOffset: number;
  24029. /**
  24030. * Define an offset on the texture to offset the v coordinates of the UVs
  24031. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  24032. */
  24033. vOffset: number;
  24034. /**
  24035. * Define an offset on the texture to scale the u coordinates of the UVs
  24036. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  24037. */
  24038. uScale: number;
  24039. /**
  24040. * Define an offset on the texture to scale the v coordinates of the UVs
  24041. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  24042. */
  24043. vScale: number;
  24044. /**
  24045. * Define an offset on the texture to rotate around the u coordinates of the UVs
  24046. * @see https://doc.babylonjs.com/how_to/more_materials
  24047. */
  24048. uAng: number;
  24049. /**
  24050. * Define an offset on the texture to rotate around the v coordinates of the UVs
  24051. * @see https://doc.babylonjs.com/how_to/more_materials
  24052. */
  24053. vAng: number;
  24054. /**
  24055. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  24056. * @see https://doc.babylonjs.com/how_to/more_materials
  24057. */
  24058. wAng: number;
  24059. /**
  24060. * Defines the center of rotation (U)
  24061. */
  24062. uRotationCenter: number;
  24063. /**
  24064. * Defines the center of rotation (V)
  24065. */
  24066. vRotationCenter: number;
  24067. /**
  24068. * Defines the center of rotation (W)
  24069. */
  24070. wRotationCenter: number;
  24071. /**
  24072. * Are mip maps generated for this texture or not.
  24073. */
  24074. get noMipmap(): boolean;
  24075. /**
  24076. * List of inspectable custom properties (used by the Inspector)
  24077. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24078. */
  24079. inspectableCustomProperties: Nullable<IInspectable[]>;
  24080. private _noMipmap;
  24081. /** @hidden */
  24082. _invertY: boolean;
  24083. private _rowGenerationMatrix;
  24084. private _cachedTextureMatrix;
  24085. private _projectionModeMatrix;
  24086. private _t0;
  24087. private _t1;
  24088. private _t2;
  24089. private _cachedUOffset;
  24090. private _cachedVOffset;
  24091. private _cachedUScale;
  24092. private _cachedVScale;
  24093. private _cachedUAng;
  24094. private _cachedVAng;
  24095. private _cachedWAng;
  24096. private _cachedProjectionMatrixId;
  24097. private _cachedCoordinatesMode;
  24098. /** @hidden */
  24099. protected _initialSamplingMode: number;
  24100. /** @hidden */
  24101. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  24102. private _deleteBuffer;
  24103. protected _format: Nullable<number>;
  24104. private _delayedOnLoad;
  24105. private _delayedOnError;
  24106. private _mimeType?;
  24107. /**
  24108. * Observable triggered once the texture has been loaded.
  24109. */
  24110. onLoadObservable: Observable<Texture>;
  24111. protected _isBlocking: boolean;
  24112. /**
  24113. * Is the texture preventing material to render while loading.
  24114. * If false, a default texture will be used instead of the loading one during the preparation step.
  24115. */
  24116. set isBlocking(value: boolean);
  24117. get isBlocking(): boolean;
  24118. /**
  24119. * Get the current sampling mode associated with the texture.
  24120. */
  24121. get samplingMode(): number;
  24122. /**
  24123. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  24124. */
  24125. get invertY(): boolean;
  24126. /**
  24127. * Instantiates a new texture.
  24128. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  24129. * @see https://doc.babylonjs.com/babylon101/materials#texture
  24130. * @param url defines the url of the picture to load as a texture
  24131. * @param sceneOrEngine defines the scene or engine the texture will belong to
  24132. * @param noMipmap defines if the texture will require mip maps or not
  24133. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  24134. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24135. * @param onLoad defines a callback triggered when the texture has been loaded
  24136. * @param onError defines a callback triggered when an error occurred during the loading session
  24137. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  24138. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  24139. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24140. * @param mimeType defines an optional mime type information
  24141. */
  24142. 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);
  24143. /**
  24144. * Update the url (and optional buffer) of this texture if url was null during construction.
  24145. * @param url the url of the texture
  24146. * @param buffer the buffer of the texture (defaults to null)
  24147. * @param onLoad callback called when the texture is loaded (defaults to null)
  24148. */
  24149. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  24150. /**
  24151. * Finish the loading sequence of a texture flagged as delayed load.
  24152. * @hidden
  24153. */
  24154. delayLoad(): void;
  24155. private _prepareRowForTextureGeneration;
  24156. /**
  24157. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  24158. * @returns the transform matrix of the texture.
  24159. */
  24160. getTextureMatrix(uBase?: number): Matrix;
  24161. /**
  24162. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  24163. * @returns The reflection texture transform
  24164. */
  24165. getReflectionTextureMatrix(): Matrix;
  24166. /**
  24167. * Clones the texture.
  24168. * @returns the cloned texture
  24169. */
  24170. clone(): Texture;
  24171. /**
  24172. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  24173. * @returns The JSON representation of the texture
  24174. */
  24175. serialize(): any;
  24176. /**
  24177. * Get the current class name of the texture useful for serialization or dynamic coding.
  24178. * @returns "Texture"
  24179. */
  24180. getClassName(): string;
  24181. /**
  24182. * Dispose the texture and release its associated resources.
  24183. */
  24184. dispose(): void;
  24185. /**
  24186. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  24187. * @param parsedTexture Define the JSON representation of the texture
  24188. * @param scene Define the scene the parsed texture should be instantiated in
  24189. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  24190. * @returns The parsed texture if successful
  24191. */
  24192. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  24193. /**
  24194. * Creates a texture from its base 64 representation.
  24195. * @param data Define the base64 payload without the data: prefix
  24196. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24197. * @param scene Define the scene the texture should belong to
  24198. * @param noMipmap Forces the texture to not create mip map information if true
  24199. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24200. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24201. * @param onLoad define a callback triggered when the texture has been loaded
  24202. * @param onError define a callback triggered when an error occurred during the loading session
  24203. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24204. * @returns the created texture
  24205. */
  24206. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  24207. /**
  24208. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  24209. * @param data Define the base64 payload without the data: prefix
  24210. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24211. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  24212. * @param scene Define the scene the texture should belong to
  24213. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  24214. * @param noMipmap Forces the texture to not create mip map information if true
  24215. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24216. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24217. * @param onLoad define a callback triggered when the texture has been loaded
  24218. * @param onError define a callback triggered when an error occurred during the loading session
  24219. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24220. * @returns the created texture
  24221. */
  24222. 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;
  24223. }
  24224. }
  24225. declare module "babylonjs/PostProcesses/postProcessManager" {
  24226. import { Nullable } from "babylonjs/types";
  24227. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24228. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24229. import { Scene } from "babylonjs/scene";
  24230. /**
  24231. * PostProcessManager is used to manage one or more post processes or post process pipelines
  24232. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  24233. */
  24234. export class PostProcessManager {
  24235. private _scene;
  24236. private _indexBuffer;
  24237. private _vertexBuffers;
  24238. /**
  24239. * Creates a new instance PostProcess
  24240. * @param scene The scene that the post process is associated with.
  24241. */
  24242. constructor(scene: Scene);
  24243. private _prepareBuffers;
  24244. private _buildIndexBuffer;
  24245. /**
  24246. * Rebuilds the vertex buffers of the manager.
  24247. * @hidden
  24248. */
  24249. _rebuild(): void;
  24250. /**
  24251. * Prepares a frame to be run through a post process.
  24252. * @param sourceTexture The input texture to the post procesess. (default: null)
  24253. * @param postProcesses An array of post processes to be run. (default: null)
  24254. * @returns True if the post processes were able to be run.
  24255. * @hidden
  24256. */
  24257. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  24258. /**
  24259. * Manually render a set of post processes to a texture.
  24260. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  24261. * @param postProcesses An array of post processes to be run.
  24262. * @param targetTexture The target texture to render to.
  24263. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  24264. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  24265. * @param lodLevel defines which lod of the texture to render to
  24266. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  24267. */
  24268. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  24269. /**
  24270. * Finalize the result of the output of the postprocesses.
  24271. * @param doNotPresent If true the result will not be displayed to the screen.
  24272. * @param targetTexture The target texture to render to.
  24273. * @param faceIndex The index of the face to bind the target texture to.
  24274. * @param postProcesses The array of post processes to render.
  24275. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  24276. * @hidden
  24277. */
  24278. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  24279. /**
  24280. * Disposes of the post process manager.
  24281. */
  24282. dispose(): void;
  24283. }
  24284. }
  24285. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  24286. import { Observable } from "babylonjs/Misc/observable";
  24287. import { SmartArray } from "babylonjs/Misc/smartArray";
  24288. import { Nullable, Immutable } from "babylonjs/types";
  24289. import { Camera } from "babylonjs/Cameras/camera";
  24290. import { Scene } from "babylonjs/scene";
  24291. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  24292. import { Color4 } from "babylonjs/Maths/math.color";
  24293. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  24294. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24295. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24296. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24297. import { Texture } from "babylonjs/Materials/Textures/texture";
  24298. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24299. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  24300. import "babylonjs/Engines/Extensions/engine.renderTarget";
  24301. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  24302. import { Engine } from "babylonjs/Engines/engine";
  24303. /**
  24304. * This Helps creating a texture that will be created from a camera in your scene.
  24305. * It is basically a dynamic texture that could be used to create special effects for instance.
  24306. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  24307. */
  24308. export class RenderTargetTexture extends Texture {
  24309. isCube: boolean;
  24310. /**
  24311. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  24312. */
  24313. static readonly REFRESHRATE_RENDER_ONCE: number;
  24314. /**
  24315. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  24316. */
  24317. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  24318. /**
  24319. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  24320. * the central point of your effect and can save a lot of performances.
  24321. */
  24322. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  24323. /**
  24324. * Use this predicate to dynamically define the list of mesh you want to render.
  24325. * If set, the renderList property will be overwritten.
  24326. */
  24327. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  24328. private _renderList;
  24329. /**
  24330. * Use this list to define the list of mesh you want to render.
  24331. */
  24332. get renderList(): Nullable<Array<AbstractMesh>>;
  24333. set renderList(value: Nullable<Array<AbstractMesh>>);
  24334. /**
  24335. * Use this function to overload the renderList array at rendering time.
  24336. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  24337. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  24338. * the cube (if the RTT is a cube, else layerOrFace=0).
  24339. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  24340. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  24341. * hold dummy elements!
  24342. */
  24343. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  24344. private _hookArray;
  24345. /**
  24346. * Define if particles should be rendered in your texture.
  24347. */
  24348. renderParticles: boolean;
  24349. /**
  24350. * Define if sprites should be rendered in your texture.
  24351. */
  24352. renderSprites: boolean;
  24353. /**
  24354. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  24355. */
  24356. coordinatesMode: number;
  24357. /**
  24358. * Define the camera used to render the texture.
  24359. */
  24360. activeCamera: Nullable<Camera>;
  24361. /**
  24362. * Override the mesh isReady function with your own one.
  24363. */
  24364. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  24365. /**
  24366. * Override the render function of the texture with your own one.
  24367. */
  24368. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  24369. /**
  24370. * Define if camera post processes should be use while rendering the texture.
  24371. */
  24372. useCameraPostProcesses: boolean;
  24373. /**
  24374. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  24375. */
  24376. ignoreCameraViewport: boolean;
  24377. private _postProcessManager;
  24378. private _postProcesses;
  24379. private _resizeObserver;
  24380. /**
  24381. * An event triggered when the texture is unbind.
  24382. */
  24383. onBeforeBindObservable: Observable<RenderTargetTexture>;
  24384. /**
  24385. * An event triggered when the texture is unbind.
  24386. */
  24387. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  24388. private _onAfterUnbindObserver;
  24389. /**
  24390. * Set a after unbind callback in the texture.
  24391. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  24392. */
  24393. set onAfterUnbind(callback: () => void);
  24394. /**
  24395. * An event triggered before rendering the texture
  24396. */
  24397. onBeforeRenderObservable: Observable<number>;
  24398. private _onBeforeRenderObserver;
  24399. /**
  24400. * Set a before render callback in the texture.
  24401. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  24402. */
  24403. set onBeforeRender(callback: (faceIndex: number) => void);
  24404. /**
  24405. * An event triggered after rendering the texture
  24406. */
  24407. onAfterRenderObservable: Observable<number>;
  24408. private _onAfterRenderObserver;
  24409. /**
  24410. * Set a after render callback in the texture.
  24411. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  24412. */
  24413. set onAfterRender(callback: (faceIndex: number) => void);
  24414. /**
  24415. * An event triggered after the texture clear
  24416. */
  24417. onClearObservable: Observable<Engine>;
  24418. private _onClearObserver;
  24419. /**
  24420. * Set a clear callback in the texture.
  24421. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  24422. */
  24423. set onClear(callback: (Engine: Engine) => void);
  24424. /**
  24425. * An event triggered when the texture is resized.
  24426. */
  24427. onResizeObservable: Observable<RenderTargetTexture>;
  24428. /**
  24429. * Define the clear color of the Render Target if it should be different from the scene.
  24430. */
  24431. clearColor: Color4;
  24432. protected _size: number | {
  24433. width: number;
  24434. height: number;
  24435. layers?: number;
  24436. };
  24437. protected _initialSizeParameter: number | {
  24438. width: number;
  24439. height: number;
  24440. } | {
  24441. ratio: number;
  24442. };
  24443. protected _sizeRatio: Nullable<number>;
  24444. /** @hidden */
  24445. _generateMipMaps: boolean;
  24446. protected _renderingManager: RenderingManager;
  24447. /** @hidden */
  24448. _waitingRenderList: string[];
  24449. protected _doNotChangeAspectRatio: boolean;
  24450. protected _currentRefreshId: number;
  24451. protected _refreshRate: number;
  24452. protected _textureMatrix: Matrix;
  24453. protected _samples: number;
  24454. protected _renderTargetOptions: RenderTargetCreationOptions;
  24455. /**
  24456. * Gets render target creation options that were used.
  24457. */
  24458. get renderTargetOptions(): RenderTargetCreationOptions;
  24459. protected _onRatioRescale(): void;
  24460. /**
  24461. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  24462. * It must define where the camera used to render the texture is set
  24463. */
  24464. boundingBoxPosition: Vector3;
  24465. private _boundingBoxSize;
  24466. /**
  24467. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  24468. * When defined, the cubemap will switch to local mode
  24469. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  24470. * @example https://www.babylonjs-playground.com/#RNASML
  24471. */
  24472. set boundingBoxSize(value: Vector3);
  24473. get boundingBoxSize(): Vector3;
  24474. /**
  24475. * In case the RTT has been created with a depth texture, get the associated
  24476. * depth texture.
  24477. * Otherwise, return null.
  24478. */
  24479. get depthStencilTexture(): Nullable<InternalTexture>;
  24480. /**
  24481. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  24482. * or used a shadow, depth texture...
  24483. * @param name The friendly name of the texture
  24484. * @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)
  24485. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  24486. * @param generateMipMaps True if mip maps need to be generated after render.
  24487. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  24488. * @param type The type of the buffer in the RTT (int, half float, float...)
  24489. * @param isCube True if a cube texture needs to be created
  24490. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  24491. * @param generateDepthBuffer True to generate a depth buffer
  24492. * @param generateStencilBuffer True to generate a stencil buffer
  24493. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  24494. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  24495. * @param delayAllocation if the texture allocation should be delayed (default: false)
  24496. */
  24497. constructor(name: string, size: number | {
  24498. width: number;
  24499. height: number;
  24500. layers?: number;
  24501. } | {
  24502. ratio: number;
  24503. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  24504. /**
  24505. * Creates a depth stencil texture.
  24506. * This is only available in WebGL 2 or with the depth texture extension available.
  24507. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  24508. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  24509. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  24510. */
  24511. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  24512. private _processSizeParameter;
  24513. /**
  24514. * Define the number of samples to use in case of MSAA.
  24515. * It defaults to one meaning no MSAA has been enabled.
  24516. */
  24517. get samples(): number;
  24518. set samples(value: number);
  24519. /**
  24520. * Resets the refresh counter of the texture and start bak from scratch.
  24521. * Could be useful to regenerate the texture if it is setup to render only once.
  24522. */
  24523. resetRefreshCounter(): void;
  24524. /**
  24525. * Define the refresh rate of the texture or the rendering frequency.
  24526. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  24527. */
  24528. get refreshRate(): number;
  24529. set refreshRate(value: number);
  24530. /**
  24531. * Adds a post process to the render target rendering passes.
  24532. * @param postProcess define the post process to add
  24533. */
  24534. addPostProcess(postProcess: PostProcess): void;
  24535. /**
  24536. * Clear all the post processes attached to the render target
  24537. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  24538. */
  24539. clearPostProcesses(dispose?: boolean): void;
  24540. /**
  24541. * Remove one of the post process from the list of attached post processes to the texture
  24542. * @param postProcess define the post process to remove from the list
  24543. */
  24544. removePostProcess(postProcess: PostProcess): void;
  24545. /** @hidden */
  24546. _shouldRender(): boolean;
  24547. /**
  24548. * Gets the actual render size of the texture.
  24549. * @returns the width of the render size
  24550. */
  24551. getRenderSize(): number;
  24552. /**
  24553. * Gets the actual render width of the texture.
  24554. * @returns the width of the render size
  24555. */
  24556. getRenderWidth(): number;
  24557. /**
  24558. * Gets the actual render height of the texture.
  24559. * @returns the height of the render size
  24560. */
  24561. getRenderHeight(): number;
  24562. /**
  24563. * Gets the actual number of layers of the texture.
  24564. * @returns the number of layers
  24565. */
  24566. getRenderLayers(): number;
  24567. /**
  24568. * Get if the texture can be rescaled or not.
  24569. */
  24570. get canRescale(): boolean;
  24571. /**
  24572. * Resize the texture using a ratio.
  24573. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  24574. */
  24575. scale(ratio: number): void;
  24576. /**
  24577. * Get the texture reflection matrix used to rotate/transform the reflection.
  24578. * @returns the reflection matrix
  24579. */
  24580. getReflectionTextureMatrix(): Matrix;
  24581. /**
  24582. * Resize the texture to a new desired size.
  24583. * Be carrefull as it will recreate all the data in the new texture.
  24584. * @param size Define the new size. It can be:
  24585. * - a number for squared texture,
  24586. * - an object containing { width: number, height: number }
  24587. * - or an object containing a ratio { ratio: number }
  24588. */
  24589. resize(size: number | {
  24590. width: number;
  24591. height: number;
  24592. } | {
  24593. ratio: number;
  24594. }): void;
  24595. private _defaultRenderListPrepared;
  24596. /**
  24597. * Renders all the objects from the render list into the texture.
  24598. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  24599. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  24600. */
  24601. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  24602. private _bestReflectionRenderTargetDimension;
  24603. private _prepareRenderingManager;
  24604. /**
  24605. * @hidden
  24606. * @param faceIndex face index to bind to if this is a cubetexture
  24607. * @param layer defines the index of the texture to bind in the array
  24608. */
  24609. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  24610. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24611. private renderToTarget;
  24612. /**
  24613. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  24614. * This allowed control for front to back rendering or reversly depending of the special needs.
  24615. *
  24616. * @param renderingGroupId The rendering group id corresponding to its index
  24617. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  24618. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  24619. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  24620. */
  24621. 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;
  24622. /**
  24623. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  24624. *
  24625. * @param renderingGroupId The rendering group id corresponding to its index
  24626. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  24627. */
  24628. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  24629. /**
  24630. * Clones the texture.
  24631. * @returns the cloned texture
  24632. */
  24633. clone(): RenderTargetTexture;
  24634. /**
  24635. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  24636. * @returns The JSON representation of the texture
  24637. */
  24638. serialize(): any;
  24639. /**
  24640. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  24641. */
  24642. disposeFramebufferObjects(): void;
  24643. /**
  24644. * Dispose the texture and release its associated resources.
  24645. */
  24646. dispose(): void;
  24647. /** @hidden */
  24648. _rebuild(): void;
  24649. /**
  24650. * Clear the info related to rendering groups preventing retention point in material dispose.
  24651. */
  24652. freeRenderingGroups(): void;
  24653. /**
  24654. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  24655. * @returns the view count
  24656. */
  24657. getViewCount(): number;
  24658. }
  24659. }
  24660. declare module "babylonjs/Misc/guid" {
  24661. /**
  24662. * Class used to manipulate GUIDs
  24663. */
  24664. export class GUID {
  24665. /**
  24666. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  24667. * Be aware Math.random() could cause collisions, but:
  24668. * "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"
  24669. * @returns a pseudo random id
  24670. */
  24671. static RandomId(): string;
  24672. }
  24673. }
  24674. declare module "babylonjs/Materials/shadowDepthWrapper" {
  24675. import { Nullable } from "babylonjs/types";
  24676. import { Scene } from "babylonjs/scene";
  24677. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24678. import { Material } from "babylonjs/Materials/material";
  24679. import { Effect } from "babylonjs/Materials/effect";
  24680. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  24681. /**
  24682. * Options to be used when creating a shadow depth material
  24683. */
  24684. export interface IIOptionShadowDepthMaterial {
  24685. /** Variables in the vertex shader code that need to have their names remapped.
  24686. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  24687. * "var_name" should be either: worldPos or vNormalW
  24688. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  24689. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  24690. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  24691. */
  24692. remappedVariables?: string[];
  24693. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  24694. standalone?: boolean;
  24695. }
  24696. /**
  24697. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  24698. */
  24699. export class ShadowDepthWrapper {
  24700. private _scene;
  24701. private _options?;
  24702. private _baseMaterial;
  24703. private _onEffectCreatedObserver;
  24704. private _subMeshToEffect;
  24705. private _subMeshToDepthEffect;
  24706. private _meshes;
  24707. /** @hidden */
  24708. _matriceNames: any;
  24709. /** Gets the standalone status of the wrapper */
  24710. get standalone(): boolean;
  24711. /** Gets the base material the wrapper is built upon */
  24712. get baseMaterial(): Material;
  24713. /**
  24714. * Instantiate a new shadow depth wrapper.
  24715. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  24716. * generate the shadow depth map. For more information, please refer to the documentation:
  24717. * https://doc.babylonjs.com/babylon101/shadows
  24718. * @param baseMaterial Material to wrap
  24719. * @param scene Define the scene the material belongs to
  24720. * @param options Options used to create the wrapper
  24721. */
  24722. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  24723. /**
  24724. * Gets the effect to use to generate the depth map
  24725. * @param subMesh subMesh to get the effect for
  24726. * @param shadowGenerator shadow generator to get the effect for
  24727. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  24728. */
  24729. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  24730. /**
  24731. * Specifies that the submesh is ready to be used for depth rendering
  24732. * @param subMesh submesh to check
  24733. * @param defines the list of defines to take into account when checking the effect
  24734. * @param shadowGenerator combined with subMesh, it defines the effect to check
  24735. * @param useInstances specifies that instances should be used
  24736. * @returns a boolean indicating that the submesh is ready or not
  24737. */
  24738. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  24739. /**
  24740. * Disposes the resources
  24741. */
  24742. dispose(): void;
  24743. private _makeEffect;
  24744. }
  24745. }
  24746. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  24747. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24748. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  24749. import { Nullable } from "babylonjs/types";
  24750. module "babylonjs/Engines/thinEngine" {
  24751. interface ThinEngine {
  24752. /**
  24753. * Unbind a list of render target textures from the webGL context
  24754. * This is used only when drawBuffer extension or webGL2 are active
  24755. * @param textures defines the render target textures to unbind
  24756. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  24757. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  24758. */
  24759. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  24760. /**
  24761. * Create a multi render target texture
  24762. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  24763. * @param size defines the size of the texture
  24764. * @param options defines the creation options
  24765. * @returns the cube texture as an InternalTexture
  24766. */
  24767. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  24768. /**
  24769. * Update the sample count for a given multiple render target texture
  24770. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  24771. * @param textures defines the textures to update
  24772. * @param samples defines the sample count to set
  24773. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  24774. */
  24775. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  24776. /**
  24777. * Select a subsets of attachments to draw to.
  24778. * @param attachments gl attachments
  24779. */
  24780. bindAttachments(attachments: number[]): void;
  24781. }
  24782. }
  24783. }
  24784. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  24785. import { Scene } from "babylonjs/scene";
  24786. import { Engine } from "babylonjs/Engines/engine";
  24787. import { Texture } from "babylonjs/Materials/Textures/texture";
  24788. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24789. import "babylonjs/Engines/Extensions/engine.multiRender";
  24790. /**
  24791. * Creation options of the multi render target texture.
  24792. */
  24793. export interface IMultiRenderTargetOptions {
  24794. /**
  24795. * Define if the texture needs to create mip maps after render.
  24796. */
  24797. generateMipMaps?: boolean;
  24798. /**
  24799. * Define the types of all the draw buffers we want to create
  24800. */
  24801. types?: number[];
  24802. /**
  24803. * Define the sampling modes of all the draw buffers we want to create
  24804. */
  24805. samplingModes?: number[];
  24806. /**
  24807. * Define if a depth buffer is required
  24808. */
  24809. generateDepthBuffer?: boolean;
  24810. /**
  24811. * Define if a stencil buffer is required
  24812. */
  24813. generateStencilBuffer?: boolean;
  24814. /**
  24815. * Define if a depth texture is required instead of a depth buffer
  24816. */
  24817. generateDepthTexture?: boolean;
  24818. /**
  24819. * Define the number of desired draw buffers
  24820. */
  24821. textureCount?: number;
  24822. /**
  24823. * Define if aspect ratio should be adapted to the texture or stay the scene one
  24824. */
  24825. doNotChangeAspectRatio?: boolean;
  24826. /**
  24827. * Define the default type of the buffers we are creating
  24828. */
  24829. defaultType?: number;
  24830. }
  24831. /**
  24832. * A multi render target, like a render target provides the ability to render to a texture.
  24833. * Unlike the render target, it can render to several draw buffers in one draw.
  24834. * This is specially interesting in deferred rendering or for any effects requiring more than
  24835. * just one color from a single pass.
  24836. */
  24837. export class MultiRenderTarget extends RenderTargetTexture {
  24838. private _internalTextures;
  24839. private _textures;
  24840. private _multiRenderTargetOptions;
  24841. private _count;
  24842. /**
  24843. * Get if draw buffers are currently supported by the used hardware and browser.
  24844. */
  24845. get isSupported(): boolean;
  24846. /**
  24847. * Get the list of textures generated by the multi render target.
  24848. */
  24849. get textures(): Texture[];
  24850. /**
  24851. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  24852. */
  24853. get count(): number;
  24854. /**
  24855. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  24856. */
  24857. get depthTexture(): Texture;
  24858. /**
  24859. * Set the wrapping mode on U of all the textures we are rendering to.
  24860. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  24861. */
  24862. set wrapU(wrap: number);
  24863. /**
  24864. * Set the wrapping mode on V of all the textures we are rendering to.
  24865. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  24866. */
  24867. set wrapV(wrap: number);
  24868. /**
  24869. * Instantiate a new multi render target texture.
  24870. * A multi render target, like a render target provides the ability to render to a texture.
  24871. * Unlike the render target, it can render to several draw buffers in one draw.
  24872. * This is specially interesting in deferred rendering or for any effects requiring more than
  24873. * just one color from a single pass.
  24874. * @param name Define the name of the texture
  24875. * @param size Define the size of the buffers to render to
  24876. * @param count Define the number of target we are rendering into
  24877. * @param scene Define the scene the texture belongs to
  24878. * @param options Define the options used to create the multi render target
  24879. */
  24880. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  24881. /** @hidden */
  24882. _rebuild(): void;
  24883. private _createInternalTextures;
  24884. private _createTextures;
  24885. /**
  24886. * Define the number of samples used if MSAA is enabled.
  24887. */
  24888. get samples(): number;
  24889. set samples(value: number);
  24890. /**
  24891. * Resize all the textures in the multi render target.
  24892. * Be carrefull as it will recreate all the data in the new texture.
  24893. * @param size Define the new size
  24894. */
  24895. resize(size: any): void;
  24896. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24897. /**
  24898. * Dispose the render targets and their associated resources
  24899. */
  24900. dispose(): void;
  24901. /**
  24902. * Release all the underlying texture used as draw buffers.
  24903. */
  24904. releaseInternalTextures(): void;
  24905. }
  24906. }
  24907. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  24908. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  24909. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  24910. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  24911. /** @hidden */
  24912. export var imageProcessingPixelShader: {
  24913. name: string;
  24914. shader: string;
  24915. };
  24916. }
  24917. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  24918. import { Nullable } from "babylonjs/types";
  24919. import { Color4 } from "babylonjs/Maths/math.color";
  24920. import { Camera } from "babylonjs/Cameras/camera";
  24921. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24922. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  24923. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  24924. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  24925. import { Engine } from "babylonjs/Engines/engine";
  24926. import "babylonjs/Shaders/imageProcessing.fragment";
  24927. import "babylonjs/Shaders/postprocess.vertex";
  24928. /**
  24929. * ImageProcessingPostProcess
  24930. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  24931. */
  24932. export class ImageProcessingPostProcess extends PostProcess {
  24933. /**
  24934. * Default configuration related to image processing available in the PBR Material.
  24935. */
  24936. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  24937. /**
  24938. * Gets the image processing configuration used either in this material.
  24939. */
  24940. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  24941. /**
  24942. * Sets the Default image processing configuration used either in the this material.
  24943. *
  24944. * If sets to null, the scene one is in use.
  24945. */
  24946. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  24947. /**
  24948. * Keep track of the image processing observer to allow dispose and replace.
  24949. */
  24950. private _imageProcessingObserver;
  24951. /**
  24952. * Attaches a new image processing configuration to the PBR Material.
  24953. * @param configuration
  24954. */
  24955. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  24956. /**
  24957. * If the post process is supported.
  24958. */
  24959. get isSupported(): boolean;
  24960. /**
  24961. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  24962. */
  24963. get colorCurves(): Nullable<ColorCurves>;
  24964. /**
  24965. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  24966. */
  24967. set colorCurves(value: Nullable<ColorCurves>);
  24968. /**
  24969. * Gets wether the color curves effect is enabled.
  24970. */
  24971. get colorCurvesEnabled(): boolean;
  24972. /**
  24973. * Sets wether the color curves effect is enabled.
  24974. */
  24975. set colorCurvesEnabled(value: boolean);
  24976. /**
  24977. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  24978. */
  24979. get colorGradingTexture(): Nullable<BaseTexture>;
  24980. /**
  24981. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  24982. */
  24983. set colorGradingTexture(value: Nullable<BaseTexture>);
  24984. /**
  24985. * Gets wether the color grading effect is enabled.
  24986. */
  24987. get colorGradingEnabled(): boolean;
  24988. /**
  24989. * Gets wether the color grading effect is enabled.
  24990. */
  24991. set colorGradingEnabled(value: boolean);
  24992. /**
  24993. * Gets exposure used in the effect.
  24994. */
  24995. get exposure(): number;
  24996. /**
  24997. * Sets exposure used in the effect.
  24998. */
  24999. set exposure(value: number);
  25000. /**
  25001. * Gets wether tonemapping is enabled or not.
  25002. */
  25003. get toneMappingEnabled(): boolean;
  25004. /**
  25005. * Sets wether tonemapping is enabled or not
  25006. */
  25007. set toneMappingEnabled(value: boolean);
  25008. /**
  25009. * Gets the type of tone mapping effect.
  25010. */
  25011. get toneMappingType(): number;
  25012. /**
  25013. * Sets the type of tone mapping effect.
  25014. */
  25015. set toneMappingType(value: number);
  25016. /**
  25017. * Gets contrast used in the effect.
  25018. */
  25019. get contrast(): number;
  25020. /**
  25021. * Sets contrast used in the effect.
  25022. */
  25023. set contrast(value: number);
  25024. /**
  25025. * Gets Vignette stretch size.
  25026. */
  25027. get vignetteStretch(): number;
  25028. /**
  25029. * Sets Vignette stretch size.
  25030. */
  25031. set vignetteStretch(value: number);
  25032. /**
  25033. * Gets Vignette centre X Offset.
  25034. */
  25035. get vignetteCentreX(): number;
  25036. /**
  25037. * Sets Vignette centre X Offset.
  25038. */
  25039. set vignetteCentreX(value: number);
  25040. /**
  25041. * Gets Vignette centre Y Offset.
  25042. */
  25043. get vignetteCentreY(): number;
  25044. /**
  25045. * Sets Vignette centre Y Offset.
  25046. */
  25047. set vignetteCentreY(value: number);
  25048. /**
  25049. * Gets Vignette weight or intensity of the vignette effect.
  25050. */
  25051. get vignetteWeight(): number;
  25052. /**
  25053. * Sets Vignette weight or intensity of the vignette effect.
  25054. */
  25055. set vignetteWeight(value: number);
  25056. /**
  25057. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  25058. * if vignetteEnabled is set to true.
  25059. */
  25060. get vignetteColor(): Color4;
  25061. /**
  25062. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  25063. * if vignetteEnabled is set to true.
  25064. */
  25065. set vignetteColor(value: Color4);
  25066. /**
  25067. * Gets Camera field of view used by the Vignette effect.
  25068. */
  25069. get vignetteCameraFov(): number;
  25070. /**
  25071. * Sets Camera field of view used by the Vignette effect.
  25072. */
  25073. set vignetteCameraFov(value: number);
  25074. /**
  25075. * Gets the vignette blend mode allowing different kind of effect.
  25076. */
  25077. get vignetteBlendMode(): number;
  25078. /**
  25079. * Sets the vignette blend mode allowing different kind of effect.
  25080. */
  25081. set vignetteBlendMode(value: number);
  25082. /**
  25083. * Gets wether the vignette effect is enabled.
  25084. */
  25085. get vignetteEnabled(): boolean;
  25086. /**
  25087. * Sets wether the vignette effect is enabled.
  25088. */
  25089. set vignetteEnabled(value: boolean);
  25090. private _fromLinearSpace;
  25091. /**
  25092. * Gets wether the input of the processing is in Gamma or Linear Space.
  25093. */
  25094. get fromLinearSpace(): boolean;
  25095. /**
  25096. * Sets wether the input of the processing is in Gamma or Linear Space.
  25097. */
  25098. set fromLinearSpace(value: boolean);
  25099. /**
  25100. * Defines cache preventing GC.
  25101. */
  25102. private _defines;
  25103. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  25104. /**
  25105. * "ImageProcessingPostProcess"
  25106. * @returns "ImageProcessingPostProcess"
  25107. */
  25108. getClassName(): string;
  25109. /**
  25110. * @hidden
  25111. */
  25112. _updateParameters(): void;
  25113. dispose(camera?: Camera): void;
  25114. }
  25115. }
  25116. declare module "babylonjs/Shaders/ShadersInclude/fibonacci" {
  25117. /** @hidden */
  25118. export var fibonacci: {
  25119. name: string;
  25120. shader: string;
  25121. };
  25122. }
  25123. declare module "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions" {
  25124. /** @hidden */
  25125. export var subSurfaceScatteringFunctions: {
  25126. name: string;
  25127. shader: string;
  25128. };
  25129. }
  25130. declare module "babylonjs/Shaders/ShadersInclude/diffusionProfile" {
  25131. /** @hidden */
  25132. export var diffusionProfile: {
  25133. name: string;
  25134. shader: string;
  25135. };
  25136. }
  25137. declare module "babylonjs/Shaders/subSurfaceScattering.fragment" {
  25138. import "babylonjs/Shaders/ShadersInclude/fibonacci";
  25139. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  25140. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  25141. import "babylonjs/Shaders/ShadersInclude/diffusionProfile";
  25142. /** @hidden */
  25143. export var subSurfaceScatteringPixelShader: {
  25144. name: string;
  25145. shader: string;
  25146. };
  25147. }
  25148. declare module "babylonjs/PostProcesses/subSurfaceScatteringPostProcess" {
  25149. import { Nullable } from "babylonjs/types";
  25150. import { Camera } from "babylonjs/Cameras/camera";
  25151. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  25152. import { Engine } from "babylonjs/Engines/engine";
  25153. import { Scene } from "babylonjs/scene";
  25154. import "babylonjs/Shaders/imageProcessing.fragment";
  25155. import "babylonjs/Shaders/subSurfaceScattering.fragment";
  25156. import "babylonjs/Shaders/postprocess.vertex";
  25157. /**
  25158. * Sub surface scattering post process
  25159. */
  25160. export class SubSurfaceScatteringPostProcess extends PostProcess {
  25161. /**
  25162. * Gets a string identifying the name of the class
  25163. * @returns "SubSurfaceScatteringPostProcess" string
  25164. */
  25165. getClassName(): string;
  25166. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  25167. }
  25168. }
  25169. declare module "babylonjs/Rendering/prePassEffectConfiguration" {
  25170. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25171. /**
  25172. * Interface for defining prepass effects in the prepass post-process pipeline
  25173. */
  25174. export interface PrePassEffectConfiguration {
  25175. /**
  25176. * Post process to attach for this effect
  25177. */
  25178. postProcess: PostProcess;
  25179. /**
  25180. * Is the effect enabled
  25181. */
  25182. enabled: boolean;
  25183. /**
  25184. * Disposes the effect configuration
  25185. */
  25186. dispose(): void;
  25187. /**
  25188. * Disposes the effect configuration
  25189. */
  25190. createPostProcess: () => PostProcess;
  25191. }
  25192. }
  25193. declare module "babylonjs/Rendering/subSurfaceConfiguration" {
  25194. import { Scene } from "babylonjs/scene";
  25195. import { Color3 } from "babylonjs/Maths/math.color";
  25196. import { SubSurfaceScatteringPostProcess } from "babylonjs/PostProcesses/subSurfaceScatteringPostProcess";
  25197. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  25198. /**
  25199. * Contains all parameters needed for the prepass to perform
  25200. * screen space subsurface scattering
  25201. */
  25202. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  25203. private _ssDiffusionS;
  25204. private _ssFilterRadii;
  25205. private _ssDiffusionD;
  25206. /**
  25207. * Post process to attach for screen space subsurface scattering
  25208. */
  25209. postProcess: SubSurfaceScatteringPostProcess;
  25210. /**
  25211. * Diffusion profile color for subsurface scattering
  25212. */
  25213. get ssDiffusionS(): number[];
  25214. /**
  25215. * Diffusion profile max color channel value for subsurface scattering
  25216. */
  25217. get ssDiffusionD(): number[];
  25218. /**
  25219. * Diffusion profile filter radius for subsurface scattering
  25220. */
  25221. get ssFilterRadii(): number[];
  25222. /**
  25223. * Is subsurface enabled
  25224. */
  25225. enabled: boolean;
  25226. /**
  25227. * Diffusion profile colors for subsurface scattering
  25228. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  25229. * See ...
  25230. * Note that you can only store up to 5 of them
  25231. */
  25232. ssDiffusionProfileColors: Color3[];
  25233. /**
  25234. * Defines the ratio real world => scene units.
  25235. * Used for subsurface scattering
  25236. */
  25237. metersPerUnit: number;
  25238. private _scene;
  25239. /**
  25240. * Builds a subsurface configuration object
  25241. * @param scene The scene
  25242. */
  25243. constructor(scene: Scene);
  25244. /**
  25245. * Adds a new diffusion profile.
  25246. * Useful for more realistic subsurface scattering on diverse materials.
  25247. * @param color The color of the diffusion profile. Should be the average color of the material.
  25248. * @return The index of the diffusion profile for the material subsurface configuration
  25249. */
  25250. addDiffusionProfile(color: Color3): number;
  25251. /**
  25252. * Creates the sss post process
  25253. * @return The created post process
  25254. */
  25255. createPostProcess(): SubSurfaceScatteringPostProcess;
  25256. /**
  25257. * Deletes all diffusion profiles.
  25258. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  25259. */
  25260. clearAllDiffusionProfiles(): void;
  25261. /**
  25262. * Disposes this object
  25263. */
  25264. dispose(): void;
  25265. /**
  25266. * @hidden
  25267. * https://zero-radiance.github.io/post/sampling-diffusion/
  25268. *
  25269. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  25270. * ------------------------------------------------------------------------------------
  25271. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  25272. * PDF[r, phi, s] = r * R[r, phi, s]
  25273. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  25274. * ------------------------------------------------------------------------------------
  25275. * We importance sample the color channel with the widest scattering distance.
  25276. */
  25277. getDiffusionProfileParameters(color: Color3): number;
  25278. /**
  25279. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  25280. * 'u' is the random number (the value of the CDF): [0, 1).
  25281. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  25282. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  25283. */
  25284. private _sampleBurleyDiffusionProfile;
  25285. }
  25286. }
  25287. declare module "babylonjs/Rendering/prePassRenderer" {
  25288. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  25289. import { Scene } from "babylonjs/scene";
  25290. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  25291. import { Effect } from "babylonjs/Materials/effect";
  25292. import { SubSurfaceConfiguration } from "babylonjs/Rendering/subSurfaceConfiguration";
  25293. /**
  25294. * Renders a pre pass of the scene
  25295. * This means every mesh in the scene will be rendered to a render target texture
  25296. * And then this texture will be composited to the rendering canvas with post processes
  25297. * It is necessary for effects like subsurface scattering or deferred shading
  25298. */
  25299. export class PrePassRenderer {
  25300. /** @hidden */
  25301. static _SceneComponentInitialization: (scene: Scene) => void;
  25302. private _scene;
  25303. private _engine;
  25304. private _isDirty;
  25305. /**
  25306. * Number of textures in the multi render target texture where the scene is directly rendered
  25307. */
  25308. readonly mrtCount: number;
  25309. /**
  25310. * The render target where the scene is directly rendered
  25311. */
  25312. prePassRT: MultiRenderTarget;
  25313. private _mrtTypes;
  25314. private _multiRenderAttachments;
  25315. private _defaultAttachments;
  25316. private _clearAttachments;
  25317. private _postProcesses;
  25318. private readonly _clearColor;
  25319. /**
  25320. * Image processing post process for composition
  25321. */
  25322. imageProcessingPostProcess: ImageProcessingPostProcess;
  25323. /**
  25324. * Configuration for sub surface scattering post process
  25325. */
  25326. subSurfaceConfiguration: SubSurfaceConfiguration;
  25327. /**
  25328. * Should materials render their geometry on the MRT
  25329. */
  25330. materialsShouldRenderGeometry: boolean;
  25331. /**
  25332. * Should materials render the irradiance information on the MRT
  25333. */
  25334. materialsShouldRenderIrradiance: boolean;
  25335. private _enabled;
  25336. /**
  25337. * Indicates if the prepass is enabled
  25338. */
  25339. get enabled(): boolean;
  25340. /**
  25341. * How many samples are used for MSAA of the scene render target
  25342. */
  25343. get samples(): number;
  25344. set samples(n: number);
  25345. /**
  25346. * Instanciates a prepass renderer
  25347. * @param scene The scene
  25348. */
  25349. constructor(scene: Scene);
  25350. private _initializeAttachments;
  25351. private _createCompositionEffect;
  25352. /**
  25353. * Indicates if rendering a prepass is supported
  25354. */
  25355. get isSupported(): boolean;
  25356. /**
  25357. * Sets the proper output textures to draw in the engine.
  25358. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  25359. */
  25360. bindAttachmentsForEffect(effect: Effect): void;
  25361. /**
  25362. * @hidden
  25363. */
  25364. _beforeCameraDraw(): void;
  25365. /**
  25366. * @hidden
  25367. */
  25368. _afterCameraDraw(): void;
  25369. private _checkRTSize;
  25370. private _bindFrameBuffer;
  25371. /**
  25372. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  25373. */
  25374. clear(): void;
  25375. private _setState;
  25376. private _enable;
  25377. private _disable;
  25378. private _resetPostProcessChain;
  25379. private _bindPostProcessChain;
  25380. /**
  25381. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  25382. */
  25383. markAsDirty(): void;
  25384. private _update;
  25385. /**
  25386. * Disposes the prepass renderer.
  25387. */
  25388. dispose(): void;
  25389. }
  25390. }
  25391. declare module "babylonjs/Materials/material" {
  25392. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25393. import { SmartArray } from "babylonjs/Misc/smartArray";
  25394. import { Observable } from "babylonjs/Misc/observable";
  25395. import { Nullable } from "babylonjs/types";
  25396. import { Scene } from "babylonjs/scene";
  25397. import { Matrix } from "babylonjs/Maths/math.vector";
  25398. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25399. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25400. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  25401. import { Effect } from "babylonjs/Materials/effect";
  25402. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25403. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25404. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  25405. import { IInspectable } from "babylonjs/Misc/iInspectable";
  25406. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  25407. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  25408. import { Mesh } from "babylonjs/Meshes/mesh";
  25409. import { Animation } from "babylonjs/Animations/animation";
  25410. /**
  25411. * Options for compiling materials.
  25412. */
  25413. export interface IMaterialCompilationOptions {
  25414. /**
  25415. * Defines whether clip planes are enabled.
  25416. */
  25417. clipPlane: boolean;
  25418. /**
  25419. * Defines whether instances are enabled.
  25420. */
  25421. useInstances: boolean;
  25422. }
  25423. /**
  25424. * Options passed when calling customShaderNameResolve
  25425. */
  25426. export interface ICustomShaderNameResolveOptions {
  25427. /**
  25428. * 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
  25429. */
  25430. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  25431. }
  25432. /**
  25433. * Base class for the main features of a material in Babylon.js
  25434. */
  25435. export class Material implements IAnimatable {
  25436. /**
  25437. * Returns the triangle fill mode
  25438. */
  25439. static readonly TriangleFillMode: number;
  25440. /**
  25441. * Returns the wireframe mode
  25442. */
  25443. static readonly WireFrameFillMode: number;
  25444. /**
  25445. * Returns the point fill mode
  25446. */
  25447. static readonly PointFillMode: number;
  25448. /**
  25449. * Returns the point list draw mode
  25450. */
  25451. static readonly PointListDrawMode: number;
  25452. /**
  25453. * Returns the line list draw mode
  25454. */
  25455. static readonly LineListDrawMode: number;
  25456. /**
  25457. * Returns the line loop draw mode
  25458. */
  25459. static readonly LineLoopDrawMode: number;
  25460. /**
  25461. * Returns the line strip draw mode
  25462. */
  25463. static readonly LineStripDrawMode: number;
  25464. /**
  25465. * Returns the triangle strip draw mode
  25466. */
  25467. static readonly TriangleStripDrawMode: number;
  25468. /**
  25469. * Returns the triangle fan draw mode
  25470. */
  25471. static readonly TriangleFanDrawMode: number;
  25472. /**
  25473. * Stores the clock-wise side orientation
  25474. */
  25475. static readonly ClockWiseSideOrientation: number;
  25476. /**
  25477. * Stores the counter clock-wise side orientation
  25478. */
  25479. static readonly CounterClockWiseSideOrientation: number;
  25480. /**
  25481. * The dirty texture flag value
  25482. */
  25483. static readonly TextureDirtyFlag: number;
  25484. /**
  25485. * The dirty light flag value
  25486. */
  25487. static readonly LightDirtyFlag: number;
  25488. /**
  25489. * The dirty fresnel flag value
  25490. */
  25491. static readonly FresnelDirtyFlag: number;
  25492. /**
  25493. * The dirty attribute flag value
  25494. */
  25495. static readonly AttributesDirtyFlag: number;
  25496. /**
  25497. * The dirty misc flag value
  25498. */
  25499. static readonly MiscDirtyFlag: number;
  25500. /**
  25501. * The all dirty flag value
  25502. */
  25503. static readonly AllDirtyFlag: number;
  25504. /**
  25505. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  25506. */
  25507. static readonly MATERIAL_OPAQUE: number;
  25508. /**
  25509. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  25510. */
  25511. static readonly MATERIAL_ALPHATEST: number;
  25512. /**
  25513. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  25514. */
  25515. static readonly MATERIAL_ALPHABLEND: number;
  25516. /**
  25517. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  25518. * They are also discarded below the alpha cutoff threshold to improve performances.
  25519. */
  25520. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  25521. /**
  25522. * The Whiteout method is used to blend normals.
  25523. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  25524. */
  25525. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  25526. /**
  25527. * The Reoriented Normal Mapping method is used to blend normals.
  25528. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  25529. */
  25530. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  25531. /**
  25532. * Custom callback helping to override the default shader used in the material.
  25533. */
  25534. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  25535. /**
  25536. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  25537. */
  25538. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  25539. /**
  25540. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  25541. * This means that the material can keep using a previous shader while a new one is being compiled.
  25542. * This is mostly used when shader parallel compilation is supported (true by default)
  25543. */
  25544. allowShaderHotSwapping: boolean;
  25545. /**
  25546. * The ID of the material
  25547. */
  25548. id: string;
  25549. /**
  25550. * Gets or sets the unique id of the material
  25551. */
  25552. uniqueId: number;
  25553. /**
  25554. * The name of the material
  25555. */
  25556. name: string;
  25557. /**
  25558. * Gets or sets user defined metadata
  25559. */
  25560. metadata: any;
  25561. /**
  25562. * For internal use only. Please do not use.
  25563. */
  25564. reservedDataStore: any;
  25565. /**
  25566. * Specifies if the ready state should be checked on each call
  25567. */
  25568. checkReadyOnEveryCall: boolean;
  25569. /**
  25570. * Specifies if the ready state should be checked once
  25571. */
  25572. checkReadyOnlyOnce: boolean;
  25573. /**
  25574. * The state of the material
  25575. */
  25576. state: string;
  25577. /**
  25578. * If the material can be rendered to several textures with MRT extension
  25579. */
  25580. get canRenderToMRT(): boolean;
  25581. /**
  25582. * The alpha value of the material
  25583. */
  25584. protected _alpha: number;
  25585. /**
  25586. * List of inspectable custom properties (used by the Inspector)
  25587. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25588. */
  25589. inspectableCustomProperties: IInspectable[];
  25590. /**
  25591. * Sets the alpha value of the material
  25592. */
  25593. set alpha(value: number);
  25594. /**
  25595. * Gets the alpha value of the material
  25596. */
  25597. get alpha(): number;
  25598. /**
  25599. * Specifies if back face culling is enabled
  25600. */
  25601. protected _backFaceCulling: boolean;
  25602. /**
  25603. * Sets the back-face culling state
  25604. */
  25605. set backFaceCulling(value: boolean);
  25606. /**
  25607. * Gets the back-face culling state
  25608. */
  25609. get backFaceCulling(): boolean;
  25610. /**
  25611. * Stores the value for side orientation
  25612. */
  25613. sideOrientation: number;
  25614. /**
  25615. * Callback triggered when the material is compiled
  25616. */
  25617. onCompiled: Nullable<(effect: Effect) => void>;
  25618. /**
  25619. * Callback triggered when an error occurs
  25620. */
  25621. onError: Nullable<(effect: Effect, errors: string) => void>;
  25622. /**
  25623. * Callback triggered to get the render target textures
  25624. */
  25625. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  25626. /**
  25627. * Gets a boolean indicating that current material needs to register RTT
  25628. */
  25629. get hasRenderTargetTextures(): boolean;
  25630. /**
  25631. * Specifies if the material should be serialized
  25632. */
  25633. doNotSerialize: boolean;
  25634. /**
  25635. * @hidden
  25636. */
  25637. _storeEffectOnSubMeshes: boolean;
  25638. /**
  25639. * Stores the animations for the material
  25640. */
  25641. animations: Nullable<Array<Animation>>;
  25642. /**
  25643. * An event triggered when the material is disposed
  25644. */
  25645. onDisposeObservable: Observable<Material>;
  25646. /**
  25647. * An observer which watches for dispose events
  25648. */
  25649. private _onDisposeObserver;
  25650. private _onUnBindObservable;
  25651. /**
  25652. * Called during a dispose event
  25653. */
  25654. set onDispose(callback: () => void);
  25655. private _onBindObservable;
  25656. /**
  25657. * An event triggered when the material is bound
  25658. */
  25659. get onBindObservable(): Observable<AbstractMesh>;
  25660. /**
  25661. * An observer which watches for bind events
  25662. */
  25663. private _onBindObserver;
  25664. /**
  25665. * Called during a bind event
  25666. */
  25667. set onBind(callback: (Mesh: AbstractMesh) => void);
  25668. /**
  25669. * An event triggered when the material is unbound
  25670. */
  25671. get onUnBindObservable(): Observable<Material>;
  25672. protected _onEffectCreatedObservable: Nullable<Observable<{
  25673. effect: Effect;
  25674. subMesh: Nullable<SubMesh>;
  25675. }>>;
  25676. /**
  25677. * An event triggered when the effect is (re)created
  25678. */
  25679. get onEffectCreatedObservable(): Observable<{
  25680. effect: Effect;
  25681. subMesh: Nullable<SubMesh>;
  25682. }>;
  25683. /**
  25684. * Stores the value of the alpha mode
  25685. */
  25686. private _alphaMode;
  25687. /**
  25688. * Sets the value of the alpha mode.
  25689. *
  25690. * | Value | Type | Description |
  25691. * | --- | --- | --- |
  25692. * | 0 | ALPHA_DISABLE | |
  25693. * | 1 | ALPHA_ADD | |
  25694. * | 2 | ALPHA_COMBINE | |
  25695. * | 3 | ALPHA_SUBTRACT | |
  25696. * | 4 | ALPHA_MULTIPLY | |
  25697. * | 5 | ALPHA_MAXIMIZED | |
  25698. * | 6 | ALPHA_ONEONE | |
  25699. * | 7 | ALPHA_PREMULTIPLIED | |
  25700. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  25701. * | 9 | ALPHA_INTERPOLATE | |
  25702. * | 10 | ALPHA_SCREENMODE | |
  25703. *
  25704. */
  25705. set alphaMode(value: number);
  25706. /**
  25707. * Gets the value of the alpha mode
  25708. */
  25709. get alphaMode(): number;
  25710. /**
  25711. * Stores the state of the need depth pre-pass value
  25712. */
  25713. private _needDepthPrePass;
  25714. /**
  25715. * Sets the need depth pre-pass value
  25716. */
  25717. set needDepthPrePass(value: boolean);
  25718. /**
  25719. * Gets the depth pre-pass value
  25720. */
  25721. get needDepthPrePass(): boolean;
  25722. /**
  25723. * Specifies if depth writing should be disabled
  25724. */
  25725. disableDepthWrite: boolean;
  25726. /**
  25727. * Specifies if color writing should be disabled
  25728. */
  25729. disableColorWrite: boolean;
  25730. /**
  25731. * Specifies if depth writing should be forced
  25732. */
  25733. forceDepthWrite: boolean;
  25734. /**
  25735. * Specifies the depth function that should be used. 0 means the default engine function
  25736. */
  25737. depthFunction: number;
  25738. /**
  25739. * Specifies if there should be a separate pass for culling
  25740. */
  25741. separateCullingPass: boolean;
  25742. /**
  25743. * Stores the state specifing if fog should be enabled
  25744. */
  25745. private _fogEnabled;
  25746. /**
  25747. * Sets the state for enabling fog
  25748. */
  25749. set fogEnabled(value: boolean);
  25750. /**
  25751. * Gets the value of the fog enabled state
  25752. */
  25753. get fogEnabled(): boolean;
  25754. /**
  25755. * Stores the size of points
  25756. */
  25757. pointSize: number;
  25758. /**
  25759. * Stores the z offset value
  25760. */
  25761. zOffset: number;
  25762. get wireframe(): boolean;
  25763. /**
  25764. * Sets the state of wireframe mode
  25765. */
  25766. set wireframe(value: boolean);
  25767. /**
  25768. * Gets the value specifying if point clouds are enabled
  25769. */
  25770. get pointsCloud(): boolean;
  25771. /**
  25772. * Sets the state of point cloud mode
  25773. */
  25774. set pointsCloud(value: boolean);
  25775. /**
  25776. * Gets the material fill mode
  25777. */
  25778. get fillMode(): number;
  25779. /**
  25780. * Sets the material fill mode
  25781. */
  25782. set fillMode(value: number);
  25783. /**
  25784. * @hidden
  25785. * Stores the effects for the material
  25786. */
  25787. _effect: Nullable<Effect>;
  25788. /**
  25789. * Specifies if uniform buffers should be used
  25790. */
  25791. private _useUBO;
  25792. /**
  25793. * Stores a reference to the scene
  25794. */
  25795. private _scene;
  25796. /**
  25797. * Stores the fill mode state
  25798. */
  25799. private _fillMode;
  25800. /**
  25801. * Specifies if the depth write state should be cached
  25802. */
  25803. private _cachedDepthWriteState;
  25804. /**
  25805. * Specifies if the color write state should be cached
  25806. */
  25807. private _cachedColorWriteState;
  25808. /**
  25809. * Specifies if the depth function state should be cached
  25810. */
  25811. private _cachedDepthFunctionState;
  25812. /**
  25813. * Stores the uniform buffer
  25814. */
  25815. protected _uniformBuffer: UniformBuffer;
  25816. /** @hidden */
  25817. _indexInSceneMaterialArray: number;
  25818. /** @hidden */
  25819. meshMap: Nullable<{
  25820. [id: string]: AbstractMesh | undefined;
  25821. }>;
  25822. /**
  25823. * Creates a material instance
  25824. * @param name defines the name of the material
  25825. * @param scene defines the scene to reference
  25826. * @param doNotAdd specifies if the material should be added to the scene
  25827. */
  25828. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  25829. /**
  25830. * Returns a string representation of the current material
  25831. * @param fullDetails defines a boolean indicating which levels of logging is desired
  25832. * @returns a string with material information
  25833. */
  25834. toString(fullDetails?: boolean): string;
  25835. /**
  25836. * Gets the class name of the material
  25837. * @returns a string with the class name of the material
  25838. */
  25839. getClassName(): string;
  25840. /**
  25841. * Specifies if updates for the material been locked
  25842. */
  25843. get isFrozen(): boolean;
  25844. /**
  25845. * Locks updates for the material
  25846. */
  25847. freeze(): void;
  25848. /**
  25849. * Unlocks updates for the material
  25850. */
  25851. unfreeze(): void;
  25852. /**
  25853. * Specifies if the material is ready to be used
  25854. * @param mesh defines the mesh to check
  25855. * @param useInstances specifies if instances should be used
  25856. * @returns a boolean indicating if the material is ready to be used
  25857. */
  25858. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  25859. /**
  25860. * Specifies that the submesh is ready to be used
  25861. * @param mesh defines the mesh to check
  25862. * @param subMesh defines which submesh to check
  25863. * @param useInstances specifies that instances should be used
  25864. * @returns a boolean indicating that the submesh is ready or not
  25865. */
  25866. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25867. /**
  25868. * Returns the material effect
  25869. * @returns the effect associated with the material
  25870. */
  25871. getEffect(): Nullable<Effect>;
  25872. /**
  25873. * Returns the current scene
  25874. * @returns a Scene
  25875. */
  25876. getScene(): Scene;
  25877. /**
  25878. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  25879. */
  25880. protected _forceAlphaTest: boolean;
  25881. /**
  25882. * The transparency mode of the material.
  25883. */
  25884. protected _transparencyMode: Nullable<number>;
  25885. /**
  25886. * Gets the current transparency mode.
  25887. */
  25888. get transparencyMode(): Nullable<number>;
  25889. /**
  25890. * Sets the transparency mode of the material.
  25891. *
  25892. * | Value | Type | Description |
  25893. * | ----- | ----------------------------------- | ----------- |
  25894. * | 0 | OPAQUE | |
  25895. * | 1 | ALPHATEST | |
  25896. * | 2 | ALPHABLEND | |
  25897. * | 3 | ALPHATESTANDBLEND | |
  25898. *
  25899. */
  25900. set transparencyMode(value: Nullable<number>);
  25901. /**
  25902. * Returns true if alpha blending should be disabled.
  25903. */
  25904. protected get _disableAlphaBlending(): boolean;
  25905. /**
  25906. * Specifies whether or not this material should be rendered in alpha blend mode.
  25907. * @returns a boolean specifying if alpha blending is needed
  25908. */
  25909. needAlphaBlending(): boolean;
  25910. /**
  25911. * Specifies if the mesh will require alpha blending
  25912. * @param mesh defines the mesh to check
  25913. * @returns a boolean specifying if alpha blending is needed for the mesh
  25914. */
  25915. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  25916. /**
  25917. * Specifies whether or not this material should be rendered in alpha test mode.
  25918. * @returns a boolean specifying if an alpha test is needed.
  25919. */
  25920. needAlphaTesting(): boolean;
  25921. /**
  25922. * Specifies if material alpha testing should be turned on for the mesh
  25923. * @param mesh defines the mesh to check
  25924. */
  25925. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  25926. /**
  25927. * Gets the texture used for the alpha test
  25928. * @returns the texture to use for alpha testing
  25929. */
  25930. getAlphaTestTexture(): Nullable<BaseTexture>;
  25931. /**
  25932. * Marks the material to indicate that it needs to be re-calculated
  25933. */
  25934. markDirty(): void;
  25935. /** @hidden */
  25936. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  25937. /**
  25938. * Binds the material to the mesh
  25939. * @param world defines the world transformation matrix
  25940. * @param mesh defines the mesh to bind the material to
  25941. */
  25942. bind(world: Matrix, mesh?: Mesh): void;
  25943. /**
  25944. * Binds the submesh to the material
  25945. * @param world defines the world transformation matrix
  25946. * @param mesh defines the mesh containing the submesh
  25947. * @param subMesh defines the submesh to bind the material to
  25948. */
  25949. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  25950. /**
  25951. * Binds the world matrix to the material
  25952. * @param world defines the world transformation matrix
  25953. */
  25954. bindOnlyWorldMatrix(world: Matrix): void;
  25955. /**
  25956. * Binds the scene's uniform buffer to the effect.
  25957. * @param effect defines the effect to bind to the scene uniform buffer
  25958. * @param sceneUbo defines the uniform buffer storing scene data
  25959. */
  25960. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  25961. /**
  25962. * Binds the view matrix to the effect
  25963. * @param effect defines the effect to bind the view matrix to
  25964. */
  25965. bindView(effect: Effect): void;
  25966. /**
  25967. * Binds the view projection matrix to the effect
  25968. * @param effect defines the effect to bind the view projection matrix to
  25969. */
  25970. bindViewProjection(effect: Effect): void;
  25971. /**
  25972. * Processes to execute after binding the material to a mesh
  25973. * @param mesh defines the rendered mesh
  25974. */
  25975. protected _afterBind(mesh?: Mesh): void;
  25976. /**
  25977. * Unbinds the material from the mesh
  25978. */
  25979. unbind(): void;
  25980. /**
  25981. * Gets the active textures from the material
  25982. * @returns an array of textures
  25983. */
  25984. getActiveTextures(): BaseTexture[];
  25985. /**
  25986. * Specifies if the material uses a texture
  25987. * @param texture defines the texture to check against the material
  25988. * @returns a boolean specifying if the material uses the texture
  25989. */
  25990. hasTexture(texture: BaseTexture): boolean;
  25991. /**
  25992. * Makes a duplicate of the material, and gives it a new name
  25993. * @param name defines the new name for the duplicated material
  25994. * @returns the cloned material
  25995. */
  25996. clone(name: string): Nullable<Material>;
  25997. /**
  25998. * Gets the meshes bound to the material
  25999. * @returns an array of meshes bound to the material
  26000. */
  26001. getBindedMeshes(): AbstractMesh[];
  26002. /**
  26003. * Force shader compilation
  26004. * @param mesh defines the mesh associated with this material
  26005. * @param onCompiled defines a function to execute once the material is compiled
  26006. * @param options defines the options to configure the compilation
  26007. * @param onError defines a function to execute if the material fails compiling
  26008. */
  26009. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  26010. /**
  26011. * Force shader compilation
  26012. * @param mesh defines the mesh that will use this material
  26013. * @param options defines additional options for compiling the shaders
  26014. * @returns a promise that resolves when the compilation completes
  26015. */
  26016. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  26017. private static readonly _AllDirtyCallBack;
  26018. private static readonly _ImageProcessingDirtyCallBack;
  26019. private static readonly _TextureDirtyCallBack;
  26020. private static readonly _FresnelDirtyCallBack;
  26021. private static readonly _MiscDirtyCallBack;
  26022. private static readonly _LightsDirtyCallBack;
  26023. private static readonly _AttributeDirtyCallBack;
  26024. private static _FresnelAndMiscDirtyCallBack;
  26025. private static _TextureAndMiscDirtyCallBack;
  26026. private static readonly _DirtyCallbackArray;
  26027. private static readonly _RunDirtyCallBacks;
  26028. /**
  26029. * Marks a define in the material to indicate that it needs to be re-computed
  26030. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  26031. */
  26032. markAsDirty(flag: number): void;
  26033. /**
  26034. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  26035. * @param func defines a function which checks material defines against the submeshes
  26036. */
  26037. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  26038. /**
  26039. * Indicates that the scene should check if the rendering now needs a prepass
  26040. */
  26041. protected _markScenePrePassDirty(): void;
  26042. /**
  26043. * Indicates that we need to re-calculated for all submeshes
  26044. */
  26045. protected _markAllSubMeshesAsAllDirty(): void;
  26046. /**
  26047. * Indicates that image processing needs to be re-calculated for all submeshes
  26048. */
  26049. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  26050. /**
  26051. * Indicates that textures need to be re-calculated for all submeshes
  26052. */
  26053. protected _markAllSubMeshesAsTexturesDirty(): void;
  26054. /**
  26055. * Indicates that fresnel needs to be re-calculated for all submeshes
  26056. */
  26057. protected _markAllSubMeshesAsFresnelDirty(): void;
  26058. /**
  26059. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  26060. */
  26061. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  26062. /**
  26063. * Indicates that lights need to be re-calculated for all submeshes
  26064. */
  26065. protected _markAllSubMeshesAsLightsDirty(): void;
  26066. /**
  26067. * Indicates that attributes need to be re-calculated for all submeshes
  26068. */
  26069. protected _markAllSubMeshesAsAttributesDirty(): void;
  26070. /**
  26071. * Indicates that misc needs to be re-calculated for all submeshes
  26072. */
  26073. protected _markAllSubMeshesAsMiscDirty(): void;
  26074. /**
  26075. * Indicates that textures and misc need to be re-calculated for all submeshes
  26076. */
  26077. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  26078. /**
  26079. * Sets the required values to the prepass renderer.
  26080. * @param prePassRenderer defines the prepass renderer to setup.
  26081. * @returns true if the pre pass is needed.
  26082. */
  26083. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  26084. /**
  26085. * Disposes the material
  26086. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  26087. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  26088. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  26089. */
  26090. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  26091. /** @hidden */
  26092. private releaseVertexArrayObject;
  26093. /**
  26094. * Serializes this material
  26095. * @returns the serialized material object
  26096. */
  26097. serialize(): any;
  26098. /**
  26099. * Creates a material from parsed material data
  26100. * @param parsedMaterial defines parsed material data
  26101. * @param scene defines the hosting scene
  26102. * @param rootUrl defines the root URL to use to load textures
  26103. * @returns a new material
  26104. */
  26105. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  26106. }
  26107. }
  26108. declare module "babylonjs/Materials/multiMaterial" {
  26109. import { Nullable } from "babylonjs/types";
  26110. import { Scene } from "babylonjs/scene";
  26111. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26112. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26113. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26114. import { Material } from "babylonjs/Materials/material";
  26115. /**
  26116. * A multi-material is used to apply different materials to different parts of the same object without the need of
  26117. * separate meshes. This can be use to improve performances.
  26118. * @see https://doc.babylonjs.com/how_to/multi_materials
  26119. */
  26120. export class MultiMaterial extends Material {
  26121. private _subMaterials;
  26122. /**
  26123. * Gets or Sets the list of Materials used within the multi material.
  26124. * They need to be ordered according to the submeshes order in the associated mesh
  26125. */
  26126. get subMaterials(): Nullable<Material>[];
  26127. set subMaterials(value: Nullable<Material>[]);
  26128. /**
  26129. * Function used to align with Node.getChildren()
  26130. * @returns the list of Materials used within the multi material
  26131. */
  26132. getChildren(): Nullable<Material>[];
  26133. /**
  26134. * Instantiates a new Multi Material
  26135. * A multi-material is used to apply different materials to different parts of the same object without the need of
  26136. * separate meshes. This can be use to improve performances.
  26137. * @see https://doc.babylonjs.com/how_to/multi_materials
  26138. * @param name Define the name in the scene
  26139. * @param scene Define the scene the material belongs to
  26140. */
  26141. constructor(name: string, scene: Scene);
  26142. private _hookArray;
  26143. /**
  26144. * Get one of the submaterial by its index in the submaterials array
  26145. * @param index The index to look the sub material at
  26146. * @returns The Material if the index has been defined
  26147. */
  26148. getSubMaterial(index: number): Nullable<Material>;
  26149. /**
  26150. * Get the list of active textures for the whole sub materials list.
  26151. * @returns All the textures that will be used during the rendering
  26152. */
  26153. getActiveTextures(): BaseTexture[];
  26154. /**
  26155. * Gets the current class name of the material e.g. "MultiMaterial"
  26156. * Mainly use in serialization.
  26157. * @returns the class name
  26158. */
  26159. getClassName(): string;
  26160. /**
  26161. * Checks if the material is ready to render the requested sub mesh
  26162. * @param mesh Define the mesh the submesh belongs to
  26163. * @param subMesh Define the sub mesh to look readyness for
  26164. * @param useInstances Define whether or not the material is used with instances
  26165. * @returns true if ready, otherwise false
  26166. */
  26167. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26168. /**
  26169. * Clones the current material and its related sub materials
  26170. * @param name Define the name of the newly cloned material
  26171. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  26172. * @returns the cloned material
  26173. */
  26174. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  26175. /**
  26176. * Serializes the materials into a JSON representation.
  26177. * @returns the JSON representation
  26178. */
  26179. serialize(): any;
  26180. /**
  26181. * Dispose the material and release its associated resources
  26182. * @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)
  26183. * @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)
  26184. * @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)
  26185. */
  26186. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  26187. /**
  26188. * Creates a MultiMaterial from parsed MultiMaterial data.
  26189. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  26190. * @param scene defines the hosting scene
  26191. * @returns a new MultiMaterial
  26192. */
  26193. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  26194. }
  26195. }
  26196. declare module "babylonjs/Meshes/subMesh" {
  26197. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  26198. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  26199. import { Engine } from "babylonjs/Engines/engine";
  26200. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  26201. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26202. import { Effect } from "babylonjs/Materials/effect";
  26203. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  26204. import { Plane } from "babylonjs/Maths/math.plane";
  26205. import { Collider } from "babylonjs/Collisions/collider";
  26206. import { Material } from "babylonjs/Materials/material";
  26207. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  26208. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26209. import { Mesh } from "babylonjs/Meshes/mesh";
  26210. import { Ray } from "babylonjs/Culling/ray";
  26211. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26212. /**
  26213. * Defines a subdivision inside a mesh
  26214. */
  26215. export class SubMesh implements ICullable {
  26216. /** the material index to use */
  26217. materialIndex: number;
  26218. /** vertex index start */
  26219. verticesStart: number;
  26220. /** vertices count */
  26221. verticesCount: number;
  26222. /** index start */
  26223. indexStart: number;
  26224. /** indices count */
  26225. indexCount: number;
  26226. /** @hidden */
  26227. _materialDefines: Nullable<MaterialDefines>;
  26228. /** @hidden */
  26229. _materialEffect: Nullable<Effect>;
  26230. /** @hidden */
  26231. _effectOverride: Nullable<Effect>;
  26232. /**
  26233. * Gets material defines used by the effect associated to the sub mesh
  26234. */
  26235. get materialDefines(): Nullable<MaterialDefines>;
  26236. /**
  26237. * Sets material defines used by the effect associated to the sub mesh
  26238. */
  26239. set materialDefines(defines: Nullable<MaterialDefines>);
  26240. /**
  26241. * Gets associated effect
  26242. */
  26243. get effect(): Nullable<Effect>;
  26244. /**
  26245. * Sets associated effect (effect used to render this submesh)
  26246. * @param effect defines the effect to associate with
  26247. * @param defines defines the set of defines used to compile this effect
  26248. */
  26249. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  26250. /** @hidden */
  26251. _linesIndexCount: number;
  26252. private _mesh;
  26253. private _renderingMesh;
  26254. private _boundingInfo;
  26255. private _linesIndexBuffer;
  26256. /** @hidden */
  26257. _lastColliderWorldVertices: Nullable<Vector3[]>;
  26258. /** @hidden */
  26259. _trianglePlanes: Plane[];
  26260. /** @hidden */
  26261. _lastColliderTransformMatrix: Nullable<Matrix>;
  26262. /** @hidden */
  26263. _renderId: number;
  26264. /** @hidden */
  26265. _alphaIndex: number;
  26266. /** @hidden */
  26267. _distanceToCamera: number;
  26268. /** @hidden */
  26269. _id: number;
  26270. private _currentMaterial;
  26271. /**
  26272. * Add a new submesh to a mesh
  26273. * @param materialIndex defines the material index to use
  26274. * @param verticesStart defines vertex index start
  26275. * @param verticesCount defines vertices count
  26276. * @param indexStart defines index start
  26277. * @param indexCount defines indices count
  26278. * @param mesh defines the parent mesh
  26279. * @param renderingMesh defines an optional rendering mesh
  26280. * @param createBoundingBox defines if bounding box should be created for this submesh
  26281. * @returns the new submesh
  26282. */
  26283. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  26284. /**
  26285. * Creates a new submesh
  26286. * @param materialIndex defines the material index to use
  26287. * @param verticesStart defines vertex index start
  26288. * @param verticesCount defines vertices count
  26289. * @param indexStart defines index start
  26290. * @param indexCount defines indices count
  26291. * @param mesh defines the parent mesh
  26292. * @param renderingMesh defines an optional rendering mesh
  26293. * @param createBoundingBox defines if bounding box should be created for this submesh
  26294. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  26295. */
  26296. constructor(
  26297. /** the material index to use */
  26298. materialIndex: number,
  26299. /** vertex index start */
  26300. verticesStart: number,
  26301. /** vertices count */
  26302. verticesCount: number,
  26303. /** index start */
  26304. indexStart: number,
  26305. /** indices count */
  26306. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  26307. /**
  26308. * Returns true if this submesh covers the entire parent mesh
  26309. * @ignorenaming
  26310. */
  26311. get IsGlobal(): boolean;
  26312. /**
  26313. * Returns the submesh BoudingInfo object
  26314. * @returns current bounding info (or mesh's one if the submesh is global)
  26315. */
  26316. getBoundingInfo(): BoundingInfo;
  26317. /**
  26318. * Sets the submesh BoundingInfo
  26319. * @param boundingInfo defines the new bounding info to use
  26320. * @returns the SubMesh
  26321. */
  26322. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  26323. /**
  26324. * Returns the mesh of the current submesh
  26325. * @return the parent mesh
  26326. */
  26327. getMesh(): AbstractMesh;
  26328. /**
  26329. * Returns the rendering mesh of the submesh
  26330. * @returns the rendering mesh (could be different from parent mesh)
  26331. */
  26332. getRenderingMesh(): Mesh;
  26333. /**
  26334. * Returns the replacement mesh of the submesh
  26335. * @returns the replacement mesh (could be different from parent mesh)
  26336. */
  26337. getReplacementMesh(): Nullable<AbstractMesh>;
  26338. /**
  26339. * Returns the effective mesh of the submesh
  26340. * @returns the effective mesh (could be different from parent mesh)
  26341. */
  26342. getEffectiveMesh(): AbstractMesh;
  26343. /**
  26344. * Returns the submesh material
  26345. * @returns null or the current material
  26346. */
  26347. getMaterial(): Nullable<Material>;
  26348. private _IsMultiMaterial;
  26349. /**
  26350. * Sets a new updated BoundingInfo object to the submesh
  26351. * @param data defines an optional position array to use to determine the bounding info
  26352. * @returns the SubMesh
  26353. */
  26354. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  26355. /** @hidden */
  26356. _checkCollision(collider: Collider): boolean;
  26357. /**
  26358. * Updates the submesh BoundingInfo
  26359. * @param world defines the world matrix to use to update the bounding info
  26360. * @returns the submesh
  26361. */
  26362. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  26363. /**
  26364. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  26365. * @param frustumPlanes defines the frustum planes
  26366. * @returns true if the submesh is intersecting with the frustum
  26367. */
  26368. isInFrustum(frustumPlanes: Plane[]): boolean;
  26369. /**
  26370. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  26371. * @param frustumPlanes defines the frustum planes
  26372. * @returns true if the submesh is inside the frustum
  26373. */
  26374. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26375. /**
  26376. * Renders the submesh
  26377. * @param enableAlphaMode defines if alpha needs to be used
  26378. * @returns the submesh
  26379. */
  26380. render(enableAlphaMode: boolean): SubMesh;
  26381. /**
  26382. * @hidden
  26383. */
  26384. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  26385. /**
  26386. * Checks if the submesh intersects with a ray
  26387. * @param ray defines the ray to test
  26388. * @returns true is the passed ray intersects the submesh bounding box
  26389. */
  26390. canIntersects(ray: Ray): boolean;
  26391. /**
  26392. * Intersects current submesh with a ray
  26393. * @param ray defines the ray to test
  26394. * @param positions defines mesh's positions array
  26395. * @param indices defines mesh's indices array
  26396. * @param fastCheck defines if the first intersection will be used (and not the closest)
  26397. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26398. * @returns intersection info or null if no intersection
  26399. */
  26400. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  26401. /** @hidden */
  26402. private _intersectLines;
  26403. /** @hidden */
  26404. private _intersectUnIndexedLines;
  26405. /** @hidden */
  26406. private _intersectTriangles;
  26407. /** @hidden */
  26408. private _intersectUnIndexedTriangles;
  26409. /** @hidden */
  26410. _rebuild(): void;
  26411. /**
  26412. * Creates a new submesh from the passed mesh
  26413. * @param newMesh defines the new hosting mesh
  26414. * @param newRenderingMesh defines an optional rendering mesh
  26415. * @returns the new submesh
  26416. */
  26417. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  26418. /**
  26419. * Release associated resources
  26420. */
  26421. dispose(): void;
  26422. /**
  26423. * Gets the class name
  26424. * @returns the string "SubMesh".
  26425. */
  26426. getClassName(): string;
  26427. /**
  26428. * Creates a new submesh from indices data
  26429. * @param materialIndex the index of the main mesh material
  26430. * @param startIndex the index where to start the copy in the mesh indices array
  26431. * @param indexCount the number of indices to copy then from the startIndex
  26432. * @param mesh the main mesh to create the submesh from
  26433. * @param renderingMesh the optional rendering mesh
  26434. * @returns a new submesh
  26435. */
  26436. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  26437. }
  26438. }
  26439. declare module "babylonjs/Loading/sceneLoaderFlags" {
  26440. /**
  26441. * Class used to represent data loading progression
  26442. */
  26443. export class SceneLoaderFlags {
  26444. private static _ForceFullSceneLoadingForIncremental;
  26445. private static _ShowLoadingScreen;
  26446. private static _CleanBoneMatrixWeights;
  26447. private static _loggingLevel;
  26448. /**
  26449. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  26450. */
  26451. static get ForceFullSceneLoadingForIncremental(): boolean;
  26452. static set ForceFullSceneLoadingForIncremental(value: boolean);
  26453. /**
  26454. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  26455. */
  26456. static get ShowLoadingScreen(): boolean;
  26457. static set ShowLoadingScreen(value: boolean);
  26458. /**
  26459. * Defines the current logging level (while loading the scene)
  26460. * @ignorenaming
  26461. */
  26462. static get loggingLevel(): number;
  26463. static set loggingLevel(value: number);
  26464. /**
  26465. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  26466. */
  26467. static get CleanBoneMatrixWeights(): boolean;
  26468. static set CleanBoneMatrixWeights(value: boolean);
  26469. }
  26470. }
  26471. declare module "babylonjs/Meshes/geometry" {
  26472. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  26473. import { Scene } from "babylonjs/scene";
  26474. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26475. import { Engine } from "babylonjs/Engines/engine";
  26476. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  26477. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  26478. import { Effect } from "babylonjs/Materials/effect";
  26479. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26480. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  26481. import { Mesh } from "babylonjs/Meshes/mesh";
  26482. /**
  26483. * Class used to store geometry data (vertex buffers + index buffer)
  26484. */
  26485. export class Geometry implements IGetSetVerticesData {
  26486. /**
  26487. * Gets or sets the ID of the geometry
  26488. */
  26489. id: string;
  26490. /**
  26491. * Gets or sets the unique ID of the geometry
  26492. */
  26493. uniqueId: number;
  26494. /**
  26495. * Gets the delay loading state of the geometry (none by default which means not delayed)
  26496. */
  26497. delayLoadState: number;
  26498. /**
  26499. * Gets the file containing the data to load when running in delay load state
  26500. */
  26501. delayLoadingFile: Nullable<string>;
  26502. /**
  26503. * Callback called when the geometry is updated
  26504. */
  26505. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  26506. private _scene;
  26507. private _engine;
  26508. private _meshes;
  26509. private _totalVertices;
  26510. /** @hidden */
  26511. _indices: IndicesArray;
  26512. /** @hidden */
  26513. _vertexBuffers: {
  26514. [key: string]: VertexBuffer;
  26515. };
  26516. private _isDisposed;
  26517. private _extend;
  26518. private _boundingBias;
  26519. /** @hidden */
  26520. _delayInfo: Array<string>;
  26521. private _indexBuffer;
  26522. private _indexBufferIsUpdatable;
  26523. /** @hidden */
  26524. _boundingInfo: Nullable<BoundingInfo>;
  26525. /** @hidden */
  26526. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  26527. /** @hidden */
  26528. _softwareSkinningFrameId: number;
  26529. private _vertexArrayObjects;
  26530. private _updatable;
  26531. /** @hidden */
  26532. _positions: Nullable<Vector3[]>;
  26533. /**
  26534. * 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
  26535. */
  26536. get boundingBias(): Vector2;
  26537. /**
  26538. * 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
  26539. */
  26540. set boundingBias(value: Vector2);
  26541. /**
  26542. * Static function used to attach a new empty geometry to a mesh
  26543. * @param mesh defines the mesh to attach the geometry to
  26544. * @returns the new Geometry
  26545. */
  26546. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  26547. /** Get the list of meshes using this geometry */
  26548. get meshes(): Mesh[];
  26549. /**
  26550. * 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
  26551. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  26552. */
  26553. useBoundingInfoFromGeometry: boolean;
  26554. /**
  26555. * Creates a new geometry
  26556. * @param id defines the unique ID
  26557. * @param scene defines the hosting scene
  26558. * @param vertexData defines the VertexData used to get geometry data
  26559. * @param updatable defines if geometry must be updatable (false by default)
  26560. * @param mesh defines the mesh that will be associated with the geometry
  26561. */
  26562. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  26563. /**
  26564. * Gets the current extend of the geometry
  26565. */
  26566. get extend(): {
  26567. minimum: Vector3;
  26568. maximum: Vector3;
  26569. };
  26570. /**
  26571. * Gets the hosting scene
  26572. * @returns the hosting Scene
  26573. */
  26574. getScene(): Scene;
  26575. /**
  26576. * Gets the hosting engine
  26577. * @returns the hosting Engine
  26578. */
  26579. getEngine(): Engine;
  26580. /**
  26581. * Defines if the geometry is ready to use
  26582. * @returns true if the geometry is ready to be used
  26583. */
  26584. isReady(): boolean;
  26585. /**
  26586. * Gets a value indicating that the geometry should not be serialized
  26587. */
  26588. get doNotSerialize(): boolean;
  26589. /** @hidden */
  26590. _rebuild(): void;
  26591. /**
  26592. * Affects all geometry data in one call
  26593. * @param vertexData defines the geometry data
  26594. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  26595. */
  26596. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  26597. /**
  26598. * Set specific vertex data
  26599. * @param kind defines the data kind (Position, normal, etc...)
  26600. * @param data defines the vertex data to use
  26601. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  26602. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  26603. */
  26604. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  26605. /**
  26606. * Removes a specific vertex data
  26607. * @param kind defines the data kind (Position, normal, etc...)
  26608. */
  26609. removeVerticesData(kind: string): void;
  26610. /**
  26611. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  26612. * @param buffer defines the vertex buffer to use
  26613. * @param totalVertices defines the total number of vertices for position kind (could be null)
  26614. */
  26615. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  26616. /**
  26617. * Update a specific vertex buffer
  26618. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  26619. * It will do nothing if the buffer is not updatable
  26620. * @param kind defines the data kind (Position, normal, etc...)
  26621. * @param data defines the data to use
  26622. * @param offset defines the offset in the target buffer where to store the data
  26623. * @param useBytes set to true if the offset is in bytes
  26624. */
  26625. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  26626. /**
  26627. * Update a specific vertex buffer
  26628. * This function will create a new buffer if the current one is not updatable
  26629. * @param kind defines the data kind (Position, normal, etc...)
  26630. * @param data defines the data to use
  26631. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  26632. */
  26633. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  26634. private _updateBoundingInfo;
  26635. /** @hidden */
  26636. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  26637. /**
  26638. * Gets total number of vertices
  26639. * @returns the total number of vertices
  26640. */
  26641. getTotalVertices(): number;
  26642. /**
  26643. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  26644. * @param kind defines the data kind (Position, normal, etc...)
  26645. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26646. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26647. * @returns a float array containing vertex data
  26648. */
  26649. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26650. /**
  26651. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  26652. * @param kind defines the data kind (Position, normal, etc...)
  26653. * @returns true if the vertex buffer with the specified kind is updatable
  26654. */
  26655. isVertexBufferUpdatable(kind: string): boolean;
  26656. /**
  26657. * Gets a specific vertex buffer
  26658. * @param kind defines the data kind (Position, normal, etc...)
  26659. * @returns a VertexBuffer
  26660. */
  26661. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  26662. /**
  26663. * Returns all vertex buffers
  26664. * @return an object holding all vertex buffers indexed by kind
  26665. */
  26666. getVertexBuffers(): Nullable<{
  26667. [key: string]: VertexBuffer;
  26668. }>;
  26669. /**
  26670. * Gets a boolean indicating if specific vertex buffer is present
  26671. * @param kind defines the data kind (Position, normal, etc...)
  26672. * @returns true if data is present
  26673. */
  26674. isVerticesDataPresent(kind: string): boolean;
  26675. /**
  26676. * Gets a list of all attached data kinds (Position, normal, etc...)
  26677. * @returns a list of string containing all kinds
  26678. */
  26679. getVerticesDataKinds(): string[];
  26680. /**
  26681. * Update index buffer
  26682. * @param indices defines the indices to store in the index buffer
  26683. * @param offset defines the offset in the target buffer where to store the data
  26684. * @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)
  26685. */
  26686. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  26687. /**
  26688. * Creates a new index buffer
  26689. * @param indices defines the indices to store in the index buffer
  26690. * @param totalVertices defines the total number of vertices (could be null)
  26691. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  26692. */
  26693. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  26694. /**
  26695. * Return the total number of indices
  26696. * @returns the total number of indices
  26697. */
  26698. getTotalIndices(): number;
  26699. /**
  26700. * Gets the index buffer array
  26701. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26702. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26703. * @returns the index buffer array
  26704. */
  26705. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26706. /**
  26707. * Gets the index buffer
  26708. * @return the index buffer
  26709. */
  26710. getIndexBuffer(): Nullable<DataBuffer>;
  26711. /** @hidden */
  26712. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  26713. /**
  26714. * Release the associated resources for a specific mesh
  26715. * @param mesh defines the source mesh
  26716. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  26717. */
  26718. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  26719. /**
  26720. * Apply current geometry to a given mesh
  26721. * @param mesh defines the mesh to apply geometry to
  26722. */
  26723. applyToMesh(mesh: Mesh): void;
  26724. private _updateExtend;
  26725. private _applyToMesh;
  26726. private notifyUpdate;
  26727. /**
  26728. * Load the geometry if it was flagged as delay loaded
  26729. * @param scene defines the hosting scene
  26730. * @param onLoaded defines a callback called when the geometry is loaded
  26731. */
  26732. load(scene: Scene, onLoaded?: () => void): void;
  26733. private _queueLoad;
  26734. /**
  26735. * Invert the geometry to move from a right handed system to a left handed one.
  26736. */
  26737. toLeftHanded(): void;
  26738. /** @hidden */
  26739. _resetPointsArrayCache(): void;
  26740. /** @hidden */
  26741. _generatePointsArray(): boolean;
  26742. /**
  26743. * Gets a value indicating if the geometry is disposed
  26744. * @returns true if the geometry was disposed
  26745. */
  26746. isDisposed(): boolean;
  26747. private _disposeVertexArrayObjects;
  26748. /**
  26749. * Free all associated resources
  26750. */
  26751. dispose(): void;
  26752. /**
  26753. * Clone the current geometry into a new geometry
  26754. * @param id defines the unique ID of the new geometry
  26755. * @returns a new geometry object
  26756. */
  26757. copy(id: string): Geometry;
  26758. /**
  26759. * Serialize the current geometry info (and not the vertices data) into a JSON object
  26760. * @return a JSON representation of the current geometry data (without the vertices data)
  26761. */
  26762. serialize(): any;
  26763. private toNumberArray;
  26764. /**
  26765. * Serialize all vertices data into a JSON oject
  26766. * @returns a JSON representation of the current geometry data
  26767. */
  26768. serializeVerticeData(): any;
  26769. /**
  26770. * Extracts a clone of a mesh geometry
  26771. * @param mesh defines the source mesh
  26772. * @param id defines the unique ID of the new geometry object
  26773. * @returns the new geometry object
  26774. */
  26775. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  26776. /**
  26777. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  26778. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  26779. * Be aware Math.random() could cause collisions, but:
  26780. * "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"
  26781. * @returns a string containing a new GUID
  26782. */
  26783. static RandomId(): string;
  26784. /** @hidden */
  26785. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  26786. private static _CleanMatricesWeights;
  26787. /**
  26788. * Create a new geometry from persisted data (Using .babylon file format)
  26789. * @param parsedVertexData defines the persisted data
  26790. * @param scene defines the hosting scene
  26791. * @param rootUrl defines the root url to use to load assets (like delayed data)
  26792. * @returns the new geometry object
  26793. */
  26794. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  26795. }
  26796. }
  26797. declare module "babylonjs/Meshes/mesh.vertexData" {
  26798. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  26799. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  26800. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  26801. import { Geometry } from "babylonjs/Meshes/geometry";
  26802. import { Mesh } from "babylonjs/Meshes/mesh";
  26803. /**
  26804. * Define an interface for all classes that will get and set the data on vertices
  26805. */
  26806. export interface IGetSetVerticesData {
  26807. /**
  26808. * Gets a boolean indicating if specific vertex data is present
  26809. * @param kind defines the vertex data kind to use
  26810. * @returns true is data kind is present
  26811. */
  26812. isVerticesDataPresent(kind: string): boolean;
  26813. /**
  26814. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  26815. * @param kind defines the data kind (Position, normal, etc...)
  26816. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26817. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26818. * @returns a float array containing vertex data
  26819. */
  26820. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26821. /**
  26822. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26823. * @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.
  26824. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26825. * @returns the indices array or an empty array if the mesh has no geometry
  26826. */
  26827. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26828. /**
  26829. * Set specific vertex data
  26830. * @param kind defines the data kind (Position, normal, etc...)
  26831. * @param data defines the vertex data to use
  26832. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  26833. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  26834. */
  26835. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  26836. /**
  26837. * Update a specific associated vertex buffer
  26838. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26839. * - VertexBuffer.PositionKind
  26840. * - VertexBuffer.UVKind
  26841. * - VertexBuffer.UV2Kind
  26842. * - VertexBuffer.UV3Kind
  26843. * - VertexBuffer.UV4Kind
  26844. * - VertexBuffer.UV5Kind
  26845. * - VertexBuffer.UV6Kind
  26846. * - VertexBuffer.ColorKind
  26847. * - VertexBuffer.MatricesIndicesKind
  26848. * - VertexBuffer.MatricesIndicesExtraKind
  26849. * - VertexBuffer.MatricesWeightsKind
  26850. * - VertexBuffer.MatricesWeightsExtraKind
  26851. * @param data defines the data source
  26852. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  26853. * @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)
  26854. */
  26855. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  26856. /**
  26857. * Creates a new index buffer
  26858. * @param indices defines the indices to store in the index buffer
  26859. * @param totalVertices defines the total number of vertices (could be null)
  26860. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  26861. */
  26862. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  26863. }
  26864. /**
  26865. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  26866. */
  26867. export class VertexData {
  26868. /**
  26869. * Mesh side orientation : usually the external or front surface
  26870. */
  26871. static readonly FRONTSIDE: number;
  26872. /**
  26873. * Mesh side orientation : usually the internal or back surface
  26874. */
  26875. static readonly BACKSIDE: number;
  26876. /**
  26877. * Mesh side orientation : both internal and external or front and back surfaces
  26878. */
  26879. static readonly DOUBLESIDE: number;
  26880. /**
  26881. * Mesh side orientation : by default, `FRONTSIDE`
  26882. */
  26883. static readonly DEFAULTSIDE: number;
  26884. /**
  26885. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  26886. */
  26887. positions: Nullable<FloatArray>;
  26888. /**
  26889. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  26890. */
  26891. normals: Nullable<FloatArray>;
  26892. /**
  26893. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  26894. */
  26895. tangents: Nullable<FloatArray>;
  26896. /**
  26897. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26898. */
  26899. uvs: Nullable<FloatArray>;
  26900. /**
  26901. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26902. */
  26903. uvs2: Nullable<FloatArray>;
  26904. /**
  26905. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26906. */
  26907. uvs3: Nullable<FloatArray>;
  26908. /**
  26909. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26910. */
  26911. uvs4: Nullable<FloatArray>;
  26912. /**
  26913. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26914. */
  26915. uvs5: Nullable<FloatArray>;
  26916. /**
  26917. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26918. */
  26919. uvs6: Nullable<FloatArray>;
  26920. /**
  26921. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  26922. */
  26923. colors: Nullable<FloatArray>;
  26924. /**
  26925. * 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).
  26926. */
  26927. matricesIndices: Nullable<FloatArray>;
  26928. /**
  26929. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  26930. */
  26931. matricesWeights: Nullable<FloatArray>;
  26932. /**
  26933. * An array extending the number of possible indices
  26934. */
  26935. matricesIndicesExtra: Nullable<FloatArray>;
  26936. /**
  26937. * An array extending the number of possible weights when the number of indices is extended
  26938. */
  26939. matricesWeightsExtra: Nullable<FloatArray>;
  26940. /**
  26941. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  26942. */
  26943. indices: Nullable<IndicesArray>;
  26944. /**
  26945. * Uses the passed data array to set the set the values for the specified kind of data
  26946. * @param data a linear array of floating numbers
  26947. * @param kind the type of data that is being set, eg positions, colors etc
  26948. */
  26949. set(data: FloatArray, kind: string): void;
  26950. /**
  26951. * Associates the vertexData to the passed Mesh.
  26952. * Sets it as updatable or not (default `false`)
  26953. * @param mesh the mesh the vertexData is applied to
  26954. * @param updatable when used and having the value true allows new data to update the vertexData
  26955. * @returns the VertexData
  26956. */
  26957. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  26958. /**
  26959. * Associates the vertexData to the passed Geometry.
  26960. * Sets it as updatable or not (default `false`)
  26961. * @param geometry the geometry the vertexData is applied to
  26962. * @param updatable when used and having the value true allows new data to update the vertexData
  26963. * @returns VertexData
  26964. */
  26965. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  26966. /**
  26967. * Updates the associated mesh
  26968. * @param mesh the mesh to be updated
  26969. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26970. * @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
  26971. * @returns VertexData
  26972. */
  26973. updateMesh(mesh: Mesh): VertexData;
  26974. /**
  26975. * Updates the associated geometry
  26976. * @param geometry the geometry to be updated
  26977. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26978. * @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
  26979. * @returns VertexData.
  26980. */
  26981. updateGeometry(geometry: Geometry): VertexData;
  26982. private _applyTo;
  26983. private _update;
  26984. /**
  26985. * Transforms each position and each normal of the vertexData according to the passed Matrix
  26986. * @param matrix the transforming matrix
  26987. * @returns the VertexData
  26988. */
  26989. transform(matrix: Matrix): VertexData;
  26990. /**
  26991. * Merges the passed VertexData into the current one
  26992. * @param other the VertexData to be merged into the current one
  26993. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  26994. * @returns the modified VertexData
  26995. */
  26996. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  26997. private _mergeElement;
  26998. private _validate;
  26999. /**
  27000. * Serializes the VertexData
  27001. * @returns a serialized object
  27002. */
  27003. serialize(): any;
  27004. /**
  27005. * Extracts the vertexData from a mesh
  27006. * @param mesh the mesh from which to extract the VertexData
  27007. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  27008. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27009. * @returns the object VertexData associated to the passed mesh
  27010. */
  27011. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27012. /**
  27013. * Extracts the vertexData from the geometry
  27014. * @param geometry the geometry from which to extract the VertexData
  27015. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  27016. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27017. * @returns the object VertexData associated to the passed mesh
  27018. */
  27019. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27020. private static _ExtractFrom;
  27021. /**
  27022. * Creates the VertexData for a Ribbon
  27023. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  27024. * * pathArray array of paths, each of which an array of successive Vector3
  27025. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  27026. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  27027. * * 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
  27028. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27029. * * 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)
  27030. * * 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)
  27031. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  27032. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  27033. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  27034. * @returns the VertexData of the ribbon
  27035. */
  27036. static CreateRibbon(options: {
  27037. pathArray: Vector3[][];
  27038. closeArray?: boolean;
  27039. closePath?: boolean;
  27040. offset?: number;
  27041. sideOrientation?: number;
  27042. frontUVs?: Vector4;
  27043. backUVs?: Vector4;
  27044. invertUV?: boolean;
  27045. uvs?: Vector2[];
  27046. colors?: Color4[];
  27047. }): VertexData;
  27048. /**
  27049. * Creates the VertexData for a box
  27050. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27051. * * size sets the width, height and depth of the box to the value of size, optional default 1
  27052. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  27053. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  27054. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  27055. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  27056. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  27057. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27058. * * 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)
  27059. * * 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)
  27060. * @returns the VertexData of the box
  27061. */
  27062. static CreateBox(options: {
  27063. size?: number;
  27064. width?: number;
  27065. height?: number;
  27066. depth?: number;
  27067. faceUV?: Vector4[];
  27068. faceColors?: Color4[];
  27069. sideOrientation?: number;
  27070. frontUVs?: Vector4;
  27071. backUVs?: Vector4;
  27072. }): VertexData;
  27073. /**
  27074. * Creates the VertexData for a tiled box
  27075. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27076. * * faceTiles sets the pattern, tile size and number of tiles for a face
  27077. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  27078. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  27079. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27080. * @returns the VertexData of the box
  27081. */
  27082. static CreateTiledBox(options: {
  27083. pattern?: number;
  27084. width?: number;
  27085. height?: number;
  27086. depth?: number;
  27087. tileSize?: number;
  27088. tileWidth?: number;
  27089. tileHeight?: number;
  27090. alignHorizontal?: number;
  27091. alignVertical?: number;
  27092. faceUV?: Vector4[];
  27093. faceColors?: Color4[];
  27094. sideOrientation?: number;
  27095. }): VertexData;
  27096. /**
  27097. * Creates the VertexData for a tiled plane
  27098. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27099. * * pattern a limited pattern arrangement depending on the number
  27100. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  27101. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  27102. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  27103. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27104. * * 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)
  27105. * * 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)
  27106. * @returns the VertexData of the tiled plane
  27107. */
  27108. static CreateTiledPlane(options: {
  27109. pattern?: number;
  27110. tileSize?: number;
  27111. tileWidth?: number;
  27112. tileHeight?: number;
  27113. size?: number;
  27114. width?: number;
  27115. height?: number;
  27116. alignHorizontal?: number;
  27117. alignVertical?: number;
  27118. sideOrientation?: number;
  27119. frontUVs?: Vector4;
  27120. backUVs?: Vector4;
  27121. }): VertexData;
  27122. /**
  27123. * Creates the VertexData for an ellipsoid, defaults to a sphere
  27124. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27125. * * segments sets the number of horizontal strips optional, default 32
  27126. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  27127. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  27128. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  27129. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  27130. * * 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
  27131. * * 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
  27132. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27133. * * 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)
  27134. * * 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)
  27135. * @returns the VertexData of the ellipsoid
  27136. */
  27137. static CreateSphere(options: {
  27138. segments?: number;
  27139. diameter?: number;
  27140. diameterX?: number;
  27141. diameterY?: number;
  27142. diameterZ?: number;
  27143. arc?: number;
  27144. slice?: number;
  27145. sideOrientation?: number;
  27146. frontUVs?: Vector4;
  27147. backUVs?: Vector4;
  27148. }): VertexData;
  27149. /**
  27150. * Creates the VertexData for a cylinder, cone or prism
  27151. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27152. * * height sets the height (y direction) of the cylinder, optional, default 2
  27153. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  27154. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  27155. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  27156. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27157. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  27158. * * 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
  27159. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27160. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27161. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  27162. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  27163. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27164. * * 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)
  27165. * * 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)
  27166. * @returns the VertexData of the cylinder, cone or prism
  27167. */
  27168. static CreateCylinder(options: {
  27169. height?: number;
  27170. diameterTop?: number;
  27171. diameterBottom?: number;
  27172. diameter?: number;
  27173. tessellation?: number;
  27174. subdivisions?: number;
  27175. arc?: number;
  27176. faceColors?: Color4[];
  27177. faceUV?: Vector4[];
  27178. hasRings?: boolean;
  27179. enclose?: boolean;
  27180. sideOrientation?: number;
  27181. frontUVs?: Vector4;
  27182. backUVs?: Vector4;
  27183. }): VertexData;
  27184. /**
  27185. * Creates the VertexData for a torus
  27186. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27187. * * diameter the diameter of the torus, optional default 1
  27188. * * thickness the diameter of the tube forming the torus, optional default 0.5
  27189. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27190. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27191. * * 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)
  27192. * * 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)
  27193. * @returns the VertexData of the torus
  27194. */
  27195. static CreateTorus(options: {
  27196. diameter?: number;
  27197. thickness?: number;
  27198. tessellation?: number;
  27199. sideOrientation?: number;
  27200. frontUVs?: Vector4;
  27201. backUVs?: Vector4;
  27202. }): VertexData;
  27203. /**
  27204. * Creates the VertexData of the LineSystem
  27205. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  27206. * - lines an array of lines, each line being an array of successive Vector3
  27207. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  27208. * @returns the VertexData of the LineSystem
  27209. */
  27210. static CreateLineSystem(options: {
  27211. lines: Vector3[][];
  27212. colors?: Nullable<Color4[][]>;
  27213. }): VertexData;
  27214. /**
  27215. * Create the VertexData for a DashedLines
  27216. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  27217. * - points an array successive Vector3
  27218. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  27219. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  27220. * - dashNb the intended total number of dashes, optional, default 200
  27221. * @returns the VertexData for the DashedLines
  27222. */
  27223. static CreateDashedLines(options: {
  27224. points: Vector3[];
  27225. dashSize?: number;
  27226. gapSize?: number;
  27227. dashNb?: number;
  27228. }): VertexData;
  27229. /**
  27230. * Creates the VertexData for a Ground
  27231. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27232. * - width the width (x direction) of the ground, optional, default 1
  27233. * - height the height (z direction) of the ground, optional, default 1
  27234. * - subdivisions the number of subdivisions per side, optional, default 1
  27235. * @returns the VertexData of the Ground
  27236. */
  27237. static CreateGround(options: {
  27238. width?: number;
  27239. height?: number;
  27240. subdivisions?: number;
  27241. subdivisionsX?: number;
  27242. subdivisionsY?: number;
  27243. }): VertexData;
  27244. /**
  27245. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  27246. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27247. * * xmin the ground minimum X coordinate, optional, default -1
  27248. * * zmin the ground minimum Z coordinate, optional, default -1
  27249. * * xmax the ground maximum X coordinate, optional, default 1
  27250. * * zmax the ground maximum Z coordinate, optional, default 1
  27251. * * 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}
  27252. * * 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}
  27253. * @returns the VertexData of the TiledGround
  27254. */
  27255. static CreateTiledGround(options: {
  27256. xmin: number;
  27257. zmin: number;
  27258. xmax: number;
  27259. zmax: number;
  27260. subdivisions?: {
  27261. w: number;
  27262. h: number;
  27263. };
  27264. precision?: {
  27265. w: number;
  27266. h: number;
  27267. };
  27268. }): VertexData;
  27269. /**
  27270. * Creates the VertexData of the Ground designed from a heightmap
  27271. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  27272. * * width the width (x direction) of the ground
  27273. * * height the height (z direction) of the ground
  27274. * * subdivisions the number of subdivisions per side
  27275. * * minHeight the minimum altitude on the ground, optional, default 0
  27276. * * maxHeight the maximum altitude on the ground, optional default 1
  27277. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  27278. * * buffer the array holding the image color data
  27279. * * bufferWidth the width of image
  27280. * * bufferHeight the height of image
  27281. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  27282. * @returns the VertexData of the Ground designed from a heightmap
  27283. */
  27284. static CreateGroundFromHeightMap(options: {
  27285. width: number;
  27286. height: number;
  27287. subdivisions: number;
  27288. minHeight: number;
  27289. maxHeight: number;
  27290. colorFilter: Color3;
  27291. buffer: Uint8Array;
  27292. bufferWidth: number;
  27293. bufferHeight: number;
  27294. alphaFilter: number;
  27295. }): VertexData;
  27296. /**
  27297. * Creates the VertexData for a Plane
  27298. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  27299. * * size sets the width and height of the plane to the value of size, optional default 1
  27300. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  27301. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  27302. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27303. * * 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)
  27304. * * 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)
  27305. * @returns the VertexData of the box
  27306. */
  27307. static CreatePlane(options: {
  27308. size?: number;
  27309. width?: number;
  27310. height?: number;
  27311. sideOrientation?: number;
  27312. frontUVs?: Vector4;
  27313. backUVs?: Vector4;
  27314. }): VertexData;
  27315. /**
  27316. * Creates the VertexData of the Disc or regular Polygon
  27317. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  27318. * * radius the radius of the disc, optional default 0.5
  27319. * * tessellation the number of polygon sides, optional, default 64
  27320. * * 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
  27321. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27322. * * 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)
  27323. * * 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)
  27324. * @returns the VertexData of the box
  27325. */
  27326. static CreateDisc(options: {
  27327. radius?: number;
  27328. tessellation?: number;
  27329. arc?: number;
  27330. sideOrientation?: number;
  27331. frontUVs?: Vector4;
  27332. backUVs?: Vector4;
  27333. }): VertexData;
  27334. /**
  27335. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  27336. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  27337. * @param polygon a mesh built from polygonTriangulation.build()
  27338. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27339. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27340. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27341. * @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)
  27342. * @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)
  27343. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  27344. * @returns the VertexData of the Polygon
  27345. */
  27346. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  27347. /**
  27348. * Creates the VertexData of the IcoSphere
  27349. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  27350. * * radius the radius of the IcoSphere, optional default 1
  27351. * * radiusX allows stretching in the x direction, optional, default radius
  27352. * * radiusY allows stretching in the y direction, optional, default radius
  27353. * * radiusZ allows stretching in the z direction, optional, default radius
  27354. * * flat when true creates a flat shaded mesh, optional, default true
  27355. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27356. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27357. * * 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)
  27358. * * 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)
  27359. * @returns the VertexData of the IcoSphere
  27360. */
  27361. static CreateIcoSphere(options: {
  27362. radius?: number;
  27363. radiusX?: number;
  27364. radiusY?: number;
  27365. radiusZ?: number;
  27366. flat?: boolean;
  27367. subdivisions?: number;
  27368. sideOrientation?: number;
  27369. frontUVs?: Vector4;
  27370. backUVs?: Vector4;
  27371. }): VertexData;
  27372. /**
  27373. * Creates the VertexData for a Polyhedron
  27374. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  27375. * * type provided types are:
  27376. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  27377. * * 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)
  27378. * * size the size of the IcoSphere, optional default 1
  27379. * * sizeX allows stretching in the x direction, optional, default size
  27380. * * sizeY allows stretching in the y direction, optional, default size
  27381. * * sizeZ allows stretching in the z direction, optional, default size
  27382. * * 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
  27383. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27384. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27385. * * flat when true creates a flat shaded mesh, optional, default true
  27386. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27387. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27388. * * 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)
  27389. * * 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)
  27390. * @returns the VertexData of the Polyhedron
  27391. */
  27392. static CreatePolyhedron(options: {
  27393. type?: number;
  27394. size?: number;
  27395. sizeX?: number;
  27396. sizeY?: number;
  27397. sizeZ?: number;
  27398. custom?: any;
  27399. faceUV?: Vector4[];
  27400. faceColors?: Color4[];
  27401. flat?: boolean;
  27402. sideOrientation?: number;
  27403. frontUVs?: Vector4;
  27404. backUVs?: Vector4;
  27405. }): VertexData;
  27406. /**
  27407. * Creates the VertexData for a TorusKnot
  27408. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  27409. * * radius the radius of the torus knot, optional, default 2
  27410. * * tube the thickness of the tube, optional, default 0.5
  27411. * * radialSegments the number of sides on each tube segments, optional, default 32
  27412. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  27413. * * p the number of windings around the z axis, optional, default 2
  27414. * * q the number of windings around the x axis, optional, default 3
  27415. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27416. * * 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)
  27417. * * 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)
  27418. * @returns the VertexData of the Torus Knot
  27419. */
  27420. static CreateTorusKnot(options: {
  27421. radius?: number;
  27422. tube?: number;
  27423. radialSegments?: number;
  27424. tubularSegments?: number;
  27425. p?: number;
  27426. q?: number;
  27427. sideOrientation?: number;
  27428. frontUVs?: Vector4;
  27429. backUVs?: Vector4;
  27430. }): VertexData;
  27431. /**
  27432. * Compute normals for given positions and indices
  27433. * @param positions an array of vertex positions, [...., x, y, z, ......]
  27434. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  27435. * @param normals an array of vertex normals, [...., x, y, z, ......]
  27436. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  27437. * * facetNormals : optional array of facet normals (vector3)
  27438. * * facetPositions : optional array of facet positions (vector3)
  27439. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  27440. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  27441. * * bInfo : optional bounding info, required for facetPartitioning computation
  27442. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  27443. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  27444. * * useRightHandedSystem: optional boolean to for right handed system computation
  27445. * * depthSort : optional boolean to enable the facet depth sort computation
  27446. * * distanceTo : optional Vector3 to compute the facet depth from this location
  27447. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  27448. */
  27449. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  27450. facetNormals?: any;
  27451. facetPositions?: any;
  27452. facetPartitioning?: any;
  27453. ratio?: number;
  27454. bInfo?: any;
  27455. bbSize?: Vector3;
  27456. subDiv?: any;
  27457. useRightHandedSystem?: boolean;
  27458. depthSort?: boolean;
  27459. distanceTo?: Vector3;
  27460. depthSortedFacets?: any;
  27461. }): void;
  27462. /** @hidden */
  27463. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  27464. /**
  27465. * Applies VertexData created from the imported parameters to the geometry
  27466. * @param parsedVertexData the parsed data from an imported file
  27467. * @param geometry the geometry to apply the VertexData to
  27468. */
  27469. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  27470. }
  27471. }
  27472. declare module "babylonjs/Morph/morphTarget" {
  27473. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27474. import { Observable } from "babylonjs/Misc/observable";
  27475. import { Nullable, FloatArray } from "babylonjs/types";
  27476. import { Scene } from "babylonjs/scene";
  27477. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27478. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27479. /**
  27480. * Defines a target to use with MorphTargetManager
  27481. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27482. */
  27483. export class MorphTarget implements IAnimatable {
  27484. /** defines the name of the target */
  27485. name: string;
  27486. /**
  27487. * Gets or sets the list of animations
  27488. */
  27489. animations: import("babylonjs/Animations/animation").Animation[];
  27490. private _scene;
  27491. private _positions;
  27492. private _normals;
  27493. private _tangents;
  27494. private _uvs;
  27495. private _influence;
  27496. private _uniqueId;
  27497. /**
  27498. * Observable raised when the influence changes
  27499. */
  27500. onInfluenceChanged: Observable<boolean>;
  27501. /** @hidden */
  27502. _onDataLayoutChanged: Observable<void>;
  27503. /**
  27504. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  27505. */
  27506. get influence(): number;
  27507. set influence(influence: number);
  27508. /**
  27509. * Gets or sets the id of the morph Target
  27510. */
  27511. id: string;
  27512. private _animationPropertiesOverride;
  27513. /**
  27514. * Gets or sets the animation properties override
  27515. */
  27516. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  27517. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  27518. /**
  27519. * Creates a new MorphTarget
  27520. * @param name defines the name of the target
  27521. * @param influence defines the influence to use
  27522. * @param scene defines the scene the morphtarget belongs to
  27523. */
  27524. constructor(
  27525. /** defines the name of the target */
  27526. name: string, influence?: number, scene?: Nullable<Scene>);
  27527. /**
  27528. * Gets the unique ID of this manager
  27529. */
  27530. get uniqueId(): number;
  27531. /**
  27532. * Gets a boolean defining if the target contains position data
  27533. */
  27534. get hasPositions(): boolean;
  27535. /**
  27536. * Gets a boolean defining if the target contains normal data
  27537. */
  27538. get hasNormals(): boolean;
  27539. /**
  27540. * Gets a boolean defining if the target contains tangent data
  27541. */
  27542. get hasTangents(): boolean;
  27543. /**
  27544. * Gets a boolean defining if the target contains texture coordinates data
  27545. */
  27546. get hasUVs(): boolean;
  27547. /**
  27548. * Affects position data to this target
  27549. * @param data defines the position data to use
  27550. */
  27551. setPositions(data: Nullable<FloatArray>): void;
  27552. /**
  27553. * Gets the position data stored in this target
  27554. * @returns a FloatArray containing the position data (or null if not present)
  27555. */
  27556. getPositions(): Nullable<FloatArray>;
  27557. /**
  27558. * Affects normal data to this target
  27559. * @param data defines the normal data to use
  27560. */
  27561. setNormals(data: Nullable<FloatArray>): void;
  27562. /**
  27563. * Gets the normal data stored in this target
  27564. * @returns a FloatArray containing the normal data (or null if not present)
  27565. */
  27566. getNormals(): Nullable<FloatArray>;
  27567. /**
  27568. * Affects tangent data to this target
  27569. * @param data defines the tangent data to use
  27570. */
  27571. setTangents(data: Nullable<FloatArray>): void;
  27572. /**
  27573. * Gets the tangent data stored in this target
  27574. * @returns a FloatArray containing the tangent data (or null if not present)
  27575. */
  27576. getTangents(): Nullable<FloatArray>;
  27577. /**
  27578. * Affects texture coordinates data to this target
  27579. * @param data defines the texture coordinates data to use
  27580. */
  27581. setUVs(data: Nullable<FloatArray>): void;
  27582. /**
  27583. * Gets the texture coordinates data stored in this target
  27584. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  27585. */
  27586. getUVs(): Nullable<FloatArray>;
  27587. /**
  27588. * Clone the current target
  27589. * @returns a new MorphTarget
  27590. */
  27591. clone(): MorphTarget;
  27592. /**
  27593. * Serializes the current target into a Serialization object
  27594. * @returns the serialized object
  27595. */
  27596. serialize(): any;
  27597. /**
  27598. * Returns the string "MorphTarget"
  27599. * @returns "MorphTarget"
  27600. */
  27601. getClassName(): string;
  27602. /**
  27603. * Creates a new target from serialized data
  27604. * @param serializationObject defines the serialized data to use
  27605. * @returns a new MorphTarget
  27606. */
  27607. static Parse(serializationObject: any): MorphTarget;
  27608. /**
  27609. * Creates a MorphTarget from mesh data
  27610. * @param mesh defines the source mesh
  27611. * @param name defines the name to use for the new target
  27612. * @param influence defines the influence to attach to the target
  27613. * @returns a new MorphTarget
  27614. */
  27615. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  27616. }
  27617. }
  27618. declare module "babylonjs/Morph/morphTargetManager" {
  27619. import { Nullable } from "babylonjs/types";
  27620. import { Scene } from "babylonjs/scene";
  27621. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  27622. /**
  27623. * This class is used to deform meshes using morphing between different targets
  27624. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27625. */
  27626. export class MorphTargetManager {
  27627. private _targets;
  27628. private _targetInfluenceChangedObservers;
  27629. private _targetDataLayoutChangedObservers;
  27630. private _activeTargets;
  27631. private _scene;
  27632. private _influences;
  27633. private _supportsNormals;
  27634. private _supportsTangents;
  27635. private _supportsUVs;
  27636. private _vertexCount;
  27637. private _uniqueId;
  27638. private _tempInfluences;
  27639. /**
  27640. * Gets or sets a boolean indicating if normals must be morphed
  27641. */
  27642. enableNormalMorphing: boolean;
  27643. /**
  27644. * Gets or sets a boolean indicating if tangents must be morphed
  27645. */
  27646. enableTangentMorphing: boolean;
  27647. /**
  27648. * Gets or sets a boolean indicating if UV must be morphed
  27649. */
  27650. enableUVMorphing: boolean;
  27651. /**
  27652. * Creates a new MorphTargetManager
  27653. * @param scene defines the current scene
  27654. */
  27655. constructor(scene?: Nullable<Scene>);
  27656. /**
  27657. * Gets the unique ID of this manager
  27658. */
  27659. get uniqueId(): number;
  27660. /**
  27661. * Gets the number of vertices handled by this manager
  27662. */
  27663. get vertexCount(): number;
  27664. /**
  27665. * Gets a boolean indicating if this manager supports morphing of normals
  27666. */
  27667. get supportsNormals(): boolean;
  27668. /**
  27669. * Gets a boolean indicating if this manager supports morphing of tangents
  27670. */
  27671. get supportsTangents(): boolean;
  27672. /**
  27673. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  27674. */
  27675. get supportsUVs(): boolean;
  27676. /**
  27677. * Gets the number of targets stored in this manager
  27678. */
  27679. get numTargets(): number;
  27680. /**
  27681. * Gets the number of influencers (ie. the number of targets with influences > 0)
  27682. */
  27683. get numInfluencers(): number;
  27684. /**
  27685. * Gets the list of influences (one per target)
  27686. */
  27687. get influences(): Float32Array;
  27688. /**
  27689. * Gets the active target at specified index. An active target is a target with an influence > 0
  27690. * @param index defines the index to check
  27691. * @returns the requested target
  27692. */
  27693. getActiveTarget(index: number): MorphTarget;
  27694. /**
  27695. * Gets the target at specified index
  27696. * @param index defines the index to check
  27697. * @returns the requested target
  27698. */
  27699. getTarget(index: number): MorphTarget;
  27700. /**
  27701. * Add a new target to this manager
  27702. * @param target defines the target to add
  27703. */
  27704. addTarget(target: MorphTarget): void;
  27705. /**
  27706. * Removes a target from the manager
  27707. * @param target defines the target to remove
  27708. */
  27709. removeTarget(target: MorphTarget): void;
  27710. /**
  27711. * Clone the current manager
  27712. * @returns a new MorphTargetManager
  27713. */
  27714. clone(): MorphTargetManager;
  27715. /**
  27716. * Serializes the current manager into a Serialization object
  27717. * @returns the serialized object
  27718. */
  27719. serialize(): any;
  27720. private _syncActiveTargets;
  27721. /**
  27722. * Syncrhonize the targets with all the meshes using this morph target manager
  27723. */
  27724. synchronize(): void;
  27725. /**
  27726. * Creates a new MorphTargetManager from serialized data
  27727. * @param serializationObject defines the serialized data
  27728. * @param scene defines the hosting scene
  27729. * @returns the new MorphTargetManager
  27730. */
  27731. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  27732. }
  27733. }
  27734. declare module "babylonjs/Meshes/meshLODLevel" {
  27735. import { Mesh } from "babylonjs/Meshes/mesh";
  27736. import { Nullable } from "babylonjs/types";
  27737. /**
  27738. * Class used to represent a specific level of detail of a mesh
  27739. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27740. */
  27741. export class MeshLODLevel {
  27742. /** Defines the distance where this level should start being displayed */
  27743. distance: number;
  27744. /** Defines the mesh to use to render this level */
  27745. mesh: Nullable<Mesh>;
  27746. /**
  27747. * Creates a new LOD level
  27748. * @param distance defines the distance where this level should star being displayed
  27749. * @param mesh defines the mesh to use to render this level
  27750. */
  27751. constructor(
  27752. /** Defines the distance where this level should start being displayed */
  27753. distance: number,
  27754. /** Defines the mesh to use to render this level */
  27755. mesh: Nullable<Mesh>);
  27756. }
  27757. }
  27758. declare module "babylonjs/Misc/canvasGenerator" {
  27759. /**
  27760. * Helper class used to generate a canvas to manipulate images
  27761. */
  27762. export class CanvasGenerator {
  27763. /**
  27764. * Create a new canvas (or offscreen canvas depending on the context)
  27765. * @param width defines the expected width
  27766. * @param height defines the expected height
  27767. * @return a new canvas or offscreen canvas
  27768. */
  27769. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  27770. }
  27771. }
  27772. declare module "babylonjs/Meshes/groundMesh" {
  27773. import { Scene } from "babylonjs/scene";
  27774. import { Vector3 } from "babylonjs/Maths/math.vector";
  27775. import { Mesh } from "babylonjs/Meshes/mesh";
  27776. /**
  27777. * Mesh representing the gorund
  27778. */
  27779. export class GroundMesh extends Mesh {
  27780. /** If octree should be generated */
  27781. generateOctree: boolean;
  27782. private _heightQuads;
  27783. /** @hidden */
  27784. _subdivisionsX: number;
  27785. /** @hidden */
  27786. _subdivisionsY: number;
  27787. /** @hidden */
  27788. _width: number;
  27789. /** @hidden */
  27790. _height: number;
  27791. /** @hidden */
  27792. _minX: number;
  27793. /** @hidden */
  27794. _maxX: number;
  27795. /** @hidden */
  27796. _minZ: number;
  27797. /** @hidden */
  27798. _maxZ: number;
  27799. constructor(name: string, scene: Scene);
  27800. /**
  27801. * "GroundMesh"
  27802. * @returns "GroundMesh"
  27803. */
  27804. getClassName(): string;
  27805. /**
  27806. * The minimum of x and y subdivisions
  27807. */
  27808. get subdivisions(): number;
  27809. /**
  27810. * X subdivisions
  27811. */
  27812. get subdivisionsX(): number;
  27813. /**
  27814. * Y subdivisions
  27815. */
  27816. get subdivisionsY(): number;
  27817. /**
  27818. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  27819. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  27820. * @param chunksCount the number of subdivisions for x and y
  27821. * @param octreeBlocksSize (Default: 32)
  27822. */
  27823. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  27824. /**
  27825. * Returns a height (y) value in the Worl system :
  27826. * the ground altitude at the coordinates (x, z) expressed in the World system.
  27827. * @param x x coordinate
  27828. * @param z z coordinate
  27829. * @returns the ground y position if (x, z) are outside the ground surface.
  27830. */
  27831. getHeightAtCoordinates(x: number, z: number): number;
  27832. /**
  27833. * Returns a normalized vector (Vector3) orthogonal to the ground
  27834. * at the ground coordinates (x, z) expressed in the World system.
  27835. * @param x x coordinate
  27836. * @param z z coordinate
  27837. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  27838. */
  27839. getNormalAtCoordinates(x: number, z: number): Vector3;
  27840. /**
  27841. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  27842. * at the ground coordinates (x, z) expressed in the World system.
  27843. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  27844. * @param x x coordinate
  27845. * @param z z coordinate
  27846. * @param ref vector to store the result
  27847. * @returns the GroundMesh.
  27848. */
  27849. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  27850. /**
  27851. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  27852. * if the ground has been updated.
  27853. * This can be used in the render loop.
  27854. * @returns the GroundMesh.
  27855. */
  27856. updateCoordinateHeights(): GroundMesh;
  27857. private _getFacetAt;
  27858. private _initHeightQuads;
  27859. private _computeHeightQuads;
  27860. /**
  27861. * Serializes this ground mesh
  27862. * @param serializationObject object to write serialization to
  27863. */
  27864. serialize(serializationObject: any): void;
  27865. /**
  27866. * Parses a serialized ground mesh
  27867. * @param parsedMesh the serialized mesh
  27868. * @param scene the scene to create the ground mesh in
  27869. * @returns the created ground mesh
  27870. */
  27871. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  27872. }
  27873. }
  27874. declare module "babylonjs/Physics/physicsJoint" {
  27875. import { Vector3 } from "babylonjs/Maths/math.vector";
  27876. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  27877. /**
  27878. * Interface for Physics-Joint data
  27879. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27880. */
  27881. export interface PhysicsJointData {
  27882. /**
  27883. * The main pivot of the joint
  27884. */
  27885. mainPivot?: Vector3;
  27886. /**
  27887. * The connected pivot of the joint
  27888. */
  27889. connectedPivot?: Vector3;
  27890. /**
  27891. * The main axis of the joint
  27892. */
  27893. mainAxis?: Vector3;
  27894. /**
  27895. * The connected axis of the joint
  27896. */
  27897. connectedAxis?: Vector3;
  27898. /**
  27899. * The collision of the joint
  27900. */
  27901. collision?: boolean;
  27902. /**
  27903. * Native Oimo/Cannon/Energy data
  27904. */
  27905. nativeParams?: any;
  27906. }
  27907. /**
  27908. * This is a holder class for the physics joint created by the physics plugin
  27909. * It holds a set of functions to control the underlying joint
  27910. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27911. */
  27912. export class PhysicsJoint {
  27913. /**
  27914. * The type of the physics joint
  27915. */
  27916. type: number;
  27917. /**
  27918. * The data for the physics joint
  27919. */
  27920. jointData: PhysicsJointData;
  27921. private _physicsJoint;
  27922. protected _physicsPlugin: IPhysicsEnginePlugin;
  27923. /**
  27924. * Initializes the physics joint
  27925. * @param type The type of the physics joint
  27926. * @param jointData The data for the physics joint
  27927. */
  27928. constructor(
  27929. /**
  27930. * The type of the physics joint
  27931. */
  27932. type: number,
  27933. /**
  27934. * The data for the physics joint
  27935. */
  27936. jointData: PhysicsJointData);
  27937. /**
  27938. * Gets the physics joint
  27939. */
  27940. get physicsJoint(): any;
  27941. /**
  27942. * Sets the physics joint
  27943. */
  27944. set physicsJoint(newJoint: any);
  27945. /**
  27946. * Sets the physics plugin
  27947. */
  27948. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  27949. /**
  27950. * Execute a function that is physics-plugin specific.
  27951. * @param {Function} func the function that will be executed.
  27952. * It accepts two parameters: the physics world and the physics joint
  27953. */
  27954. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  27955. /**
  27956. * Distance-Joint type
  27957. */
  27958. static DistanceJoint: number;
  27959. /**
  27960. * Hinge-Joint type
  27961. */
  27962. static HingeJoint: number;
  27963. /**
  27964. * Ball-and-Socket joint type
  27965. */
  27966. static BallAndSocketJoint: number;
  27967. /**
  27968. * Wheel-Joint type
  27969. */
  27970. static WheelJoint: number;
  27971. /**
  27972. * Slider-Joint type
  27973. */
  27974. static SliderJoint: number;
  27975. /**
  27976. * Prismatic-Joint type
  27977. */
  27978. static PrismaticJoint: number;
  27979. /**
  27980. * Universal-Joint type
  27981. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  27982. */
  27983. static UniversalJoint: number;
  27984. /**
  27985. * Hinge-Joint 2 type
  27986. */
  27987. static Hinge2Joint: number;
  27988. /**
  27989. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  27990. */
  27991. static PointToPointJoint: number;
  27992. /**
  27993. * Spring-Joint type
  27994. */
  27995. static SpringJoint: number;
  27996. /**
  27997. * Lock-Joint type
  27998. */
  27999. static LockJoint: number;
  28000. }
  28001. /**
  28002. * A class representing a physics distance joint
  28003. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28004. */
  28005. export class DistanceJoint extends PhysicsJoint {
  28006. /**
  28007. *
  28008. * @param jointData The data for the Distance-Joint
  28009. */
  28010. constructor(jointData: DistanceJointData);
  28011. /**
  28012. * Update the predefined distance.
  28013. * @param maxDistance The maximum preferred distance
  28014. * @param minDistance The minimum preferred distance
  28015. */
  28016. updateDistance(maxDistance: number, minDistance?: number): void;
  28017. }
  28018. /**
  28019. * Represents a Motor-Enabled Joint
  28020. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28021. */
  28022. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  28023. /**
  28024. * Initializes the Motor-Enabled Joint
  28025. * @param type The type of the joint
  28026. * @param jointData The physica joint data for the joint
  28027. */
  28028. constructor(type: number, jointData: PhysicsJointData);
  28029. /**
  28030. * Set the motor values.
  28031. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28032. * @param force the force to apply
  28033. * @param maxForce max force for this motor.
  28034. */
  28035. setMotor(force?: number, maxForce?: number): void;
  28036. /**
  28037. * Set the motor's limits.
  28038. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28039. * @param upperLimit The upper limit of the motor
  28040. * @param lowerLimit The lower limit of the motor
  28041. */
  28042. setLimit(upperLimit: number, lowerLimit?: number): void;
  28043. }
  28044. /**
  28045. * This class represents a single physics Hinge-Joint
  28046. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28047. */
  28048. export class HingeJoint extends MotorEnabledJoint {
  28049. /**
  28050. * Initializes the Hinge-Joint
  28051. * @param jointData The joint data for the Hinge-Joint
  28052. */
  28053. constructor(jointData: PhysicsJointData);
  28054. /**
  28055. * Set the motor values.
  28056. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28057. * @param {number} force the force to apply
  28058. * @param {number} maxForce max force for this motor.
  28059. */
  28060. setMotor(force?: number, maxForce?: number): void;
  28061. /**
  28062. * Set the motor's limits.
  28063. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28064. * @param upperLimit The upper limit of the motor
  28065. * @param lowerLimit The lower limit of the motor
  28066. */
  28067. setLimit(upperLimit: number, lowerLimit?: number): void;
  28068. }
  28069. /**
  28070. * This class represents a dual hinge physics joint (same as wheel joint)
  28071. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28072. */
  28073. export class Hinge2Joint extends MotorEnabledJoint {
  28074. /**
  28075. * Initializes the Hinge2-Joint
  28076. * @param jointData The joint data for the Hinge2-Joint
  28077. */
  28078. constructor(jointData: PhysicsJointData);
  28079. /**
  28080. * Set the motor values.
  28081. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28082. * @param {number} targetSpeed the speed the motor is to reach
  28083. * @param {number} maxForce max force for this motor.
  28084. * @param {motorIndex} the motor's index, 0 or 1.
  28085. */
  28086. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  28087. /**
  28088. * Set the motor limits.
  28089. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28090. * @param {number} upperLimit the upper limit
  28091. * @param {number} lowerLimit lower limit
  28092. * @param {motorIndex} the motor's index, 0 or 1.
  28093. */
  28094. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  28095. }
  28096. /**
  28097. * Interface for a motor enabled joint
  28098. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28099. */
  28100. export interface IMotorEnabledJoint {
  28101. /**
  28102. * Physics joint
  28103. */
  28104. physicsJoint: any;
  28105. /**
  28106. * Sets the motor of the motor-enabled joint
  28107. * @param force The force of the motor
  28108. * @param maxForce The maximum force of the motor
  28109. * @param motorIndex The index of the motor
  28110. */
  28111. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  28112. /**
  28113. * Sets the limit of the motor
  28114. * @param upperLimit The upper limit of the motor
  28115. * @param lowerLimit The lower limit of the motor
  28116. * @param motorIndex The index of the motor
  28117. */
  28118. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  28119. }
  28120. /**
  28121. * Joint data for a Distance-Joint
  28122. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28123. */
  28124. export interface DistanceJointData extends PhysicsJointData {
  28125. /**
  28126. * Max distance the 2 joint objects can be apart
  28127. */
  28128. maxDistance: number;
  28129. }
  28130. /**
  28131. * Joint data from a spring joint
  28132. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28133. */
  28134. export interface SpringJointData extends PhysicsJointData {
  28135. /**
  28136. * Length of the spring
  28137. */
  28138. length: number;
  28139. /**
  28140. * Stiffness of the spring
  28141. */
  28142. stiffness: number;
  28143. /**
  28144. * Damping of the spring
  28145. */
  28146. damping: number;
  28147. /** this callback will be called when applying the force to the impostors. */
  28148. forceApplicationCallback: () => void;
  28149. }
  28150. }
  28151. declare module "babylonjs/Physics/physicsRaycastResult" {
  28152. import { Vector3 } from "babylonjs/Maths/math.vector";
  28153. /**
  28154. * Holds the data for the raycast result
  28155. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28156. */
  28157. export class PhysicsRaycastResult {
  28158. private _hasHit;
  28159. private _hitDistance;
  28160. private _hitNormalWorld;
  28161. private _hitPointWorld;
  28162. private _rayFromWorld;
  28163. private _rayToWorld;
  28164. /**
  28165. * Gets if there was a hit
  28166. */
  28167. get hasHit(): boolean;
  28168. /**
  28169. * Gets the distance from the hit
  28170. */
  28171. get hitDistance(): number;
  28172. /**
  28173. * Gets the hit normal/direction in the world
  28174. */
  28175. get hitNormalWorld(): Vector3;
  28176. /**
  28177. * Gets the hit point in the world
  28178. */
  28179. get hitPointWorld(): Vector3;
  28180. /**
  28181. * Gets the ray "start point" of the ray in the world
  28182. */
  28183. get rayFromWorld(): Vector3;
  28184. /**
  28185. * Gets the ray "end point" of the ray in the world
  28186. */
  28187. get rayToWorld(): Vector3;
  28188. /**
  28189. * Sets the hit data (normal & point in world space)
  28190. * @param hitNormalWorld defines the normal in world space
  28191. * @param hitPointWorld defines the point in world space
  28192. */
  28193. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  28194. /**
  28195. * Sets the distance from the start point to the hit point
  28196. * @param distance
  28197. */
  28198. setHitDistance(distance: number): void;
  28199. /**
  28200. * Calculates the distance manually
  28201. */
  28202. calculateHitDistance(): void;
  28203. /**
  28204. * Resets all the values to default
  28205. * @param from The from point on world space
  28206. * @param to The to point on world space
  28207. */
  28208. reset(from?: Vector3, to?: Vector3): void;
  28209. }
  28210. /**
  28211. * Interface for the size containing width and height
  28212. */
  28213. interface IXYZ {
  28214. /**
  28215. * X
  28216. */
  28217. x: number;
  28218. /**
  28219. * Y
  28220. */
  28221. y: number;
  28222. /**
  28223. * Z
  28224. */
  28225. z: number;
  28226. }
  28227. }
  28228. declare module "babylonjs/Physics/IPhysicsEngine" {
  28229. import { Nullable } from "babylonjs/types";
  28230. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  28231. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28232. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  28233. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  28234. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  28235. /**
  28236. * Interface used to describe a physics joint
  28237. */
  28238. export interface PhysicsImpostorJoint {
  28239. /** Defines the main impostor to which the joint is linked */
  28240. mainImpostor: PhysicsImpostor;
  28241. /** Defines the impostor that is connected to the main impostor using this joint */
  28242. connectedImpostor: PhysicsImpostor;
  28243. /** Defines the joint itself */
  28244. joint: PhysicsJoint;
  28245. }
  28246. /** @hidden */
  28247. export interface IPhysicsEnginePlugin {
  28248. world: any;
  28249. name: string;
  28250. setGravity(gravity: Vector3): void;
  28251. setTimeStep(timeStep: number): void;
  28252. getTimeStep(): number;
  28253. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  28254. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  28255. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  28256. generatePhysicsBody(impostor: PhysicsImpostor): void;
  28257. removePhysicsBody(impostor: PhysicsImpostor): void;
  28258. generateJoint(joint: PhysicsImpostorJoint): void;
  28259. removeJoint(joint: PhysicsImpostorJoint): void;
  28260. isSupported(): boolean;
  28261. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  28262. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  28263. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  28264. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  28265. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  28266. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  28267. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  28268. getBodyMass(impostor: PhysicsImpostor): number;
  28269. getBodyFriction(impostor: PhysicsImpostor): number;
  28270. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  28271. getBodyRestitution(impostor: PhysicsImpostor): number;
  28272. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  28273. getBodyPressure?(impostor: PhysicsImpostor): number;
  28274. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  28275. getBodyStiffness?(impostor: PhysicsImpostor): number;
  28276. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  28277. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  28278. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  28279. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  28280. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  28281. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  28282. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  28283. sleepBody(impostor: PhysicsImpostor): void;
  28284. wakeUpBody(impostor: PhysicsImpostor): void;
  28285. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  28286. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  28287. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  28288. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  28289. getRadius(impostor: PhysicsImpostor): number;
  28290. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  28291. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  28292. dispose(): void;
  28293. }
  28294. /**
  28295. * Interface used to define a physics engine
  28296. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28297. */
  28298. export interface IPhysicsEngine {
  28299. /**
  28300. * Gets the gravity vector used by the simulation
  28301. */
  28302. gravity: Vector3;
  28303. /**
  28304. * Sets the gravity vector used by the simulation
  28305. * @param gravity defines the gravity vector to use
  28306. */
  28307. setGravity(gravity: Vector3): void;
  28308. /**
  28309. * Set the time step of the physics engine.
  28310. * Default is 1/60.
  28311. * To slow it down, enter 1/600 for example.
  28312. * To speed it up, 1/30
  28313. * @param newTimeStep the new timestep to apply to this world.
  28314. */
  28315. setTimeStep(newTimeStep: number): void;
  28316. /**
  28317. * Get the time step of the physics engine.
  28318. * @returns the current time step
  28319. */
  28320. getTimeStep(): number;
  28321. /**
  28322. * Set the sub time step of the physics engine.
  28323. * Default is 0 meaning there is no sub steps
  28324. * To increase physics resolution precision, set a small value (like 1 ms)
  28325. * @param subTimeStep defines the new sub timestep used for physics resolution.
  28326. */
  28327. setSubTimeStep(subTimeStep: number): void;
  28328. /**
  28329. * Get the sub time step of the physics engine.
  28330. * @returns the current sub time step
  28331. */
  28332. getSubTimeStep(): number;
  28333. /**
  28334. * Release all resources
  28335. */
  28336. dispose(): void;
  28337. /**
  28338. * Gets the name of the current physics plugin
  28339. * @returns the name of the plugin
  28340. */
  28341. getPhysicsPluginName(): string;
  28342. /**
  28343. * Adding a new impostor for the impostor tracking.
  28344. * This will be done by the impostor itself.
  28345. * @param impostor the impostor to add
  28346. */
  28347. addImpostor(impostor: PhysicsImpostor): void;
  28348. /**
  28349. * Remove an impostor from the engine.
  28350. * This impostor and its mesh will not longer be updated by the physics engine.
  28351. * @param impostor the impostor to remove
  28352. */
  28353. removeImpostor(impostor: PhysicsImpostor): void;
  28354. /**
  28355. * Add a joint to the physics engine
  28356. * @param mainImpostor defines the main impostor to which the joint is added.
  28357. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  28358. * @param joint defines the joint that will connect both impostors.
  28359. */
  28360. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  28361. /**
  28362. * Removes a joint from the simulation
  28363. * @param mainImpostor defines the impostor used with the joint
  28364. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  28365. * @param joint defines the joint to remove
  28366. */
  28367. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  28368. /**
  28369. * Gets the current plugin used to run the simulation
  28370. * @returns current plugin
  28371. */
  28372. getPhysicsPlugin(): IPhysicsEnginePlugin;
  28373. /**
  28374. * Gets the list of physic impostors
  28375. * @returns an array of PhysicsImpostor
  28376. */
  28377. getImpostors(): Array<PhysicsImpostor>;
  28378. /**
  28379. * Gets the impostor for a physics enabled object
  28380. * @param object defines the object impersonated by the impostor
  28381. * @returns the PhysicsImpostor or null if not found
  28382. */
  28383. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  28384. /**
  28385. * Gets the impostor for a physics body object
  28386. * @param body defines physics body used by the impostor
  28387. * @returns the PhysicsImpostor or null if not found
  28388. */
  28389. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  28390. /**
  28391. * Does a raycast in the physics world
  28392. * @param from when should the ray start?
  28393. * @param to when should the ray end?
  28394. * @returns PhysicsRaycastResult
  28395. */
  28396. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  28397. /**
  28398. * Called by the scene. No need to call it.
  28399. * @param delta defines the timespam between frames
  28400. */
  28401. _step(delta: number): void;
  28402. }
  28403. }
  28404. declare module "babylonjs/Physics/physicsImpostor" {
  28405. import { Nullable, IndicesArray } from "babylonjs/types";
  28406. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  28407. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28408. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28409. import { Scene } from "babylonjs/scene";
  28410. import { Bone } from "babylonjs/Bones/bone";
  28411. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28412. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  28413. import { Space } from "babylonjs/Maths/math.axis";
  28414. /**
  28415. * The interface for the physics imposter parameters
  28416. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28417. */
  28418. export interface PhysicsImpostorParameters {
  28419. /**
  28420. * The mass of the physics imposter
  28421. */
  28422. mass: number;
  28423. /**
  28424. * The friction of the physics imposter
  28425. */
  28426. friction?: number;
  28427. /**
  28428. * The coefficient of restitution of the physics imposter
  28429. */
  28430. restitution?: number;
  28431. /**
  28432. * The native options of the physics imposter
  28433. */
  28434. nativeOptions?: any;
  28435. /**
  28436. * Specifies if the parent should be ignored
  28437. */
  28438. ignoreParent?: boolean;
  28439. /**
  28440. * Specifies if bi-directional transformations should be disabled
  28441. */
  28442. disableBidirectionalTransformation?: boolean;
  28443. /**
  28444. * The pressure inside the physics imposter, soft object only
  28445. */
  28446. pressure?: number;
  28447. /**
  28448. * The stiffness the physics imposter, soft object only
  28449. */
  28450. stiffness?: number;
  28451. /**
  28452. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  28453. */
  28454. velocityIterations?: number;
  28455. /**
  28456. * The number of iterations used in maintaining consistent vertex positions, soft object only
  28457. */
  28458. positionIterations?: number;
  28459. /**
  28460. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  28461. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  28462. * Add to fix multiple points
  28463. */
  28464. fixedPoints?: number;
  28465. /**
  28466. * The collision margin around a soft object
  28467. */
  28468. margin?: number;
  28469. /**
  28470. * The collision margin around a soft object
  28471. */
  28472. damping?: number;
  28473. /**
  28474. * The path for a rope based on an extrusion
  28475. */
  28476. path?: any;
  28477. /**
  28478. * The shape of an extrusion used for a rope based on an extrusion
  28479. */
  28480. shape?: any;
  28481. }
  28482. /**
  28483. * Interface for a physics-enabled object
  28484. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28485. */
  28486. export interface IPhysicsEnabledObject {
  28487. /**
  28488. * The position of the physics-enabled object
  28489. */
  28490. position: Vector3;
  28491. /**
  28492. * The rotation of the physics-enabled object
  28493. */
  28494. rotationQuaternion: Nullable<Quaternion>;
  28495. /**
  28496. * The scale of the physics-enabled object
  28497. */
  28498. scaling: Vector3;
  28499. /**
  28500. * The rotation of the physics-enabled object
  28501. */
  28502. rotation?: Vector3;
  28503. /**
  28504. * The parent of the physics-enabled object
  28505. */
  28506. parent?: any;
  28507. /**
  28508. * The bounding info of the physics-enabled object
  28509. * @returns The bounding info of the physics-enabled object
  28510. */
  28511. getBoundingInfo(): BoundingInfo;
  28512. /**
  28513. * Computes the world matrix
  28514. * @param force Specifies if the world matrix should be computed by force
  28515. * @returns A world matrix
  28516. */
  28517. computeWorldMatrix(force: boolean): Matrix;
  28518. /**
  28519. * Gets the world matrix
  28520. * @returns A world matrix
  28521. */
  28522. getWorldMatrix?(): Matrix;
  28523. /**
  28524. * Gets the child meshes
  28525. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  28526. * @returns An array of abstract meshes
  28527. */
  28528. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  28529. /**
  28530. * Gets the vertex data
  28531. * @param kind The type of vertex data
  28532. * @returns A nullable array of numbers, or a float32 array
  28533. */
  28534. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  28535. /**
  28536. * Gets the indices from the mesh
  28537. * @returns A nullable array of index arrays
  28538. */
  28539. getIndices?(): Nullable<IndicesArray>;
  28540. /**
  28541. * Gets the scene from the mesh
  28542. * @returns the indices array or null
  28543. */
  28544. getScene?(): Scene;
  28545. /**
  28546. * Gets the absolute position from the mesh
  28547. * @returns the absolute position
  28548. */
  28549. getAbsolutePosition(): Vector3;
  28550. /**
  28551. * Gets the absolute pivot point from the mesh
  28552. * @returns the absolute pivot point
  28553. */
  28554. getAbsolutePivotPoint(): Vector3;
  28555. /**
  28556. * Rotates the mesh
  28557. * @param axis The axis of rotation
  28558. * @param amount The amount of rotation
  28559. * @param space The space of the rotation
  28560. * @returns The rotation transform node
  28561. */
  28562. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  28563. /**
  28564. * Translates the mesh
  28565. * @param axis The axis of translation
  28566. * @param distance The distance of translation
  28567. * @param space The space of the translation
  28568. * @returns The transform node
  28569. */
  28570. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  28571. /**
  28572. * Sets the absolute position of the mesh
  28573. * @param absolutePosition The absolute position of the mesh
  28574. * @returns The transform node
  28575. */
  28576. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  28577. /**
  28578. * Gets the class name of the mesh
  28579. * @returns The class name
  28580. */
  28581. getClassName(): string;
  28582. }
  28583. /**
  28584. * Represents a physics imposter
  28585. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28586. */
  28587. export class PhysicsImpostor {
  28588. /**
  28589. * The physics-enabled object used as the physics imposter
  28590. */
  28591. object: IPhysicsEnabledObject;
  28592. /**
  28593. * The type of the physics imposter
  28594. */
  28595. type: number;
  28596. private _options;
  28597. private _scene?;
  28598. /**
  28599. * The default object size of the imposter
  28600. */
  28601. static DEFAULT_OBJECT_SIZE: Vector3;
  28602. /**
  28603. * The identity quaternion of the imposter
  28604. */
  28605. static IDENTITY_QUATERNION: Quaternion;
  28606. /** @hidden */
  28607. _pluginData: any;
  28608. private _physicsEngine;
  28609. private _physicsBody;
  28610. private _bodyUpdateRequired;
  28611. private _onBeforePhysicsStepCallbacks;
  28612. private _onAfterPhysicsStepCallbacks;
  28613. /** @hidden */
  28614. _onPhysicsCollideCallbacks: Array<{
  28615. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  28616. otherImpostors: Array<PhysicsImpostor>;
  28617. }>;
  28618. private _deltaPosition;
  28619. private _deltaRotation;
  28620. private _deltaRotationConjugated;
  28621. /** @hidden */
  28622. _isFromLine: boolean;
  28623. private _parent;
  28624. private _isDisposed;
  28625. private static _tmpVecs;
  28626. private static _tmpQuat;
  28627. /**
  28628. * Specifies if the physics imposter is disposed
  28629. */
  28630. get isDisposed(): boolean;
  28631. /**
  28632. * Gets the mass of the physics imposter
  28633. */
  28634. get mass(): number;
  28635. set mass(value: number);
  28636. /**
  28637. * Gets the coefficient of friction
  28638. */
  28639. get friction(): number;
  28640. /**
  28641. * Sets the coefficient of friction
  28642. */
  28643. set friction(value: number);
  28644. /**
  28645. * Gets the coefficient of restitution
  28646. */
  28647. get restitution(): number;
  28648. /**
  28649. * Sets the coefficient of restitution
  28650. */
  28651. set restitution(value: number);
  28652. /**
  28653. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  28654. */
  28655. get pressure(): number;
  28656. /**
  28657. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  28658. */
  28659. set pressure(value: number);
  28660. /**
  28661. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  28662. */
  28663. get stiffness(): number;
  28664. /**
  28665. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  28666. */
  28667. set stiffness(value: number);
  28668. /**
  28669. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  28670. */
  28671. get velocityIterations(): number;
  28672. /**
  28673. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  28674. */
  28675. set velocityIterations(value: number);
  28676. /**
  28677. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  28678. */
  28679. get positionIterations(): number;
  28680. /**
  28681. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  28682. */
  28683. set positionIterations(value: number);
  28684. /**
  28685. * The unique id of the physics imposter
  28686. * set by the physics engine when adding this impostor to the array
  28687. */
  28688. uniqueId: number;
  28689. /**
  28690. * @hidden
  28691. */
  28692. soft: boolean;
  28693. /**
  28694. * @hidden
  28695. */
  28696. segments: number;
  28697. private _joints;
  28698. /**
  28699. * Initializes the physics imposter
  28700. * @param object The physics-enabled object used as the physics imposter
  28701. * @param type The type of the physics imposter
  28702. * @param _options The options for the physics imposter
  28703. * @param _scene The Babylon scene
  28704. */
  28705. constructor(
  28706. /**
  28707. * The physics-enabled object used as the physics imposter
  28708. */
  28709. object: IPhysicsEnabledObject,
  28710. /**
  28711. * The type of the physics imposter
  28712. */
  28713. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  28714. /**
  28715. * This function will completly initialize this impostor.
  28716. * It will create a new body - but only if this mesh has no parent.
  28717. * If it has, this impostor will not be used other than to define the impostor
  28718. * of the child mesh.
  28719. * @hidden
  28720. */
  28721. _init(): void;
  28722. private _getPhysicsParent;
  28723. /**
  28724. * Should a new body be generated.
  28725. * @returns boolean specifying if body initialization is required
  28726. */
  28727. isBodyInitRequired(): boolean;
  28728. /**
  28729. * Sets the updated scaling
  28730. * @param updated Specifies if the scaling is updated
  28731. */
  28732. setScalingUpdated(): void;
  28733. /**
  28734. * Force a regeneration of this or the parent's impostor's body.
  28735. * Use under cautious - This will remove all joints already implemented.
  28736. */
  28737. forceUpdate(): void;
  28738. /**
  28739. * Gets the body that holds this impostor. Either its own, or its parent.
  28740. */
  28741. get physicsBody(): any;
  28742. /**
  28743. * Get the parent of the physics imposter
  28744. * @returns Physics imposter or null
  28745. */
  28746. get parent(): Nullable<PhysicsImpostor>;
  28747. /**
  28748. * Sets the parent of the physics imposter
  28749. */
  28750. set parent(value: Nullable<PhysicsImpostor>);
  28751. /**
  28752. * Set the physics body. Used mainly by the physics engine/plugin
  28753. */
  28754. set physicsBody(physicsBody: any);
  28755. /**
  28756. * Resets the update flags
  28757. */
  28758. resetUpdateFlags(): void;
  28759. /**
  28760. * Gets the object extend size
  28761. * @returns the object extend size
  28762. */
  28763. getObjectExtendSize(): Vector3;
  28764. /**
  28765. * Gets the object center
  28766. * @returns The object center
  28767. */
  28768. getObjectCenter(): Vector3;
  28769. /**
  28770. * Get a specific parameter from the options parameters
  28771. * @param paramName The object parameter name
  28772. * @returns The object parameter
  28773. */
  28774. getParam(paramName: string): any;
  28775. /**
  28776. * Sets a specific parameter in the options given to the physics plugin
  28777. * @param paramName The parameter name
  28778. * @param value The value of the parameter
  28779. */
  28780. setParam(paramName: string, value: number): void;
  28781. /**
  28782. * Specifically change the body's mass option. Won't recreate the physics body object
  28783. * @param mass The mass of the physics imposter
  28784. */
  28785. setMass(mass: number): void;
  28786. /**
  28787. * Gets the linear velocity
  28788. * @returns linear velocity or null
  28789. */
  28790. getLinearVelocity(): Nullable<Vector3>;
  28791. /**
  28792. * Sets the linear velocity
  28793. * @param velocity linear velocity or null
  28794. */
  28795. setLinearVelocity(velocity: Nullable<Vector3>): void;
  28796. /**
  28797. * Gets the angular velocity
  28798. * @returns angular velocity or null
  28799. */
  28800. getAngularVelocity(): Nullable<Vector3>;
  28801. /**
  28802. * Sets the angular velocity
  28803. * @param velocity The velocity or null
  28804. */
  28805. setAngularVelocity(velocity: Nullable<Vector3>): void;
  28806. /**
  28807. * Execute a function with the physics plugin native code
  28808. * Provide a function the will have two variables - the world object and the physics body object
  28809. * @param func The function to execute with the physics plugin native code
  28810. */
  28811. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  28812. /**
  28813. * Register a function that will be executed before the physics world is stepping forward
  28814. * @param func The function to execute before the physics world is stepped forward
  28815. */
  28816. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28817. /**
  28818. * Unregister a function that will be executed before the physics world is stepping forward
  28819. * @param func The function to execute before the physics world is stepped forward
  28820. */
  28821. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28822. /**
  28823. * Register a function that will be executed after the physics step
  28824. * @param func The function to execute after physics step
  28825. */
  28826. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28827. /**
  28828. * Unregisters a function that will be executed after the physics step
  28829. * @param func The function to execute after physics step
  28830. */
  28831. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28832. /**
  28833. * register a function that will be executed when this impostor collides against a different body
  28834. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  28835. * @param func Callback that is executed on collision
  28836. */
  28837. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  28838. /**
  28839. * Unregisters the physics imposter on contact
  28840. * @param collideAgainst The physics object to collide against
  28841. * @param func Callback to execute on collision
  28842. */
  28843. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  28844. private _tmpQuat;
  28845. private _tmpQuat2;
  28846. /**
  28847. * Get the parent rotation
  28848. * @returns The parent rotation
  28849. */
  28850. getParentsRotation(): Quaternion;
  28851. /**
  28852. * this function is executed by the physics engine.
  28853. */
  28854. beforeStep: () => void;
  28855. /**
  28856. * this function is executed by the physics engine
  28857. */
  28858. afterStep: () => void;
  28859. /**
  28860. * Legacy collision detection event support
  28861. */
  28862. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  28863. /**
  28864. * event and body object due to cannon's event-based architecture.
  28865. */
  28866. onCollide: (e: {
  28867. body: any;
  28868. }) => void;
  28869. /**
  28870. * Apply a force
  28871. * @param force The force to apply
  28872. * @param contactPoint The contact point for the force
  28873. * @returns The physics imposter
  28874. */
  28875. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  28876. /**
  28877. * Apply an impulse
  28878. * @param force The impulse force
  28879. * @param contactPoint The contact point for the impulse force
  28880. * @returns The physics imposter
  28881. */
  28882. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  28883. /**
  28884. * A help function to create a joint
  28885. * @param otherImpostor A physics imposter used to create a joint
  28886. * @param jointType The type of joint
  28887. * @param jointData The data for the joint
  28888. * @returns The physics imposter
  28889. */
  28890. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  28891. /**
  28892. * Add a joint to this impostor with a different impostor
  28893. * @param otherImpostor A physics imposter used to add a joint
  28894. * @param joint The joint to add
  28895. * @returns The physics imposter
  28896. */
  28897. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  28898. /**
  28899. * Add an anchor to a cloth impostor
  28900. * @param otherImpostor rigid impostor to anchor to
  28901. * @param width ratio across width from 0 to 1
  28902. * @param height ratio up height from 0 to 1
  28903. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  28904. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  28905. * @returns impostor the soft imposter
  28906. */
  28907. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  28908. /**
  28909. * Add a hook to a rope impostor
  28910. * @param otherImpostor rigid impostor to anchor to
  28911. * @param length ratio across rope from 0 to 1
  28912. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  28913. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  28914. * @returns impostor the rope imposter
  28915. */
  28916. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  28917. /**
  28918. * Will keep this body still, in a sleep mode.
  28919. * @returns the physics imposter
  28920. */
  28921. sleep(): PhysicsImpostor;
  28922. /**
  28923. * Wake the body up.
  28924. * @returns The physics imposter
  28925. */
  28926. wakeUp(): PhysicsImpostor;
  28927. /**
  28928. * Clones the physics imposter
  28929. * @param newObject The physics imposter clones to this physics-enabled object
  28930. * @returns A nullable physics imposter
  28931. */
  28932. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  28933. /**
  28934. * Disposes the physics imposter
  28935. */
  28936. dispose(): void;
  28937. /**
  28938. * Sets the delta position
  28939. * @param position The delta position amount
  28940. */
  28941. setDeltaPosition(position: Vector3): void;
  28942. /**
  28943. * Sets the delta rotation
  28944. * @param rotation The delta rotation amount
  28945. */
  28946. setDeltaRotation(rotation: Quaternion): void;
  28947. /**
  28948. * Gets the box size of the physics imposter and stores the result in the input parameter
  28949. * @param result Stores the box size
  28950. * @returns The physics imposter
  28951. */
  28952. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  28953. /**
  28954. * Gets the radius of the physics imposter
  28955. * @returns Radius of the physics imposter
  28956. */
  28957. getRadius(): number;
  28958. /**
  28959. * Sync a bone with this impostor
  28960. * @param bone The bone to sync to the impostor.
  28961. * @param boneMesh The mesh that the bone is influencing.
  28962. * @param jointPivot The pivot of the joint / bone in local space.
  28963. * @param distToJoint Optional distance from the impostor to the joint.
  28964. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  28965. */
  28966. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  28967. /**
  28968. * Sync impostor to a bone
  28969. * @param bone The bone that the impostor will be synced to.
  28970. * @param boneMesh The mesh that the bone is influencing.
  28971. * @param jointPivot The pivot of the joint / bone in local space.
  28972. * @param distToJoint Optional distance from the impostor to the joint.
  28973. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  28974. * @param boneAxis Optional vector3 axis the bone is aligned with
  28975. */
  28976. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  28977. /**
  28978. * No-Imposter type
  28979. */
  28980. static NoImpostor: number;
  28981. /**
  28982. * Sphere-Imposter type
  28983. */
  28984. static SphereImpostor: number;
  28985. /**
  28986. * Box-Imposter type
  28987. */
  28988. static BoxImpostor: number;
  28989. /**
  28990. * Plane-Imposter type
  28991. */
  28992. static PlaneImpostor: number;
  28993. /**
  28994. * Mesh-imposter type
  28995. */
  28996. static MeshImpostor: number;
  28997. /**
  28998. * Capsule-Impostor type (Ammo.js plugin only)
  28999. */
  29000. static CapsuleImpostor: number;
  29001. /**
  29002. * Cylinder-Imposter type
  29003. */
  29004. static CylinderImpostor: number;
  29005. /**
  29006. * Particle-Imposter type
  29007. */
  29008. static ParticleImpostor: number;
  29009. /**
  29010. * Heightmap-Imposter type
  29011. */
  29012. static HeightmapImpostor: number;
  29013. /**
  29014. * ConvexHull-Impostor type (Ammo.js plugin only)
  29015. */
  29016. static ConvexHullImpostor: number;
  29017. /**
  29018. * Custom-Imposter type (Ammo.js plugin only)
  29019. */
  29020. static CustomImpostor: number;
  29021. /**
  29022. * Rope-Imposter type
  29023. */
  29024. static RopeImpostor: number;
  29025. /**
  29026. * Cloth-Imposter type
  29027. */
  29028. static ClothImpostor: number;
  29029. /**
  29030. * Softbody-Imposter type
  29031. */
  29032. static SoftbodyImpostor: number;
  29033. }
  29034. }
  29035. declare module "babylonjs/Meshes/mesh" {
  29036. import { Observable } from "babylonjs/Misc/observable";
  29037. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29038. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  29039. import { Camera } from "babylonjs/Cameras/camera";
  29040. import { Scene } from "babylonjs/scene";
  29041. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  29042. import { Color4 } from "babylonjs/Maths/math.color";
  29043. import { Engine } from "babylonjs/Engines/engine";
  29044. import { Node } from "babylonjs/node";
  29045. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  29046. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  29047. import { Buffer } from "babylonjs/Meshes/buffer";
  29048. import { Geometry } from "babylonjs/Meshes/geometry";
  29049. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29050. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29051. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  29052. import { Effect } from "babylonjs/Materials/effect";
  29053. import { Material } from "babylonjs/Materials/material";
  29054. import { Skeleton } from "babylonjs/Bones/skeleton";
  29055. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  29056. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  29057. import { Path3D } from "babylonjs/Maths/math.path";
  29058. import { Plane } from "babylonjs/Maths/math.plane";
  29059. import { TransformNode } from "babylonjs/Meshes/transformNode";
  29060. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  29061. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  29062. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  29063. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  29064. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  29065. /**
  29066. * @hidden
  29067. **/
  29068. export class _CreationDataStorage {
  29069. closePath?: boolean;
  29070. closeArray?: boolean;
  29071. idx: number[];
  29072. dashSize: number;
  29073. gapSize: number;
  29074. path3D: Path3D;
  29075. pathArray: Vector3[][];
  29076. arc: number;
  29077. radius: number;
  29078. cap: number;
  29079. tessellation: number;
  29080. }
  29081. /**
  29082. * @hidden
  29083. **/
  29084. class _InstanceDataStorage {
  29085. visibleInstances: any;
  29086. batchCache: _InstancesBatch;
  29087. instancesBufferSize: number;
  29088. instancesBuffer: Nullable<Buffer>;
  29089. instancesData: Float32Array;
  29090. overridenInstanceCount: number;
  29091. isFrozen: boolean;
  29092. previousBatch: Nullable<_InstancesBatch>;
  29093. hardwareInstancedRendering: boolean;
  29094. sideOrientation: number;
  29095. manualUpdate: boolean;
  29096. }
  29097. /**
  29098. * @hidden
  29099. **/
  29100. export class _InstancesBatch {
  29101. mustReturn: boolean;
  29102. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  29103. renderSelf: boolean[];
  29104. hardwareInstancedRendering: boolean[];
  29105. }
  29106. /**
  29107. * @hidden
  29108. **/
  29109. class _ThinInstanceDataStorage {
  29110. instancesCount: number;
  29111. matrixBuffer: Nullable<Buffer>;
  29112. matrixBufferSize: number;
  29113. matrixData: Nullable<Float32Array>;
  29114. boundingVectors: Array<Vector3>;
  29115. worldMatrices: Nullable<Matrix[]>;
  29116. }
  29117. /**
  29118. * Class used to represent renderable models
  29119. */
  29120. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  29121. /**
  29122. * Mesh side orientation : usually the external or front surface
  29123. */
  29124. static readonly FRONTSIDE: number;
  29125. /**
  29126. * Mesh side orientation : usually the internal or back surface
  29127. */
  29128. static readonly BACKSIDE: number;
  29129. /**
  29130. * Mesh side orientation : both internal and external or front and back surfaces
  29131. */
  29132. static readonly DOUBLESIDE: number;
  29133. /**
  29134. * Mesh side orientation : by default, `FRONTSIDE`
  29135. */
  29136. static readonly DEFAULTSIDE: number;
  29137. /**
  29138. * Mesh cap setting : no cap
  29139. */
  29140. static readonly NO_CAP: number;
  29141. /**
  29142. * Mesh cap setting : one cap at the beginning of the mesh
  29143. */
  29144. static readonly CAP_START: number;
  29145. /**
  29146. * Mesh cap setting : one cap at the end of the mesh
  29147. */
  29148. static readonly CAP_END: number;
  29149. /**
  29150. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  29151. */
  29152. static readonly CAP_ALL: number;
  29153. /**
  29154. * Mesh pattern setting : no flip or rotate
  29155. */
  29156. static readonly NO_FLIP: number;
  29157. /**
  29158. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  29159. */
  29160. static readonly FLIP_TILE: number;
  29161. /**
  29162. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  29163. */
  29164. static readonly ROTATE_TILE: number;
  29165. /**
  29166. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  29167. */
  29168. static readonly FLIP_ROW: number;
  29169. /**
  29170. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  29171. */
  29172. static readonly ROTATE_ROW: number;
  29173. /**
  29174. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  29175. */
  29176. static readonly FLIP_N_ROTATE_TILE: number;
  29177. /**
  29178. * Mesh pattern setting : rotate pattern and rotate
  29179. */
  29180. static readonly FLIP_N_ROTATE_ROW: number;
  29181. /**
  29182. * Mesh tile positioning : part tiles same on left/right or top/bottom
  29183. */
  29184. static readonly CENTER: number;
  29185. /**
  29186. * Mesh tile positioning : part tiles on left
  29187. */
  29188. static readonly LEFT: number;
  29189. /**
  29190. * Mesh tile positioning : part tiles on right
  29191. */
  29192. static readonly RIGHT: number;
  29193. /**
  29194. * Mesh tile positioning : part tiles on top
  29195. */
  29196. static readonly TOP: number;
  29197. /**
  29198. * Mesh tile positioning : part tiles on bottom
  29199. */
  29200. static readonly BOTTOM: number;
  29201. /**
  29202. * Gets the default side orientation.
  29203. * @param orientation the orientation to value to attempt to get
  29204. * @returns the default orientation
  29205. * @hidden
  29206. */
  29207. static _GetDefaultSideOrientation(orientation?: number): number;
  29208. private _internalMeshDataInfo;
  29209. get computeBonesUsingShaders(): boolean;
  29210. set computeBonesUsingShaders(value: boolean);
  29211. /**
  29212. * An event triggered before rendering the mesh
  29213. */
  29214. get onBeforeRenderObservable(): Observable<Mesh>;
  29215. /**
  29216. * An event triggered before binding the mesh
  29217. */
  29218. get onBeforeBindObservable(): Observable<Mesh>;
  29219. /**
  29220. * An event triggered after rendering the mesh
  29221. */
  29222. get onAfterRenderObservable(): Observable<Mesh>;
  29223. /**
  29224. * An event triggered before drawing the mesh
  29225. */
  29226. get onBeforeDrawObservable(): Observable<Mesh>;
  29227. private _onBeforeDrawObserver;
  29228. /**
  29229. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  29230. */
  29231. set onBeforeDraw(callback: () => void);
  29232. get hasInstances(): boolean;
  29233. get hasThinInstances(): boolean;
  29234. /**
  29235. * Gets the delay loading state of the mesh (when delay loading is turned on)
  29236. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  29237. */
  29238. delayLoadState: number;
  29239. /**
  29240. * Gets the list of instances created from this mesh
  29241. * it is not supposed to be modified manually.
  29242. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  29243. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  29244. */
  29245. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  29246. /**
  29247. * Gets the file containing delay loading data for this mesh
  29248. */
  29249. delayLoadingFile: string;
  29250. /** @hidden */
  29251. _binaryInfo: any;
  29252. /**
  29253. * User defined function used to change how LOD level selection is done
  29254. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29255. */
  29256. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  29257. /**
  29258. * Gets or sets the morph target manager
  29259. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  29260. */
  29261. get morphTargetManager(): Nullable<MorphTargetManager>;
  29262. set morphTargetManager(value: Nullable<MorphTargetManager>);
  29263. /** @hidden */
  29264. _creationDataStorage: Nullable<_CreationDataStorage>;
  29265. /** @hidden */
  29266. _geometry: Nullable<Geometry>;
  29267. /** @hidden */
  29268. _delayInfo: Array<string>;
  29269. /** @hidden */
  29270. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  29271. /** @hidden */
  29272. _instanceDataStorage: _InstanceDataStorage;
  29273. /** @hidden */
  29274. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  29275. private _effectiveMaterial;
  29276. /** @hidden */
  29277. _shouldGenerateFlatShading: boolean;
  29278. /** @hidden */
  29279. _originalBuilderSideOrientation: number;
  29280. /**
  29281. * Use this property to change the original side orientation defined at construction time
  29282. */
  29283. overrideMaterialSideOrientation: Nullable<number>;
  29284. /**
  29285. * Gets the source mesh (the one used to clone this one from)
  29286. */
  29287. get source(): Nullable<Mesh>;
  29288. /**
  29289. * Gets or sets a boolean indicating that this mesh does not use index buffer
  29290. */
  29291. get isUnIndexed(): boolean;
  29292. set isUnIndexed(value: boolean);
  29293. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  29294. get worldMatrixInstancedBuffer(): Float32Array;
  29295. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  29296. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  29297. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  29298. /**
  29299. * @constructor
  29300. * @param name The value used by scene.getMeshByName() to do a lookup.
  29301. * @param scene The scene to add this mesh to.
  29302. * @param parent The parent of this mesh, if it has one
  29303. * @param source An optional Mesh from which geometry is shared, cloned.
  29304. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  29305. * When false, achieved by calling a clone(), also passing False.
  29306. * This will make creation of children, recursive.
  29307. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  29308. */
  29309. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  29310. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  29311. doNotInstantiate: boolean;
  29312. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  29313. /**
  29314. * Gets the class name
  29315. * @returns the string "Mesh".
  29316. */
  29317. getClassName(): string;
  29318. /** @hidden */
  29319. get _isMesh(): boolean;
  29320. /**
  29321. * Returns a description of this mesh
  29322. * @param fullDetails define if full details about this mesh must be used
  29323. * @returns a descriptive string representing this mesh
  29324. */
  29325. toString(fullDetails?: boolean): string;
  29326. /** @hidden */
  29327. _unBindEffect(): void;
  29328. /**
  29329. * Gets a boolean indicating if this mesh has LOD
  29330. */
  29331. get hasLODLevels(): boolean;
  29332. /**
  29333. * Gets the list of MeshLODLevel associated with the current mesh
  29334. * @returns an array of MeshLODLevel
  29335. */
  29336. getLODLevels(): MeshLODLevel[];
  29337. private _sortLODLevels;
  29338. /**
  29339. * Add a mesh as LOD level triggered at the given distance.
  29340. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29341. * @param distance The distance from the center of the object to show this level
  29342. * @param mesh The mesh to be added as LOD level (can be null)
  29343. * @return This mesh (for chaining)
  29344. */
  29345. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  29346. /**
  29347. * Returns the LOD level mesh at the passed distance or null if not found.
  29348. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29349. * @param distance The distance from the center of the object to show this level
  29350. * @returns a Mesh or `null`
  29351. */
  29352. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  29353. /**
  29354. * Remove a mesh from the LOD array
  29355. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29356. * @param mesh defines the mesh to be removed
  29357. * @return This mesh (for chaining)
  29358. */
  29359. removeLODLevel(mesh: Mesh): Mesh;
  29360. /**
  29361. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  29362. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29363. * @param camera defines the camera to use to compute distance
  29364. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  29365. * @return This mesh (for chaining)
  29366. */
  29367. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  29368. /**
  29369. * Gets the mesh internal Geometry object
  29370. */
  29371. get geometry(): Nullable<Geometry>;
  29372. /**
  29373. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  29374. * @returns the total number of vertices
  29375. */
  29376. getTotalVertices(): number;
  29377. /**
  29378. * Returns the content of an associated vertex buffer
  29379. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29380. * - VertexBuffer.PositionKind
  29381. * - VertexBuffer.UVKind
  29382. * - VertexBuffer.UV2Kind
  29383. * - VertexBuffer.UV3Kind
  29384. * - VertexBuffer.UV4Kind
  29385. * - VertexBuffer.UV5Kind
  29386. * - VertexBuffer.UV6Kind
  29387. * - VertexBuffer.ColorKind
  29388. * - VertexBuffer.MatricesIndicesKind
  29389. * - VertexBuffer.MatricesIndicesExtraKind
  29390. * - VertexBuffer.MatricesWeightsKind
  29391. * - VertexBuffer.MatricesWeightsExtraKind
  29392. * @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
  29393. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  29394. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  29395. */
  29396. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  29397. /**
  29398. * Returns the mesh VertexBuffer object from the requested `kind`
  29399. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29400. * - VertexBuffer.PositionKind
  29401. * - VertexBuffer.NormalKind
  29402. * - VertexBuffer.UVKind
  29403. * - VertexBuffer.UV2Kind
  29404. * - VertexBuffer.UV3Kind
  29405. * - VertexBuffer.UV4Kind
  29406. * - VertexBuffer.UV5Kind
  29407. * - VertexBuffer.UV6Kind
  29408. * - VertexBuffer.ColorKind
  29409. * - VertexBuffer.MatricesIndicesKind
  29410. * - VertexBuffer.MatricesIndicesExtraKind
  29411. * - VertexBuffer.MatricesWeightsKind
  29412. * - VertexBuffer.MatricesWeightsExtraKind
  29413. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  29414. */
  29415. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  29416. /**
  29417. * Tests if a specific vertex buffer is associated with this mesh
  29418. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  29419. * - VertexBuffer.PositionKind
  29420. * - VertexBuffer.NormalKind
  29421. * - VertexBuffer.UVKind
  29422. * - VertexBuffer.UV2Kind
  29423. * - VertexBuffer.UV3Kind
  29424. * - VertexBuffer.UV4Kind
  29425. * - VertexBuffer.UV5Kind
  29426. * - VertexBuffer.UV6Kind
  29427. * - VertexBuffer.ColorKind
  29428. * - VertexBuffer.MatricesIndicesKind
  29429. * - VertexBuffer.MatricesIndicesExtraKind
  29430. * - VertexBuffer.MatricesWeightsKind
  29431. * - VertexBuffer.MatricesWeightsExtraKind
  29432. * @returns a boolean
  29433. */
  29434. isVerticesDataPresent(kind: string): boolean;
  29435. /**
  29436. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  29437. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  29438. * - VertexBuffer.PositionKind
  29439. * - VertexBuffer.UVKind
  29440. * - VertexBuffer.UV2Kind
  29441. * - VertexBuffer.UV3Kind
  29442. * - VertexBuffer.UV4Kind
  29443. * - VertexBuffer.UV5Kind
  29444. * - VertexBuffer.UV6Kind
  29445. * - VertexBuffer.ColorKind
  29446. * - VertexBuffer.MatricesIndicesKind
  29447. * - VertexBuffer.MatricesIndicesExtraKind
  29448. * - VertexBuffer.MatricesWeightsKind
  29449. * - VertexBuffer.MatricesWeightsExtraKind
  29450. * @returns a boolean
  29451. */
  29452. isVertexBufferUpdatable(kind: string): boolean;
  29453. /**
  29454. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  29455. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29456. * - VertexBuffer.PositionKind
  29457. * - VertexBuffer.NormalKind
  29458. * - VertexBuffer.UVKind
  29459. * - VertexBuffer.UV2Kind
  29460. * - VertexBuffer.UV3Kind
  29461. * - VertexBuffer.UV4Kind
  29462. * - VertexBuffer.UV5Kind
  29463. * - VertexBuffer.UV6Kind
  29464. * - VertexBuffer.ColorKind
  29465. * - VertexBuffer.MatricesIndicesKind
  29466. * - VertexBuffer.MatricesIndicesExtraKind
  29467. * - VertexBuffer.MatricesWeightsKind
  29468. * - VertexBuffer.MatricesWeightsExtraKind
  29469. * @returns an array of strings
  29470. */
  29471. getVerticesDataKinds(): string[];
  29472. /**
  29473. * Returns a positive integer : the total number of indices in this mesh geometry.
  29474. * @returns the numner of indices or zero if the mesh has no geometry.
  29475. */
  29476. getTotalIndices(): number;
  29477. /**
  29478. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  29479. * @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.
  29480. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  29481. * @returns the indices array or an empty array if the mesh has no geometry
  29482. */
  29483. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  29484. get isBlocked(): boolean;
  29485. /**
  29486. * Determine if the current mesh is ready to be rendered
  29487. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29488. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  29489. * @returns true if all associated assets are ready (material, textures, shaders)
  29490. */
  29491. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  29492. /**
  29493. * 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.
  29494. */
  29495. get areNormalsFrozen(): boolean;
  29496. /**
  29497. * 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.
  29498. * @returns the current mesh
  29499. */
  29500. freezeNormals(): Mesh;
  29501. /**
  29502. * 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
  29503. * @returns the current mesh
  29504. */
  29505. unfreezeNormals(): Mesh;
  29506. /**
  29507. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  29508. */
  29509. set overridenInstanceCount(count: number);
  29510. /** @hidden */
  29511. _preActivate(): Mesh;
  29512. /** @hidden */
  29513. _preActivateForIntermediateRendering(renderId: number): Mesh;
  29514. /** @hidden */
  29515. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  29516. protected _afterComputeWorldMatrix(): void;
  29517. /** @hidden */
  29518. _postActivate(): void;
  29519. /**
  29520. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  29521. * This means the mesh underlying bounding box and sphere are recomputed.
  29522. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  29523. * @returns the current mesh
  29524. */
  29525. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  29526. /** @hidden */
  29527. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  29528. /**
  29529. * This function will subdivide the mesh into multiple submeshes
  29530. * @param count defines the expected number of submeshes
  29531. */
  29532. subdivide(count: number): void;
  29533. /**
  29534. * Copy a FloatArray into a specific associated vertex buffer
  29535. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  29536. * - VertexBuffer.PositionKind
  29537. * - VertexBuffer.UVKind
  29538. * - VertexBuffer.UV2Kind
  29539. * - VertexBuffer.UV3Kind
  29540. * - VertexBuffer.UV4Kind
  29541. * - VertexBuffer.UV5Kind
  29542. * - VertexBuffer.UV6Kind
  29543. * - VertexBuffer.ColorKind
  29544. * - VertexBuffer.MatricesIndicesKind
  29545. * - VertexBuffer.MatricesIndicesExtraKind
  29546. * - VertexBuffer.MatricesWeightsKind
  29547. * - VertexBuffer.MatricesWeightsExtraKind
  29548. * @param data defines the data source
  29549. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  29550. * @param stride defines the data stride size (can be null)
  29551. * @returns the current mesh
  29552. */
  29553. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  29554. /**
  29555. * Delete a vertex buffer associated with this mesh
  29556. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  29557. * - VertexBuffer.PositionKind
  29558. * - VertexBuffer.UVKind
  29559. * - VertexBuffer.UV2Kind
  29560. * - VertexBuffer.UV3Kind
  29561. * - VertexBuffer.UV4Kind
  29562. * - VertexBuffer.UV5Kind
  29563. * - VertexBuffer.UV6Kind
  29564. * - VertexBuffer.ColorKind
  29565. * - VertexBuffer.MatricesIndicesKind
  29566. * - VertexBuffer.MatricesIndicesExtraKind
  29567. * - VertexBuffer.MatricesWeightsKind
  29568. * - VertexBuffer.MatricesWeightsExtraKind
  29569. */
  29570. removeVerticesData(kind: string): void;
  29571. /**
  29572. * Flags an associated vertex buffer as updatable
  29573. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  29574. * - VertexBuffer.PositionKind
  29575. * - VertexBuffer.UVKind
  29576. * - VertexBuffer.UV2Kind
  29577. * - VertexBuffer.UV3Kind
  29578. * - VertexBuffer.UV4Kind
  29579. * - VertexBuffer.UV5Kind
  29580. * - VertexBuffer.UV6Kind
  29581. * - VertexBuffer.ColorKind
  29582. * - VertexBuffer.MatricesIndicesKind
  29583. * - VertexBuffer.MatricesIndicesExtraKind
  29584. * - VertexBuffer.MatricesWeightsKind
  29585. * - VertexBuffer.MatricesWeightsExtraKind
  29586. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  29587. */
  29588. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  29589. /**
  29590. * Sets the mesh global Vertex Buffer
  29591. * @param buffer defines the buffer to use
  29592. * @returns the current mesh
  29593. */
  29594. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  29595. /**
  29596. * Update a specific associated vertex buffer
  29597. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  29598. * - VertexBuffer.PositionKind
  29599. * - VertexBuffer.UVKind
  29600. * - VertexBuffer.UV2Kind
  29601. * - VertexBuffer.UV3Kind
  29602. * - VertexBuffer.UV4Kind
  29603. * - VertexBuffer.UV5Kind
  29604. * - VertexBuffer.UV6Kind
  29605. * - VertexBuffer.ColorKind
  29606. * - VertexBuffer.MatricesIndicesKind
  29607. * - VertexBuffer.MatricesIndicesExtraKind
  29608. * - VertexBuffer.MatricesWeightsKind
  29609. * - VertexBuffer.MatricesWeightsExtraKind
  29610. * @param data defines the data source
  29611. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  29612. * @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)
  29613. * @returns the current mesh
  29614. */
  29615. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  29616. /**
  29617. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  29618. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  29619. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  29620. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  29621. * @returns the current mesh
  29622. */
  29623. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  29624. /**
  29625. * Creates a un-shared specific occurence of the geometry for the mesh.
  29626. * @returns the current mesh
  29627. */
  29628. makeGeometryUnique(): Mesh;
  29629. /**
  29630. * Set the index buffer of this mesh
  29631. * @param indices defines the source data
  29632. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  29633. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  29634. * @returns the current mesh
  29635. */
  29636. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  29637. /**
  29638. * Update the current index buffer
  29639. * @param indices defines the source data
  29640. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29641. * @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)
  29642. * @returns the current mesh
  29643. */
  29644. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29645. /**
  29646. * Invert the geometry to move from a right handed system to a left handed one.
  29647. * @returns the current mesh
  29648. */
  29649. toLeftHanded(): Mesh;
  29650. /** @hidden */
  29651. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  29652. /** @hidden */
  29653. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  29654. /**
  29655. * Registers for this mesh a javascript function called just before the rendering process
  29656. * @param func defines the function to call before rendering this mesh
  29657. * @returns the current mesh
  29658. */
  29659. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  29660. /**
  29661. * Disposes a previously registered javascript function called before the rendering
  29662. * @param func defines the function to remove
  29663. * @returns the current mesh
  29664. */
  29665. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  29666. /**
  29667. * Registers for this mesh a javascript function called just after the rendering is complete
  29668. * @param func defines the function to call after rendering this mesh
  29669. * @returns the current mesh
  29670. */
  29671. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  29672. /**
  29673. * Disposes a previously registered javascript function called after the rendering.
  29674. * @param func defines the function to remove
  29675. * @returns the current mesh
  29676. */
  29677. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  29678. /** @hidden */
  29679. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  29680. /** @hidden */
  29681. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  29682. /** @hidden */
  29683. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  29684. /** @hidden */
  29685. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  29686. /** @hidden */
  29687. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  29688. /** @hidden */
  29689. _rebuild(): void;
  29690. /** @hidden */
  29691. _freeze(): void;
  29692. /** @hidden */
  29693. _unFreeze(): void;
  29694. /**
  29695. * 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
  29696. * @param subMesh defines the subMesh to render
  29697. * @param enableAlphaMode defines if alpha mode can be changed
  29698. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  29699. * @returns the current mesh
  29700. */
  29701. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  29702. private _onBeforeDraw;
  29703. /**
  29704. * Renormalize the mesh and patch it up if there are no weights
  29705. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  29706. * However in the case of zero weights then we set just a single influence to 1.
  29707. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  29708. */
  29709. cleanMatrixWeights(): void;
  29710. private normalizeSkinFourWeights;
  29711. private normalizeSkinWeightsAndExtra;
  29712. /**
  29713. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  29714. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  29715. * the user know there was an issue with importing the mesh
  29716. * @returns a validation object with skinned, valid and report string
  29717. */
  29718. validateSkinning(): {
  29719. skinned: boolean;
  29720. valid: boolean;
  29721. report: string;
  29722. };
  29723. /** @hidden */
  29724. _checkDelayState(): Mesh;
  29725. private _queueLoad;
  29726. /**
  29727. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  29728. * A mesh is in the frustum if its bounding box intersects the frustum
  29729. * @param frustumPlanes defines the frustum to test
  29730. * @returns true if the mesh is in the frustum planes
  29731. */
  29732. isInFrustum(frustumPlanes: Plane[]): boolean;
  29733. /**
  29734. * Sets the mesh material by the material or multiMaterial `id` property
  29735. * @param id is a string identifying the material or the multiMaterial
  29736. * @returns the current mesh
  29737. */
  29738. setMaterialByID(id: string): Mesh;
  29739. /**
  29740. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  29741. * @returns an array of IAnimatable
  29742. */
  29743. getAnimatables(): IAnimatable[];
  29744. /**
  29745. * Modifies the mesh geometry according to the passed transformation matrix.
  29746. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  29747. * The mesh normals are modified using the same transformation.
  29748. * Note that, under the hood, this method sets a new VertexBuffer each call.
  29749. * @param transform defines the transform matrix to use
  29750. * @see https://doc.babylonjs.com/resources/baking_transformations
  29751. * @returns the current mesh
  29752. */
  29753. bakeTransformIntoVertices(transform: Matrix): Mesh;
  29754. /**
  29755. * Modifies the mesh geometry according to its own current World Matrix.
  29756. * The mesh World Matrix is then reset.
  29757. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  29758. * Note that, under the hood, this method sets a new VertexBuffer each call.
  29759. * @see https://doc.babylonjs.com/resources/baking_transformations
  29760. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  29761. * @returns the current mesh
  29762. */
  29763. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  29764. /** @hidden */
  29765. get _positions(): Nullable<Vector3[]>;
  29766. /** @hidden */
  29767. _resetPointsArrayCache(): Mesh;
  29768. /** @hidden */
  29769. _generatePointsArray(): boolean;
  29770. /**
  29771. * Returns a new Mesh object generated from the current mesh properties.
  29772. * This method must not get confused with createInstance()
  29773. * @param name is a string, the name given to the new mesh
  29774. * @param newParent can be any Node object (default `null`)
  29775. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  29776. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  29777. * @returns a new mesh
  29778. */
  29779. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  29780. /**
  29781. * Releases resources associated with this mesh.
  29782. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29783. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29784. */
  29785. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29786. /** @hidden */
  29787. _disposeInstanceSpecificData(): void;
  29788. /** @hidden */
  29789. _disposeThinInstanceSpecificData(): void;
  29790. /**
  29791. * Modifies the mesh geometry according to a displacement map.
  29792. * 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.
  29793. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  29794. * @param url is a string, the URL from the image file is to be downloaded.
  29795. * @param minHeight is the lower limit of the displacement.
  29796. * @param maxHeight is the upper limit of the displacement.
  29797. * @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.
  29798. * @param uvOffset is an optional vector2 used to offset UV.
  29799. * @param uvScale is an optional vector2 used to scale UV.
  29800. * @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.
  29801. * @returns the Mesh.
  29802. */
  29803. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  29804. /**
  29805. * Modifies the mesh geometry according to a displacementMap buffer.
  29806. * 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.
  29807. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  29808. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  29809. * @param heightMapWidth is the width of the buffer image.
  29810. * @param heightMapHeight is the height of the buffer image.
  29811. * @param minHeight is the lower limit of the displacement.
  29812. * @param maxHeight is the upper limit of the displacement.
  29813. * @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.
  29814. * @param uvOffset is an optional vector2 used to offset UV.
  29815. * @param uvScale is an optional vector2 used to scale UV.
  29816. * @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.
  29817. * @returns the Mesh.
  29818. */
  29819. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  29820. /**
  29821. * Modify the mesh to get a flat shading rendering.
  29822. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  29823. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  29824. * @returns current mesh
  29825. */
  29826. convertToFlatShadedMesh(): Mesh;
  29827. /**
  29828. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  29829. * In other words, more vertices, no more indices and a single bigger VBO.
  29830. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  29831. * @returns current mesh
  29832. */
  29833. convertToUnIndexedMesh(): Mesh;
  29834. /**
  29835. * Inverses facet orientations.
  29836. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  29837. * @param flipNormals will also inverts the normals
  29838. * @returns current mesh
  29839. */
  29840. flipFaces(flipNormals?: boolean): Mesh;
  29841. /**
  29842. * Increase the number of facets and hence vertices in a mesh
  29843. * Vertex normals are interpolated from existing vertex normals
  29844. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  29845. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  29846. */
  29847. increaseVertices(numberPerEdge: number): void;
  29848. /**
  29849. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  29850. * This will undo any application of covertToFlatShadedMesh
  29851. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  29852. */
  29853. forceSharedVertices(): void;
  29854. /** @hidden */
  29855. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  29856. /** @hidden */
  29857. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  29858. /**
  29859. * Creates a new InstancedMesh object from the mesh model.
  29860. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  29861. * @param name defines the name of the new instance
  29862. * @returns a new InstancedMesh
  29863. */
  29864. createInstance(name: string): InstancedMesh;
  29865. /**
  29866. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  29867. * After this call, all the mesh instances have the same submeshes than the current mesh.
  29868. * @returns the current mesh
  29869. */
  29870. synchronizeInstances(): Mesh;
  29871. /**
  29872. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  29873. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  29874. * This should be used together with the simplification to avoid disappearing triangles.
  29875. * @param successCallback an optional success callback to be called after the optimization finished.
  29876. * @returns the current mesh
  29877. */
  29878. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  29879. /**
  29880. * Serialize current mesh
  29881. * @param serializationObject defines the object which will receive the serialization data
  29882. */
  29883. serialize(serializationObject: any): void;
  29884. /** @hidden */
  29885. _syncGeometryWithMorphTargetManager(): void;
  29886. /** @hidden */
  29887. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  29888. /**
  29889. * Returns a new Mesh object parsed from the source provided.
  29890. * @param parsedMesh is the source
  29891. * @param scene defines the hosting scene
  29892. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  29893. * @returns a new Mesh
  29894. */
  29895. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  29896. /**
  29897. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  29898. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29899. * @param name defines the name of the mesh to create
  29900. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  29901. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  29902. * @param closePath creates a seam between the first and the last points of each path of the path array
  29903. * @param offset is taken in account only if the `pathArray` is containing a single path
  29904. * @param scene defines the hosting scene
  29905. * @param updatable defines if the mesh must be flagged as updatable
  29906. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29907. * @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)
  29908. * @returns a new Mesh
  29909. */
  29910. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29911. /**
  29912. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  29913. * @param name defines the name of the mesh to create
  29914. * @param radius sets the radius size (float) of the polygon (default 0.5)
  29915. * @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
  29916. * @param scene defines the hosting scene
  29917. * @param updatable defines if the mesh must be flagged as updatable
  29918. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29919. * @returns a new Mesh
  29920. */
  29921. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  29922. /**
  29923. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  29924. * @param name defines the name of the mesh to create
  29925. * @param size sets the size (float) of each box side (default 1)
  29926. * @param scene defines the hosting scene
  29927. * @param updatable defines if the mesh must be flagged as updatable
  29928. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29929. * @returns a new Mesh
  29930. */
  29931. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  29932. /**
  29933. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  29934. * @param name defines the name of the mesh to create
  29935. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  29936. * @param diameter sets the diameter size (float) of the sphere (default 1)
  29937. * @param scene defines the hosting scene
  29938. * @param updatable defines if the mesh must be flagged as updatable
  29939. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29940. * @returns a new Mesh
  29941. */
  29942. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29943. /**
  29944. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  29945. * @param name defines the name of the mesh to create
  29946. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  29947. * @param diameter sets the diameter size (float) of the sphere (default 1)
  29948. * @param scene defines the hosting scene
  29949. * @returns a new Mesh
  29950. */
  29951. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  29952. /**
  29953. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  29954. * @param name defines the name of the mesh to create
  29955. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  29956. * @param diameterTop set the top cap diameter (floats, default 1)
  29957. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  29958. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  29959. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  29960. * @param scene defines the hosting scene
  29961. * @param updatable defines if the mesh must be flagged as updatable
  29962. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29963. * @returns a new Mesh
  29964. */
  29965. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  29966. /**
  29967. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  29968. * @param name defines the name of the mesh to create
  29969. * @param diameter sets the diameter size (float) of the torus (default 1)
  29970. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  29971. * @param tessellation sets the number of torus sides (postive integer, default 16)
  29972. * @param scene defines the hosting scene
  29973. * @param updatable defines if the mesh must be flagged as updatable
  29974. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29975. * @returns a new Mesh
  29976. */
  29977. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29978. /**
  29979. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  29980. * @param name defines the name of the mesh to create
  29981. * @param radius sets the global radius size (float) of the torus knot (default 2)
  29982. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  29983. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  29984. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  29985. * @param p the number of windings on X axis (positive integers, default 2)
  29986. * @param q the number of windings on Y axis (positive integers, default 3)
  29987. * @param scene defines the hosting scene
  29988. * @param updatable defines if the mesh must be flagged as updatable
  29989. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29990. * @returns a new Mesh
  29991. */
  29992. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29993. /**
  29994. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  29995. * @param name defines the name of the mesh to create
  29996. * @param points is an array successive Vector3
  29997. * @param scene defines the hosting scene
  29998. * @param updatable defines if the mesh must be flagged as updatable
  29999. * @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).
  30000. * @returns a new Mesh
  30001. */
  30002. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  30003. /**
  30004. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  30005. * @param name defines the name of the mesh to create
  30006. * @param points is an array successive Vector3
  30007. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  30008. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  30009. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  30010. * @param scene defines the hosting scene
  30011. * @param updatable defines if the mesh must be flagged as updatable
  30012. * @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)
  30013. * @returns a new Mesh
  30014. */
  30015. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  30016. /**
  30017. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  30018. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  30019. * 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.
  30020. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30021. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  30022. * Remember you can only change the shape positions, not their number when updating a polygon.
  30023. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  30024. * @param name defines the name of the mesh to create
  30025. * @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
  30026. * @param scene defines the hosting scene
  30027. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  30028. * @param updatable defines if the mesh must be flagged as updatable
  30029. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30030. * @param earcutInjection can be used to inject your own earcut reference
  30031. * @returns a new Mesh
  30032. */
  30033. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  30034. /**
  30035. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  30036. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  30037. * @param name defines the name of the mesh to create
  30038. * @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
  30039. * @param depth defines the height of extrusion
  30040. * @param scene defines the hosting scene
  30041. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  30042. * @param updatable defines if the mesh must be flagged as updatable
  30043. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30044. * @param earcutInjection can be used to inject your own earcut reference
  30045. * @returns a new Mesh
  30046. */
  30047. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  30048. /**
  30049. * Creates an extruded shape mesh.
  30050. * 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
  30051. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  30052. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  30053. * @param name defines the name of the mesh to create
  30054. * @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
  30055. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  30056. * @param scale is the value to scale the shape
  30057. * @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
  30058. * @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
  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. * @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)
  30063. * @returns a new Mesh
  30064. */
  30065. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  30066. /**
  30067. * Creates an custom extruded shape mesh.
  30068. * The custom extrusion is a parametric shape.
  30069. * It has no predefined shape. Its final shape will depend on the input parameters.
  30070. * Please consider using the same method from the MeshBuilder class instead
  30071. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  30072. * @param name defines the name of the mesh to create
  30073. * @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
  30074. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  30075. * @param scaleFunction is a custom Javascript function called on each path point
  30076. * @param rotationFunction is a custom Javascript function called on each path point
  30077. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  30078. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  30079. * @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
  30080. * @param scene defines the hosting scene
  30081. * @param updatable defines if the mesh must be flagged as updatable
  30082. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30083. * @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)
  30084. * @returns a new Mesh
  30085. */
  30086. 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;
  30087. /**
  30088. * Creates lathe mesh.
  30089. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  30090. * Please consider using the same method from the MeshBuilder class instead
  30091. * @param name defines the name of the mesh to create
  30092. * @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
  30093. * @param radius is the radius value of the lathe
  30094. * @param tessellation is the side number of the lathe.
  30095. * @param scene defines the hosting scene
  30096. * @param updatable defines if the mesh must be flagged as updatable
  30097. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30098. * @returns a new Mesh
  30099. */
  30100. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30101. /**
  30102. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  30103. * @param name defines the name of the mesh to create
  30104. * @param size sets the size (float) of both sides of the plane at once (default 1)
  30105. * @param scene defines the hosting scene
  30106. * @param updatable defines if the mesh must be flagged as updatable
  30107. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30108. * @returns a new Mesh
  30109. */
  30110. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30111. /**
  30112. * Creates a ground mesh.
  30113. * Please consider using the same method from the MeshBuilder class instead
  30114. * @param name defines the name of the mesh to create
  30115. * @param width set the width of the ground
  30116. * @param height set the height of the ground
  30117. * @param subdivisions sets the number of subdivisions per side
  30118. * @param scene defines the hosting scene
  30119. * @param updatable defines if the mesh must be flagged as updatable
  30120. * @returns a new Mesh
  30121. */
  30122. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  30123. /**
  30124. * Creates a tiled ground mesh.
  30125. * Please consider using the same method from the MeshBuilder class instead
  30126. * @param name defines the name of the mesh to create
  30127. * @param xmin set the ground minimum X coordinate
  30128. * @param zmin set the ground minimum Y coordinate
  30129. * @param xmax set the ground maximum X coordinate
  30130. * @param zmax set the ground maximum Z coordinate
  30131. * @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
  30132. * @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
  30133. * @param scene defines the hosting scene
  30134. * @param updatable defines if the mesh must be flagged as updatable
  30135. * @returns a new Mesh
  30136. */
  30137. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  30138. w: number;
  30139. h: number;
  30140. }, precision: {
  30141. w: number;
  30142. h: number;
  30143. }, scene: Scene, updatable?: boolean): Mesh;
  30144. /**
  30145. * Creates a ground mesh from a height map.
  30146. * Please consider using the same method from the MeshBuilder class instead
  30147. * @see https://doc.babylonjs.com/babylon101/height_map
  30148. * @param name defines the name of the mesh to create
  30149. * @param url sets the URL of the height map image resource
  30150. * @param width set the ground width size
  30151. * @param height set the ground height size
  30152. * @param subdivisions sets the number of subdivision per side
  30153. * @param minHeight is the minimum altitude on the ground
  30154. * @param maxHeight is the maximum altitude on the ground
  30155. * @param scene defines the hosting scene
  30156. * @param updatable defines if the mesh must be flagged as updatable
  30157. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  30158. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  30159. * @returns a new Mesh
  30160. */
  30161. 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;
  30162. /**
  30163. * Creates a tube mesh.
  30164. * The tube is a parametric shape.
  30165. * It has no predefined shape. Its final shape will depend on the input parameters.
  30166. * Please consider using the same method from the MeshBuilder class instead
  30167. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  30168. * @param name defines the name of the mesh to create
  30169. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  30170. * @param radius sets the tube radius size
  30171. * @param tessellation is the number of sides on the tubular surface
  30172. * @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
  30173. * @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
  30174. * @param scene defines the hosting scene
  30175. * @param updatable defines if the mesh must be flagged as updatable
  30176. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30177. * @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)
  30178. * @returns a new Mesh
  30179. */
  30180. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  30181. (i: number, distance: number): number;
  30182. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  30183. /**
  30184. * Creates a polyhedron mesh.
  30185. * Please consider using the same method from the MeshBuilder class instead.
  30186. * * 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
  30187. * * The parameter `size` (positive float, default 1) sets the polygon size
  30188. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  30189. * * 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`
  30190. * * 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
  30191. * * 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)`)
  30192. * * 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
  30193. * * 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
  30194. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30195. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  30196. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30197. * @param name defines the name of the mesh to create
  30198. * @param options defines the options used to create the mesh
  30199. * @param scene defines the hosting scene
  30200. * @returns a new Mesh
  30201. */
  30202. static CreatePolyhedron(name: string, options: {
  30203. type?: number;
  30204. size?: number;
  30205. sizeX?: number;
  30206. sizeY?: number;
  30207. sizeZ?: number;
  30208. custom?: any;
  30209. faceUV?: Vector4[];
  30210. faceColors?: Color4[];
  30211. updatable?: boolean;
  30212. sideOrientation?: number;
  30213. }, scene: Scene): Mesh;
  30214. /**
  30215. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  30216. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  30217. * * 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`)
  30218. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  30219. * * 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
  30220. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30221. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  30222. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30223. * @param name defines the name of the mesh
  30224. * @param options defines the options used to create the mesh
  30225. * @param scene defines the hosting scene
  30226. * @returns a new Mesh
  30227. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  30228. */
  30229. static CreateIcoSphere(name: string, options: {
  30230. radius?: number;
  30231. flat?: boolean;
  30232. subdivisions?: number;
  30233. sideOrientation?: number;
  30234. updatable?: boolean;
  30235. }, scene: Scene): Mesh;
  30236. /**
  30237. * Creates a decal mesh.
  30238. * Please consider using the same method from the MeshBuilder class instead.
  30239. * A decal is a mesh usually applied as a model onto the surface of another mesh
  30240. * @param name defines the name of the mesh
  30241. * @param sourceMesh defines the mesh receiving the decal
  30242. * @param position sets the position of the decal in world coordinates
  30243. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  30244. * @param size sets the decal scaling
  30245. * @param angle sets the angle to rotate the decal
  30246. * @returns a new Mesh
  30247. */
  30248. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  30249. /**
  30250. * Prepare internal position array for software CPU skinning
  30251. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  30252. */
  30253. setPositionsForCPUSkinning(): Float32Array;
  30254. /**
  30255. * Prepare internal normal array for software CPU skinning
  30256. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  30257. */
  30258. setNormalsForCPUSkinning(): Float32Array;
  30259. /**
  30260. * Updates the vertex buffer by applying transformation from the bones
  30261. * @param skeleton defines the skeleton to apply to current mesh
  30262. * @returns the current mesh
  30263. */
  30264. applySkeleton(skeleton: Skeleton): Mesh;
  30265. /**
  30266. * 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
  30267. * @param meshes defines the list of meshes to scan
  30268. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  30269. */
  30270. static MinMax(meshes: AbstractMesh[]): {
  30271. min: Vector3;
  30272. max: Vector3;
  30273. };
  30274. /**
  30275. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  30276. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  30277. * @returns a vector3
  30278. */
  30279. static Center(meshesOrMinMaxVector: {
  30280. min: Vector3;
  30281. max: Vector3;
  30282. } | AbstractMesh[]): Vector3;
  30283. /**
  30284. * Merge the array of meshes into a single mesh for performance reasons.
  30285. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  30286. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  30287. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  30288. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  30289. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  30290. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  30291. * @returns a new mesh
  30292. */
  30293. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  30294. /** @hidden */
  30295. addInstance(instance: InstancedMesh): void;
  30296. /** @hidden */
  30297. removeInstance(instance: InstancedMesh): void;
  30298. }
  30299. }
  30300. declare module "babylonjs/Cameras/camera" {
  30301. import { SmartArray } from "babylonjs/Misc/smartArray";
  30302. import { Observable } from "babylonjs/Misc/observable";
  30303. import { Nullable } from "babylonjs/types";
  30304. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30305. import { Scene } from "babylonjs/scene";
  30306. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  30307. import { Node } from "babylonjs/node";
  30308. import { Mesh } from "babylonjs/Meshes/mesh";
  30309. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30310. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30311. import { Viewport } from "babylonjs/Maths/math.viewport";
  30312. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30313. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30314. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30315. import { Ray } from "babylonjs/Culling/ray";
  30316. /**
  30317. * This is the base class of all the camera used in the application.
  30318. * @see https://doc.babylonjs.com/features/cameras
  30319. */
  30320. export class Camera extends Node {
  30321. /** @hidden */
  30322. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30323. /**
  30324. * This is the default projection mode used by the cameras.
  30325. * It helps recreating a feeling of perspective and better appreciate depth.
  30326. * This is the best way to simulate real life cameras.
  30327. */
  30328. static readonly PERSPECTIVE_CAMERA: number;
  30329. /**
  30330. * This helps creating camera with an orthographic mode.
  30331. * 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.
  30332. */
  30333. static readonly ORTHOGRAPHIC_CAMERA: number;
  30334. /**
  30335. * This is the default FOV mode for perspective cameras.
  30336. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30337. */
  30338. static readonly FOVMODE_VERTICAL_FIXED: number;
  30339. /**
  30340. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30341. */
  30342. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30343. /**
  30344. * This specifies ther is no need for a camera rig.
  30345. * Basically only one eye is rendered corresponding to the camera.
  30346. */
  30347. static readonly RIG_MODE_NONE: number;
  30348. /**
  30349. * Simulates a camera Rig with one blue eye and one red eye.
  30350. * This can be use with 3d blue and red glasses.
  30351. */
  30352. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30353. /**
  30354. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30355. */
  30356. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30357. /**
  30358. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30359. */
  30360. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30361. /**
  30362. * Defines that both eyes of the camera will be rendered over under each other.
  30363. */
  30364. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30365. /**
  30366. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  30367. */
  30368. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  30369. /**
  30370. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30371. */
  30372. static readonly RIG_MODE_VR: number;
  30373. /**
  30374. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30375. */
  30376. static readonly RIG_MODE_WEBVR: number;
  30377. /**
  30378. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30379. */
  30380. static readonly RIG_MODE_CUSTOM: number;
  30381. /**
  30382. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30383. */
  30384. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30385. /**
  30386. * Define the input manager associated with the camera.
  30387. */
  30388. inputs: CameraInputsManager<Camera>;
  30389. /** @hidden */
  30390. _position: Vector3;
  30391. /**
  30392. * Define the current local position of the camera in the scene
  30393. */
  30394. get position(): Vector3;
  30395. set position(newPosition: Vector3);
  30396. /**
  30397. * The vector the camera should consider as up.
  30398. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30399. */
  30400. upVector: Vector3;
  30401. /**
  30402. * Define the current limit on the left side for an orthographic camera
  30403. * In scene unit
  30404. */
  30405. orthoLeft: Nullable<number>;
  30406. /**
  30407. * Define the current limit on the right side for an orthographic camera
  30408. * In scene unit
  30409. */
  30410. orthoRight: Nullable<number>;
  30411. /**
  30412. * Define the current limit on the bottom side for an orthographic camera
  30413. * In scene unit
  30414. */
  30415. orthoBottom: Nullable<number>;
  30416. /**
  30417. * Define the current limit on the top side for an orthographic camera
  30418. * In scene unit
  30419. */
  30420. orthoTop: Nullable<number>;
  30421. /**
  30422. * Field Of View is set in Radians. (default is 0.8)
  30423. */
  30424. fov: number;
  30425. /**
  30426. * Define the minimum distance the camera can see from.
  30427. * This is important to note that the depth buffer are not infinite and the closer it starts
  30428. * the more your scene might encounter depth fighting issue.
  30429. */
  30430. minZ: number;
  30431. /**
  30432. * Define the maximum distance the camera can see to.
  30433. * This is important to note that the depth buffer are not infinite and the further it end
  30434. * the more your scene might encounter depth fighting issue.
  30435. */
  30436. maxZ: number;
  30437. /**
  30438. * Define the default inertia of the camera.
  30439. * This helps giving a smooth feeling to the camera movement.
  30440. */
  30441. inertia: number;
  30442. /**
  30443. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  30444. */
  30445. mode: number;
  30446. /**
  30447. * Define whether the camera is intermediate.
  30448. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30449. */
  30450. isIntermediate: boolean;
  30451. /**
  30452. * Define the viewport of the camera.
  30453. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30454. */
  30455. viewport: Viewport;
  30456. /**
  30457. * Restricts the camera to viewing objects with the same layerMask.
  30458. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30459. */
  30460. layerMask: number;
  30461. /**
  30462. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30463. */
  30464. fovMode: number;
  30465. /**
  30466. * Rig mode of the camera.
  30467. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30468. * This is normally controlled byt the camera themselves as internal use.
  30469. */
  30470. cameraRigMode: number;
  30471. /**
  30472. * Defines the distance between both "eyes" in case of a RIG
  30473. */
  30474. interaxialDistance: number;
  30475. /**
  30476. * Defines if stereoscopic rendering is done side by side or over under.
  30477. */
  30478. isStereoscopicSideBySide: boolean;
  30479. /**
  30480. * 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
  30481. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30482. * else in the scene. (Eg. security camera)
  30483. *
  30484. * 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)
  30485. */
  30486. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  30487. /**
  30488. * When set, the camera will render to this render target instead of the default canvas
  30489. *
  30490. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  30491. */
  30492. outputRenderTarget: Nullable<RenderTargetTexture>;
  30493. /**
  30494. * Observable triggered when the camera view matrix has changed.
  30495. */
  30496. onViewMatrixChangedObservable: Observable<Camera>;
  30497. /**
  30498. * Observable triggered when the camera Projection matrix has changed.
  30499. */
  30500. onProjectionMatrixChangedObservable: Observable<Camera>;
  30501. /**
  30502. * Observable triggered when the inputs have been processed.
  30503. */
  30504. onAfterCheckInputsObservable: Observable<Camera>;
  30505. /**
  30506. * Observable triggered when reset has been called and applied to the camera.
  30507. */
  30508. onRestoreStateObservable: Observable<Camera>;
  30509. /**
  30510. * Is this camera a part of a rig system?
  30511. */
  30512. isRigCamera: boolean;
  30513. /**
  30514. * If isRigCamera set to true this will be set with the parent camera.
  30515. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  30516. */
  30517. rigParent?: Camera;
  30518. /** @hidden */
  30519. _cameraRigParams: any;
  30520. /** @hidden */
  30521. _rigCameras: Camera[];
  30522. /** @hidden */
  30523. _rigPostProcess: Nullable<PostProcess>;
  30524. protected _webvrViewMatrix: Matrix;
  30525. /** @hidden */
  30526. _skipRendering: boolean;
  30527. /** @hidden */
  30528. _projectionMatrix: Matrix;
  30529. /** @hidden */
  30530. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  30531. /** @hidden */
  30532. _activeMeshes: SmartArray<AbstractMesh>;
  30533. protected _globalPosition: Vector3;
  30534. /** @hidden */
  30535. _computedViewMatrix: Matrix;
  30536. private _doNotComputeProjectionMatrix;
  30537. private _transformMatrix;
  30538. private _frustumPlanes;
  30539. private _refreshFrustumPlanes;
  30540. private _storedFov;
  30541. private _stateStored;
  30542. /**
  30543. * Instantiates a new camera object.
  30544. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30545. * @see https://doc.babylonjs.com/features/cameras
  30546. * @param name Defines the name of the camera in the scene
  30547. * @param position Defines the position of the camera
  30548. * @param scene Defines the scene the camera belongs too
  30549. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30550. */
  30551. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30552. /**
  30553. * Store current camera state (fov, position, etc..)
  30554. * @returns the camera
  30555. */
  30556. storeState(): Camera;
  30557. /**
  30558. * Restores the camera state values if it has been stored. You must call storeState() first
  30559. */
  30560. protected _restoreStateValues(): boolean;
  30561. /**
  30562. * Restored camera state. You must call storeState() first.
  30563. * @returns true if restored and false otherwise
  30564. */
  30565. restoreState(): boolean;
  30566. /**
  30567. * Gets the class name of the camera.
  30568. * @returns the class name
  30569. */
  30570. getClassName(): string;
  30571. /** @hidden */
  30572. readonly _isCamera: boolean;
  30573. /**
  30574. * Gets a string representation of the camera useful for debug purpose.
  30575. * @param fullDetails Defines that a more verboe level of logging is required
  30576. * @returns the string representation
  30577. */
  30578. toString(fullDetails?: boolean): string;
  30579. /**
  30580. * Gets the current world space position of the camera.
  30581. */
  30582. get globalPosition(): Vector3;
  30583. /**
  30584. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30585. * @returns the active meshe list
  30586. */
  30587. getActiveMeshes(): SmartArray<AbstractMesh>;
  30588. /**
  30589. * Check whether a mesh is part of the current active mesh list of the camera
  30590. * @param mesh Defines the mesh to check
  30591. * @returns true if active, false otherwise
  30592. */
  30593. isActiveMesh(mesh: Mesh): boolean;
  30594. /**
  30595. * Is this camera ready to be used/rendered
  30596. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30597. * @return true if the camera is ready
  30598. */
  30599. isReady(completeCheck?: boolean): boolean;
  30600. /** @hidden */
  30601. _initCache(): void;
  30602. /** @hidden */
  30603. _updateCache(ignoreParentClass?: boolean): void;
  30604. /** @hidden */
  30605. _isSynchronized(): boolean;
  30606. /** @hidden */
  30607. _isSynchronizedViewMatrix(): boolean;
  30608. /** @hidden */
  30609. _isSynchronizedProjectionMatrix(): boolean;
  30610. /**
  30611. * Attach the input controls to a specific dom element to get the input from.
  30612. * @param element Defines the element the controls should be listened from
  30613. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30614. */
  30615. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30616. /**
  30617. * Detach the current controls from the specified dom element.
  30618. * @param element Defines the element to stop listening the inputs from
  30619. */
  30620. detachControl(element: HTMLElement): void;
  30621. /**
  30622. * Update the camera state according to the different inputs gathered during the frame.
  30623. */
  30624. update(): void;
  30625. /** @hidden */
  30626. _checkInputs(): void;
  30627. /** @hidden */
  30628. get rigCameras(): Camera[];
  30629. /**
  30630. * Gets the post process used by the rig cameras
  30631. */
  30632. get rigPostProcess(): Nullable<PostProcess>;
  30633. /**
  30634. * Internal, gets the first post proces.
  30635. * @returns the first post process to be run on this camera.
  30636. */
  30637. _getFirstPostProcess(): Nullable<PostProcess>;
  30638. private _cascadePostProcessesToRigCams;
  30639. /**
  30640. * Attach a post process to the camera.
  30641. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30642. * @param postProcess The post process to attach to the camera
  30643. * @param insertAt The position of the post process in case several of them are in use in the scene
  30644. * @returns the position the post process has been inserted at
  30645. */
  30646. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30647. /**
  30648. * Detach a post process to the camera.
  30649. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30650. * @param postProcess The post process to detach from the camera
  30651. */
  30652. detachPostProcess(postProcess: PostProcess): void;
  30653. /**
  30654. * Gets the current world matrix of the camera
  30655. */
  30656. getWorldMatrix(): Matrix;
  30657. /** @hidden */
  30658. _getViewMatrix(): Matrix;
  30659. /**
  30660. * Gets the current view matrix of the camera.
  30661. * @param force forces the camera to recompute the matrix without looking at the cached state
  30662. * @returns the view matrix
  30663. */
  30664. getViewMatrix(force?: boolean): Matrix;
  30665. /**
  30666. * Freeze the projection matrix.
  30667. * It will prevent the cache check of the camera projection compute and can speed up perf
  30668. * if no parameter of the camera are meant to change
  30669. * @param projection Defines manually a projection if necessary
  30670. */
  30671. freezeProjectionMatrix(projection?: Matrix): void;
  30672. /**
  30673. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30674. */
  30675. unfreezeProjectionMatrix(): void;
  30676. /**
  30677. * Gets the current projection matrix of the camera.
  30678. * @param force forces the camera to recompute the matrix without looking at the cached state
  30679. * @returns the projection matrix
  30680. */
  30681. getProjectionMatrix(force?: boolean): Matrix;
  30682. /**
  30683. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30684. * @returns a Matrix
  30685. */
  30686. getTransformationMatrix(): Matrix;
  30687. private _updateFrustumPlanes;
  30688. /**
  30689. * Checks if a cullable object (mesh...) is in the camera frustum
  30690. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30691. * @param target The object to check
  30692. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  30693. * @returns true if the object is in frustum otherwise false
  30694. */
  30695. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  30696. /**
  30697. * Checks if a cullable object (mesh...) is in the camera frustum
  30698. * Unlike isInFrustum this cheks the full bounding box
  30699. * @param target The object to check
  30700. * @returns true if the object is in frustum otherwise false
  30701. */
  30702. isCompletelyInFrustum(target: ICullable): boolean;
  30703. /**
  30704. * Gets a ray in the forward direction from the camera.
  30705. * @param length Defines the length of the ray to create
  30706. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30707. * @param origin Defines the start point of the ray which defaults to the camera position
  30708. * @returns the forward ray
  30709. */
  30710. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30711. /**
  30712. * Gets a ray in the forward direction from the camera.
  30713. * @param refRay the ray to (re)use when setting the values
  30714. * @param length Defines the length of the ray to create
  30715. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30716. * @param origin Defines the start point of the ray which defaults to the camera position
  30717. * @returns the forward ray
  30718. */
  30719. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30720. /**
  30721. * Releases resources associated with this node.
  30722. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30723. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30724. */
  30725. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30726. /** @hidden */
  30727. _isLeftCamera: boolean;
  30728. /**
  30729. * Gets the left camera of a rig setup in case of Rigged Camera
  30730. */
  30731. get isLeftCamera(): boolean;
  30732. /** @hidden */
  30733. _isRightCamera: boolean;
  30734. /**
  30735. * Gets the right camera of a rig setup in case of Rigged Camera
  30736. */
  30737. get isRightCamera(): boolean;
  30738. /**
  30739. * Gets the left camera of a rig setup in case of Rigged Camera
  30740. */
  30741. get leftCamera(): Nullable<FreeCamera>;
  30742. /**
  30743. * Gets the right camera of a rig setup in case of Rigged Camera
  30744. */
  30745. get rightCamera(): Nullable<FreeCamera>;
  30746. /**
  30747. * Gets the left camera target of a rig setup in case of Rigged Camera
  30748. * @returns the target position
  30749. */
  30750. getLeftTarget(): Nullable<Vector3>;
  30751. /**
  30752. * Gets the right camera target of a rig setup in case of Rigged Camera
  30753. * @returns the target position
  30754. */
  30755. getRightTarget(): Nullable<Vector3>;
  30756. /**
  30757. * @hidden
  30758. */
  30759. setCameraRigMode(mode: number, rigParams: any): void;
  30760. /** @hidden */
  30761. static _setStereoscopicRigMode(camera: Camera): void;
  30762. /** @hidden */
  30763. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30764. /** @hidden */
  30765. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30766. /** @hidden */
  30767. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30768. /** @hidden */
  30769. _getVRProjectionMatrix(): Matrix;
  30770. protected _updateCameraRotationMatrix(): void;
  30771. protected _updateWebVRCameraRotationMatrix(): void;
  30772. /**
  30773. * This function MUST be overwritten by the different WebVR cameras available.
  30774. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30775. * @hidden
  30776. */
  30777. _getWebVRProjectionMatrix(): Matrix;
  30778. /**
  30779. * This function MUST be overwritten by the different WebVR cameras available.
  30780. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30781. * @hidden
  30782. */
  30783. _getWebVRViewMatrix(): Matrix;
  30784. /** @hidden */
  30785. setCameraRigParameter(name: string, value: any): void;
  30786. /**
  30787. * needs to be overridden by children so sub has required properties to be copied
  30788. * @hidden
  30789. */
  30790. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30791. /**
  30792. * May need to be overridden by children
  30793. * @hidden
  30794. */
  30795. _updateRigCameras(): void;
  30796. /** @hidden */
  30797. _setupInputs(): void;
  30798. /**
  30799. * Serialiaze the camera setup to a json represention
  30800. * @returns the JSON representation
  30801. */
  30802. serialize(): any;
  30803. /**
  30804. * Clones the current camera.
  30805. * @param name The cloned camera name
  30806. * @returns the cloned camera
  30807. */
  30808. clone(name: string): Camera;
  30809. /**
  30810. * Gets the direction of the camera relative to a given local axis.
  30811. * @param localAxis Defines the reference axis to provide a relative direction.
  30812. * @return the direction
  30813. */
  30814. getDirection(localAxis: Vector3): Vector3;
  30815. /**
  30816. * Returns the current camera absolute rotation
  30817. */
  30818. get absoluteRotation(): Quaternion;
  30819. /**
  30820. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30821. * @param localAxis Defines the reference axis to provide a relative direction.
  30822. * @param result Defines the vector to store the result in
  30823. */
  30824. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30825. /**
  30826. * Gets a camera constructor for a given camera type
  30827. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30828. * @param name The name of the camera the result will be able to instantiate
  30829. * @param scene The scene the result will construct the camera in
  30830. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30831. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30832. * @returns a factory method to construc the camera
  30833. */
  30834. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30835. /**
  30836. * Compute the world matrix of the camera.
  30837. * @returns the camera world matrix
  30838. */
  30839. computeWorldMatrix(): Matrix;
  30840. /**
  30841. * Parse a JSON and creates the camera from the parsed information
  30842. * @param parsedCamera The JSON to parse
  30843. * @param scene The scene to instantiate the camera in
  30844. * @returns the newly constructed camera
  30845. */
  30846. static Parse(parsedCamera: any, scene: Scene): Camera;
  30847. }
  30848. }
  30849. declare module "babylonjs/Meshes/Builders/discBuilder" {
  30850. import { Nullable } from "babylonjs/types";
  30851. import { Scene } from "babylonjs/scene";
  30852. import { Vector4 } from "babylonjs/Maths/math.vector";
  30853. import { Mesh } from "babylonjs/Meshes/mesh";
  30854. /**
  30855. * Class containing static functions to help procedurally build meshes
  30856. */
  30857. export class DiscBuilder {
  30858. /**
  30859. * Creates a plane polygonal mesh. By default, this is a disc
  30860. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  30861. * * 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
  30862. * * 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
  30863. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  30864. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  30865. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30866. * @param name defines the name of the mesh
  30867. * @param options defines the options used to create the mesh
  30868. * @param scene defines the hosting scene
  30869. * @returns the plane polygonal mesh
  30870. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  30871. */
  30872. static CreateDisc(name: string, options: {
  30873. radius?: number;
  30874. tessellation?: number;
  30875. arc?: number;
  30876. updatable?: boolean;
  30877. sideOrientation?: number;
  30878. frontUVs?: Vector4;
  30879. backUVs?: Vector4;
  30880. }, scene?: Nullable<Scene>): Mesh;
  30881. }
  30882. }
  30883. declare module "babylonjs/Materials/fresnelParameters" {
  30884. import { DeepImmutable } from "babylonjs/types";
  30885. import { Color3 } from "babylonjs/Maths/math.color";
  30886. /**
  30887. * Options to be used when creating a FresnelParameters.
  30888. */
  30889. export type IFresnelParametersCreationOptions = {
  30890. /**
  30891. * Define the color used on edges (grazing angle)
  30892. */
  30893. leftColor?: Color3;
  30894. /**
  30895. * Define the color used on center
  30896. */
  30897. rightColor?: Color3;
  30898. /**
  30899. * Define bias applied to computed fresnel term
  30900. */
  30901. bias?: number;
  30902. /**
  30903. * Defined the power exponent applied to fresnel term
  30904. */
  30905. power?: number;
  30906. /**
  30907. * Define if the fresnel effect is enable or not.
  30908. */
  30909. isEnabled?: boolean;
  30910. };
  30911. /**
  30912. * Serialized format for FresnelParameters.
  30913. */
  30914. export type IFresnelParametersSerialized = {
  30915. /**
  30916. * Define the color used on edges (grazing angle) [as an array]
  30917. */
  30918. leftColor: number[];
  30919. /**
  30920. * Define the color used on center [as an array]
  30921. */
  30922. rightColor: number[];
  30923. /**
  30924. * Define bias applied to computed fresnel term
  30925. */
  30926. bias: number;
  30927. /**
  30928. * Defined the power exponent applied to fresnel term
  30929. */
  30930. power?: number;
  30931. /**
  30932. * Define if the fresnel effect is enable or not.
  30933. */
  30934. isEnabled: boolean;
  30935. };
  30936. /**
  30937. * This represents all the required information to add a fresnel effect on a material:
  30938. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30939. */
  30940. export class FresnelParameters {
  30941. private _isEnabled;
  30942. /**
  30943. * Define if the fresnel effect is enable or not.
  30944. */
  30945. get isEnabled(): boolean;
  30946. set isEnabled(value: boolean);
  30947. /**
  30948. * Define the color used on edges (grazing angle)
  30949. */
  30950. leftColor: Color3;
  30951. /**
  30952. * Define the color used on center
  30953. */
  30954. rightColor: Color3;
  30955. /**
  30956. * Define bias applied to computed fresnel term
  30957. */
  30958. bias: number;
  30959. /**
  30960. * Defined the power exponent applied to fresnel term
  30961. */
  30962. power: number;
  30963. /**
  30964. * Creates a new FresnelParameters object.
  30965. *
  30966. * @param options provide your own settings to optionally to override defaults
  30967. */
  30968. constructor(options?: IFresnelParametersCreationOptions);
  30969. /**
  30970. * Clones the current fresnel and its valuues
  30971. * @returns a clone fresnel configuration
  30972. */
  30973. clone(): FresnelParameters;
  30974. /**
  30975. * Determines equality between FresnelParameters objects
  30976. * @param otherFresnelParameters defines the second operand
  30977. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  30978. */
  30979. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  30980. /**
  30981. * Serializes the current fresnel parameters to a JSON representation.
  30982. * @return the JSON serialization
  30983. */
  30984. serialize(): IFresnelParametersSerialized;
  30985. /**
  30986. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30987. * @param parsedFresnelParameters Define the JSON representation
  30988. * @returns the parsed parameters
  30989. */
  30990. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  30991. }
  30992. }
  30993. declare module "babylonjs/Materials/materialFlags" {
  30994. /**
  30995. * This groups all the flags used to control the materials channel.
  30996. */
  30997. export class MaterialFlags {
  30998. private static _DiffuseTextureEnabled;
  30999. /**
  31000. * Are diffuse textures enabled in the application.
  31001. */
  31002. static get DiffuseTextureEnabled(): boolean;
  31003. static set DiffuseTextureEnabled(value: boolean);
  31004. private static _DetailTextureEnabled;
  31005. /**
  31006. * Are detail textures enabled in the application.
  31007. */
  31008. static get DetailTextureEnabled(): boolean;
  31009. static set DetailTextureEnabled(value: boolean);
  31010. private static _AmbientTextureEnabled;
  31011. /**
  31012. * Are ambient textures enabled in the application.
  31013. */
  31014. static get AmbientTextureEnabled(): boolean;
  31015. static set AmbientTextureEnabled(value: boolean);
  31016. private static _OpacityTextureEnabled;
  31017. /**
  31018. * Are opacity textures enabled in the application.
  31019. */
  31020. static get OpacityTextureEnabled(): boolean;
  31021. static set OpacityTextureEnabled(value: boolean);
  31022. private static _ReflectionTextureEnabled;
  31023. /**
  31024. * Are reflection textures enabled in the application.
  31025. */
  31026. static get ReflectionTextureEnabled(): boolean;
  31027. static set ReflectionTextureEnabled(value: boolean);
  31028. private static _EmissiveTextureEnabled;
  31029. /**
  31030. * Are emissive textures enabled in the application.
  31031. */
  31032. static get EmissiveTextureEnabled(): boolean;
  31033. static set EmissiveTextureEnabled(value: boolean);
  31034. private static _SpecularTextureEnabled;
  31035. /**
  31036. * Are specular textures enabled in the application.
  31037. */
  31038. static get SpecularTextureEnabled(): boolean;
  31039. static set SpecularTextureEnabled(value: boolean);
  31040. private static _BumpTextureEnabled;
  31041. /**
  31042. * Are bump textures enabled in the application.
  31043. */
  31044. static get BumpTextureEnabled(): boolean;
  31045. static set BumpTextureEnabled(value: boolean);
  31046. private static _LightmapTextureEnabled;
  31047. /**
  31048. * Are lightmap textures enabled in the application.
  31049. */
  31050. static get LightmapTextureEnabled(): boolean;
  31051. static set LightmapTextureEnabled(value: boolean);
  31052. private static _RefractionTextureEnabled;
  31053. /**
  31054. * Are refraction textures enabled in the application.
  31055. */
  31056. static get RefractionTextureEnabled(): boolean;
  31057. static set RefractionTextureEnabled(value: boolean);
  31058. private static _ColorGradingTextureEnabled;
  31059. /**
  31060. * Are color grading textures enabled in the application.
  31061. */
  31062. static get ColorGradingTextureEnabled(): boolean;
  31063. static set ColorGradingTextureEnabled(value: boolean);
  31064. private static _FresnelEnabled;
  31065. /**
  31066. * Are fresnels enabled in the application.
  31067. */
  31068. static get FresnelEnabled(): boolean;
  31069. static set FresnelEnabled(value: boolean);
  31070. private static _ClearCoatTextureEnabled;
  31071. /**
  31072. * Are clear coat textures enabled in the application.
  31073. */
  31074. static get ClearCoatTextureEnabled(): boolean;
  31075. static set ClearCoatTextureEnabled(value: boolean);
  31076. private static _ClearCoatBumpTextureEnabled;
  31077. /**
  31078. * Are clear coat bump textures enabled in the application.
  31079. */
  31080. static get ClearCoatBumpTextureEnabled(): boolean;
  31081. static set ClearCoatBumpTextureEnabled(value: boolean);
  31082. private static _ClearCoatTintTextureEnabled;
  31083. /**
  31084. * Are clear coat tint textures enabled in the application.
  31085. */
  31086. static get ClearCoatTintTextureEnabled(): boolean;
  31087. static set ClearCoatTintTextureEnabled(value: boolean);
  31088. private static _SheenTextureEnabled;
  31089. /**
  31090. * Are sheen textures enabled in the application.
  31091. */
  31092. static get SheenTextureEnabled(): boolean;
  31093. static set SheenTextureEnabled(value: boolean);
  31094. private static _AnisotropicTextureEnabled;
  31095. /**
  31096. * Are anisotropic textures enabled in the application.
  31097. */
  31098. static get AnisotropicTextureEnabled(): boolean;
  31099. static set AnisotropicTextureEnabled(value: boolean);
  31100. private static _ThicknessTextureEnabled;
  31101. /**
  31102. * Are thickness textures enabled in the application.
  31103. */
  31104. static get ThicknessTextureEnabled(): boolean;
  31105. static set ThicknessTextureEnabled(value: boolean);
  31106. }
  31107. }
  31108. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  31109. /** @hidden */
  31110. export var defaultFragmentDeclaration: {
  31111. name: string;
  31112. shader: string;
  31113. };
  31114. }
  31115. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  31116. /** @hidden */
  31117. export var defaultUboDeclaration: {
  31118. name: string;
  31119. shader: string;
  31120. };
  31121. }
  31122. declare module "babylonjs/Shaders/ShadersInclude/prePassDeclaration" {
  31123. /** @hidden */
  31124. export var prePassDeclaration: {
  31125. name: string;
  31126. shader: string;
  31127. };
  31128. }
  31129. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  31130. /** @hidden */
  31131. export var lightFragmentDeclaration: {
  31132. name: string;
  31133. shader: string;
  31134. };
  31135. }
  31136. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  31137. /** @hidden */
  31138. export var lightUboDeclaration: {
  31139. name: string;
  31140. shader: string;
  31141. };
  31142. }
  31143. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  31144. /** @hidden */
  31145. export var lightsFragmentFunctions: {
  31146. name: string;
  31147. shader: string;
  31148. };
  31149. }
  31150. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  31151. /** @hidden */
  31152. export var shadowsFragmentFunctions: {
  31153. name: string;
  31154. shader: string;
  31155. };
  31156. }
  31157. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  31158. /** @hidden */
  31159. export var fresnelFunction: {
  31160. name: string;
  31161. shader: string;
  31162. };
  31163. }
  31164. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  31165. /** @hidden */
  31166. export var bumpFragmentMainFunctions: {
  31167. name: string;
  31168. shader: string;
  31169. };
  31170. }
  31171. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  31172. /** @hidden */
  31173. export var bumpFragmentFunctions: {
  31174. name: string;
  31175. shader: string;
  31176. };
  31177. }
  31178. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  31179. /** @hidden */
  31180. export var logDepthDeclaration: {
  31181. name: string;
  31182. shader: string;
  31183. };
  31184. }
  31185. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  31186. /** @hidden */
  31187. export var bumpFragment: {
  31188. name: string;
  31189. shader: string;
  31190. };
  31191. }
  31192. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  31193. /** @hidden */
  31194. export var depthPrePass: {
  31195. name: string;
  31196. shader: string;
  31197. };
  31198. }
  31199. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  31200. /** @hidden */
  31201. export var lightFragment: {
  31202. name: string;
  31203. shader: string;
  31204. };
  31205. }
  31206. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  31207. /** @hidden */
  31208. export var logDepthFragment: {
  31209. name: string;
  31210. shader: string;
  31211. };
  31212. }
  31213. declare module "babylonjs/Shaders/default.fragment" {
  31214. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  31215. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  31216. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  31217. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  31218. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  31219. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  31220. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  31221. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  31222. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  31223. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  31224. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  31225. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  31226. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  31227. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  31228. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  31229. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  31230. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  31231. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  31232. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  31233. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  31234. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  31235. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  31236. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  31237. /** @hidden */
  31238. export var defaultPixelShader: {
  31239. name: string;
  31240. shader: string;
  31241. };
  31242. }
  31243. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  31244. /** @hidden */
  31245. export var defaultVertexDeclaration: {
  31246. name: string;
  31247. shader: string;
  31248. };
  31249. }
  31250. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  31251. /** @hidden */
  31252. export var bumpVertexDeclaration: {
  31253. name: string;
  31254. shader: string;
  31255. };
  31256. }
  31257. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  31258. /** @hidden */
  31259. export var bumpVertex: {
  31260. name: string;
  31261. shader: string;
  31262. };
  31263. }
  31264. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  31265. /** @hidden */
  31266. export var fogVertex: {
  31267. name: string;
  31268. shader: string;
  31269. };
  31270. }
  31271. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  31272. /** @hidden */
  31273. export var shadowsVertex: {
  31274. name: string;
  31275. shader: string;
  31276. };
  31277. }
  31278. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  31279. /** @hidden */
  31280. export var pointCloudVertex: {
  31281. name: string;
  31282. shader: string;
  31283. };
  31284. }
  31285. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  31286. /** @hidden */
  31287. export var logDepthVertex: {
  31288. name: string;
  31289. shader: string;
  31290. };
  31291. }
  31292. declare module "babylonjs/Shaders/default.vertex" {
  31293. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  31294. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  31295. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  31296. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  31297. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  31298. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  31299. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  31300. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  31301. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  31302. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  31303. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  31304. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  31305. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  31306. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  31307. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  31308. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  31309. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  31310. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  31311. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  31312. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  31313. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  31314. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  31315. /** @hidden */
  31316. export var defaultVertexShader: {
  31317. name: string;
  31318. shader: string;
  31319. };
  31320. }
  31321. declare module "babylonjs/Materials/material.detailMapConfiguration" {
  31322. import { Nullable } from "babylonjs/types";
  31323. import { Scene } from "babylonjs/scene";
  31324. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31325. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31326. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31327. /**
  31328. * @hidden
  31329. */
  31330. export interface IMaterialDetailMapDefines {
  31331. DETAIL: boolean;
  31332. DETAILDIRECTUV: number;
  31333. DETAIL_NORMALBLENDMETHOD: number;
  31334. /** @hidden */
  31335. _areTexturesDirty: boolean;
  31336. }
  31337. /**
  31338. * Define the code related to the detail map parameters of a material
  31339. *
  31340. * Inspired from:
  31341. * 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
  31342. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  31343. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  31344. */
  31345. export class DetailMapConfiguration {
  31346. private _texture;
  31347. /**
  31348. * The detail texture of the material.
  31349. */
  31350. texture: Nullable<BaseTexture>;
  31351. /**
  31352. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  31353. * Bigger values mean stronger blending
  31354. */
  31355. diffuseBlendLevel: number;
  31356. /**
  31357. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  31358. * Bigger values mean stronger blending. Only used with PBR materials
  31359. */
  31360. roughnessBlendLevel: number;
  31361. /**
  31362. * Defines how strong the bump effect from the detail map is
  31363. * Bigger values mean stronger effect
  31364. */
  31365. bumpLevel: number;
  31366. private _normalBlendMethod;
  31367. /**
  31368. * The method used to blend the bump and detail normals together
  31369. */
  31370. normalBlendMethod: number;
  31371. private _isEnabled;
  31372. /**
  31373. * Enable or disable the detail map on this material
  31374. */
  31375. isEnabled: boolean;
  31376. /** @hidden */
  31377. private _internalMarkAllSubMeshesAsTexturesDirty;
  31378. /** @hidden */
  31379. _markAllSubMeshesAsTexturesDirty(): void;
  31380. /**
  31381. * Instantiate a new detail map
  31382. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  31383. */
  31384. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  31385. /**
  31386. * Gets whether the submesh is ready to be used or not.
  31387. * @param defines the list of "defines" to update.
  31388. * @param scene defines the scene the material belongs to.
  31389. * @returns - boolean indicating that the submesh is ready or not.
  31390. */
  31391. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  31392. /**
  31393. * Update the defines for detail map usage
  31394. * @param defines the list of "defines" to update.
  31395. * @param scene defines the scene the material belongs to.
  31396. */
  31397. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  31398. /**
  31399. * Binds the material data.
  31400. * @param uniformBuffer defines the Uniform buffer to fill in.
  31401. * @param scene defines the scene the material belongs to.
  31402. * @param isFrozen defines whether the material is frozen or not.
  31403. */
  31404. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  31405. /**
  31406. * Checks to see if a texture is used in the material.
  31407. * @param texture - Base texture to use.
  31408. * @returns - Boolean specifying if a texture is used in the material.
  31409. */
  31410. hasTexture(texture: BaseTexture): boolean;
  31411. /**
  31412. * Returns an array of the actively used textures.
  31413. * @param activeTextures Array of BaseTextures
  31414. */
  31415. getActiveTextures(activeTextures: BaseTexture[]): void;
  31416. /**
  31417. * Returns the animatable textures.
  31418. * @param animatables Array of animatable textures.
  31419. */
  31420. getAnimatables(animatables: IAnimatable[]): void;
  31421. /**
  31422. * Disposes the resources of the material.
  31423. * @param forceDisposeTextures - Forces the disposal of all textures.
  31424. */
  31425. dispose(forceDisposeTextures?: boolean): void;
  31426. /**
  31427. * Get the current class name useful for serialization or dynamic coding.
  31428. * @returns "DetailMap"
  31429. */
  31430. getClassName(): string;
  31431. /**
  31432. * Add the required uniforms to the current list.
  31433. * @param uniforms defines the current uniform list.
  31434. */
  31435. static AddUniforms(uniforms: string[]): void;
  31436. /**
  31437. * Add the required samplers to the current list.
  31438. * @param samplers defines the current sampler list.
  31439. */
  31440. static AddSamplers(samplers: string[]): void;
  31441. /**
  31442. * Add the required uniforms to the current buffer.
  31443. * @param uniformBuffer defines the current uniform buffer.
  31444. */
  31445. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  31446. /**
  31447. * Makes a duplicate of the current instance into another one.
  31448. * @param detailMap define the instance where to copy the info
  31449. */
  31450. copyTo(detailMap: DetailMapConfiguration): void;
  31451. /**
  31452. * Serializes this detail map instance
  31453. * @returns - An object with the serialized instance.
  31454. */
  31455. serialize(): any;
  31456. /**
  31457. * Parses a detail map setting from a serialized object.
  31458. * @param source - Serialized object.
  31459. * @param scene Defines the scene we are parsing for
  31460. * @param rootUrl Defines the rootUrl to load from
  31461. */
  31462. parse(source: any, scene: Scene, rootUrl: string): void;
  31463. }
  31464. }
  31465. declare module "babylonjs/Materials/standardMaterial" {
  31466. import { SmartArray } from "babylonjs/Misc/smartArray";
  31467. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31468. import { Nullable } from "babylonjs/types";
  31469. import { Scene } from "babylonjs/scene";
  31470. import { Matrix } from "babylonjs/Maths/math.vector";
  31471. import { Color3 } from "babylonjs/Maths/math.color";
  31472. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31473. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31474. import { Mesh } from "babylonjs/Meshes/mesh";
  31475. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  31476. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  31477. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  31478. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  31479. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  31480. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31481. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31482. import "babylonjs/Shaders/default.fragment";
  31483. import "babylonjs/Shaders/default.vertex";
  31484. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  31485. /** @hidden */
  31486. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  31487. MAINUV1: boolean;
  31488. MAINUV2: boolean;
  31489. DIFFUSE: boolean;
  31490. DIFFUSEDIRECTUV: number;
  31491. DETAIL: boolean;
  31492. DETAILDIRECTUV: number;
  31493. DETAIL_NORMALBLENDMETHOD: number;
  31494. AMBIENT: boolean;
  31495. AMBIENTDIRECTUV: number;
  31496. OPACITY: boolean;
  31497. OPACITYDIRECTUV: number;
  31498. OPACITYRGB: boolean;
  31499. REFLECTION: boolean;
  31500. EMISSIVE: boolean;
  31501. EMISSIVEDIRECTUV: number;
  31502. SPECULAR: boolean;
  31503. SPECULARDIRECTUV: number;
  31504. BUMP: boolean;
  31505. BUMPDIRECTUV: number;
  31506. PARALLAX: boolean;
  31507. PARALLAXOCCLUSION: boolean;
  31508. SPECULAROVERALPHA: boolean;
  31509. CLIPPLANE: boolean;
  31510. CLIPPLANE2: boolean;
  31511. CLIPPLANE3: boolean;
  31512. CLIPPLANE4: boolean;
  31513. CLIPPLANE5: boolean;
  31514. CLIPPLANE6: boolean;
  31515. ALPHATEST: boolean;
  31516. DEPTHPREPASS: boolean;
  31517. ALPHAFROMDIFFUSE: boolean;
  31518. POINTSIZE: boolean;
  31519. FOG: boolean;
  31520. SPECULARTERM: boolean;
  31521. DIFFUSEFRESNEL: boolean;
  31522. OPACITYFRESNEL: boolean;
  31523. REFLECTIONFRESNEL: boolean;
  31524. REFRACTIONFRESNEL: boolean;
  31525. EMISSIVEFRESNEL: boolean;
  31526. FRESNEL: boolean;
  31527. NORMAL: boolean;
  31528. UV1: boolean;
  31529. UV2: boolean;
  31530. VERTEXCOLOR: boolean;
  31531. VERTEXALPHA: boolean;
  31532. NUM_BONE_INFLUENCERS: number;
  31533. BonesPerMesh: number;
  31534. BONETEXTURE: boolean;
  31535. INSTANCES: boolean;
  31536. THIN_INSTANCES: boolean;
  31537. GLOSSINESS: boolean;
  31538. ROUGHNESS: boolean;
  31539. EMISSIVEASILLUMINATION: boolean;
  31540. LINKEMISSIVEWITHDIFFUSE: boolean;
  31541. REFLECTIONFRESNELFROMSPECULAR: boolean;
  31542. LIGHTMAP: boolean;
  31543. LIGHTMAPDIRECTUV: number;
  31544. OBJECTSPACE_NORMALMAP: boolean;
  31545. USELIGHTMAPASSHADOWMAP: boolean;
  31546. REFLECTIONMAP_3D: boolean;
  31547. REFLECTIONMAP_SPHERICAL: boolean;
  31548. REFLECTIONMAP_PLANAR: boolean;
  31549. REFLECTIONMAP_CUBIC: boolean;
  31550. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  31551. REFLECTIONMAP_PROJECTION: boolean;
  31552. REFLECTIONMAP_SKYBOX: boolean;
  31553. REFLECTIONMAP_EXPLICIT: boolean;
  31554. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  31555. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  31556. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  31557. INVERTCUBICMAP: boolean;
  31558. LOGARITHMICDEPTH: boolean;
  31559. REFRACTION: boolean;
  31560. REFRACTIONMAP_3D: boolean;
  31561. REFLECTIONOVERALPHA: boolean;
  31562. TWOSIDEDLIGHTING: boolean;
  31563. SHADOWFLOAT: boolean;
  31564. MORPHTARGETS: boolean;
  31565. MORPHTARGETS_NORMAL: boolean;
  31566. MORPHTARGETS_TANGENT: boolean;
  31567. MORPHTARGETS_UV: boolean;
  31568. NUM_MORPH_INFLUENCERS: number;
  31569. NONUNIFORMSCALING: boolean;
  31570. PREMULTIPLYALPHA: boolean;
  31571. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  31572. ALPHABLEND: boolean;
  31573. PREPASS: boolean;
  31574. SCENE_MRT_COUNT: number;
  31575. RGBDLIGHTMAP: boolean;
  31576. RGBDREFLECTION: boolean;
  31577. RGBDREFRACTION: boolean;
  31578. IMAGEPROCESSING: boolean;
  31579. VIGNETTE: boolean;
  31580. VIGNETTEBLENDMODEMULTIPLY: boolean;
  31581. VIGNETTEBLENDMODEOPAQUE: boolean;
  31582. TONEMAPPING: boolean;
  31583. TONEMAPPING_ACES: boolean;
  31584. CONTRAST: boolean;
  31585. COLORCURVES: boolean;
  31586. COLORGRADING: boolean;
  31587. COLORGRADING3D: boolean;
  31588. SAMPLER3DGREENDEPTH: boolean;
  31589. SAMPLER3DBGRMAP: boolean;
  31590. IMAGEPROCESSINGPOSTPROCESS: boolean;
  31591. MULTIVIEW: boolean;
  31592. /**
  31593. * If the reflection texture on this material is in linear color space
  31594. * @hidden
  31595. */
  31596. IS_REFLECTION_LINEAR: boolean;
  31597. /**
  31598. * If the refraction texture on this material is in linear color space
  31599. * @hidden
  31600. */
  31601. IS_REFRACTION_LINEAR: boolean;
  31602. EXPOSURE: boolean;
  31603. constructor();
  31604. setReflectionMode(modeToEnable: string): void;
  31605. }
  31606. /**
  31607. * This is the default material used in Babylon. It is the best trade off between quality
  31608. * and performances.
  31609. * @see https://doc.babylonjs.com/babylon101/materials
  31610. */
  31611. export class StandardMaterial extends PushMaterial {
  31612. private _diffuseTexture;
  31613. /**
  31614. * The basic texture of the material as viewed under a light.
  31615. */
  31616. diffuseTexture: Nullable<BaseTexture>;
  31617. private _ambientTexture;
  31618. /**
  31619. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  31620. */
  31621. ambientTexture: Nullable<BaseTexture>;
  31622. private _opacityTexture;
  31623. /**
  31624. * Define the transparency of the material from a texture.
  31625. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  31626. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  31627. */
  31628. opacityTexture: Nullable<BaseTexture>;
  31629. private _reflectionTexture;
  31630. /**
  31631. * Define the texture used to display the reflection.
  31632. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31633. */
  31634. reflectionTexture: Nullable<BaseTexture>;
  31635. private _emissiveTexture;
  31636. /**
  31637. * Define texture of the material as if self lit.
  31638. * This will be mixed in the final result even in the absence of light.
  31639. */
  31640. emissiveTexture: Nullable<BaseTexture>;
  31641. private _specularTexture;
  31642. /**
  31643. * Define how the color and intensity of the highlight given by the light in the material.
  31644. */
  31645. specularTexture: Nullable<BaseTexture>;
  31646. private _bumpTexture;
  31647. /**
  31648. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  31649. * 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.
  31650. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  31651. */
  31652. bumpTexture: Nullable<BaseTexture>;
  31653. private _lightmapTexture;
  31654. /**
  31655. * Complex lighting can be computationally expensive to compute at runtime.
  31656. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  31657. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  31658. */
  31659. lightmapTexture: Nullable<BaseTexture>;
  31660. private _refractionTexture;
  31661. /**
  31662. * Define the texture used to display the refraction.
  31663. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31664. */
  31665. refractionTexture: Nullable<BaseTexture>;
  31666. /**
  31667. * The color of the material lit by the environmental background lighting.
  31668. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  31669. */
  31670. ambientColor: Color3;
  31671. /**
  31672. * The basic color of the material as viewed under a light.
  31673. */
  31674. diffuseColor: Color3;
  31675. /**
  31676. * Define how the color and intensity of the highlight given by the light in the material.
  31677. */
  31678. specularColor: Color3;
  31679. /**
  31680. * Define the color of the material as if self lit.
  31681. * This will be mixed in the final result even in the absence of light.
  31682. */
  31683. emissiveColor: Color3;
  31684. /**
  31685. * Defines how sharp are the highlights in the material.
  31686. * The bigger the value the sharper giving a more glossy feeling to the result.
  31687. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  31688. */
  31689. specularPower: number;
  31690. private _useAlphaFromDiffuseTexture;
  31691. /**
  31692. * Does the transparency come from the diffuse texture alpha channel.
  31693. */
  31694. useAlphaFromDiffuseTexture: boolean;
  31695. private _useEmissiveAsIllumination;
  31696. /**
  31697. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  31698. */
  31699. useEmissiveAsIllumination: boolean;
  31700. private _linkEmissiveWithDiffuse;
  31701. /**
  31702. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  31703. * the emissive level when the final color is close to one.
  31704. */
  31705. linkEmissiveWithDiffuse: boolean;
  31706. private _useSpecularOverAlpha;
  31707. /**
  31708. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  31709. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  31710. */
  31711. useSpecularOverAlpha: boolean;
  31712. private _useReflectionOverAlpha;
  31713. /**
  31714. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  31715. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  31716. */
  31717. useReflectionOverAlpha: boolean;
  31718. private _disableLighting;
  31719. /**
  31720. * Does lights from the scene impacts this material.
  31721. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  31722. */
  31723. disableLighting: boolean;
  31724. private _useObjectSpaceNormalMap;
  31725. /**
  31726. * Allows using an object space normal map (instead of tangent space).
  31727. */
  31728. useObjectSpaceNormalMap: boolean;
  31729. private _useParallax;
  31730. /**
  31731. * Is parallax enabled or not.
  31732. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  31733. */
  31734. useParallax: boolean;
  31735. private _useParallaxOcclusion;
  31736. /**
  31737. * Is parallax occlusion enabled or not.
  31738. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  31739. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  31740. */
  31741. useParallaxOcclusion: boolean;
  31742. /**
  31743. * 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.
  31744. */
  31745. parallaxScaleBias: number;
  31746. private _roughness;
  31747. /**
  31748. * Helps to define how blurry the reflections should appears in the material.
  31749. */
  31750. roughness: number;
  31751. /**
  31752. * In case of refraction, define the value of the index of refraction.
  31753. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31754. */
  31755. indexOfRefraction: number;
  31756. /**
  31757. * Invert the refraction texture alongside the y axis.
  31758. * It can be useful with procedural textures or probe for instance.
  31759. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31760. */
  31761. invertRefractionY: boolean;
  31762. /**
  31763. * Defines the alpha limits in alpha test mode.
  31764. */
  31765. alphaCutOff: number;
  31766. private _useLightmapAsShadowmap;
  31767. /**
  31768. * In case of light mapping, define whether the map contains light or shadow informations.
  31769. */
  31770. useLightmapAsShadowmap: boolean;
  31771. private _diffuseFresnelParameters;
  31772. /**
  31773. * Define the diffuse fresnel parameters of the material.
  31774. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31775. */
  31776. diffuseFresnelParameters: FresnelParameters;
  31777. private _opacityFresnelParameters;
  31778. /**
  31779. * Define the opacity fresnel parameters of the material.
  31780. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31781. */
  31782. opacityFresnelParameters: FresnelParameters;
  31783. private _reflectionFresnelParameters;
  31784. /**
  31785. * Define the reflection fresnel parameters of the material.
  31786. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31787. */
  31788. reflectionFresnelParameters: FresnelParameters;
  31789. private _refractionFresnelParameters;
  31790. /**
  31791. * Define the refraction fresnel parameters of the material.
  31792. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31793. */
  31794. refractionFresnelParameters: FresnelParameters;
  31795. private _emissiveFresnelParameters;
  31796. /**
  31797. * Define the emissive fresnel parameters of the material.
  31798. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31799. */
  31800. emissiveFresnelParameters: FresnelParameters;
  31801. private _useReflectionFresnelFromSpecular;
  31802. /**
  31803. * If true automatically deducts the fresnels values from the material specularity.
  31804. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31805. */
  31806. useReflectionFresnelFromSpecular: boolean;
  31807. private _useGlossinessFromSpecularMapAlpha;
  31808. /**
  31809. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  31810. */
  31811. useGlossinessFromSpecularMapAlpha: boolean;
  31812. private _maxSimultaneousLights;
  31813. /**
  31814. * Defines the maximum number of lights that can be used in the material
  31815. */
  31816. maxSimultaneousLights: number;
  31817. private _invertNormalMapX;
  31818. /**
  31819. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  31820. */
  31821. invertNormalMapX: boolean;
  31822. private _invertNormalMapY;
  31823. /**
  31824. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  31825. */
  31826. invertNormalMapY: boolean;
  31827. private _twoSidedLighting;
  31828. /**
  31829. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  31830. */
  31831. twoSidedLighting: boolean;
  31832. /**
  31833. * Default configuration related to image processing available in the standard Material.
  31834. */
  31835. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31836. /**
  31837. * Gets the image processing configuration used either in this material.
  31838. */
  31839. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  31840. /**
  31841. * Sets the Default image processing configuration used either in the this material.
  31842. *
  31843. * If sets to null, the scene one is in use.
  31844. */
  31845. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  31846. /**
  31847. * Keep track of the image processing observer to allow dispose and replace.
  31848. */
  31849. private _imageProcessingObserver;
  31850. /**
  31851. * Attaches a new image processing configuration to the Standard Material.
  31852. * @param configuration
  31853. */
  31854. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  31855. /**
  31856. * Gets wether the color curves effect is enabled.
  31857. */
  31858. get cameraColorCurvesEnabled(): boolean;
  31859. /**
  31860. * Sets wether the color curves effect is enabled.
  31861. */
  31862. set cameraColorCurvesEnabled(value: boolean);
  31863. /**
  31864. * Gets wether the color grading effect is enabled.
  31865. */
  31866. get cameraColorGradingEnabled(): boolean;
  31867. /**
  31868. * Gets wether the color grading effect is enabled.
  31869. */
  31870. set cameraColorGradingEnabled(value: boolean);
  31871. /**
  31872. * Gets wether tonemapping is enabled or not.
  31873. */
  31874. get cameraToneMappingEnabled(): boolean;
  31875. /**
  31876. * Sets wether tonemapping is enabled or not
  31877. */
  31878. set cameraToneMappingEnabled(value: boolean);
  31879. /**
  31880. * The camera exposure used on this material.
  31881. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  31882. * This corresponds to a photographic exposure.
  31883. */
  31884. get cameraExposure(): number;
  31885. /**
  31886. * The camera exposure used on this material.
  31887. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  31888. * This corresponds to a photographic exposure.
  31889. */
  31890. set cameraExposure(value: number);
  31891. /**
  31892. * Gets The camera contrast used on this material.
  31893. */
  31894. get cameraContrast(): number;
  31895. /**
  31896. * Sets The camera contrast used on this material.
  31897. */
  31898. set cameraContrast(value: number);
  31899. /**
  31900. * Gets the Color Grading 2D Lookup Texture.
  31901. */
  31902. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  31903. /**
  31904. * Sets the Color Grading 2D Lookup Texture.
  31905. */
  31906. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  31907. /**
  31908. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  31909. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  31910. * 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;
  31911. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  31912. */
  31913. get cameraColorCurves(): Nullable<ColorCurves>;
  31914. /**
  31915. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  31916. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  31917. * 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;
  31918. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  31919. */
  31920. set cameraColorCurves(value: Nullable<ColorCurves>);
  31921. /**
  31922. * Can this material render to several textures at once
  31923. */
  31924. get canRenderToMRT(): boolean;
  31925. /**
  31926. * Defines the detail map parameters for the material.
  31927. */
  31928. readonly detailMap: DetailMapConfiguration;
  31929. protected _renderTargets: SmartArray<RenderTargetTexture>;
  31930. protected _worldViewProjectionMatrix: Matrix;
  31931. protected _globalAmbientColor: Color3;
  31932. protected _useLogarithmicDepth: boolean;
  31933. protected _rebuildInParallel: boolean;
  31934. /**
  31935. * Instantiates a new standard material.
  31936. * This is the default material used in Babylon. It is the best trade off between quality
  31937. * and performances.
  31938. * @see https://doc.babylonjs.com/babylon101/materials
  31939. * @param name Define the name of the material in the scene
  31940. * @param scene Define the scene the material belong to
  31941. */
  31942. constructor(name: string, scene: Scene);
  31943. /**
  31944. * Gets a boolean indicating that current material needs to register RTT
  31945. */
  31946. get hasRenderTargetTextures(): boolean;
  31947. /**
  31948. * Gets the current class name of the material e.g. "StandardMaterial"
  31949. * Mainly use in serialization.
  31950. * @returns the class name
  31951. */
  31952. getClassName(): string;
  31953. /**
  31954. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  31955. * You can try switching to logarithmic depth.
  31956. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  31957. */
  31958. get useLogarithmicDepth(): boolean;
  31959. set useLogarithmicDepth(value: boolean);
  31960. /**
  31961. * Specifies if the material will require alpha blending
  31962. * @returns a boolean specifying if alpha blending is needed
  31963. */
  31964. needAlphaBlending(): boolean;
  31965. /**
  31966. * Specifies if this material should be rendered in alpha test mode
  31967. * @returns a boolean specifying if an alpha test is needed.
  31968. */
  31969. needAlphaTesting(): boolean;
  31970. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  31971. /**
  31972. * Get the texture used for alpha test purpose.
  31973. * @returns the diffuse texture in case of the standard material.
  31974. */
  31975. getAlphaTestTexture(): Nullable<BaseTexture>;
  31976. /**
  31977. * Get if the submesh is ready to be used and all its information available.
  31978. * Child classes can use it to update shaders
  31979. * @param mesh defines the mesh to check
  31980. * @param subMesh defines which submesh to check
  31981. * @param useInstances specifies that instances should be used
  31982. * @returns a boolean indicating that the submesh is ready or not
  31983. */
  31984. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  31985. /**
  31986. * Builds the material UBO layouts.
  31987. * Used internally during the effect preparation.
  31988. */
  31989. buildUniformLayout(): void;
  31990. /**
  31991. * Unbinds the material from the mesh
  31992. */
  31993. unbind(): void;
  31994. /**
  31995. * Binds the submesh to this material by preparing the effect and shader to draw
  31996. * @param world defines the world transformation matrix
  31997. * @param mesh defines the mesh containing the submesh
  31998. * @param subMesh defines the submesh to bind the material to
  31999. */
  32000. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  32001. /**
  32002. * Get the list of animatables in the material.
  32003. * @returns the list of animatables object used in the material
  32004. */
  32005. getAnimatables(): IAnimatable[];
  32006. /**
  32007. * Gets the active textures from the material
  32008. * @returns an array of textures
  32009. */
  32010. getActiveTextures(): BaseTexture[];
  32011. /**
  32012. * Specifies if the material uses a texture
  32013. * @param texture defines the texture to check against the material
  32014. * @returns a boolean specifying if the material uses the texture
  32015. */
  32016. hasTexture(texture: BaseTexture): boolean;
  32017. /**
  32018. * Disposes the material
  32019. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  32020. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  32021. */
  32022. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  32023. /**
  32024. * Makes a duplicate of the material, and gives it a new name
  32025. * @param name defines the new name for the duplicated material
  32026. * @returns the cloned material
  32027. */
  32028. clone(name: string): StandardMaterial;
  32029. /**
  32030. * Serializes this material in a JSON representation
  32031. * @returns the serialized material object
  32032. */
  32033. serialize(): any;
  32034. /**
  32035. * Creates a standard material from parsed material data
  32036. * @param source defines the JSON representation of the material
  32037. * @param scene defines the hosting scene
  32038. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  32039. * @returns a new standard material
  32040. */
  32041. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  32042. /**
  32043. * Are diffuse textures enabled in the application.
  32044. */
  32045. static get DiffuseTextureEnabled(): boolean;
  32046. static set DiffuseTextureEnabled(value: boolean);
  32047. /**
  32048. * Are detail textures enabled in the application.
  32049. */
  32050. static get DetailTextureEnabled(): boolean;
  32051. static set DetailTextureEnabled(value: boolean);
  32052. /**
  32053. * Are ambient textures enabled in the application.
  32054. */
  32055. static get AmbientTextureEnabled(): boolean;
  32056. static set AmbientTextureEnabled(value: boolean);
  32057. /**
  32058. * Are opacity textures enabled in the application.
  32059. */
  32060. static get OpacityTextureEnabled(): boolean;
  32061. static set OpacityTextureEnabled(value: boolean);
  32062. /**
  32063. * Are reflection textures enabled in the application.
  32064. */
  32065. static get ReflectionTextureEnabled(): boolean;
  32066. static set ReflectionTextureEnabled(value: boolean);
  32067. /**
  32068. * Are emissive textures enabled in the application.
  32069. */
  32070. static get EmissiveTextureEnabled(): boolean;
  32071. static set EmissiveTextureEnabled(value: boolean);
  32072. /**
  32073. * Are specular textures enabled in the application.
  32074. */
  32075. static get SpecularTextureEnabled(): boolean;
  32076. static set SpecularTextureEnabled(value: boolean);
  32077. /**
  32078. * Are bump textures enabled in the application.
  32079. */
  32080. static get BumpTextureEnabled(): boolean;
  32081. static set BumpTextureEnabled(value: boolean);
  32082. /**
  32083. * Are lightmap textures enabled in the application.
  32084. */
  32085. static get LightmapTextureEnabled(): boolean;
  32086. static set LightmapTextureEnabled(value: boolean);
  32087. /**
  32088. * Are refraction textures enabled in the application.
  32089. */
  32090. static get RefractionTextureEnabled(): boolean;
  32091. static set RefractionTextureEnabled(value: boolean);
  32092. /**
  32093. * Are color grading textures enabled in the application.
  32094. */
  32095. static get ColorGradingTextureEnabled(): boolean;
  32096. static set ColorGradingTextureEnabled(value: boolean);
  32097. /**
  32098. * Are fresnels enabled in the application.
  32099. */
  32100. static get FresnelEnabled(): boolean;
  32101. static set FresnelEnabled(value: boolean);
  32102. }
  32103. }
  32104. declare module "babylonjs/Particles/solidParticleSystem" {
  32105. import { Nullable } from "babylonjs/types";
  32106. import { Mesh } from "babylonjs/Meshes/mesh";
  32107. import { Scene, IDisposable } from "babylonjs/scene";
  32108. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  32109. import { Material } from "babylonjs/Materials/material";
  32110. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  32111. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32112. /**
  32113. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  32114. *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.
  32115. * The SPS is also a particle system. It provides some methods to manage the particles.
  32116. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  32117. *
  32118. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  32119. */
  32120. export class SolidParticleSystem implements IDisposable {
  32121. /**
  32122. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  32123. * Example : var p = SPS.particles[i];
  32124. */
  32125. particles: SolidParticle[];
  32126. /**
  32127. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  32128. */
  32129. nbParticles: number;
  32130. /**
  32131. * If the particles must ever face the camera (default false). Useful for planar particles.
  32132. */
  32133. billboard: boolean;
  32134. /**
  32135. * Recompute normals when adding a shape
  32136. */
  32137. recomputeNormals: boolean;
  32138. /**
  32139. * This a counter ofr your own usage. It's not set by any SPS functions.
  32140. */
  32141. counter: number;
  32142. /**
  32143. * The SPS name. This name is also given to the underlying mesh.
  32144. */
  32145. name: string;
  32146. /**
  32147. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  32148. */
  32149. mesh: Mesh;
  32150. /**
  32151. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  32152. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  32153. */
  32154. vars: any;
  32155. /**
  32156. * This array is populated when the SPS is set as 'pickable'.
  32157. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  32158. * Each element of this array is an object `{idx: int, faceId: int}`.
  32159. * `idx` is the picked particle index in the `SPS.particles` array
  32160. * `faceId` is the picked face index counted within this particle.
  32161. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  32162. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  32163. * Use the method SPS.pickedParticle(pickingInfo) instead.
  32164. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  32165. */
  32166. pickedParticles: {
  32167. idx: number;
  32168. faceId: number;
  32169. }[];
  32170. /**
  32171. * This array is populated when the SPS is set as 'pickable'
  32172. * Each key of this array is a submesh index.
  32173. * Each element of this array is a second array defined like this :
  32174. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  32175. * Each element of this second array is an object `{idx: int, faceId: int}`.
  32176. * `idx` is the picked particle index in the `SPS.particles` array
  32177. * `faceId` is the picked face index counted within this particle.
  32178. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  32179. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  32180. */
  32181. pickedBySubMesh: {
  32182. idx: number;
  32183. faceId: number;
  32184. }[][];
  32185. /**
  32186. * This array is populated when `enableDepthSort` is set to true.
  32187. * Each element of this array is an instance of the class DepthSortedParticle.
  32188. */
  32189. depthSortedParticles: DepthSortedParticle[];
  32190. /**
  32191. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  32192. * @hidden
  32193. */
  32194. _bSphereOnly: boolean;
  32195. /**
  32196. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  32197. * @hidden
  32198. */
  32199. _bSphereRadiusFactor: number;
  32200. private _scene;
  32201. private _positions;
  32202. private _indices;
  32203. private _normals;
  32204. private _colors;
  32205. private _uvs;
  32206. private _indices32;
  32207. private _positions32;
  32208. private _normals32;
  32209. private _fixedNormal32;
  32210. private _colors32;
  32211. private _uvs32;
  32212. private _index;
  32213. private _updatable;
  32214. private _pickable;
  32215. private _isVisibilityBoxLocked;
  32216. private _alwaysVisible;
  32217. private _depthSort;
  32218. private _expandable;
  32219. private _shapeCounter;
  32220. private _copy;
  32221. private _color;
  32222. private _computeParticleColor;
  32223. private _computeParticleTexture;
  32224. private _computeParticleRotation;
  32225. private _computeParticleVertex;
  32226. private _computeBoundingBox;
  32227. private _depthSortParticles;
  32228. private _camera;
  32229. private _mustUnrotateFixedNormals;
  32230. private _particlesIntersect;
  32231. private _needs32Bits;
  32232. private _isNotBuilt;
  32233. private _lastParticleId;
  32234. private _idxOfId;
  32235. private _multimaterialEnabled;
  32236. private _useModelMaterial;
  32237. private _indicesByMaterial;
  32238. private _materialIndexes;
  32239. private _depthSortFunction;
  32240. private _materialSortFunction;
  32241. private _materials;
  32242. private _multimaterial;
  32243. private _materialIndexesById;
  32244. private _defaultMaterial;
  32245. private _autoUpdateSubMeshes;
  32246. private _tmpVertex;
  32247. /**
  32248. * Creates a SPS (Solid Particle System) object.
  32249. * @param name (String) is the SPS name, this will be the underlying mesh name.
  32250. * @param scene (Scene) is the scene in which the SPS is added.
  32251. * @param options defines the options of the sps e.g.
  32252. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  32253. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  32254. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  32255. * * 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.
  32256. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  32257. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  32258. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  32259. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  32260. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  32261. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  32262. */
  32263. constructor(name: string, scene: Scene, options?: {
  32264. updatable?: boolean;
  32265. isPickable?: boolean;
  32266. enableDepthSort?: boolean;
  32267. particleIntersection?: boolean;
  32268. boundingSphereOnly?: boolean;
  32269. bSphereRadiusFactor?: number;
  32270. expandable?: boolean;
  32271. useModelMaterial?: boolean;
  32272. enableMultiMaterial?: boolean;
  32273. });
  32274. /**
  32275. * Builds the SPS underlying mesh. Returns a standard Mesh.
  32276. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  32277. * @returns the created mesh
  32278. */
  32279. buildMesh(): Mesh;
  32280. /**
  32281. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  32282. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  32283. * Thus the particles generated from `digest()` have their property `position` set yet.
  32284. * @param mesh ( Mesh ) is the mesh to be digested
  32285. * @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
  32286. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  32287. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  32288. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  32289. * @returns the current SPS
  32290. */
  32291. digest(mesh: Mesh, options?: {
  32292. facetNb?: number;
  32293. number?: number;
  32294. delta?: number;
  32295. storage?: [];
  32296. }): SolidParticleSystem;
  32297. /**
  32298. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  32299. * @hidden
  32300. */
  32301. private _unrotateFixedNormals;
  32302. /**
  32303. * Resets the temporary working copy particle
  32304. * @hidden
  32305. */
  32306. private _resetCopy;
  32307. /**
  32308. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  32309. * @param p the current index in the positions array to be updated
  32310. * @param ind the current index in the indices array
  32311. * @param shape a Vector3 array, the shape geometry
  32312. * @param positions the positions array to be updated
  32313. * @param meshInd the shape indices array
  32314. * @param indices the indices array to be updated
  32315. * @param meshUV the shape uv array
  32316. * @param uvs the uv array to be updated
  32317. * @param meshCol the shape color array
  32318. * @param colors the color array to be updated
  32319. * @param meshNor the shape normals array
  32320. * @param normals the normals array to be updated
  32321. * @param idx the particle index
  32322. * @param idxInShape the particle index in its shape
  32323. * @param options the addShape() method passed options
  32324. * @model the particle model
  32325. * @hidden
  32326. */
  32327. private _meshBuilder;
  32328. /**
  32329. * Returns a shape Vector3 array from positions float array
  32330. * @param positions float array
  32331. * @returns a vector3 array
  32332. * @hidden
  32333. */
  32334. private _posToShape;
  32335. /**
  32336. * Returns a shapeUV array from a float uvs (array deep copy)
  32337. * @param uvs as a float array
  32338. * @returns a shapeUV array
  32339. * @hidden
  32340. */
  32341. private _uvsToShapeUV;
  32342. /**
  32343. * Adds a new particle object in the particles array
  32344. * @param idx particle index in particles array
  32345. * @param id particle id
  32346. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  32347. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  32348. * @param model particle ModelShape object
  32349. * @param shapeId model shape identifier
  32350. * @param idxInShape index of the particle in the current model
  32351. * @param bInfo model bounding info object
  32352. * @param storage target storage array, if any
  32353. * @hidden
  32354. */
  32355. private _addParticle;
  32356. /**
  32357. * Adds some particles to the SPS from the model shape. Returns the shape id.
  32358. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  32359. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  32360. * @param nb (positive integer) the number of particles to be created from this model
  32361. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  32362. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  32363. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  32364. * @returns the number of shapes in the system
  32365. */
  32366. addShape(mesh: Mesh, nb: number, options?: {
  32367. positionFunction?: any;
  32368. vertexFunction?: any;
  32369. storage?: [];
  32370. }): number;
  32371. /**
  32372. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  32373. * @hidden
  32374. */
  32375. private _rebuildParticle;
  32376. /**
  32377. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  32378. * @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.
  32379. * @returns the SPS.
  32380. */
  32381. rebuildMesh(reset?: boolean): SolidParticleSystem;
  32382. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  32383. * Returns an array with the removed particles.
  32384. * 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.
  32385. * The SPS can't be empty so at least one particle needs to remain in place.
  32386. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  32387. * @param start index of the first particle to remove
  32388. * @param end index of the last particle to remove (included)
  32389. * @returns an array populated with the removed particles
  32390. */
  32391. removeParticles(start: number, end: number): SolidParticle[];
  32392. /**
  32393. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  32394. * @param solidParticleArray an array populated with Solid Particles objects
  32395. * @returns the SPS
  32396. */
  32397. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  32398. /**
  32399. * Creates a new particle and modifies the SPS mesh geometry :
  32400. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  32401. * - calls _addParticle() to populate the particle array
  32402. * factorized code from addShape() and insertParticlesFromArray()
  32403. * @param idx particle index in the particles array
  32404. * @param i particle index in its shape
  32405. * @param modelShape particle ModelShape object
  32406. * @param shape shape vertex array
  32407. * @param meshInd shape indices array
  32408. * @param meshUV shape uv array
  32409. * @param meshCol shape color array
  32410. * @param meshNor shape normals array
  32411. * @param bbInfo shape bounding info
  32412. * @param storage target particle storage
  32413. * @options addShape() passed options
  32414. * @hidden
  32415. */
  32416. private _insertNewParticle;
  32417. /**
  32418. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  32419. * This method calls `updateParticle()` for each particle of the SPS.
  32420. * For an animated SPS, it is usually called within the render loop.
  32421. * 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.
  32422. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  32423. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  32424. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  32425. * @returns the SPS.
  32426. */
  32427. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  32428. /**
  32429. * Disposes the SPS.
  32430. */
  32431. dispose(): void;
  32432. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  32433. * idx is the particle index in the SPS
  32434. * faceId is the picked face index counted within this particle.
  32435. * Returns null if the pickInfo can't identify a picked particle.
  32436. * @param pickingInfo (PickingInfo object)
  32437. * @returns {idx: number, faceId: number} or null
  32438. */
  32439. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  32440. idx: number;
  32441. faceId: number;
  32442. }>;
  32443. /**
  32444. * Returns a SolidParticle object from its identifier : particle.id
  32445. * @param id (integer) the particle Id
  32446. * @returns the searched particle or null if not found in the SPS.
  32447. */
  32448. getParticleById(id: number): Nullable<SolidParticle>;
  32449. /**
  32450. * Returns a new array populated with the particles having the passed shapeId.
  32451. * @param shapeId (integer) the shape identifier
  32452. * @returns a new solid particle array
  32453. */
  32454. getParticlesByShapeId(shapeId: number): SolidParticle[];
  32455. /**
  32456. * Populates the passed array "ref" with the particles having the passed shapeId.
  32457. * @param shapeId the shape identifier
  32458. * @returns the SPS
  32459. * @param ref
  32460. */
  32461. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  32462. /**
  32463. * Computes the required SubMeshes according the materials assigned to the particles.
  32464. * @returns the solid particle system.
  32465. * Does nothing if called before the SPS mesh is built.
  32466. */
  32467. computeSubMeshes(): SolidParticleSystem;
  32468. /**
  32469. * Sorts the solid particles by material when MultiMaterial is enabled.
  32470. * Updates the indices32 array.
  32471. * Updates the indicesByMaterial array.
  32472. * Updates the mesh indices array.
  32473. * @returns the SPS
  32474. * @hidden
  32475. */
  32476. private _sortParticlesByMaterial;
  32477. /**
  32478. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  32479. * @hidden
  32480. */
  32481. private _setMaterialIndexesById;
  32482. /**
  32483. * Returns an array with unique values of Materials from the passed array
  32484. * @param array the material array to be checked and filtered
  32485. * @hidden
  32486. */
  32487. private _filterUniqueMaterialId;
  32488. /**
  32489. * Sets a new Standard Material as _defaultMaterial if not already set.
  32490. * @hidden
  32491. */
  32492. private _setDefaultMaterial;
  32493. /**
  32494. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  32495. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32496. * @returns the SPS.
  32497. */
  32498. refreshVisibleSize(): SolidParticleSystem;
  32499. /**
  32500. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  32501. * @param size the size (float) of the visibility box
  32502. * note : this doesn't lock the SPS mesh bounding box.
  32503. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32504. */
  32505. setVisibilityBox(size: number): void;
  32506. /**
  32507. * Gets whether the SPS as always visible or not
  32508. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32509. */
  32510. get isAlwaysVisible(): boolean;
  32511. /**
  32512. * Sets the SPS as always visible or not
  32513. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32514. */
  32515. set isAlwaysVisible(val: boolean);
  32516. /**
  32517. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32518. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32519. */
  32520. set isVisibilityBoxLocked(val: boolean);
  32521. /**
  32522. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32523. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32524. */
  32525. get isVisibilityBoxLocked(): boolean;
  32526. /**
  32527. * Tells to `setParticles()` to compute the particle rotations or not.
  32528. * Default value : true. The SPS is faster when it's set to false.
  32529. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32530. */
  32531. set computeParticleRotation(val: boolean);
  32532. /**
  32533. * Tells to `setParticles()` to compute the particle colors or not.
  32534. * Default value : true. The SPS is faster when it's set to false.
  32535. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32536. */
  32537. set computeParticleColor(val: boolean);
  32538. set computeParticleTexture(val: boolean);
  32539. /**
  32540. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  32541. * Default value : false. The SPS is faster when it's set to false.
  32542. * Note : the particle custom vertex positions aren't stored values.
  32543. */
  32544. set computeParticleVertex(val: boolean);
  32545. /**
  32546. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  32547. */
  32548. set computeBoundingBox(val: boolean);
  32549. /**
  32550. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  32551. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32552. * Default : `true`
  32553. */
  32554. set depthSortParticles(val: boolean);
  32555. /**
  32556. * Gets if `setParticles()` computes the particle rotations or not.
  32557. * Default value : true. The SPS is faster when it's set to false.
  32558. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32559. */
  32560. get computeParticleRotation(): boolean;
  32561. /**
  32562. * Gets if `setParticles()` computes the particle colors or not.
  32563. * Default value : true. The SPS is faster when it's set to false.
  32564. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32565. */
  32566. get computeParticleColor(): boolean;
  32567. /**
  32568. * Gets if `setParticles()` computes the particle textures or not.
  32569. * Default value : true. The SPS is faster when it's set to false.
  32570. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  32571. */
  32572. get computeParticleTexture(): boolean;
  32573. /**
  32574. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  32575. * Default value : false. The SPS is faster when it's set to false.
  32576. * Note : the particle custom vertex positions aren't stored values.
  32577. */
  32578. get computeParticleVertex(): boolean;
  32579. /**
  32580. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  32581. */
  32582. get computeBoundingBox(): boolean;
  32583. /**
  32584. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  32585. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32586. * Default : `true`
  32587. */
  32588. get depthSortParticles(): boolean;
  32589. /**
  32590. * Gets if the SPS is created as expandable at construction time.
  32591. * Default : `false`
  32592. */
  32593. get expandable(): boolean;
  32594. /**
  32595. * Gets if the SPS supports the Multi Materials
  32596. */
  32597. get multimaterialEnabled(): boolean;
  32598. /**
  32599. * Gets if the SPS uses the model materials for its own multimaterial.
  32600. */
  32601. get useModelMaterial(): boolean;
  32602. /**
  32603. * The SPS used material array.
  32604. */
  32605. get materials(): Material[];
  32606. /**
  32607. * Sets the SPS MultiMaterial from the passed materials.
  32608. * Note : the passed array is internally copied and not used then by reference.
  32609. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  32610. */
  32611. setMultiMaterial(materials: Material[]): void;
  32612. /**
  32613. * The SPS computed multimaterial object
  32614. */
  32615. get multimaterial(): MultiMaterial;
  32616. set multimaterial(mm: MultiMaterial);
  32617. /**
  32618. * If the subMeshes must be updated on the next call to setParticles()
  32619. */
  32620. get autoUpdateSubMeshes(): boolean;
  32621. set autoUpdateSubMeshes(val: boolean);
  32622. /**
  32623. * This function does nothing. It may be overwritten to set all the particle first values.
  32624. * The SPS doesn't call this function, you may have to call it by your own.
  32625. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32626. */
  32627. initParticles(): void;
  32628. /**
  32629. * This function does nothing. It may be overwritten to recycle a particle.
  32630. * The SPS doesn't call this function, you may have to call it by your own.
  32631. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32632. * @param particle The particle to recycle
  32633. * @returns the recycled particle
  32634. */
  32635. recycleParticle(particle: SolidParticle): SolidParticle;
  32636. /**
  32637. * Updates a particle : this function should be overwritten by the user.
  32638. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  32639. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32640. * @example : just set a particle position or velocity and recycle conditions
  32641. * @param particle The particle to update
  32642. * @returns the updated particle
  32643. */
  32644. updateParticle(particle: SolidParticle): SolidParticle;
  32645. /**
  32646. * Updates a vertex of a particle : it can be overwritten by the user.
  32647. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  32648. * @param particle the current particle
  32649. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  32650. * @param pt the index of the current vertex in the particle shape
  32651. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  32652. * @example : just set a vertex particle position or color
  32653. * @returns the sps
  32654. */
  32655. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  32656. /**
  32657. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  32658. * This does nothing and may be overwritten by the user.
  32659. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32660. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32661. * @param update the boolean update value actually passed to setParticles()
  32662. */
  32663. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32664. /**
  32665. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  32666. * This will be passed three parameters.
  32667. * This does nothing and may be overwritten by the user.
  32668. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32669. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32670. * @param update the boolean update value actually passed to setParticles()
  32671. */
  32672. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32673. }
  32674. }
  32675. declare module "babylonjs/Particles/solidParticle" {
  32676. import { Nullable } from "babylonjs/types";
  32677. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  32678. import { Color4 } from "babylonjs/Maths/math.color";
  32679. import { Mesh } from "babylonjs/Meshes/mesh";
  32680. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  32681. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  32682. import { Plane } from "babylonjs/Maths/math.plane";
  32683. import { Material } from "babylonjs/Materials/material";
  32684. /**
  32685. * Represents one particle of a solid particle system.
  32686. */
  32687. export class SolidParticle {
  32688. /**
  32689. * particle global index
  32690. */
  32691. idx: number;
  32692. /**
  32693. * particle identifier
  32694. */
  32695. id: number;
  32696. /**
  32697. * The color of the particle
  32698. */
  32699. color: Nullable<Color4>;
  32700. /**
  32701. * The world space position of the particle.
  32702. */
  32703. position: Vector3;
  32704. /**
  32705. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  32706. */
  32707. rotation: Vector3;
  32708. /**
  32709. * The world space rotation quaternion of the particle.
  32710. */
  32711. rotationQuaternion: Nullable<Quaternion>;
  32712. /**
  32713. * The scaling of the particle.
  32714. */
  32715. scaling: Vector3;
  32716. /**
  32717. * The uvs of the particle.
  32718. */
  32719. uvs: Vector4;
  32720. /**
  32721. * The current speed of the particle.
  32722. */
  32723. velocity: Vector3;
  32724. /**
  32725. * The pivot point in the particle local space.
  32726. */
  32727. pivot: Vector3;
  32728. /**
  32729. * Must the particle be translated from its pivot point in its local space ?
  32730. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  32731. * Default : false
  32732. */
  32733. translateFromPivot: boolean;
  32734. /**
  32735. * Is the particle active or not ?
  32736. */
  32737. alive: boolean;
  32738. /**
  32739. * Is the particle visible or not ?
  32740. */
  32741. isVisible: boolean;
  32742. /**
  32743. * Index of this particle in the global "positions" array (Internal use)
  32744. * @hidden
  32745. */
  32746. _pos: number;
  32747. /**
  32748. * @hidden Index of this particle in the global "indices" array (Internal use)
  32749. */
  32750. _ind: number;
  32751. /**
  32752. * @hidden ModelShape of this particle (Internal use)
  32753. */
  32754. _model: ModelShape;
  32755. /**
  32756. * ModelShape id of this particle
  32757. */
  32758. shapeId: number;
  32759. /**
  32760. * Index of the particle in its shape id
  32761. */
  32762. idxInShape: number;
  32763. /**
  32764. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  32765. */
  32766. _modelBoundingInfo: BoundingInfo;
  32767. /**
  32768. * @hidden Particle BoundingInfo object (Internal use)
  32769. */
  32770. _boundingInfo: BoundingInfo;
  32771. /**
  32772. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  32773. */
  32774. _sps: SolidParticleSystem;
  32775. /**
  32776. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  32777. */
  32778. _stillInvisible: boolean;
  32779. /**
  32780. * @hidden Last computed particle rotation matrix
  32781. */
  32782. _rotationMatrix: number[];
  32783. /**
  32784. * Parent particle Id, if any.
  32785. * Default null.
  32786. */
  32787. parentId: Nullable<number>;
  32788. /**
  32789. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  32790. */
  32791. materialIndex: Nullable<number>;
  32792. /**
  32793. * Custom object or properties.
  32794. */
  32795. props: Nullable<any>;
  32796. /**
  32797. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  32798. * The possible values are :
  32799. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  32800. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32801. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  32802. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  32803. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32804. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  32805. * */
  32806. cullingStrategy: number;
  32807. /**
  32808. * @hidden Internal global position in the SPS.
  32809. */
  32810. _globalPosition: Vector3;
  32811. /**
  32812. * Creates a Solid Particle object.
  32813. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  32814. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  32815. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  32816. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  32817. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  32818. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  32819. * @param shapeId (integer) is the model shape identifier in the SPS.
  32820. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  32821. * @param sps defines the sps it is associated to
  32822. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  32823. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  32824. */
  32825. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  32826. /**
  32827. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  32828. * @param target the particle target
  32829. * @returns the current particle
  32830. */
  32831. copyToRef(target: SolidParticle): SolidParticle;
  32832. /**
  32833. * Legacy support, changed scale to scaling
  32834. */
  32835. get scale(): Vector3;
  32836. /**
  32837. * Legacy support, changed scale to scaling
  32838. */
  32839. set scale(scale: Vector3);
  32840. /**
  32841. * Legacy support, changed quaternion to rotationQuaternion
  32842. */
  32843. get quaternion(): Nullable<Quaternion>;
  32844. /**
  32845. * Legacy support, changed quaternion to rotationQuaternion
  32846. */
  32847. set quaternion(q: Nullable<Quaternion>);
  32848. /**
  32849. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  32850. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  32851. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  32852. * @returns true if it intersects
  32853. */
  32854. intersectsMesh(target: Mesh | SolidParticle): boolean;
  32855. /**
  32856. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  32857. * A particle is in the frustum if its bounding box intersects the frustum
  32858. * @param frustumPlanes defines the frustum to test
  32859. * @returns true if the particle is in the frustum planes
  32860. */
  32861. isInFrustum(frustumPlanes: Plane[]): boolean;
  32862. /**
  32863. * get the rotation matrix of the particle
  32864. * @hidden
  32865. */
  32866. getRotationMatrix(m: Matrix): void;
  32867. }
  32868. /**
  32869. * Represents the shape of the model used by one particle of a solid particle system.
  32870. * SPS internal tool, don't use it manually.
  32871. */
  32872. export class ModelShape {
  32873. /**
  32874. * The shape id
  32875. * @hidden
  32876. */
  32877. shapeID: number;
  32878. /**
  32879. * flat array of model positions (internal use)
  32880. * @hidden
  32881. */
  32882. _shape: Vector3[];
  32883. /**
  32884. * flat array of model UVs (internal use)
  32885. * @hidden
  32886. */
  32887. _shapeUV: number[];
  32888. /**
  32889. * color array of the model
  32890. * @hidden
  32891. */
  32892. _shapeColors: number[];
  32893. /**
  32894. * indices array of the model
  32895. * @hidden
  32896. */
  32897. _indices: number[];
  32898. /**
  32899. * normals array of the model
  32900. * @hidden
  32901. */
  32902. _normals: number[];
  32903. /**
  32904. * length of the shape in the model indices array (internal use)
  32905. * @hidden
  32906. */
  32907. _indicesLength: number;
  32908. /**
  32909. * Custom position function (internal use)
  32910. * @hidden
  32911. */
  32912. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  32913. /**
  32914. * Custom vertex function (internal use)
  32915. * @hidden
  32916. */
  32917. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  32918. /**
  32919. * Model material (internal use)
  32920. * @hidden
  32921. */
  32922. _material: Nullable<Material>;
  32923. /**
  32924. * 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.
  32925. * SPS internal tool, don't use it manually.
  32926. * @hidden
  32927. */
  32928. 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>);
  32929. }
  32930. /**
  32931. * Represents a Depth Sorted Particle in the solid particle system.
  32932. * @hidden
  32933. */
  32934. export class DepthSortedParticle {
  32935. /**
  32936. * Particle index
  32937. */
  32938. idx: number;
  32939. /**
  32940. * Index of the particle in the "indices" array
  32941. */
  32942. ind: number;
  32943. /**
  32944. * Length of the particle shape in the "indices" array
  32945. */
  32946. indicesLength: number;
  32947. /**
  32948. * Squared distance from the particle to the camera
  32949. */
  32950. sqDistance: number;
  32951. /**
  32952. * Material index when used with MultiMaterials
  32953. */
  32954. materialIndex: number;
  32955. /**
  32956. * Creates a new sorted particle
  32957. * @param materialIndex
  32958. */
  32959. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  32960. }
  32961. /**
  32962. * Represents a solid particle vertex
  32963. */
  32964. export class SolidParticleVertex {
  32965. /**
  32966. * Vertex position
  32967. */
  32968. position: Vector3;
  32969. /**
  32970. * Vertex color
  32971. */
  32972. color: Color4;
  32973. /**
  32974. * Vertex UV
  32975. */
  32976. uv: Vector2;
  32977. /**
  32978. * Creates a new solid particle vertex
  32979. */
  32980. constructor();
  32981. /** Vertex x coordinate */
  32982. get x(): number;
  32983. set x(val: number);
  32984. /** Vertex y coordinate */
  32985. get y(): number;
  32986. set y(val: number);
  32987. /** Vertex z coordinate */
  32988. get z(): number;
  32989. set z(val: number);
  32990. }
  32991. }
  32992. declare module "babylonjs/Collisions/meshCollisionData" {
  32993. import { Collider } from "babylonjs/Collisions/collider";
  32994. import { Vector3 } from "babylonjs/Maths/math.vector";
  32995. import { Nullable } from "babylonjs/types";
  32996. import { Observer } from "babylonjs/Misc/observable";
  32997. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32998. /**
  32999. * @hidden
  33000. */
  33001. export class _MeshCollisionData {
  33002. _checkCollisions: boolean;
  33003. _collisionMask: number;
  33004. _collisionGroup: number;
  33005. _surroundingMeshes: Nullable<AbstractMesh[]>;
  33006. _collider: Nullable<Collider>;
  33007. _oldPositionForCollisions: Vector3;
  33008. _diffPositionForCollisions: Vector3;
  33009. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  33010. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  33011. }
  33012. }
  33013. declare module "babylonjs/Meshes/abstractMesh" {
  33014. import { Observable } from "babylonjs/Misc/observable";
  33015. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  33016. import { Camera } from "babylonjs/Cameras/camera";
  33017. import { Scene, IDisposable } from "babylonjs/scene";
  33018. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  33019. import { Node } from "babylonjs/node";
  33020. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  33021. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33022. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33023. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33024. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  33025. import { Material } from "babylonjs/Materials/material";
  33026. import { Light } from "babylonjs/Lights/light";
  33027. import { Skeleton } from "babylonjs/Bones/skeleton";
  33028. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  33029. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  33030. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33031. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  33032. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  33033. import { Plane } from "babylonjs/Maths/math.plane";
  33034. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33035. import { Ray } from "babylonjs/Culling/ray";
  33036. import { Collider } from "babylonjs/Collisions/collider";
  33037. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33038. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  33039. /** @hidden */
  33040. class _FacetDataStorage {
  33041. facetPositions: Vector3[];
  33042. facetNormals: Vector3[];
  33043. facetPartitioning: number[][];
  33044. facetNb: number;
  33045. partitioningSubdivisions: number;
  33046. partitioningBBoxRatio: number;
  33047. facetDataEnabled: boolean;
  33048. facetParameters: any;
  33049. bbSize: Vector3;
  33050. subDiv: {
  33051. max: number;
  33052. X: number;
  33053. Y: number;
  33054. Z: number;
  33055. };
  33056. facetDepthSort: boolean;
  33057. facetDepthSortEnabled: boolean;
  33058. depthSortedIndices: IndicesArray;
  33059. depthSortedFacets: {
  33060. ind: number;
  33061. sqDistance: number;
  33062. }[];
  33063. facetDepthSortFunction: (f1: {
  33064. ind: number;
  33065. sqDistance: number;
  33066. }, f2: {
  33067. ind: number;
  33068. sqDistance: number;
  33069. }) => number;
  33070. facetDepthSortFrom: Vector3;
  33071. facetDepthSortOrigin: Vector3;
  33072. invertedMatrix: Matrix;
  33073. }
  33074. /**
  33075. * @hidden
  33076. **/
  33077. class _InternalAbstractMeshDataInfo {
  33078. _hasVertexAlpha: boolean;
  33079. _useVertexColors: boolean;
  33080. _numBoneInfluencers: number;
  33081. _applyFog: boolean;
  33082. _receiveShadows: boolean;
  33083. _facetData: _FacetDataStorage;
  33084. _visibility: number;
  33085. _skeleton: Nullable<Skeleton>;
  33086. _layerMask: number;
  33087. _computeBonesUsingShaders: boolean;
  33088. _isActive: boolean;
  33089. _onlyForInstances: boolean;
  33090. _isActiveIntermediate: boolean;
  33091. _onlyForInstancesIntermediate: boolean;
  33092. _actAsRegularMesh: boolean;
  33093. }
  33094. /**
  33095. * Class used to store all common mesh properties
  33096. */
  33097. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  33098. /** No occlusion */
  33099. static OCCLUSION_TYPE_NONE: number;
  33100. /** Occlusion set to optimisitic */
  33101. static OCCLUSION_TYPE_OPTIMISTIC: number;
  33102. /** Occlusion set to strict */
  33103. static OCCLUSION_TYPE_STRICT: number;
  33104. /** Use an accurante occlusion algorithm */
  33105. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  33106. /** Use a conservative occlusion algorithm */
  33107. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  33108. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  33109. * Test order :
  33110. * Is the bounding sphere outside the frustum ?
  33111. * If not, are the bounding box vertices outside the frustum ?
  33112. * It not, then the cullable object is in the frustum.
  33113. */
  33114. static readonly CULLINGSTRATEGY_STANDARD: number;
  33115. /** Culling strategy : Bounding Sphere Only.
  33116. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  33117. * It's also less accurate than the standard because some not visible objects can still be selected.
  33118. * Test : is the bounding sphere outside the frustum ?
  33119. * If not, then the cullable object is in the frustum.
  33120. */
  33121. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  33122. /** Culling strategy : Optimistic Inclusion.
  33123. * This in an inclusion test first, then the standard exclusion test.
  33124. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  33125. * 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.
  33126. * Anyway, it's as accurate as the standard strategy.
  33127. * Test :
  33128. * Is the cullable object bounding sphere center in the frustum ?
  33129. * If not, apply the default culling strategy.
  33130. */
  33131. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  33132. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  33133. * This in an inclusion test first, then the bounding sphere only exclusion test.
  33134. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  33135. * 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.
  33136. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  33137. * Test :
  33138. * Is the cullable object bounding sphere center in the frustum ?
  33139. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  33140. */
  33141. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  33142. /**
  33143. * No billboard
  33144. */
  33145. static get BILLBOARDMODE_NONE(): number;
  33146. /** Billboard on X axis */
  33147. static get BILLBOARDMODE_X(): number;
  33148. /** Billboard on Y axis */
  33149. static get BILLBOARDMODE_Y(): number;
  33150. /** Billboard on Z axis */
  33151. static get BILLBOARDMODE_Z(): number;
  33152. /** Billboard on all axes */
  33153. static get BILLBOARDMODE_ALL(): number;
  33154. /** Billboard on using position instead of orientation */
  33155. static get BILLBOARDMODE_USE_POSITION(): number;
  33156. /** @hidden */
  33157. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  33158. /**
  33159. * The culling strategy to use to check whether the mesh must be rendered or not.
  33160. * This value can be changed at any time and will be used on the next render mesh selection.
  33161. * The possible values are :
  33162. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  33163. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  33164. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  33165. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  33166. * Please read each static variable documentation to get details about the culling process.
  33167. * */
  33168. cullingStrategy: number;
  33169. /**
  33170. * Gets the number of facets in the mesh
  33171. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  33172. */
  33173. get facetNb(): number;
  33174. /**
  33175. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  33176. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  33177. */
  33178. get partitioningSubdivisions(): number;
  33179. set partitioningSubdivisions(nb: number);
  33180. /**
  33181. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  33182. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  33183. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  33184. */
  33185. get partitioningBBoxRatio(): number;
  33186. set partitioningBBoxRatio(ratio: number);
  33187. /**
  33188. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  33189. * Works only for updatable meshes.
  33190. * Doesn't work with multi-materials
  33191. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  33192. */
  33193. get mustDepthSortFacets(): boolean;
  33194. set mustDepthSortFacets(sort: boolean);
  33195. /**
  33196. * The location (Vector3) where the facet depth sort must be computed from.
  33197. * By default, the active camera position.
  33198. * Used only when facet depth sort is enabled
  33199. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  33200. */
  33201. get facetDepthSortFrom(): Vector3;
  33202. set facetDepthSortFrom(location: Vector3);
  33203. /**
  33204. * gets a boolean indicating if facetData is enabled
  33205. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  33206. */
  33207. get isFacetDataEnabled(): boolean;
  33208. /** @hidden */
  33209. _updateNonUniformScalingState(value: boolean): boolean;
  33210. /**
  33211. * An event triggered when this mesh collides with another one
  33212. */
  33213. onCollideObservable: Observable<AbstractMesh>;
  33214. /** Set a function to call when this mesh collides with another one */
  33215. set onCollide(callback: () => void);
  33216. /**
  33217. * An event triggered when the collision's position changes
  33218. */
  33219. onCollisionPositionChangeObservable: Observable<Vector3>;
  33220. /** Set a function to call when the collision's position changes */
  33221. set onCollisionPositionChange(callback: () => void);
  33222. /**
  33223. * An event triggered when material is changed
  33224. */
  33225. onMaterialChangedObservable: Observable<AbstractMesh>;
  33226. /**
  33227. * Gets or sets the orientation for POV movement & rotation
  33228. */
  33229. definedFacingForward: boolean;
  33230. /** @hidden */
  33231. _occlusionQuery: Nullable<WebGLQuery>;
  33232. /** @hidden */
  33233. _renderingGroup: Nullable<RenderingGroup>;
  33234. /**
  33235. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  33236. */
  33237. get visibility(): number;
  33238. /**
  33239. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  33240. */
  33241. set visibility(value: number);
  33242. /** Gets or sets the alpha index used to sort transparent meshes
  33243. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  33244. */
  33245. alphaIndex: number;
  33246. /**
  33247. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  33248. */
  33249. isVisible: boolean;
  33250. /**
  33251. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  33252. */
  33253. isPickable: boolean;
  33254. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  33255. showSubMeshesBoundingBox: boolean;
  33256. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  33257. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  33258. */
  33259. isBlocker: boolean;
  33260. /**
  33261. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  33262. */
  33263. enablePointerMoveEvents: boolean;
  33264. /**
  33265. * Specifies the rendering group id for this mesh (0 by default)
  33266. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  33267. */
  33268. renderingGroupId: number;
  33269. private _material;
  33270. /** Gets or sets current material */
  33271. get material(): Nullable<Material>;
  33272. set material(value: Nullable<Material>);
  33273. /**
  33274. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  33275. * @see https://doc.babylonjs.com/babylon101/shadows
  33276. */
  33277. get receiveShadows(): boolean;
  33278. set receiveShadows(value: boolean);
  33279. /** Defines color to use when rendering outline */
  33280. outlineColor: Color3;
  33281. /** Define width to use when rendering outline */
  33282. outlineWidth: number;
  33283. /** Defines color to use when rendering overlay */
  33284. overlayColor: Color3;
  33285. /** Defines alpha to use when rendering overlay */
  33286. overlayAlpha: number;
  33287. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  33288. get hasVertexAlpha(): boolean;
  33289. set hasVertexAlpha(value: boolean);
  33290. /** 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) */
  33291. get useVertexColors(): boolean;
  33292. set useVertexColors(value: boolean);
  33293. /**
  33294. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  33295. */
  33296. get computeBonesUsingShaders(): boolean;
  33297. set computeBonesUsingShaders(value: boolean);
  33298. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  33299. get numBoneInfluencers(): number;
  33300. set numBoneInfluencers(value: number);
  33301. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  33302. get applyFog(): boolean;
  33303. set applyFog(value: boolean);
  33304. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  33305. useOctreeForRenderingSelection: boolean;
  33306. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  33307. useOctreeForPicking: boolean;
  33308. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  33309. useOctreeForCollisions: boolean;
  33310. /**
  33311. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  33312. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  33313. */
  33314. get layerMask(): number;
  33315. set layerMask(value: number);
  33316. /**
  33317. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  33318. */
  33319. alwaysSelectAsActiveMesh: boolean;
  33320. /**
  33321. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  33322. */
  33323. doNotSyncBoundingInfo: boolean;
  33324. /**
  33325. * Gets or sets the current action manager
  33326. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  33327. */
  33328. actionManager: Nullable<AbstractActionManager>;
  33329. private _meshCollisionData;
  33330. /**
  33331. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  33332. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33333. */
  33334. ellipsoid: Vector3;
  33335. /**
  33336. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  33337. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33338. */
  33339. ellipsoidOffset: Vector3;
  33340. /**
  33341. * Gets or sets a collision mask used to mask collisions (default is -1).
  33342. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  33343. */
  33344. get collisionMask(): number;
  33345. set collisionMask(mask: number);
  33346. /**
  33347. * Gets or sets the current collision group mask (-1 by default).
  33348. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  33349. */
  33350. get collisionGroup(): number;
  33351. set collisionGroup(mask: number);
  33352. /**
  33353. * Gets or sets current surrounding meshes (null by default).
  33354. *
  33355. * By default collision detection is tested against every mesh in the scene.
  33356. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  33357. * meshes will be tested for the collision.
  33358. *
  33359. * Note: if set to an empty array no collision will happen when this mesh is moved.
  33360. */
  33361. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  33362. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  33363. /**
  33364. * Defines edge width used when edgesRenderer is enabled
  33365. * @see https://www.babylonjs-playground.com/#10OJSG#13
  33366. */
  33367. edgesWidth: number;
  33368. /**
  33369. * Defines edge color used when edgesRenderer is enabled
  33370. * @see https://www.babylonjs-playground.com/#10OJSG#13
  33371. */
  33372. edgesColor: Color4;
  33373. /** @hidden */
  33374. _edgesRenderer: Nullable<IEdgesRenderer>;
  33375. /** @hidden */
  33376. _masterMesh: Nullable<AbstractMesh>;
  33377. /** @hidden */
  33378. _boundingInfo: Nullable<BoundingInfo>;
  33379. /** @hidden */
  33380. _renderId: number;
  33381. /**
  33382. * Gets or sets the list of subMeshes
  33383. * @see https://doc.babylonjs.com/how_to/multi_materials
  33384. */
  33385. subMeshes: SubMesh[];
  33386. /** @hidden */
  33387. _intersectionsInProgress: AbstractMesh[];
  33388. /** @hidden */
  33389. _unIndexed: boolean;
  33390. /** @hidden */
  33391. _lightSources: Light[];
  33392. /** Gets the list of lights affecting that mesh */
  33393. get lightSources(): Light[];
  33394. /** @hidden */
  33395. get _positions(): Nullable<Vector3[]>;
  33396. /** @hidden */
  33397. _waitingData: {
  33398. lods: Nullable<any>;
  33399. actions: Nullable<any>;
  33400. freezeWorldMatrix: Nullable<boolean>;
  33401. };
  33402. /** @hidden */
  33403. _bonesTransformMatrices: Nullable<Float32Array>;
  33404. /** @hidden */
  33405. _transformMatrixTexture: Nullable<RawTexture>;
  33406. /**
  33407. * Gets or sets a skeleton to apply skining transformations
  33408. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33409. */
  33410. set skeleton(value: Nullable<Skeleton>);
  33411. get skeleton(): Nullable<Skeleton>;
  33412. /**
  33413. * An event triggered when the mesh is rebuilt.
  33414. */
  33415. onRebuildObservable: Observable<AbstractMesh>;
  33416. /**
  33417. * Creates a new AbstractMesh
  33418. * @param name defines the name of the mesh
  33419. * @param scene defines the hosting scene
  33420. */
  33421. constructor(name: string, scene?: Nullable<Scene>);
  33422. /**
  33423. * Returns the string "AbstractMesh"
  33424. * @returns "AbstractMesh"
  33425. */
  33426. getClassName(): string;
  33427. /**
  33428. * Gets a string representation of the current mesh
  33429. * @param fullDetails defines a boolean indicating if full details must be included
  33430. * @returns a string representation of the current mesh
  33431. */
  33432. toString(fullDetails?: boolean): string;
  33433. /**
  33434. * @hidden
  33435. */
  33436. protected _getEffectiveParent(): Nullable<Node>;
  33437. /** @hidden */
  33438. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  33439. /** @hidden */
  33440. _rebuild(): void;
  33441. /** @hidden */
  33442. _resyncLightSources(): void;
  33443. /** @hidden */
  33444. _resyncLightSource(light: Light): void;
  33445. /** @hidden */
  33446. _unBindEffect(): void;
  33447. /** @hidden */
  33448. _removeLightSource(light: Light, dispose: boolean): void;
  33449. private _markSubMeshesAsDirty;
  33450. /** @hidden */
  33451. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  33452. /** @hidden */
  33453. _markSubMeshesAsAttributesDirty(): void;
  33454. /** @hidden */
  33455. _markSubMeshesAsMiscDirty(): void;
  33456. /**
  33457. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  33458. */
  33459. get scaling(): Vector3;
  33460. set scaling(newScaling: Vector3);
  33461. /**
  33462. * Returns true if the mesh is blocked. Implemented by child classes
  33463. */
  33464. get isBlocked(): boolean;
  33465. /**
  33466. * Returns the mesh itself by default. Implemented by child classes
  33467. * @param camera defines the camera to use to pick the right LOD level
  33468. * @returns the currentAbstractMesh
  33469. */
  33470. getLOD(camera: Camera): Nullable<AbstractMesh>;
  33471. /**
  33472. * Returns 0 by default. Implemented by child classes
  33473. * @returns an integer
  33474. */
  33475. getTotalVertices(): number;
  33476. /**
  33477. * Returns a positive integer : the total number of indices in this mesh geometry.
  33478. * @returns the numner of indices or zero if the mesh has no geometry.
  33479. */
  33480. getTotalIndices(): number;
  33481. /**
  33482. * Returns null by default. Implemented by child classes
  33483. * @returns null
  33484. */
  33485. getIndices(): Nullable<IndicesArray>;
  33486. /**
  33487. * Returns the array of the requested vertex data kind. Implemented by child classes
  33488. * @param kind defines the vertex data kind to use
  33489. * @returns null
  33490. */
  33491. getVerticesData(kind: string): Nullable<FloatArray>;
  33492. /**
  33493. * Sets the vertex data of the mesh geometry for the requested `kind`.
  33494. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  33495. * Note that a new underlying VertexBuffer object is created each call.
  33496. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  33497. * @param kind defines vertex data kind:
  33498. * * VertexBuffer.PositionKind
  33499. * * VertexBuffer.UVKind
  33500. * * VertexBuffer.UV2Kind
  33501. * * VertexBuffer.UV3Kind
  33502. * * VertexBuffer.UV4Kind
  33503. * * VertexBuffer.UV5Kind
  33504. * * VertexBuffer.UV6Kind
  33505. * * VertexBuffer.ColorKind
  33506. * * VertexBuffer.MatricesIndicesKind
  33507. * * VertexBuffer.MatricesIndicesExtraKind
  33508. * * VertexBuffer.MatricesWeightsKind
  33509. * * VertexBuffer.MatricesWeightsExtraKind
  33510. * @param data defines the data source
  33511. * @param updatable defines if the data must be flagged as updatable (or static)
  33512. * @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
  33513. * @returns the current mesh
  33514. */
  33515. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  33516. /**
  33517. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  33518. * If the mesh has no geometry, it is simply returned as it is.
  33519. * @param kind defines vertex data kind:
  33520. * * VertexBuffer.PositionKind
  33521. * * VertexBuffer.UVKind
  33522. * * VertexBuffer.UV2Kind
  33523. * * VertexBuffer.UV3Kind
  33524. * * VertexBuffer.UV4Kind
  33525. * * VertexBuffer.UV5Kind
  33526. * * VertexBuffer.UV6Kind
  33527. * * VertexBuffer.ColorKind
  33528. * * VertexBuffer.MatricesIndicesKind
  33529. * * VertexBuffer.MatricesIndicesExtraKind
  33530. * * VertexBuffer.MatricesWeightsKind
  33531. * * VertexBuffer.MatricesWeightsExtraKind
  33532. * @param data defines the data source
  33533. * @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
  33534. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  33535. * @returns the current mesh
  33536. */
  33537. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  33538. /**
  33539. * Sets the mesh indices,
  33540. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  33541. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  33542. * @param totalVertices Defines the total number of vertices
  33543. * @returns the current mesh
  33544. */
  33545. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  33546. /**
  33547. * Gets a boolean indicating if specific vertex data is present
  33548. * @param kind defines the vertex data kind to use
  33549. * @returns true is data kind is present
  33550. */
  33551. isVerticesDataPresent(kind: string): boolean;
  33552. /**
  33553. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  33554. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  33555. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  33556. * @returns a BoundingInfo
  33557. */
  33558. getBoundingInfo(): BoundingInfo;
  33559. /**
  33560. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  33561. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  33562. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  33563. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  33564. * @returns the current mesh
  33565. */
  33566. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  33567. /**
  33568. * Overwrite the current bounding info
  33569. * @param boundingInfo defines the new bounding info
  33570. * @returns the current mesh
  33571. */
  33572. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  33573. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  33574. get useBones(): boolean;
  33575. /** @hidden */
  33576. _preActivate(): void;
  33577. /** @hidden */
  33578. _preActivateForIntermediateRendering(renderId: number): void;
  33579. /** @hidden */
  33580. _activate(renderId: number, intermediateRendering: boolean): boolean;
  33581. /** @hidden */
  33582. _postActivate(): void;
  33583. /** @hidden */
  33584. _freeze(): void;
  33585. /** @hidden */
  33586. _unFreeze(): void;
  33587. /**
  33588. * Gets the current world matrix
  33589. * @returns a Matrix
  33590. */
  33591. getWorldMatrix(): Matrix;
  33592. /** @hidden */
  33593. _getWorldMatrixDeterminant(): number;
  33594. /**
  33595. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  33596. */
  33597. get isAnInstance(): boolean;
  33598. /**
  33599. * Gets a boolean indicating if this mesh has instances
  33600. */
  33601. get hasInstances(): boolean;
  33602. /**
  33603. * Gets a boolean indicating if this mesh has thin instances
  33604. */
  33605. get hasThinInstances(): boolean;
  33606. /**
  33607. * Perform relative position change from the point of view of behind the front of the mesh.
  33608. * This is performed taking into account the meshes current rotation, so you do not have to care.
  33609. * Supports definition of mesh facing forward or backward
  33610. * @param amountRight defines the distance on the right axis
  33611. * @param amountUp defines the distance on the up axis
  33612. * @param amountForward defines the distance on the forward axis
  33613. * @returns the current mesh
  33614. */
  33615. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  33616. /**
  33617. * Calculate relative position change from the point of view of behind the front of the mesh.
  33618. * This is performed taking into account the meshes current rotation, so you do not have to care.
  33619. * Supports definition of mesh facing forward or backward
  33620. * @param amountRight defines the distance on the right axis
  33621. * @param amountUp defines the distance on the up axis
  33622. * @param amountForward defines the distance on the forward axis
  33623. * @returns the new displacement vector
  33624. */
  33625. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  33626. /**
  33627. * Perform relative rotation change from the point of view of behind the front of the mesh.
  33628. * Supports definition of mesh facing forward or backward
  33629. * @param flipBack defines the flip
  33630. * @param twirlClockwise defines the twirl
  33631. * @param tiltRight defines the tilt
  33632. * @returns the current mesh
  33633. */
  33634. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  33635. /**
  33636. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  33637. * Supports definition of mesh facing forward or backward.
  33638. * @param flipBack defines the flip
  33639. * @param twirlClockwise defines the twirl
  33640. * @param tiltRight defines the tilt
  33641. * @returns the new rotation vector
  33642. */
  33643. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  33644. /**
  33645. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  33646. * This means the mesh underlying bounding box and sphere are recomputed.
  33647. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  33648. * @returns the current mesh
  33649. */
  33650. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  33651. /** @hidden */
  33652. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  33653. /** @hidden */
  33654. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  33655. /** @hidden */
  33656. _updateBoundingInfo(): AbstractMesh;
  33657. /** @hidden */
  33658. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  33659. /** @hidden */
  33660. protected _afterComputeWorldMatrix(): void;
  33661. /** @hidden */
  33662. get _effectiveMesh(): AbstractMesh;
  33663. /**
  33664. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  33665. * A mesh is in the frustum if its bounding box intersects the frustum
  33666. * @param frustumPlanes defines the frustum to test
  33667. * @returns true if the mesh is in the frustum planes
  33668. */
  33669. isInFrustum(frustumPlanes: Plane[]): boolean;
  33670. /**
  33671. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  33672. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  33673. * @param frustumPlanes defines the frustum to test
  33674. * @returns true if the mesh is completely in the frustum planes
  33675. */
  33676. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  33677. /**
  33678. * True if the mesh intersects another mesh or a SolidParticle object
  33679. * @param mesh defines a target mesh or SolidParticle to test
  33680. * @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)
  33681. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  33682. * @returns true if there is an intersection
  33683. */
  33684. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  33685. /**
  33686. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  33687. * @param point defines the point to test
  33688. * @returns true if there is an intersection
  33689. */
  33690. intersectsPoint(point: Vector3): boolean;
  33691. /**
  33692. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  33693. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33694. */
  33695. get checkCollisions(): boolean;
  33696. set checkCollisions(collisionEnabled: boolean);
  33697. /**
  33698. * Gets Collider object used to compute collisions (not physics)
  33699. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33700. */
  33701. get collider(): Nullable<Collider>;
  33702. /**
  33703. * Move the mesh using collision engine
  33704. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33705. * @param displacement defines the requested displacement vector
  33706. * @returns the current mesh
  33707. */
  33708. moveWithCollisions(displacement: Vector3): AbstractMesh;
  33709. private _onCollisionPositionChange;
  33710. /** @hidden */
  33711. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  33712. /** @hidden */
  33713. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  33714. /** @hidden */
  33715. _checkCollision(collider: Collider): AbstractMesh;
  33716. /** @hidden */
  33717. _generatePointsArray(): boolean;
  33718. /**
  33719. * Checks if the passed Ray intersects with the mesh
  33720. * @param ray defines the ray to use
  33721. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  33722. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33723. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  33724. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  33725. * @returns the picking info
  33726. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  33727. */
  33728. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  33729. /**
  33730. * Clones the current mesh
  33731. * @param name defines the mesh name
  33732. * @param newParent defines the new mesh parent
  33733. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  33734. * @returns the new mesh
  33735. */
  33736. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  33737. /**
  33738. * Disposes all the submeshes of the current meshnp
  33739. * @returns the current mesh
  33740. */
  33741. releaseSubMeshes(): AbstractMesh;
  33742. /**
  33743. * Releases resources associated with this abstract mesh.
  33744. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33745. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33746. */
  33747. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33748. /**
  33749. * Adds the passed mesh as a child to the current mesh
  33750. * @param mesh defines the child mesh
  33751. * @returns the current mesh
  33752. */
  33753. addChild(mesh: AbstractMesh): AbstractMesh;
  33754. /**
  33755. * Removes the passed mesh from the current mesh children list
  33756. * @param mesh defines the child mesh
  33757. * @returns the current mesh
  33758. */
  33759. removeChild(mesh: AbstractMesh): AbstractMesh;
  33760. /** @hidden */
  33761. private _initFacetData;
  33762. /**
  33763. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  33764. * This method can be called within the render loop.
  33765. * 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
  33766. * @returns the current mesh
  33767. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33768. */
  33769. updateFacetData(): AbstractMesh;
  33770. /**
  33771. * Returns the facetLocalNormals array.
  33772. * The normals are expressed in the mesh local spac
  33773. * @returns an array of Vector3
  33774. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33775. */
  33776. getFacetLocalNormals(): Vector3[];
  33777. /**
  33778. * Returns the facetLocalPositions array.
  33779. * The facet positions are expressed in the mesh local space
  33780. * @returns an array of Vector3
  33781. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33782. */
  33783. getFacetLocalPositions(): Vector3[];
  33784. /**
  33785. * Returns the facetLocalPartioning array
  33786. * @returns an array of array of numbers
  33787. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33788. */
  33789. getFacetLocalPartitioning(): number[][];
  33790. /**
  33791. * Returns the i-th facet position in the world system.
  33792. * This method allocates a new Vector3 per call
  33793. * @param i defines the facet index
  33794. * @returns a new Vector3
  33795. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33796. */
  33797. getFacetPosition(i: number): Vector3;
  33798. /**
  33799. * Sets the reference Vector3 with the i-th facet position in the world system
  33800. * @param i defines the facet index
  33801. * @param ref defines the target vector
  33802. * @returns the current mesh
  33803. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33804. */
  33805. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  33806. /**
  33807. * Returns the i-th facet normal in the world system.
  33808. * This method allocates a new Vector3 per call
  33809. * @param i defines the facet index
  33810. * @returns a new Vector3
  33811. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33812. */
  33813. getFacetNormal(i: number): Vector3;
  33814. /**
  33815. * Sets the reference Vector3 with the i-th facet normal in the world system
  33816. * @param i defines the facet index
  33817. * @param ref defines the target vector
  33818. * @returns the current mesh
  33819. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33820. */
  33821. getFacetNormalToRef(i: number, ref: Vector3): this;
  33822. /**
  33823. * 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)
  33824. * @param x defines x coordinate
  33825. * @param y defines y coordinate
  33826. * @param z defines z coordinate
  33827. * @returns the array of facet indexes
  33828. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33829. */
  33830. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  33831. /**
  33832. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  33833. * @param projected sets as the (x,y,z) world projection on the facet
  33834. * @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
  33835. * @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
  33836. * @param x defines x coordinate
  33837. * @param y defines y coordinate
  33838. * @param z defines z coordinate
  33839. * @returns the face index if found (or null instead)
  33840. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33841. */
  33842. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  33843. /**
  33844. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  33845. * @param projected sets as the (x,y,z) local projection on the facet
  33846. * @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
  33847. * @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
  33848. * @param x defines x coordinate
  33849. * @param y defines y coordinate
  33850. * @param z defines z coordinate
  33851. * @returns the face index if found (or null instead)
  33852. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33853. */
  33854. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  33855. /**
  33856. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  33857. * @returns the parameters
  33858. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33859. */
  33860. getFacetDataParameters(): any;
  33861. /**
  33862. * Disables the feature FacetData and frees the related memory
  33863. * @returns the current mesh
  33864. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33865. */
  33866. disableFacetData(): AbstractMesh;
  33867. /**
  33868. * Updates the AbstractMesh indices array
  33869. * @param indices defines the data source
  33870. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  33871. * @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)
  33872. * @returns the current mesh
  33873. */
  33874. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  33875. /**
  33876. * Creates new normals data for the mesh
  33877. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  33878. * @returns the current mesh
  33879. */
  33880. createNormals(updatable: boolean): AbstractMesh;
  33881. /**
  33882. * Align the mesh with a normal
  33883. * @param normal defines the normal to use
  33884. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  33885. * @returns the current mesh
  33886. */
  33887. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  33888. /** @hidden */
  33889. _checkOcclusionQuery(): boolean;
  33890. /**
  33891. * Disables the mesh edge rendering mode
  33892. * @returns the currentAbstractMesh
  33893. */
  33894. disableEdgesRendering(): AbstractMesh;
  33895. /**
  33896. * Enables the edge rendering mode on the mesh.
  33897. * This mode makes the mesh edges visible
  33898. * @param epsilon defines the maximal distance between two angles to detect a face
  33899. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  33900. * @returns the currentAbstractMesh
  33901. * @see https://www.babylonjs-playground.com/#19O9TU#0
  33902. */
  33903. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  33904. /**
  33905. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  33906. * @returns an array of particle systems in the scene that use the mesh as an emitter
  33907. */
  33908. getConnectedParticleSystems(): IParticleSystem[];
  33909. }
  33910. }
  33911. declare module "babylonjs/Actions/actionEvent" {
  33912. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33913. import { Nullable } from "babylonjs/types";
  33914. import { Sprite } from "babylonjs/Sprites/sprite";
  33915. import { Scene } from "babylonjs/scene";
  33916. import { Vector2 } from "babylonjs/Maths/math.vector";
  33917. /**
  33918. * Interface used to define ActionEvent
  33919. */
  33920. export interface IActionEvent {
  33921. /** The mesh or sprite that triggered the action */
  33922. source: any;
  33923. /** The X mouse cursor position at the time of the event */
  33924. pointerX: number;
  33925. /** The Y mouse cursor position at the time of the event */
  33926. pointerY: number;
  33927. /** The mesh that is currently pointed at (can be null) */
  33928. meshUnderPointer: Nullable<AbstractMesh>;
  33929. /** the original (browser) event that triggered the ActionEvent */
  33930. sourceEvent?: any;
  33931. /** additional data for the event */
  33932. additionalData?: any;
  33933. }
  33934. /**
  33935. * ActionEvent is the event being sent when an action is triggered.
  33936. */
  33937. export class ActionEvent implements IActionEvent {
  33938. /** The mesh or sprite that triggered the action */
  33939. source: any;
  33940. /** The X mouse cursor position at the time of the event */
  33941. pointerX: number;
  33942. /** The Y mouse cursor position at the time of the event */
  33943. pointerY: number;
  33944. /** The mesh that is currently pointed at (can be null) */
  33945. meshUnderPointer: Nullable<AbstractMesh>;
  33946. /** the original (browser) event that triggered the ActionEvent */
  33947. sourceEvent?: any;
  33948. /** additional data for the event */
  33949. additionalData?: any;
  33950. /**
  33951. * Creates a new ActionEvent
  33952. * @param source The mesh or sprite that triggered the action
  33953. * @param pointerX The X mouse cursor position at the time of the event
  33954. * @param pointerY The Y mouse cursor position at the time of the event
  33955. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  33956. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  33957. * @param additionalData additional data for the event
  33958. */
  33959. constructor(
  33960. /** The mesh or sprite that triggered the action */
  33961. source: any,
  33962. /** The X mouse cursor position at the time of the event */
  33963. pointerX: number,
  33964. /** The Y mouse cursor position at the time of the event */
  33965. pointerY: number,
  33966. /** The mesh that is currently pointed at (can be null) */
  33967. meshUnderPointer: Nullable<AbstractMesh>,
  33968. /** the original (browser) event that triggered the ActionEvent */
  33969. sourceEvent?: any,
  33970. /** additional data for the event */
  33971. additionalData?: any);
  33972. /**
  33973. * Helper function to auto-create an ActionEvent from a source mesh.
  33974. * @param source The source mesh that triggered the event
  33975. * @param evt The original (browser) event
  33976. * @param additionalData additional data for the event
  33977. * @returns the new ActionEvent
  33978. */
  33979. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  33980. /**
  33981. * Helper function to auto-create an ActionEvent from a source sprite
  33982. * @param source The source sprite that triggered the event
  33983. * @param scene Scene associated with the sprite
  33984. * @param evt The original (browser) event
  33985. * @param additionalData additional data for the event
  33986. * @returns the new ActionEvent
  33987. */
  33988. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  33989. /**
  33990. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  33991. * @param scene the scene where the event occurred
  33992. * @param evt The original (browser) event
  33993. * @returns the new ActionEvent
  33994. */
  33995. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  33996. /**
  33997. * Helper function to auto-create an ActionEvent from a primitive
  33998. * @param prim defines the target primitive
  33999. * @param pointerPos defines the pointer position
  34000. * @param evt The original (browser) event
  34001. * @param additionalData additional data for the event
  34002. * @returns the new ActionEvent
  34003. */
  34004. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  34005. }
  34006. }
  34007. declare module "babylonjs/Actions/abstractActionManager" {
  34008. import { IDisposable } from "babylonjs/scene";
  34009. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  34010. import { IAction } from "babylonjs/Actions/action";
  34011. import { Nullable } from "babylonjs/types";
  34012. /**
  34013. * Abstract class used to decouple action Manager from scene and meshes.
  34014. * Do not instantiate.
  34015. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  34016. */
  34017. export abstract class AbstractActionManager implements IDisposable {
  34018. /** Gets the list of active triggers */
  34019. static Triggers: {
  34020. [key: string]: number;
  34021. };
  34022. /** Gets the cursor to use when hovering items */
  34023. hoverCursor: string;
  34024. /** Gets the list of actions */
  34025. actions: IAction[];
  34026. /**
  34027. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  34028. */
  34029. isRecursive: boolean;
  34030. /**
  34031. * Releases all associated resources
  34032. */
  34033. abstract dispose(): void;
  34034. /**
  34035. * Does this action manager has pointer triggers
  34036. */
  34037. abstract get hasPointerTriggers(): boolean;
  34038. /**
  34039. * Does this action manager has pick triggers
  34040. */
  34041. abstract get hasPickTriggers(): boolean;
  34042. /**
  34043. * Process a specific trigger
  34044. * @param trigger defines the trigger to process
  34045. * @param evt defines the event details to be processed
  34046. */
  34047. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  34048. /**
  34049. * Does this action manager handles actions of any of the given triggers
  34050. * @param triggers defines the triggers to be tested
  34051. * @return a boolean indicating whether one (or more) of the triggers is handled
  34052. */
  34053. abstract hasSpecificTriggers(triggers: number[]): boolean;
  34054. /**
  34055. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  34056. * speed.
  34057. * @param triggerA defines the trigger to be tested
  34058. * @param triggerB defines the trigger to be tested
  34059. * @return a boolean indicating whether one (or more) of the triggers is handled
  34060. */
  34061. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  34062. /**
  34063. * Does this action manager handles actions of a given trigger
  34064. * @param trigger defines the trigger to be tested
  34065. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  34066. * @return whether the trigger is handled
  34067. */
  34068. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  34069. /**
  34070. * Serialize this manager to a JSON object
  34071. * @param name defines the property name to store this manager
  34072. * @returns a JSON representation of this manager
  34073. */
  34074. abstract serialize(name: string): any;
  34075. /**
  34076. * Registers an action to this action manager
  34077. * @param action defines the action to be registered
  34078. * @return the action amended (prepared) after registration
  34079. */
  34080. abstract registerAction(action: IAction): Nullable<IAction>;
  34081. /**
  34082. * Unregisters an action to this action manager
  34083. * @param action defines the action to be unregistered
  34084. * @return a boolean indicating whether the action has been unregistered
  34085. */
  34086. abstract unregisterAction(action: IAction): Boolean;
  34087. /**
  34088. * Does exist one action manager with at least one trigger
  34089. **/
  34090. static get HasTriggers(): boolean;
  34091. /**
  34092. * Does exist one action manager with at least one pick trigger
  34093. **/
  34094. static get HasPickTriggers(): boolean;
  34095. /**
  34096. * Does exist one action manager that handles actions of a given trigger
  34097. * @param trigger defines the trigger to be tested
  34098. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  34099. **/
  34100. static HasSpecificTrigger(trigger: number): boolean;
  34101. }
  34102. }
  34103. declare module "babylonjs/node" {
  34104. import { Scene } from "babylonjs/scene";
  34105. import { Nullable } from "babylonjs/types";
  34106. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  34107. import { Engine } from "babylonjs/Engines/engine";
  34108. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  34109. import { Observable } from "babylonjs/Misc/observable";
  34110. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34111. import { IInspectable } from "babylonjs/Misc/iInspectable";
  34112. import { Animatable } from "babylonjs/Animations/animatable";
  34113. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  34114. import { Animation } from "babylonjs/Animations/animation";
  34115. import { AnimationRange } from "babylonjs/Animations/animationRange";
  34116. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34117. /**
  34118. * Defines how a node can be built from a string name.
  34119. */
  34120. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  34121. /**
  34122. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  34123. */
  34124. export class Node implements IBehaviorAware<Node> {
  34125. /** @hidden */
  34126. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  34127. private static _NodeConstructors;
  34128. /**
  34129. * Add a new node constructor
  34130. * @param type defines the type name of the node to construct
  34131. * @param constructorFunc defines the constructor function
  34132. */
  34133. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  34134. /**
  34135. * Returns a node constructor based on type name
  34136. * @param type defines the type name
  34137. * @param name defines the new node name
  34138. * @param scene defines the hosting scene
  34139. * @param options defines optional options to transmit to constructors
  34140. * @returns the new constructor or null
  34141. */
  34142. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  34143. /**
  34144. * Gets or sets the name of the node
  34145. */
  34146. name: string;
  34147. /**
  34148. * Gets or sets the id of the node
  34149. */
  34150. id: string;
  34151. /**
  34152. * Gets or sets the unique id of the node
  34153. */
  34154. uniqueId: number;
  34155. /**
  34156. * Gets or sets a string used to store user defined state for the node
  34157. */
  34158. state: string;
  34159. /**
  34160. * Gets or sets an object used to store user defined information for the node
  34161. */
  34162. metadata: any;
  34163. /**
  34164. * For internal use only. Please do not use.
  34165. */
  34166. reservedDataStore: any;
  34167. /**
  34168. * List of inspectable custom properties (used by the Inspector)
  34169. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  34170. */
  34171. inspectableCustomProperties: IInspectable[];
  34172. private _doNotSerialize;
  34173. /**
  34174. * Gets or sets a boolean used to define if the node must be serialized
  34175. */
  34176. get doNotSerialize(): boolean;
  34177. set doNotSerialize(value: boolean);
  34178. /** @hidden */
  34179. _isDisposed: boolean;
  34180. /**
  34181. * Gets a list of Animations associated with the node
  34182. */
  34183. animations: import("babylonjs/Animations/animation").Animation[];
  34184. protected _ranges: {
  34185. [name: string]: Nullable<AnimationRange>;
  34186. };
  34187. /**
  34188. * Callback raised when the node is ready to be used
  34189. */
  34190. onReady: Nullable<(node: Node) => void>;
  34191. private _isEnabled;
  34192. private _isParentEnabled;
  34193. private _isReady;
  34194. /** @hidden */
  34195. _currentRenderId: number;
  34196. private _parentUpdateId;
  34197. /** @hidden */
  34198. _childUpdateId: number;
  34199. /** @hidden */
  34200. _waitingParentId: Nullable<string>;
  34201. /** @hidden */
  34202. _scene: Scene;
  34203. /** @hidden */
  34204. _cache: any;
  34205. private _parentNode;
  34206. private _children;
  34207. /** @hidden */
  34208. _worldMatrix: Matrix;
  34209. /** @hidden */
  34210. _worldMatrixDeterminant: number;
  34211. /** @hidden */
  34212. _worldMatrixDeterminantIsDirty: boolean;
  34213. /** @hidden */
  34214. private _sceneRootNodesIndex;
  34215. /**
  34216. * Gets a boolean indicating if the node has been disposed
  34217. * @returns true if the node was disposed
  34218. */
  34219. isDisposed(): boolean;
  34220. /**
  34221. * Gets or sets the parent of the node (without keeping the current position in the scene)
  34222. * @see https://doc.babylonjs.com/how_to/parenting
  34223. */
  34224. set parent(parent: Nullable<Node>);
  34225. get parent(): Nullable<Node>;
  34226. /** @hidden */
  34227. _addToSceneRootNodes(): void;
  34228. /** @hidden */
  34229. _removeFromSceneRootNodes(): void;
  34230. private _animationPropertiesOverride;
  34231. /**
  34232. * Gets or sets the animation properties override
  34233. */
  34234. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  34235. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  34236. /**
  34237. * Gets a string identifying the name of the class
  34238. * @returns "Node" string
  34239. */
  34240. getClassName(): string;
  34241. /** @hidden */
  34242. readonly _isNode: boolean;
  34243. /**
  34244. * An event triggered when the mesh is disposed
  34245. */
  34246. onDisposeObservable: Observable<Node>;
  34247. private _onDisposeObserver;
  34248. /**
  34249. * Sets a callback that will be raised when the node will be disposed
  34250. */
  34251. set onDispose(callback: () => void);
  34252. /**
  34253. * Creates a new Node
  34254. * @param name the name and id to be given to this node
  34255. * @param scene the scene this node will be added to
  34256. */
  34257. constructor(name: string, scene?: Nullable<Scene>);
  34258. /**
  34259. * Gets the scene of the node
  34260. * @returns a scene
  34261. */
  34262. getScene(): Scene;
  34263. /**
  34264. * Gets the engine of the node
  34265. * @returns a Engine
  34266. */
  34267. getEngine(): Engine;
  34268. private _behaviors;
  34269. /**
  34270. * Attach a behavior to the node
  34271. * @see https://doc.babylonjs.com/features/behaviour
  34272. * @param behavior defines the behavior to attach
  34273. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  34274. * @returns the current Node
  34275. */
  34276. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  34277. /**
  34278. * Remove an attached behavior
  34279. * @see https://doc.babylonjs.com/features/behaviour
  34280. * @param behavior defines the behavior to attach
  34281. * @returns the current Node
  34282. */
  34283. removeBehavior(behavior: Behavior<Node>): Node;
  34284. /**
  34285. * Gets the list of attached behaviors
  34286. * @see https://doc.babylonjs.com/features/behaviour
  34287. */
  34288. get behaviors(): Behavior<Node>[];
  34289. /**
  34290. * Gets an attached behavior by name
  34291. * @param name defines the name of the behavior to look for
  34292. * @see https://doc.babylonjs.com/features/behaviour
  34293. * @returns null if behavior was not found else the requested behavior
  34294. */
  34295. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  34296. /**
  34297. * Returns the latest update of the World matrix
  34298. * @returns a Matrix
  34299. */
  34300. getWorldMatrix(): Matrix;
  34301. /** @hidden */
  34302. _getWorldMatrixDeterminant(): number;
  34303. /**
  34304. * Returns directly the latest state of the mesh World matrix.
  34305. * A Matrix is returned.
  34306. */
  34307. get worldMatrixFromCache(): Matrix;
  34308. /** @hidden */
  34309. _initCache(): void;
  34310. /** @hidden */
  34311. updateCache(force?: boolean): void;
  34312. /** @hidden */
  34313. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  34314. /** @hidden */
  34315. _updateCache(ignoreParentClass?: boolean): void;
  34316. /** @hidden */
  34317. _isSynchronized(): boolean;
  34318. /** @hidden */
  34319. _markSyncedWithParent(): void;
  34320. /** @hidden */
  34321. isSynchronizedWithParent(): boolean;
  34322. /** @hidden */
  34323. isSynchronized(): boolean;
  34324. /**
  34325. * Is this node ready to be used/rendered
  34326. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  34327. * @return true if the node is ready
  34328. */
  34329. isReady(completeCheck?: boolean): boolean;
  34330. /**
  34331. * Is this node enabled?
  34332. * 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
  34333. * @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
  34334. * @return whether this node (and its parent) is enabled
  34335. */
  34336. isEnabled(checkAncestors?: boolean): boolean;
  34337. /** @hidden */
  34338. protected _syncParentEnabledState(): void;
  34339. /**
  34340. * Set the enabled state of this node
  34341. * @param value defines the new enabled state
  34342. */
  34343. setEnabled(value: boolean): void;
  34344. /**
  34345. * Is this node a descendant of the given node?
  34346. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  34347. * @param ancestor defines the parent node to inspect
  34348. * @returns a boolean indicating if this node is a descendant of the given node
  34349. */
  34350. isDescendantOf(ancestor: Node): boolean;
  34351. /** @hidden */
  34352. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  34353. /**
  34354. * Will return all nodes that have this node as ascendant
  34355. * @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
  34356. * @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
  34357. * @return all children nodes of all types
  34358. */
  34359. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  34360. /**
  34361. * Get all child-meshes of this node
  34362. * @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)
  34363. * @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
  34364. * @returns an array of AbstractMesh
  34365. */
  34366. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  34367. /**
  34368. * Get all direct children of this node
  34369. * @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
  34370. * @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)
  34371. * @returns an array of Node
  34372. */
  34373. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  34374. /** @hidden */
  34375. _setReady(state: boolean): void;
  34376. /**
  34377. * Get an animation by name
  34378. * @param name defines the name of the animation to look for
  34379. * @returns null if not found else the requested animation
  34380. */
  34381. getAnimationByName(name: string): Nullable<Animation>;
  34382. /**
  34383. * Creates an animation range for this node
  34384. * @param name defines the name of the range
  34385. * @param from defines the starting key
  34386. * @param to defines the end key
  34387. */
  34388. createAnimationRange(name: string, from: number, to: number): void;
  34389. /**
  34390. * Delete a specific animation range
  34391. * @param name defines the name of the range to delete
  34392. * @param deleteFrames defines if animation frames from the range must be deleted as well
  34393. */
  34394. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  34395. /**
  34396. * Get an animation range by name
  34397. * @param name defines the name of the animation range to look for
  34398. * @returns null if not found else the requested animation range
  34399. */
  34400. getAnimationRange(name: string): Nullable<AnimationRange>;
  34401. /**
  34402. * Gets the list of all animation ranges defined on this node
  34403. * @returns an array
  34404. */
  34405. getAnimationRanges(): Nullable<AnimationRange>[];
  34406. /**
  34407. * Will start the animation sequence
  34408. * @param name defines the range frames for animation sequence
  34409. * @param loop defines if the animation should loop (false by default)
  34410. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  34411. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  34412. * @returns the object created for this animation. If range does not exist, it will return null
  34413. */
  34414. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  34415. /**
  34416. * Serialize animation ranges into a JSON compatible object
  34417. * @returns serialization object
  34418. */
  34419. serializeAnimationRanges(): any;
  34420. /**
  34421. * Computes the world matrix of the node
  34422. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  34423. * @returns the world matrix
  34424. */
  34425. computeWorldMatrix(force?: boolean): Matrix;
  34426. /**
  34427. * Releases resources associated with this node.
  34428. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  34429. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  34430. */
  34431. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  34432. /**
  34433. * Parse animation range data from a serialization object and store them into a given node
  34434. * @param node defines where to store the animation ranges
  34435. * @param parsedNode defines the serialization object to read data from
  34436. * @param scene defines the hosting scene
  34437. */
  34438. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  34439. /**
  34440. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  34441. * @param includeDescendants Include bounding info from descendants as well (true by default)
  34442. * @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
  34443. * @returns the new bounding vectors
  34444. */
  34445. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  34446. min: Vector3;
  34447. max: Vector3;
  34448. };
  34449. }
  34450. }
  34451. declare module "babylonjs/Animations/animation" {
  34452. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  34453. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  34454. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  34455. import { Nullable } from "babylonjs/types";
  34456. import { Scene } from "babylonjs/scene";
  34457. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  34458. import { AnimationRange } from "babylonjs/Animations/animationRange";
  34459. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  34460. import { Node } from "babylonjs/node";
  34461. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  34462. import { Size } from "babylonjs/Maths/math.size";
  34463. import { Animatable } from "babylonjs/Animations/animatable";
  34464. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  34465. /**
  34466. * @hidden
  34467. */
  34468. export class _IAnimationState {
  34469. key: number;
  34470. repeatCount: number;
  34471. workValue?: any;
  34472. loopMode?: number;
  34473. offsetValue?: any;
  34474. highLimitValue?: any;
  34475. }
  34476. /**
  34477. * Class used to store any kind of animation
  34478. */
  34479. export class Animation {
  34480. /**Name of the animation */
  34481. name: string;
  34482. /**Property to animate */
  34483. targetProperty: string;
  34484. /**The frames per second of the animation */
  34485. framePerSecond: number;
  34486. /**The data type of the animation */
  34487. dataType: number;
  34488. /**The loop mode of the animation */
  34489. loopMode?: number | undefined;
  34490. /**Specifies if blending should be enabled */
  34491. enableBlending?: boolean | undefined;
  34492. /**
  34493. * Use matrix interpolation instead of using direct key value when animating matrices
  34494. */
  34495. static AllowMatricesInterpolation: boolean;
  34496. /**
  34497. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  34498. */
  34499. static AllowMatrixDecomposeForInterpolation: boolean;
  34500. /** Define the Url to load snippets */
  34501. static SnippetUrl: string;
  34502. /** Snippet ID if the animation was created from the snippet server */
  34503. snippetId: string;
  34504. /**
  34505. * Stores the key frames of the animation
  34506. */
  34507. private _keys;
  34508. /**
  34509. * Stores the easing function of the animation
  34510. */
  34511. private _easingFunction;
  34512. /**
  34513. * @hidden Internal use only
  34514. */
  34515. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  34516. /**
  34517. * The set of event that will be linked to this animation
  34518. */
  34519. private _events;
  34520. /**
  34521. * Stores an array of target property paths
  34522. */
  34523. targetPropertyPath: string[];
  34524. /**
  34525. * Stores the blending speed of the animation
  34526. */
  34527. blendingSpeed: number;
  34528. /**
  34529. * Stores the animation ranges for the animation
  34530. */
  34531. private _ranges;
  34532. /**
  34533. * @hidden Internal use
  34534. */
  34535. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  34536. /**
  34537. * Sets up an animation
  34538. * @param property The property to animate
  34539. * @param animationType The animation type to apply
  34540. * @param framePerSecond The frames per second of the animation
  34541. * @param easingFunction The easing function used in the animation
  34542. * @returns The created animation
  34543. */
  34544. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  34545. /**
  34546. * Create and start an animation on a node
  34547. * @param name defines the name of the global animation that will be run on all nodes
  34548. * @param node defines the root node where the animation will take place
  34549. * @param targetProperty defines property to animate
  34550. * @param framePerSecond defines the number of frame per second yo use
  34551. * @param totalFrame defines the number of frames in total
  34552. * @param from defines the initial value
  34553. * @param to defines the final value
  34554. * @param loopMode defines which loop mode you want to use (off by default)
  34555. * @param easingFunction defines the easing function to use (linear by default)
  34556. * @param onAnimationEnd defines the callback to call when animation end
  34557. * @returns the animatable created for this animation
  34558. */
  34559. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  34560. /**
  34561. * Create and start an animation on a node and its descendants
  34562. * @param name defines the name of the global animation that will be run on all nodes
  34563. * @param node defines the root node where the animation will take place
  34564. * @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
  34565. * @param targetProperty defines property to animate
  34566. * @param framePerSecond defines the number of frame per second to use
  34567. * @param totalFrame defines the number of frames in total
  34568. * @param from defines the initial value
  34569. * @param to defines the final value
  34570. * @param loopMode defines which loop mode you want to use (off by default)
  34571. * @param easingFunction defines the easing function to use (linear by default)
  34572. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  34573. * @returns the list of animatables created for all nodes
  34574. * @example https://www.babylonjs-playground.com/#MH0VLI
  34575. */
  34576. 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[]>;
  34577. /**
  34578. * Creates a new animation, merges it with the existing animations and starts it
  34579. * @param name Name of the animation
  34580. * @param node Node which contains the scene that begins the animations
  34581. * @param targetProperty Specifies which property to animate
  34582. * @param framePerSecond The frames per second of the animation
  34583. * @param totalFrame The total number of frames
  34584. * @param from The frame at the beginning of the animation
  34585. * @param to The frame at the end of the animation
  34586. * @param loopMode Specifies the loop mode of the animation
  34587. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  34588. * @param onAnimationEnd Callback to run once the animation is complete
  34589. * @returns Nullable animation
  34590. */
  34591. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  34592. /**
  34593. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  34594. * @param sourceAnimation defines the Animation containing keyframes to convert
  34595. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  34596. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  34597. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  34598. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  34599. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  34600. */
  34601. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  34602. /**
  34603. * Transition property of an host to the target Value
  34604. * @param property The property to transition
  34605. * @param targetValue The target Value of the property
  34606. * @param host The object where the property to animate belongs
  34607. * @param scene Scene used to run the animation
  34608. * @param frameRate Framerate (in frame/s) to use
  34609. * @param transition The transition type we want to use
  34610. * @param duration The duration of the animation, in milliseconds
  34611. * @param onAnimationEnd Callback trigger at the end of the animation
  34612. * @returns Nullable animation
  34613. */
  34614. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  34615. /**
  34616. * Return the array of runtime animations currently using this animation
  34617. */
  34618. get runtimeAnimations(): RuntimeAnimation[];
  34619. /**
  34620. * Specifies if any of the runtime animations are currently running
  34621. */
  34622. get hasRunningRuntimeAnimations(): boolean;
  34623. /**
  34624. * Initializes the animation
  34625. * @param name Name of the animation
  34626. * @param targetProperty Property to animate
  34627. * @param framePerSecond The frames per second of the animation
  34628. * @param dataType The data type of the animation
  34629. * @param loopMode The loop mode of the animation
  34630. * @param enableBlending Specifies if blending should be enabled
  34631. */
  34632. constructor(
  34633. /**Name of the animation */
  34634. name: string,
  34635. /**Property to animate */
  34636. targetProperty: string,
  34637. /**The frames per second of the animation */
  34638. framePerSecond: number,
  34639. /**The data type of the animation */
  34640. dataType: number,
  34641. /**The loop mode of the animation */
  34642. loopMode?: number | undefined,
  34643. /**Specifies if blending should be enabled */
  34644. enableBlending?: boolean | undefined);
  34645. /**
  34646. * Converts the animation to a string
  34647. * @param fullDetails support for multiple levels of logging within scene loading
  34648. * @returns String form of the animation
  34649. */
  34650. toString(fullDetails?: boolean): string;
  34651. /**
  34652. * Add an event to this animation
  34653. * @param event Event to add
  34654. */
  34655. addEvent(event: AnimationEvent): void;
  34656. /**
  34657. * Remove all events found at the given frame
  34658. * @param frame The frame to remove events from
  34659. */
  34660. removeEvents(frame: number): void;
  34661. /**
  34662. * Retrieves all the events from the animation
  34663. * @returns Events from the animation
  34664. */
  34665. getEvents(): AnimationEvent[];
  34666. /**
  34667. * Creates an animation range
  34668. * @param name Name of the animation range
  34669. * @param from Starting frame of the animation range
  34670. * @param to Ending frame of the animation
  34671. */
  34672. createRange(name: string, from: number, to: number): void;
  34673. /**
  34674. * Deletes an animation range by name
  34675. * @param name Name of the animation range to delete
  34676. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  34677. */
  34678. deleteRange(name: string, deleteFrames?: boolean): void;
  34679. /**
  34680. * Gets the animation range by name, or null if not defined
  34681. * @param name Name of the animation range
  34682. * @returns Nullable animation range
  34683. */
  34684. getRange(name: string): Nullable<AnimationRange>;
  34685. /**
  34686. * Gets the key frames from the animation
  34687. * @returns The key frames of the animation
  34688. */
  34689. getKeys(): Array<IAnimationKey>;
  34690. /**
  34691. * Gets the highest frame rate of the animation
  34692. * @returns Highest frame rate of the animation
  34693. */
  34694. getHighestFrame(): number;
  34695. /**
  34696. * Gets the easing function of the animation
  34697. * @returns Easing function of the animation
  34698. */
  34699. getEasingFunction(): IEasingFunction;
  34700. /**
  34701. * Sets the easing function of the animation
  34702. * @param easingFunction A custom mathematical formula for animation
  34703. */
  34704. setEasingFunction(easingFunction: EasingFunction): void;
  34705. /**
  34706. * Interpolates a scalar linearly
  34707. * @param startValue Start value of the animation curve
  34708. * @param endValue End value of the animation curve
  34709. * @param gradient Scalar amount to interpolate
  34710. * @returns Interpolated scalar value
  34711. */
  34712. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  34713. /**
  34714. * Interpolates a scalar cubically
  34715. * @param startValue Start value of the animation curve
  34716. * @param outTangent End tangent of the animation
  34717. * @param endValue End value of the animation curve
  34718. * @param inTangent Start tangent of the animation curve
  34719. * @param gradient Scalar amount to interpolate
  34720. * @returns Interpolated scalar value
  34721. */
  34722. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  34723. /**
  34724. * Interpolates a quaternion using a spherical linear interpolation
  34725. * @param startValue Start value of the animation curve
  34726. * @param endValue End value of the animation curve
  34727. * @param gradient Scalar amount to interpolate
  34728. * @returns Interpolated quaternion value
  34729. */
  34730. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  34731. /**
  34732. * Interpolates a quaternion cubically
  34733. * @param startValue Start value of the animation curve
  34734. * @param outTangent End tangent of the animation curve
  34735. * @param endValue End value of the animation curve
  34736. * @param inTangent Start tangent of the animation curve
  34737. * @param gradient Scalar amount to interpolate
  34738. * @returns Interpolated quaternion value
  34739. */
  34740. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  34741. /**
  34742. * Interpolates a Vector3 linearl
  34743. * @param startValue Start value of the animation curve
  34744. * @param endValue End value of the animation curve
  34745. * @param gradient Scalar amount to interpolate
  34746. * @returns Interpolated scalar value
  34747. */
  34748. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  34749. /**
  34750. * Interpolates a Vector3 cubically
  34751. * @param startValue Start value of the animation curve
  34752. * @param outTangent End tangent of the animation
  34753. * @param endValue End value of the animation curve
  34754. * @param inTangent Start tangent of the animation curve
  34755. * @param gradient Scalar amount to interpolate
  34756. * @returns InterpolatedVector3 value
  34757. */
  34758. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  34759. /**
  34760. * Interpolates a Vector2 linearly
  34761. * @param startValue Start value of the animation curve
  34762. * @param endValue End value of the animation curve
  34763. * @param gradient Scalar amount to interpolate
  34764. * @returns Interpolated Vector2 value
  34765. */
  34766. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  34767. /**
  34768. * Interpolates a Vector2 cubically
  34769. * @param startValue Start value of the animation curve
  34770. * @param outTangent End tangent of the animation
  34771. * @param endValue End value of the animation curve
  34772. * @param inTangent Start tangent of the animation curve
  34773. * @param gradient Scalar amount to interpolate
  34774. * @returns Interpolated Vector2 value
  34775. */
  34776. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  34777. /**
  34778. * Interpolates a size linearly
  34779. * @param startValue Start value of the animation curve
  34780. * @param endValue End value of the animation curve
  34781. * @param gradient Scalar amount to interpolate
  34782. * @returns Interpolated Size value
  34783. */
  34784. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  34785. /**
  34786. * Interpolates a Color3 linearly
  34787. * @param startValue Start value of the animation curve
  34788. * @param endValue End value of the animation curve
  34789. * @param gradient Scalar amount to interpolate
  34790. * @returns Interpolated Color3 value
  34791. */
  34792. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  34793. /**
  34794. * Interpolates a Color4 linearly
  34795. * @param startValue Start value of the animation curve
  34796. * @param endValue End value of the animation curve
  34797. * @param gradient Scalar amount to interpolate
  34798. * @returns Interpolated Color3 value
  34799. */
  34800. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  34801. /**
  34802. * @hidden Internal use only
  34803. */
  34804. _getKeyValue(value: any): any;
  34805. /**
  34806. * @hidden Internal use only
  34807. */
  34808. _interpolate(currentFrame: number, state: _IAnimationState): any;
  34809. /**
  34810. * Defines the function to use to interpolate matrices
  34811. * @param startValue defines the start matrix
  34812. * @param endValue defines the end matrix
  34813. * @param gradient defines the gradient between both matrices
  34814. * @param result defines an optional target matrix where to store the interpolation
  34815. * @returns the interpolated matrix
  34816. */
  34817. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  34818. /**
  34819. * Makes a copy of the animation
  34820. * @returns Cloned animation
  34821. */
  34822. clone(): Animation;
  34823. /**
  34824. * Sets the key frames of the animation
  34825. * @param values The animation key frames to set
  34826. */
  34827. setKeys(values: Array<IAnimationKey>): void;
  34828. /**
  34829. * Serializes the animation to an object
  34830. * @returns Serialized object
  34831. */
  34832. serialize(): any;
  34833. /**
  34834. * Float animation type
  34835. */
  34836. static readonly ANIMATIONTYPE_FLOAT: number;
  34837. /**
  34838. * Vector3 animation type
  34839. */
  34840. static readonly ANIMATIONTYPE_VECTOR3: number;
  34841. /**
  34842. * Quaternion animation type
  34843. */
  34844. static readonly ANIMATIONTYPE_QUATERNION: number;
  34845. /**
  34846. * Matrix animation type
  34847. */
  34848. static readonly ANIMATIONTYPE_MATRIX: number;
  34849. /**
  34850. * Color3 animation type
  34851. */
  34852. static readonly ANIMATIONTYPE_COLOR3: number;
  34853. /**
  34854. * Color3 animation type
  34855. */
  34856. static readonly ANIMATIONTYPE_COLOR4: number;
  34857. /**
  34858. * Vector2 animation type
  34859. */
  34860. static readonly ANIMATIONTYPE_VECTOR2: number;
  34861. /**
  34862. * Size animation type
  34863. */
  34864. static readonly ANIMATIONTYPE_SIZE: number;
  34865. /**
  34866. * Relative Loop Mode
  34867. */
  34868. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  34869. /**
  34870. * Cycle Loop Mode
  34871. */
  34872. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  34873. /**
  34874. * Constant Loop Mode
  34875. */
  34876. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  34877. /** @hidden */
  34878. static _UniversalLerp(left: any, right: any, amount: number): any;
  34879. /**
  34880. * Parses an animation object and creates an animation
  34881. * @param parsedAnimation Parsed animation object
  34882. * @returns Animation object
  34883. */
  34884. static Parse(parsedAnimation: any): Animation;
  34885. /**
  34886. * Appends the serialized animations from the source animations
  34887. * @param source Source containing the animations
  34888. * @param destination Target to store the animations
  34889. */
  34890. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  34891. /**
  34892. * Creates a new animation or an array of animations from a snippet saved in a remote file
  34893. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  34894. * @param url defines the url to load from
  34895. * @returns a promise that will resolve to the new animation or an array of animations
  34896. */
  34897. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  34898. /**
  34899. * Creates an animation or an array of animations from a snippet saved by the Inspector
  34900. * @param snippetId defines the snippet to load
  34901. * @returns a promise that will resolve to the new animation or a new array of animations
  34902. */
  34903. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  34904. }
  34905. }
  34906. declare module "babylonjs/Animations/animatable.interface" {
  34907. import { Nullable } from "babylonjs/types";
  34908. import { Animation } from "babylonjs/Animations/animation";
  34909. /**
  34910. * Interface containing an array of animations
  34911. */
  34912. export interface IAnimatable {
  34913. /**
  34914. * Array of animations
  34915. */
  34916. animations: Nullable<Array<Animation>>;
  34917. }
  34918. }
  34919. declare module "babylonjs/Misc/decorators" {
  34920. import { Nullable } from "babylonjs/types";
  34921. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  34922. import { Scene } from "babylonjs/scene";
  34923. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  34924. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  34925. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  34926. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34927. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  34928. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34929. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34930. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34931. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34932. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34933. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34934. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34935. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34936. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34937. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34938. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34939. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34940. /**
  34941. * Decorator used to define property that can be serialized as reference to a camera
  34942. * @param sourceName defines the name of the property to decorate
  34943. */
  34944. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34945. /**
  34946. * Class used to help serialization objects
  34947. */
  34948. export class SerializationHelper {
  34949. /** @hidden */
  34950. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  34951. /** @hidden */
  34952. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  34953. /** @hidden */
  34954. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  34955. /** @hidden */
  34956. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  34957. /**
  34958. * Appends the serialized animations from the source animations
  34959. * @param source Source containing the animations
  34960. * @param destination Target to store the animations
  34961. */
  34962. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  34963. /**
  34964. * Static function used to serialized a specific entity
  34965. * @param entity defines the entity to serialize
  34966. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  34967. * @returns a JSON compatible object representing the serialization of the entity
  34968. */
  34969. static Serialize<T>(entity: T, serializationObject?: any): any;
  34970. /**
  34971. * Creates a new entity from a serialization data object
  34972. * @param creationFunction defines a function used to instanciated the new entity
  34973. * @param source defines the source serialization data
  34974. * @param scene defines the hosting scene
  34975. * @param rootUrl defines the root url for resources
  34976. * @returns a new entity
  34977. */
  34978. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  34979. /**
  34980. * Clones an object
  34981. * @param creationFunction defines the function used to instanciate the new object
  34982. * @param source defines the source object
  34983. * @returns the cloned object
  34984. */
  34985. static Clone<T>(creationFunction: () => T, source: T): T;
  34986. /**
  34987. * Instanciates a new object based on a source one (some data will be shared between both object)
  34988. * @param creationFunction defines the function used to instanciate the new object
  34989. * @param source defines the source object
  34990. * @returns the new object
  34991. */
  34992. static Instanciate<T>(creationFunction: () => T, source: T): T;
  34993. }
  34994. }
  34995. declare module "babylonjs/Materials/Textures/baseTexture" {
  34996. import { Observable } from "babylonjs/Misc/observable";
  34997. import { Nullable } from "babylonjs/types";
  34998. import { Scene } from "babylonjs/scene";
  34999. import { Matrix } from "babylonjs/Maths/math.vector";
  35000. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35001. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  35002. import { ISize } from "babylonjs/Maths/math.size";
  35003. import "babylonjs/Misc/fileTools";
  35004. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  35005. /**
  35006. * Base class of all the textures in babylon.
  35007. * It groups all the common properties the materials, post process, lights... might need
  35008. * in order to make a correct use of the texture.
  35009. */
  35010. export class BaseTexture implements IAnimatable {
  35011. /**
  35012. * Default anisotropic filtering level for the application.
  35013. * It is set to 4 as a good tradeoff between perf and quality.
  35014. */
  35015. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  35016. /**
  35017. * Gets or sets the unique id of the texture
  35018. */
  35019. uniqueId: number;
  35020. /**
  35021. * Define the name of the texture.
  35022. */
  35023. name: string;
  35024. /**
  35025. * Gets or sets an object used to store user defined information.
  35026. */
  35027. metadata: any;
  35028. /**
  35029. * For internal use only. Please do not use.
  35030. */
  35031. reservedDataStore: any;
  35032. private _hasAlpha;
  35033. /**
  35034. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  35035. */
  35036. set hasAlpha(value: boolean);
  35037. get hasAlpha(): boolean;
  35038. /**
  35039. * Defines if the alpha value should be determined via the rgb values.
  35040. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  35041. */
  35042. getAlphaFromRGB: boolean;
  35043. /**
  35044. * Intensity or strength of the texture.
  35045. * It is commonly used by materials to fine tune the intensity of the texture
  35046. */
  35047. level: number;
  35048. /**
  35049. * Define the UV chanel to use starting from 0 and defaulting to 0.
  35050. * This is part of the texture as textures usually maps to one uv set.
  35051. */
  35052. coordinatesIndex: number;
  35053. private _coordinatesMode;
  35054. /**
  35055. * How a texture is mapped.
  35056. *
  35057. * | Value | Type | Description |
  35058. * | ----- | ----------------------------------- | ----------- |
  35059. * | 0 | EXPLICIT_MODE | |
  35060. * | 1 | SPHERICAL_MODE | |
  35061. * | 2 | PLANAR_MODE | |
  35062. * | 3 | CUBIC_MODE | |
  35063. * | 4 | PROJECTION_MODE | |
  35064. * | 5 | SKYBOX_MODE | |
  35065. * | 6 | INVCUBIC_MODE | |
  35066. * | 7 | EQUIRECTANGULAR_MODE | |
  35067. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  35068. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  35069. */
  35070. set coordinatesMode(value: number);
  35071. get coordinatesMode(): number;
  35072. /**
  35073. * | Value | Type | Description |
  35074. * | ----- | ------------------ | ----------- |
  35075. * | 0 | CLAMP_ADDRESSMODE | |
  35076. * | 1 | WRAP_ADDRESSMODE | |
  35077. * | 2 | MIRROR_ADDRESSMODE | |
  35078. */
  35079. wrapU: number;
  35080. /**
  35081. * | Value | Type | Description |
  35082. * | ----- | ------------------ | ----------- |
  35083. * | 0 | CLAMP_ADDRESSMODE | |
  35084. * | 1 | WRAP_ADDRESSMODE | |
  35085. * | 2 | MIRROR_ADDRESSMODE | |
  35086. */
  35087. wrapV: number;
  35088. /**
  35089. * | Value | Type | Description |
  35090. * | ----- | ------------------ | ----------- |
  35091. * | 0 | CLAMP_ADDRESSMODE | |
  35092. * | 1 | WRAP_ADDRESSMODE | |
  35093. * | 2 | MIRROR_ADDRESSMODE | |
  35094. */
  35095. wrapR: number;
  35096. /**
  35097. * With compliant hardware and browser (supporting anisotropic filtering)
  35098. * this defines the level of anisotropic filtering in the texture.
  35099. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  35100. */
  35101. anisotropicFilteringLevel: number;
  35102. /**
  35103. * Define if the texture is a cube texture or if false a 2d texture.
  35104. */
  35105. get isCube(): boolean;
  35106. set isCube(value: boolean);
  35107. /**
  35108. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  35109. */
  35110. get is3D(): boolean;
  35111. set is3D(value: boolean);
  35112. /**
  35113. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  35114. */
  35115. get is2DArray(): boolean;
  35116. set is2DArray(value: boolean);
  35117. /**
  35118. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  35119. * HDR texture are usually stored in linear space.
  35120. * This only impacts the PBR and Background materials
  35121. */
  35122. gammaSpace: boolean;
  35123. /**
  35124. * Gets or sets whether or not the texture contains RGBD data.
  35125. */
  35126. get isRGBD(): boolean;
  35127. set isRGBD(value: boolean);
  35128. /**
  35129. * Is Z inverted in the texture (useful in a cube texture).
  35130. */
  35131. invertZ: boolean;
  35132. /**
  35133. * Are mip maps generated for this texture or not.
  35134. */
  35135. get noMipmap(): boolean;
  35136. /**
  35137. * @hidden
  35138. */
  35139. lodLevelInAlpha: boolean;
  35140. /**
  35141. * With prefiltered texture, defined the offset used during the prefiltering steps.
  35142. */
  35143. get lodGenerationOffset(): number;
  35144. set lodGenerationOffset(value: number);
  35145. /**
  35146. * With prefiltered texture, defined the scale used during the prefiltering steps.
  35147. */
  35148. get lodGenerationScale(): number;
  35149. set lodGenerationScale(value: number);
  35150. /**
  35151. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  35152. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  35153. * average roughness values.
  35154. */
  35155. get linearSpecularLOD(): boolean;
  35156. set linearSpecularLOD(value: boolean);
  35157. /**
  35158. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  35159. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  35160. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  35161. */
  35162. get irradianceTexture(): Nullable<BaseTexture>;
  35163. set irradianceTexture(value: Nullable<BaseTexture>);
  35164. /**
  35165. * Define if the texture is a render target.
  35166. */
  35167. isRenderTarget: boolean;
  35168. /**
  35169. * Define the unique id of the texture in the scene.
  35170. */
  35171. get uid(): string;
  35172. /** @hidden */
  35173. _prefiltered: boolean;
  35174. /**
  35175. * Return a string representation of the texture.
  35176. * @returns the texture as a string
  35177. */
  35178. toString(): string;
  35179. /**
  35180. * Get the class name of the texture.
  35181. * @returns "BaseTexture"
  35182. */
  35183. getClassName(): string;
  35184. /**
  35185. * Define the list of animation attached to the texture.
  35186. */
  35187. animations: import("babylonjs/Animations/animation").Animation[];
  35188. /**
  35189. * An event triggered when the texture is disposed.
  35190. */
  35191. onDisposeObservable: Observable<BaseTexture>;
  35192. private _onDisposeObserver;
  35193. /**
  35194. * Callback triggered when the texture has been disposed.
  35195. * Kept for back compatibility, you can use the onDisposeObservable instead.
  35196. */
  35197. set onDispose(callback: () => void);
  35198. /**
  35199. * Define the current state of the loading sequence when in delayed load mode.
  35200. */
  35201. delayLoadState: number;
  35202. protected _scene: Nullable<Scene>;
  35203. protected _engine: Nullable<ThinEngine>;
  35204. /** @hidden */
  35205. _texture: Nullable<InternalTexture>;
  35206. private _uid;
  35207. /**
  35208. * Define if the texture is preventinga material to render or not.
  35209. * If not and the texture is not ready, the engine will use a default black texture instead.
  35210. */
  35211. get isBlocking(): boolean;
  35212. /**
  35213. * Instantiates a new BaseTexture.
  35214. * Base class of all the textures in babylon.
  35215. * It groups all the common properties the materials, post process, lights... might need
  35216. * in order to make a correct use of the texture.
  35217. * @param sceneOrEngine Define the scene or engine the texture blongs to
  35218. */
  35219. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  35220. /**
  35221. * Get the scene the texture belongs to.
  35222. * @returns the scene or null if undefined
  35223. */
  35224. getScene(): Nullable<Scene>;
  35225. /** @hidden */
  35226. protected _getEngine(): Nullable<ThinEngine>;
  35227. /**
  35228. * Get the texture transform matrix used to offset tile the texture for istance.
  35229. * @returns the transformation matrix
  35230. */
  35231. getTextureMatrix(): Matrix;
  35232. /**
  35233. * Get the texture reflection matrix used to rotate/transform the reflection.
  35234. * @returns the reflection matrix
  35235. */
  35236. getReflectionTextureMatrix(): Matrix;
  35237. /**
  35238. * Get the underlying lower level texture from Babylon.
  35239. * @returns the insternal texture
  35240. */
  35241. getInternalTexture(): Nullable<InternalTexture>;
  35242. /**
  35243. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  35244. * @returns true if ready or not blocking
  35245. */
  35246. isReadyOrNotBlocking(): boolean;
  35247. /**
  35248. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  35249. * @returns true if fully ready
  35250. */
  35251. isReady(): boolean;
  35252. private _cachedSize;
  35253. /**
  35254. * Get the size of the texture.
  35255. * @returns the texture size.
  35256. */
  35257. getSize(): ISize;
  35258. /**
  35259. * Get the base size of the texture.
  35260. * It can be different from the size if the texture has been resized for POT for instance
  35261. * @returns the base size
  35262. */
  35263. getBaseSize(): ISize;
  35264. /**
  35265. * Update the sampling mode of the texture.
  35266. * Default is Trilinear mode.
  35267. *
  35268. * | Value | Type | Description |
  35269. * | ----- | ------------------ | ----------- |
  35270. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  35271. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  35272. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  35273. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  35274. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  35275. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  35276. * | 7 | NEAREST_LINEAR | |
  35277. * | 8 | NEAREST_NEAREST | |
  35278. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  35279. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  35280. * | 11 | LINEAR_LINEAR | |
  35281. * | 12 | LINEAR_NEAREST | |
  35282. *
  35283. * > _mag_: magnification filter (close to the viewer)
  35284. * > _min_: minification filter (far from the viewer)
  35285. * > _mip_: filter used between mip map levels
  35286. *@param samplingMode Define the new sampling mode of the texture
  35287. */
  35288. updateSamplingMode(samplingMode: number): void;
  35289. /**
  35290. * Scales the texture if is `canRescale()`
  35291. * @param ratio the resize factor we want to use to rescale
  35292. */
  35293. scale(ratio: number): void;
  35294. /**
  35295. * Get if the texture can rescale.
  35296. */
  35297. get canRescale(): boolean;
  35298. /** @hidden */
  35299. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  35300. /** @hidden */
  35301. _rebuild(): void;
  35302. /**
  35303. * Triggers the load sequence in delayed load mode.
  35304. */
  35305. delayLoad(): void;
  35306. /**
  35307. * Clones the texture.
  35308. * @returns the cloned texture
  35309. */
  35310. clone(): Nullable<BaseTexture>;
  35311. /**
  35312. * Get the texture underlying type (INT, FLOAT...)
  35313. */
  35314. get textureType(): number;
  35315. /**
  35316. * Get the texture underlying format (RGB, RGBA...)
  35317. */
  35318. get textureFormat(): number;
  35319. /**
  35320. * Indicates that textures need to be re-calculated for all materials
  35321. */
  35322. protected _markAllSubMeshesAsTexturesDirty(): void;
  35323. /**
  35324. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  35325. * This will returns an RGBA array buffer containing either in values (0-255) or
  35326. * float values (0-1) depending of the underlying buffer type.
  35327. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  35328. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  35329. * @param buffer defines a user defined buffer to fill with data (can be null)
  35330. * @returns The Array buffer containing the pixels data.
  35331. */
  35332. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  35333. /**
  35334. * Release and destroy the underlying lower level texture aka internalTexture.
  35335. */
  35336. releaseInternalTexture(): void;
  35337. /** @hidden */
  35338. get _lodTextureHigh(): Nullable<BaseTexture>;
  35339. /** @hidden */
  35340. get _lodTextureMid(): Nullable<BaseTexture>;
  35341. /** @hidden */
  35342. get _lodTextureLow(): Nullable<BaseTexture>;
  35343. /**
  35344. * Dispose the texture and release its associated resources.
  35345. */
  35346. dispose(): void;
  35347. /**
  35348. * Serialize the texture into a JSON representation that can be parsed later on.
  35349. * @returns the JSON representation of the texture
  35350. */
  35351. serialize(): any;
  35352. /**
  35353. * Helper function to be called back once a list of texture contains only ready textures.
  35354. * @param textures Define the list of textures to wait for
  35355. * @param callback Define the callback triggered once the entire list will be ready
  35356. */
  35357. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  35358. private static _isScene;
  35359. }
  35360. }
  35361. declare module "babylonjs/Materials/effect" {
  35362. import { Observable } from "babylonjs/Misc/observable";
  35363. import { Nullable } from "babylonjs/types";
  35364. import { IDisposable } from "babylonjs/scene";
  35365. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  35366. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  35367. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  35368. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  35369. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  35370. import { Engine } from "babylonjs/Engines/engine";
  35371. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35372. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35373. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  35374. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  35375. /**
  35376. * Options to be used when creating an effect.
  35377. */
  35378. export interface IEffectCreationOptions {
  35379. /**
  35380. * Atrributes that will be used in the shader.
  35381. */
  35382. attributes: string[];
  35383. /**
  35384. * Uniform varible names that will be set in the shader.
  35385. */
  35386. uniformsNames: string[];
  35387. /**
  35388. * Uniform buffer variable names that will be set in the shader.
  35389. */
  35390. uniformBuffersNames: string[];
  35391. /**
  35392. * Sampler texture variable names that will be set in the shader.
  35393. */
  35394. samplers: string[];
  35395. /**
  35396. * Define statements that will be set in the shader.
  35397. */
  35398. defines: any;
  35399. /**
  35400. * Possible fallbacks for this effect to improve performance when needed.
  35401. */
  35402. fallbacks: Nullable<IEffectFallbacks>;
  35403. /**
  35404. * Callback that will be called when the shader is compiled.
  35405. */
  35406. onCompiled: Nullable<(effect: Effect) => void>;
  35407. /**
  35408. * Callback that will be called if an error occurs during shader compilation.
  35409. */
  35410. onError: Nullable<(effect: Effect, errors: string) => void>;
  35411. /**
  35412. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  35413. */
  35414. indexParameters?: any;
  35415. /**
  35416. * Max number of lights that can be used in the shader.
  35417. */
  35418. maxSimultaneousLights?: number;
  35419. /**
  35420. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  35421. */
  35422. transformFeedbackVaryings?: Nullable<string[]>;
  35423. /**
  35424. * 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
  35425. */
  35426. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  35427. /**
  35428. * Is this effect rendering to several color attachments ?
  35429. */
  35430. multiTarget?: boolean;
  35431. }
  35432. /**
  35433. * Effect containing vertex and fragment shader that can be executed on an object.
  35434. */
  35435. export class Effect implements IDisposable {
  35436. /**
  35437. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  35438. */
  35439. static ShadersRepository: string;
  35440. /**
  35441. * Enable logging of the shader code when a compilation error occurs
  35442. */
  35443. static LogShaderCodeOnCompilationError: boolean;
  35444. /**
  35445. * Name of the effect.
  35446. */
  35447. name: any;
  35448. /**
  35449. * String container all the define statements that should be set on the shader.
  35450. */
  35451. defines: string;
  35452. /**
  35453. * Callback that will be called when the shader is compiled.
  35454. */
  35455. onCompiled: Nullable<(effect: Effect) => void>;
  35456. /**
  35457. * Callback that will be called if an error occurs during shader compilation.
  35458. */
  35459. onError: Nullable<(effect: Effect, errors: string) => void>;
  35460. /**
  35461. * Callback that will be called when effect is bound.
  35462. */
  35463. onBind: Nullable<(effect: Effect) => void>;
  35464. /**
  35465. * Unique ID of the effect.
  35466. */
  35467. uniqueId: number;
  35468. /**
  35469. * Observable that will be called when the shader is compiled.
  35470. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  35471. */
  35472. onCompileObservable: Observable<Effect>;
  35473. /**
  35474. * Observable that will be called if an error occurs during shader compilation.
  35475. */
  35476. onErrorObservable: Observable<Effect>;
  35477. /** @hidden */
  35478. _onBindObservable: Nullable<Observable<Effect>>;
  35479. /**
  35480. * @hidden
  35481. * Specifies if the effect was previously ready
  35482. */
  35483. _wasPreviouslyReady: boolean;
  35484. /**
  35485. * Observable that will be called when effect is bound.
  35486. */
  35487. get onBindObservable(): Observable<Effect>;
  35488. /** @hidden */
  35489. _bonesComputationForcedToCPU: boolean;
  35490. /** @hidden */
  35491. _multiTarget: boolean;
  35492. private static _uniqueIdSeed;
  35493. private _engine;
  35494. private _uniformBuffersNames;
  35495. private _uniformBuffersNamesList;
  35496. private _uniformsNames;
  35497. private _samplerList;
  35498. private _samplers;
  35499. private _isReady;
  35500. private _compilationError;
  35501. private _allFallbacksProcessed;
  35502. private _attributesNames;
  35503. private _attributes;
  35504. private _attributeLocationByName;
  35505. private _uniforms;
  35506. /**
  35507. * Key for the effect.
  35508. * @hidden
  35509. */
  35510. _key: string;
  35511. private _indexParameters;
  35512. private _fallbacks;
  35513. private _vertexSourceCode;
  35514. private _fragmentSourceCode;
  35515. private _vertexSourceCodeOverride;
  35516. private _fragmentSourceCodeOverride;
  35517. private _transformFeedbackVaryings;
  35518. /**
  35519. * Compiled shader to webGL program.
  35520. * @hidden
  35521. */
  35522. _pipelineContext: Nullable<IPipelineContext>;
  35523. private _valueCache;
  35524. private static _baseCache;
  35525. /**
  35526. * Instantiates an effect.
  35527. * An effect can be used to create/manage/execute vertex and fragment shaders.
  35528. * @param baseName Name of the effect.
  35529. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  35530. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  35531. * @param samplers List of sampler variables that will be passed to the shader.
  35532. * @param engine Engine to be used to render the effect
  35533. * @param defines Define statements to be added to the shader.
  35534. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  35535. * @param onCompiled Callback that will be called when the shader is compiled.
  35536. * @param onError Callback that will be called if an error occurs during shader compilation.
  35537. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  35538. */
  35539. 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);
  35540. private _useFinalCode;
  35541. /**
  35542. * Unique key for this effect
  35543. */
  35544. get key(): string;
  35545. /**
  35546. * If the effect has been compiled and prepared.
  35547. * @returns if the effect is compiled and prepared.
  35548. */
  35549. isReady(): boolean;
  35550. private _isReadyInternal;
  35551. /**
  35552. * The engine the effect was initialized with.
  35553. * @returns the engine.
  35554. */
  35555. getEngine(): Engine;
  35556. /**
  35557. * The pipeline context for this effect
  35558. * @returns the associated pipeline context
  35559. */
  35560. getPipelineContext(): Nullable<IPipelineContext>;
  35561. /**
  35562. * The set of names of attribute variables for the shader.
  35563. * @returns An array of attribute names.
  35564. */
  35565. getAttributesNames(): string[];
  35566. /**
  35567. * Returns the attribute at the given index.
  35568. * @param index The index of the attribute.
  35569. * @returns The location of the attribute.
  35570. */
  35571. getAttributeLocation(index: number): number;
  35572. /**
  35573. * Returns the attribute based on the name of the variable.
  35574. * @param name of the attribute to look up.
  35575. * @returns the attribute location.
  35576. */
  35577. getAttributeLocationByName(name: string): number;
  35578. /**
  35579. * The number of attributes.
  35580. * @returns the numnber of attributes.
  35581. */
  35582. getAttributesCount(): number;
  35583. /**
  35584. * Gets the index of a uniform variable.
  35585. * @param uniformName of the uniform to look up.
  35586. * @returns the index.
  35587. */
  35588. getUniformIndex(uniformName: string): number;
  35589. /**
  35590. * Returns the attribute based on the name of the variable.
  35591. * @param uniformName of the uniform to look up.
  35592. * @returns the location of the uniform.
  35593. */
  35594. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  35595. /**
  35596. * Returns an array of sampler variable names
  35597. * @returns The array of sampler variable names.
  35598. */
  35599. getSamplers(): string[];
  35600. /**
  35601. * Returns an array of uniform variable names
  35602. * @returns The array of uniform variable names.
  35603. */
  35604. getUniformNames(): string[];
  35605. /**
  35606. * Returns an array of uniform buffer variable names
  35607. * @returns The array of uniform buffer variable names.
  35608. */
  35609. getUniformBuffersNames(): string[];
  35610. /**
  35611. * Returns the index parameters used to create the effect
  35612. * @returns The index parameters object
  35613. */
  35614. getIndexParameters(): any;
  35615. /**
  35616. * The error from the last compilation.
  35617. * @returns the error string.
  35618. */
  35619. getCompilationError(): string;
  35620. /**
  35621. * Gets a boolean indicating that all fallbacks were used during compilation
  35622. * @returns true if all fallbacks were used
  35623. */
  35624. allFallbacksProcessed(): boolean;
  35625. /**
  35626. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  35627. * @param func The callback to be used.
  35628. */
  35629. executeWhenCompiled(func: (effect: Effect) => void): void;
  35630. private _checkIsReady;
  35631. private _loadShader;
  35632. /**
  35633. * Gets the vertex shader source code of this effect
  35634. */
  35635. get vertexSourceCode(): string;
  35636. /**
  35637. * Gets the fragment shader source code of this effect
  35638. */
  35639. get fragmentSourceCode(): string;
  35640. /**
  35641. * Recompiles the webGL program
  35642. * @param vertexSourceCode The source code for the vertex shader.
  35643. * @param fragmentSourceCode The source code for the fragment shader.
  35644. * @param onCompiled Callback called when completed.
  35645. * @param onError Callback called on error.
  35646. * @hidden
  35647. */
  35648. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  35649. /**
  35650. * Prepares the effect
  35651. * @hidden
  35652. */
  35653. _prepareEffect(): void;
  35654. private _getShaderCodeAndErrorLine;
  35655. private _processCompilationErrors;
  35656. /**
  35657. * Checks if the effect is supported. (Must be called after compilation)
  35658. */
  35659. get isSupported(): boolean;
  35660. /**
  35661. * Binds a texture to the engine to be used as output of the shader.
  35662. * @param channel Name of the output variable.
  35663. * @param texture Texture to bind.
  35664. * @hidden
  35665. */
  35666. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  35667. /**
  35668. * Sets a texture on the engine to be used in the shader.
  35669. * @param channel Name of the sampler variable.
  35670. * @param texture Texture to set.
  35671. */
  35672. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  35673. /**
  35674. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  35675. * @param channel Name of the sampler variable.
  35676. * @param texture Texture to set.
  35677. */
  35678. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  35679. /**
  35680. * Sets an array of textures on the engine to be used in the shader.
  35681. * @param channel Name of the variable.
  35682. * @param textures Textures to set.
  35683. */
  35684. setTextureArray(channel: string, textures: BaseTexture[]): void;
  35685. /**
  35686. * 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)
  35687. * @param channel Name of the sampler variable.
  35688. * @param postProcess Post process to get the input texture from.
  35689. */
  35690. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  35691. /**
  35692. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  35693. * 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)
  35694. * @param channel Name of the sampler variable.
  35695. * @param postProcess Post process to get the output texture from.
  35696. */
  35697. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  35698. /** @hidden */
  35699. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  35700. /** @hidden */
  35701. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  35702. /** @hidden */
  35703. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  35704. /** @hidden */
  35705. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  35706. /**
  35707. * Binds a buffer to a uniform.
  35708. * @param buffer Buffer to bind.
  35709. * @param name Name of the uniform variable to bind to.
  35710. */
  35711. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  35712. /**
  35713. * Binds block to a uniform.
  35714. * @param blockName Name of the block to bind.
  35715. * @param index Index to bind.
  35716. */
  35717. bindUniformBlock(blockName: string, index: number): void;
  35718. /**
  35719. * Sets an interger value on a uniform variable.
  35720. * @param uniformName Name of the variable.
  35721. * @param value Value to be set.
  35722. * @returns this effect.
  35723. */
  35724. setInt(uniformName: string, value: number): Effect;
  35725. /**
  35726. * Sets an int array on a uniform variable.
  35727. * @param uniformName Name of the variable.
  35728. * @param array array to be set.
  35729. * @returns this effect.
  35730. */
  35731. setIntArray(uniformName: string, array: Int32Array): Effect;
  35732. /**
  35733. * 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)
  35734. * @param uniformName Name of the variable.
  35735. * @param array array to be set.
  35736. * @returns this effect.
  35737. */
  35738. setIntArray2(uniformName: string, array: Int32Array): Effect;
  35739. /**
  35740. * 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)
  35741. * @param uniformName Name of the variable.
  35742. * @param array array to be set.
  35743. * @returns this effect.
  35744. */
  35745. setIntArray3(uniformName: string, array: Int32Array): Effect;
  35746. /**
  35747. * 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)
  35748. * @param uniformName Name of the variable.
  35749. * @param array array to be set.
  35750. * @returns this effect.
  35751. */
  35752. setIntArray4(uniformName: string, array: Int32Array): Effect;
  35753. /**
  35754. * Sets an float array on a uniform variable.
  35755. * @param uniformName Name of the variable.
  35756. * @param array array to be set.
  35757. * @returns this effect.
  35758. */
  35759. setFloatArray(uniformName: string, array: Float32Array): Effect;
  35760. /**
  35761. * 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)
  35762. * @param uniformName Name of the variable.
  35763. * @param array array to be set.
  35764. * @returns this effect.
  35765. */
  35766. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  35767. /**
  35768. * 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)
  35769. * @param uniformName Name of the variable.
  35770. * @param array array to be set.
  35771. * @returns this effect.
  35772. */
  35773. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  35774. /**
  35775. * 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)
  35776. * @param uniformName Name of the variable.
  35777. * @param array array to be set.
  35778. * @returns this effect.
  35779. */
  35780. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  35781. /**
  35782. * Sets an array on a uniform variable.
  35783. * @param uniformName Name of the variable.
  35784. * @param array array to be set.
  35785. * @returns this effect.
  35786. */
  35787. setArray(uniformName: string, array: number[]): Effect;
  35788. /**
  35789. * 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)
  35790. * @param uniformName Name of the variable.
  35791. * @param array array to be set.
  35792. * @returns this effect.
  35793. */
  35794. setArray2(uniformName: string, array: number[]): Effect;
  35795. /**
  35796. * 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)
  35797. * @param uniformName Name of the variable.
  35798. * @param array array to be set.
  35799. * @returns this effect.
  35800. */
  35801. setArray3(uniformName: string, array: number[]): Effect;
  35802. /**
  35803. * 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)
  35804. * @param uniformName Name of the variable.
  35805. * @param array array to be set.
  35806. * @returns this effect.
  35807. */
  35808. setArray4(uniformName: string, array: number[]): Effect;
  35809. /**
  35810. * Sets matrices on a uniform variable.
  35811. * @param uniformName Name of the variable.
  35812. * @param matrices matrices to be set.
  35813. * @returns this effect.
  35814. */
  35815. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  35816. /**
  35817. * Sets matrix on a uniform variable.
  35818. * @param uniformName Name of the variable.
  35819. * @param matrix matrix to be set.
  35820. * @returns this effect.
  35821. */
  35822. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  35823. /**
  35824. * 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)
  35825. * @param uniformName Name of the variable.
  35826. * @param matrix matrix to be set.
  35827. * @returns this effect.
  35828. */
  35829. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  35830. /**
  35831. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  35832. * @param uniformName Name of the variable.
  35833. * @param matrix matrix to be set.
  35834. * @returns this effect.
  35835. */
  35836. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  35837. /**
  35838. * Sets a float on a uniform variable.
  35839. * @param uniformName Name of the variable.
  35840. * @param value value to be set.
  35841. * @returns this effect.
  35842. */
  35843. setFloat(uniformName: string, value: number): Effect;
  35844. /**
  35845. * Sets a boolean on a uniform variable.
  35846. * @param uniformName Name of the variable.
  35847. * @param bool value to be set.
  35848. * @returns this effect.
  35849. */
  35850. setBool(uniformName: string, bool: boolean): Effect;
  35851. /**
  35852. * Sets a Vector2 on a uniform variable.
  35853. * @param uniformName Name of the variable.
  35854. * @param vector2 vector2 to be set.
  35855. * @returns this effect.
  35856. */
  35857. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  35858. /**
  35859. * Sets a float2 on a uniform variable.
  35860. * @param uniformName Name of the variable.
  35861. * @param x First float in float2.
  35862. * @param y Second float in float2.
  35863. * @returns this effect.
  35864. */
  35865. setFloat2(uniformName: string, x: number, y: number): Effect;
  35866. /**
  35867. * Sets a Vector3 on a uniform variable.
  35868. * @param uniformName Name of the variable.
  35869. * @param vector3 Value to be set.
  35870. * @returns this effect.
  35871. */
  35872. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  35873. /**
  35874. * Sets a float3 on a uniform variable.
  35875. * @param uniformName Name of the variable.
  35876. * @param x First float in float3.
  35877. * @param y Second float in float3.
  35878. * @param z Third float in float3.
  35879. * @returns this effect.
  35880. */
  35881. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  35882. /**
  35883. * Sets a Vector4 on a uniform variable.
  35884. * @param uniformName Name of the variable.
  35885. * @param vector4 Value to be set.
  35886. * @returns this effect.
  35887. */
  35888. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  35889. /**
  35890. * Sets a float4 on a uniform variable.
  35891. * @param uniformName Name of the variable.
  35892. * @param x First float in float4.
  35893. * @param y Second float in float4.
  35894. * @param z Third float in float4.
  35895. * @param w Fourth float in float4.
  35896. * @returns this effect.
  35897. */
  35898. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  35899. /**
  35900. * Sets a Color3 on a uniform variable.
  35901. * @param uniformName Name of the variable.
  35902. * @param color3 Value to be set.
  35903. * @returns this effect.
  35904. */
  35905. setColor3(uniformName: string, color3: IColor3Like): Effect;
  35906. /**
  35907. * Sets a Color4 on a uniform variable.
  35908. * @param uniformName Name of the variable.
  35909. * @param color3 Value to be set.
  35910. * @param alpha Alpha value to be set.
  35911. * @returns this effect.
  35912. */
  35913. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  35914. /**
  35915. * Sets a Color4 on a uniform variable
  35916. * @param uniformName defines the name of the variable
  35917. * @param color4 defines the value to be set
  35918. * @returns this effect.
  35919. */
  35920. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  35921. /** Release all associated resources */
  35922. dispose(): void;
  35923. /**
  35924. * This function will add a new shader to the shader store
  35925. * @param name the name of the shader
  35926. * @param pixelShader optional pixel shader content
  35927. * @param vertexShader optional vertex shader content
  35928. */
  35929. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  35930. /**
  35931. * Store of each shader (The can be looked up using effect.key)
  35932. */
  35933. static ShadersStore: {
  35934. [key: string]: string;
  35935. };
  35936. /**
  35937. * Store of each included file for a shader (The can be looked up using effect.key)
  35938. */
  35939. static IncludesShadersStore: {
  35940. [key: string]: string;
  35941. };
  35942. /**
  35943. * Resets the cache of effects.
  35944. */
  35945. static ResetCache(): void;
  35946. }
  35947. }
  35948. declare module "babylonjs/Engines/engineCapabilities" {
  35949. /**
  35950. * Interface used to describe the capabilities of the engine relatively to the current browser
  35951. */
  35952. export interface EngineCapabilities {
  35953. /** Maximum textures units per fragment shader */
  35954. maxTexturesImageUnits: number;
  35955. /** Maximum texture units per vertex shader */
  35956. maxVertexTextureImageUnits: number;
  35957. /** Maximum textures units in the entire pipeline */
  35958. maxCombinedTexturesImageUnits: number;
  35959. /** Maximum texture size */
  35960. maxTextureSize: number;
  35961. /** Maximum texture samples */
  35962. maxSamples?: number;
  35963. /** Maximum cube texture size */
  35964. maxCubemapTextureSize: number;
  35965. /** Maximum render texture size */
  35966. maxRenderTextureSize: number;
  35967. /** Maximum number of vertex attributes */
  35968. maxVertexAttribs: number;
  35969. /** Maximum number of varyings */
  35970. maxVaryingVectors: number;
  35971. /** Maximum number of uniforms per vertex shader */
  35972. maxVertexUniformVectors: number;
  35973. /** Maximum number of uniforms per fragment shader */
  35974. maxFragmentUniformVectors: number;
  35975. /** Defines if standard derivates (dx/dy) are supported */
  35976. standardDerivatives: boolean;
  35977. /** Defines if s3tc texture compression is supported */
  35978. s3tc?: WEBGL_compressed_texture_s3tc;
  35979. /** Defines if pvrtc texture compression is supported */
  35980. pvrtc: any;
  35981. /** Defines if etc1 texture compression is supported */
  35982. etc1: any;
  35983. /** Defines if etc2 texture compression is supported */
  35984. etc2: any;
  35985. /** Defines if astc texture compression is supported */
  35986. astc: any;
  35987. /** Defines if float textures are supported */
  35988. textureFloat: boolean;
  35989. /** Defines if vertex array objects are supported */
  35990. vertexArrayObject: boolean;
  35991. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  35992. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  35993. /** Gets the maximum level of anisotropy supported */
  35994. maxAnisotropy: number;
  35995. /** Defines if instancing is supported */
  35996. instancedArrays: boolean;
  35997. /** Defines if 32 bits indices are supported */
  35998. uintIndices: boolean;
  35999. /** Defines if high precision shaders are supported */
  36000. highPrecisionShaderSupported: boolean;
  36001. /** Defines if depth reading in the fragment shader is supported */
  36002. fragmentDepthSupported: boolean;
  36003. /** Defines if float texture linear filtering is supported*/
  36004. textureFloatLinearFiltering: boolean;
  36005. /** Defines if rendering to float textures is supported */
  36006. textureFloatRender: boolean;
  36007. /** Defines if half float textures are supported*/
  36008. textureHalfFloat: boolean;
  36009. /** Defines if half float texture linear filtering is supported*/
  36010. textureHalfFloatLinearFiltering: boolean;
  36011. /** Defines if rendering to half float textures is supported */
  36012. textureHalfFloatRender: boolean;
  36013. /** Defines if textureLOD shader command is supported */
  36014. textureLOD: boolean;
  36015. /** Defines if draw buffers extension is supported */
  36016. drawBuffersExtension: boolean;
  36017. /** Defines if depth textures are supported */
  36018. depthTextureExtension: boolean;
  36019. /** Defines if float color buffer are supported */
  36020. colorBufferFloat: boolean;
  36021. /** Gets disjoint timer query extension (null if not supported) */
  36022. timerQuery?: EXT_disjoint_timer_query;
  36023. /** Defines if timestamp can be used with timer query */
  36024. canUseTimestampForTimerQuery: boolean;
  36025. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  36026. multiview?: any;
  36027. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  36028. oculusMultiview?: any;
  36029. /** Function used to let the system compiles shaders in background */
  36030. parallelShaderCompile?: {
  36031. COMPLETION_STATUS_KHR: number;
  36032. };
  36033. /** Max number of texture samples for MSAA */
  36034. maxMSAASamples: number;
  36035. /** Defines if the blend min max extension is supported */
  36036. blendMinMax: boolean;
  36037. }
  36038. }
  36039. declare module "babylonjs/States/depthCullingState" {
  36040. import { Nullable } from "babylonjs/types";
  36041. /**
  36042. * @hidden
  36043. **/
  36044. export class DepthCullingState {
  36045. private _isDepthTestDirty;
  36046. private _isDepthMaskDirty;
  36047. private _isDepthFuncDirty;
  36048. private _isCullFaceDirty;
  36049. private _isCullDirty;
  36050. private _isZOffsetDirty;
  36051. private _isFrontFaceDirty;
  36052. private _depthTest;
  36053. private _depthMask;
  36054. private _depthFunc;
  36055. private _cull;
  36056. private _cullFace;
  36057. private _zOffset;
  36058. private _frontFace;
  36059. /**
  36060. * Initializes the state.
  36061. */
  36062. constructor();
  36063. get isDirty(): boolean;
  36064. get zOffset(): number;
  36065. set zOffset(value: number);
  36066. get cullFace(): Nullable<number>;
  36067. set cullFace(value: Nullable<number>);
  36068. get cull(): Nullable<boolean>;
  36069. set cull(value: Nullable<boolean>);
  36070. get depthFunc(): Nullable<number>;
  36071. set depthFunc(value: Nullable<number>);
  36072. get depthMask(): boolean;
  36073. set depthMask(value: boolean);
  36074. get depthTest(): boolean;
  36075. set depthTest(value: boolean);
  36076. get frontFace(): Nullable<number>;
  36077. set frontFace(value: Nullable<number>);
  36078. reset(): void;
  36079. apply(gl: WebGLRenderingContext): void;
  36080. }
  36081. }
  36082. declare module "babylonjs/States/stencilState" {
  36083. /**
  36084. * @hidden
  36085. **/
  36086. export class StencilState {
  36087. /** 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 */
  36088. static readonly ALWAYS: number;
  36089. /** Passed to stencilOperation to specify that stencil value must be kept */
  36090. static readonly KEEP: number;
  36091. /** Passed to stencilOperation to specify that stencil value must be replaced */
  36092. static readonly REPLACE: number;
  36093. private _isStencilTestDirty;
  36094. private _isStencilMaskDirty;
  36095. private _isStencilFuncDirty;
  36096. private _isStencilOpDirty;
  36097. private _stencilTest;
  36098. private _stencilMask;
  36099. private _stencilFunc;
  36100. private _stencilFuncRef;
  36101. private _stencilFuncMask;
  36102. private _stencilOpStencilFail;
  36103. private _stencilOpDepthFail;
  36104. private _stencilOpStencilDepthPass;
  36105. get isDirty(): boolean;
  36106. get stencilFunc(): number;
  36107. set stencilFunc(value: number);
  36108. get stencilFuncRef(): number;
  36109. set stencilFuncRef(value: number);
  36110. get stencilFuncMask(): number;
  36111. set stencilFuncMask(value: number);
  36112. get stencilOpStencilFail(): number;
  36113. set stencilOpStencilFail(value: number);
  36114. get stencilOpDepthFail(): number;
  36115. set stencilOpDepthFail(value: number);
  36116. get stencilOpStencilDepthPass(): number;
  36117. set stencilOpStencilDepthPass(value: number);
  36118. get stencilMask(): number;
  36119. set stencilMask(value: number);
  36120. get stencilTest(): boolean;
  36121. set stencilTest(value: boolean);
  36122. constructor();
  36123. reset(): void;
  36124. apply(gl: WebGLRenderingContext): void;
  36125. }
  36126. }
  36127. declare module "babylonjs/States/alphaCullingState" {
  36128. /**
  36129. * @hidden
  36130. **/
  36131. export class AlphaState {
  36132. private _isAlphaBlendDirty;
  36133. private _isBlendFunctionParametersDirty;
  36134. private _isBlendEquationParametersDirty;
  36135. private _isBlendConstantsDirty;
  36136. private _alphaBlend;
  36137. private _blendFunctionParameters;
  36138. private _blendEquationParameters;
  36139. private _blendConstants;
  36140. /**
  36141. * Initializes the state.
  36142. */
  36143. constructor();
  36144. get isDirty(): boolean;
  36145. get alphaBlend(): boolean;
  36146. set alphaBlend(value: boolean);
  36147. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  36148. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  36149. setAlphaEquationParameters(rgb: number, alpha: number): void;
  36150. reset(): void;
  36151. apply(gl: WebGLRenderingContext): void;
  36152. }
  36153. }
  36154. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  36155. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  36156. /** @hidden */
  36157. export class WebGL2ShaderProcessor implements IShaderProcessor {
  36158. attributeProcessor(attribute: string): string;
  36159. varyingProcessor(varying: string, isFragment: boolean): string;
  36160. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  36161. }
  36162. }
  36163. declare module "babylonjs/Engines/instancingAttributeInfo" {
  36164. /**
  36165. * Interface for attribute information associated with buffer instanciation
  36166. */
  36167. export interface InstancingAttributeInfo {
  36168. /**
  36169. * Name of the GLSL attribute
  36170. * if attribute index is not specified, this is used to retrieve the index from the effect
  36171. */
  36172. attributeName: string;
  36173. /**
  36174. * Index/offset of the attribute in the vertex shader
  36175. * if not specified, this will be computes from the name.
  36176. */
  36177. index?: number;
  36178. /**
  36179. * size of the attribute, 1, 2, 3 or 4
  36180. */
  36181. attributeSize: number;
  36182. /**
  36183. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  36184. */
  36185. offset: number;
  36186. /**
  36187. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  36188. * default to 1
  36189. */
  36190. divisor?: number;
  36191. /**
  36192. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  36193. * default is FLOAT
  36194. */
  36195. attributeType?: number;
  36196. /**
  36197. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  36198. */
  36199. normalized?: boolean;
  36200. }
  36201. }
  36202. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  36203. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36204. import { Nullable } from "babylonjs/types";
  36205. module "babylonjs/Engines/thinEngine" {
  36206. interface ThinEngine {
  36207. /**
  36208. * Update a video texture
  36209. * @param texture defines the texture to update
  36210. * @param video defines the video element to use
  36211. * @param invertY defines if data must be stored with Y axis inverted
  36212. */
  36213. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  36214. }
  36215. }
  36216. }
  36217. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  36218. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36219. import { Nullable } from "babylonjs/types";
  36220. module "babylonjs/Engines/thinEngine" {
  36221. interface ThinEngine {
  36222. /**
  36223. * Creates a dynamic texture
  36224. * @param width defines the width of the texture
  36225. * @param height defines the height of the texture
  36226. * @param generateMipMaps defines if the engine should generate the mip levels
  36227. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  36228. * @returns the dynamic texture inside an InternalTexture
  36229. */
  36230. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  36231. /**
  36232. * Update the content of a dynamic texture
  36233. * @param texture defines the texture to update
  36234. * @param canvas defines the canvas containing the source
  36235. * @param invertY defines if data must be stored with Y axis inverted
  36236. * @param premulAlpha defines if alpha is stored as premultiplied
  36237. * @param format defines the format of the data
  36238. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  36239. */
  36240. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  36241. }
  36242. }
  36243. }
  36244. declare module "babylonjs/Materials/Textures/videoTexture" {
  36245. import { Observable } from "babylonjs/Misc/observable";
  36246. import { Nullable } from "babylonjs/types";
  36247. import { Scene } from "babylonjs/scene";
  36248. import { Texture } from "babylonjs/Materials/Textures/texture";
  36249. import "babylonjs/Engines/Extensions/engine.videoTexture";
  36250. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  36251. /**
  36252. * Settings for finer control over video usage
  36253. */
  36254. export interface VideoTextureSettings {
  36255. /**
  36256. * Applies `autoplay` to video, if specified
  36257. */
  36258. autoPlay?: boolean;
  36259. /**
  36260. * Applies `loop` to video, if specified
  36261. */
  36262. loop?: boolean;
  36263. /**
  36264. * Automatically updates internal texture from video at every frame in the render loop
  36265. */
  36266. autoUpdateTexture: boolean;
  36267. /**
  36268. * Image src displayed during the video loading or until the user interacts with the video.
  36269. */
  36270. poster?: string;
  36271. }
  36272. /**
  36273. * If you want to display a video in your scene, this is the special texture for that.
  36274. * This special texture works similar to other textures, with the exception of a few parameters.
  36275. * @see https://doc.babylonjs.com/how_to/video_texture
  36276. */
  36277. export class VideoTexture extends Texture {
  36278. /**
  36279. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  36280. */
  36281. readonly autoUpdateTexture: boolean;
  36282. /**
  36283. * The video instance used by the texture internally
  36284. */
  36285. readonly video: HTMLVideoElement;
  36286. private _onUserActionRequestedObservable;
  36287. /**
  36288. * Event triggerd when a dom action is required by the user to play the video.
  36289. * This happens due to recent changes in browser policies preventing video to auto start.
  36290. */
  36291. get onUserActionRequestedObservable(): Observable<Texture>;
  36292. private _generateMipMaps;
  36293. private _stillImageCaptured;
  36294. private _displayingPosterTexture;
  36295. private _settings;
  36296. private _createInternalTextureOnEvent;
  36297. private _frameId;
  36298. private _currentSrc;
  36299. /**
  36300. * Creates a video texture.
  36301. * If you want to display a video in your scene, this is the special texture for that.
  36302. * This special texture works similar to other textures, with the exception of a few parameters.
  36303. * @see https://doc.babylonjs.com/how_to/video_texture
  36304. * @param name optional name, will detect from video source, if not defined
  36305. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  36306. * @param scene is obviously the current scene.
  36307. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  36308. * @param invertY is false by default but can be used to invert video on Y axis
  36309. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  36310. * @param settings allows finer control over video usage
  36311. */
  36312. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  36313. private _getName;
  36314. private _getVideo;
  36315. private _createInternalTexture;
  36316. private reset;
  36317. /**
  36318. * @hidden Internal method to initiate `update`.
  36319. */
  36320. _rebuild(): void;
  36321. /**
  36322. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  36323. */
  36324. update(): void;
  36325. /**
  36326. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  36327. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  36328. */
  36329. updateTexture(isVisible: boolean): void;
  36330. protected _updateInternalTexture: () => void;
  36331. /**
  36332. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  36333. * @param url New url.
  36334. */
  36335. updateURL(url: string): void;
  36336. /**
  36337. * Clones the texture.
  36338. * @returns the cloned texture
  36339. */
  36340. clone(): VideoTexture;
  36341. /**
  36342. * Dispose the texture and release its associated resources.
  36343. */
  36344. dispose(): void;
  36345. /**
  36346. * Creates a video texture straight from a stream.
  36347. * @param scene Define the scene the texture should be created in
  36348. * @param stream Define the stream the texture should be created from
  36349. * @returns The created video texture as a promise
  36350. */
  36351. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  36352. /**
  36353. * Creates a video texture straight from your WebCam video feed.
  36354. * @param scene Define the scene the texture should be created in
  36355. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  36356. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  36357. * @returns The created video texture as a promise
  36358. */
  36359. static CreateFromWebCamAsync(scene: Scene, constraints: {
  36360. minWidth: number;
  36361. maxWidth: number;
  36362. minHeight: number;
  36363. maxHeight: number;
  36364. deviceId: string;
  36365. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  36366. /**
  36367. * Creates a video texture straight from your WebCam video feed.
  36368. * @param scene Define the scene the texture should be created in
  36369. * @param onReady Define a callback to triggered once the texture will be ready
  36370. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  36371. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  36372. */
  36373. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  36374. minWidth: number;
  36375. maxWidth: number;
  36376. minHeight: number;
  36377. maxHeight: number;
  36378. deviceId: string;
  36379. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  36380. }
  36381. }
  36382. declare module "babylonjs/Engines/thinEngine" {
  36383. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  36384. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  36385. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  36386. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  36387. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  36388. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  36389. import { Observable } from "babylonjs/Misc/observable";
  36390. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  36391. import { StencilState } from "babylonjs/States/stencilState";
  36392. import { AlphaState } from "babylonjs/States/alphaCullingState";
  36393. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36394. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  36395. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  36396. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  36397. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  36398. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  36399. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  36400. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  36401. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36402. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  36403. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  36404. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  36405. import { WebRequest } from "babylonjs/Misc/webRequest";
  36406. import { LoadFileError } from "babylonjs/Misc/fileTools";
  36407. /**
  36408. * Defines the interface used by objects working like Scene
  36409. * @hidden
  36410. */
  36411. export interface ISceneLike {
  36412. _addPendingData(data: any): void;
  36413. _removePendingData(data: any): void;
  36414. offlineProvider: IOfflineProvider;
  36415. }
  36416. /** Interface defining initialization parameters for Engine class */
  36417. export interface EngineOptions extends WebGLContextAttributes {
  36418. /**
  36419. * Defines if the engine should no exceed a specified device ratio
  36420. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  36421. */
  36422. limitDeviceRatio?: number;
  36423. /**
  36424. * Defines if webvr should be enabled automatically
  36425. * @see https://doc.babylonjs.com/how_to/webvr_camera
  36426. */
  36427. autoEnableWebVR?: boolean;
  36428. /**
  36429. * Defines if webgl2 should be turned off even if supported
  36430. * @see https://doc.babylonjs.com/features/webgl2
  36431. */
  36432. disableWebGL2Support?: boolean;
  36433. /**
  36434. * Defines if webaudio should be initialized as well
  36435. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36436. */
  36437. audioEngine?: boolean;
  36438. /**
  36439. * Defines if animations should run using a deterministic lock step
  36440. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36441. */
  36442. deterministicLockstep?: boolean;
  36443. /** Defines the maximum steps to use with deterministic lock step mode */
  36444. lockstepMaxSteps?: number;
  36445. /** Defines the seconds between each deterministic lock step */
  36446. timeStep?: number;
  36447. /**
  36448. * Defines that engine should ignore context lost events
  36449. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  36450. */
  36451. doNotHandleContextLost?: boolean;
  36452. /**
  36453. * Defines that engine should ignore modifying touch action attribute and style
  36454. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  36455. */
  36456. doNotHandleTouchAction?: boolean;
  36457. /**
  36458. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  36459. */
  36460. useHighPrecisionFloats?: boolean;
  36461. /**
  36462. * Make the canvas XR Compatible for XR sessions
  36463. */
  36464. xrCompatible?: boolean;
  36465. /**
  36466. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  36467. */
  36468. useHighPrecisionMatrix?: boolean;
  36469. }
  36470. /**
  36471. * The base engine class (root of all engines)
  36472. */
  36473. export class ThinEngine {
  36474. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  36475. static ExceptionList: ({
  36476. key: string;
  36477. capture: string;
  36478. captureConstraint: number;
  36479. targets: string[];
  36480. } | {
  36481. key: string;
  36482. capture: null;
  36483. captureConstraint: null;
  36484. targets: string[];
  36485. })[];
  36486. /** @hidden */
  36487. static _TextureLoaders: IInternalTextureLoader[];
  36488. /**
  36489. * Returns the current npm package of the sdk
  36490. */
  36491. static get NpmPackage(): string;
  36492. /**
  36493. * Returns the current version of the framework
  36494. */
  36495. static get Version(): string;
  36496. /**
  36497. * Returns a string describing the current engine
  36498. */
  36499. get description(): string;
  36500. /**
  36501. * Gets or sets the epsilon value used by collision engine
  36502. */
  36503. static CollisionsEpsilon: number;
  36504. /**
  36505. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  36506. */
  36507. static get ShadersRepository(): string;
  36508. static set ShadersRepository(value: string);
  36509. /** @hidden */
  36510. _shaderProcessor: IShaderProcessor;
  36511. /**
  36512. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  36513. */
  36514. forcePOTTextures: boolean;
  36515. /**
  36516. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  36517. */
  36518. isFullscreen: boolean;
  36519. /**
  36520. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  36521. */
  36522. cullBackFaces: boolean;
  36523. /**
  36524. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  36525. */
  36526. renderEvenInBackground: boolean;
  36527. /**
  36528. * Gets or sets a boolean indicating that cache can be kept between frames
  36529. */
  36530. preventCacheWipeBetweenFrames: boolean;
  36531. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  36532. validateShaderPrograms: boolean;
  36533. /**
  36534. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  36535. * This can provide greater z depth for distant objects.
  36536. */
  36537. useReverseDepthBuffer: boolean;
  36538. /**
  36539. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  36540. */
  36541. disableUniformBuffers: boolean;
  36542. /** @hidden */
  36543. _uniformBuffers: UniformBuffer[];
  36544. /**
  36545. * Gets a boolean indicating that the engine supports uniform buffers
  36546. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  36547. */
  36548. get supportsUniformBuffers(): boolean;
  36549. /** @hidden */
  36550. _gl: WebGLRenderingContext;
  36551. /** @hidden */
  36552. _webGLVersion: number;
  36553. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  36554. protected _windowIsBackground: boolean;
  36555. protected _creationOptions: EngineOptions;
  36556. protected _highPrecisionShadersAllowed: boolean;
  36557. /** @hidden */
  36558. get _shouldUseHighPrecisionShader(): boolean;
  36559. /**
  36560. * Gets a boolean indicating that only power of 2 textures are supported
  36561. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  36562. */
  36563. get needPOTTextures(): boolean;
  36564. /** @hidden */
  36565. _badOS: boolean;
  36566. /** @hidden */
  36567. _badDesktopOS: boolean;
  36568. private _hardwareScalingLevel;
  36569. /** @hidden */
  36570. _caps: EngineCapabilities;
  36571. private _isStencilEnable;
  36572. private _glVersion;
  36573. private _glRenderer;
  36574. private _glVendor;
  36575. /** @hidden */
  36576. _videoTextureSupported: boolean;
  36577. protected _renderingQueueLaunched: boolean;
  36578. protected _activeRenderLoops: (() => void)[];
  36579. /**
  36580. * Observable signaled when a context lost event is raised
  36581. */
  36582. onContextLostObservable: Observable<ThinEngine>;
  36583. /**
  36584. * Observable signaled when a context restored event is raised
  36585. */
  36586. onContextRestoredObservable: Observable<ThinEngine>;
  36587. private _onContextLost;
  36588. private _onContextRestored;
  36589. protected _contextWasLost: boolean;
  36590. /** @hidden */
  36591. _doNotHandleContextLost: boolean;
  36592. /**
  36593. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  36594. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  36595. */
  36596. get doNotHandleContextLost(): boolean;
  36597. set doNotHandleContextLost(value: boolean);
  36598. /**
  36599. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  36600. */
  36601. disableVertexArrayObjects: boolean;
  36602. /** @hidden */
  36603. protected _colorWrite: boolean;
  36604. /** @hidden */
  36605. protected _colorWriteChanged: boolean;
  36606. /** @hidden */
  36607. protected _depthCullingState: DepthCullingState;
  36608. /** @hidden */
  36609. protected _stencilState: StencilState;
  36610. /** @hidden */
  36611. _alphaState: AlphaState;
  36612. /** @hidden */
  36613. _alphaMode: number;
  36614. /** @hidden */
  36615. _alphaEquation: number;
  36616. /** @hidden */
  36617. _internalTexturesCache: InternalTexture[];
  36618. /** @hidden */
  36619. protected _activeChannel: number;
  36620. private _currentTextureChannel;
  36621. /** @hidden */
  36622. protected _boundTexturesCache: {
  36623. [key: string]: Nullable<InternalTexture>;
  36624. };
  36625. /** @hidden */
  36626. protected _currentEffect: Nullable<Effect>;
  36627. /** @hidden */
  36628. protected _currentProgram: Nullable<WebGLProgram>;
  36629. private _compiledEffects;
  36630. private _vertexAttribArraysEnabled;
  36631. /** @hidden */
  36632. protected _cachedViewport: Nullable<IViewportLike>;
  36633. private _cachedVertexArrayObject;
  36634. /** @hidden */
  36635. protected _cachedVertexBuffers: any;
  36636. /** @hidden */
  36637. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  36638. /** @hidden */
  36639. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  36640. /** @hidden */
  36641. _currentRenderTarget: Nullable<InternalTexture>;
  36642. private _uintIndicesCurrentlySet;
  36643. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  36644. /** @hidden */
  36645. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  36646. /** @hidden */
  36647. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  36648. private _currentBufferPointers;
  36649. private _currentInstanceLocations;
  36650. private _currentInstanceBuffers;
  36651. private _textureUnits;
  36652. /** @hidden */
  36653. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  36654. /** @hidden */
  36655. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  36656. /** @hidden */
  36657. _boundRenderFunction: any;
  36658. private _vaoRecordInProgress;
  36659. private _mustWipeVertexAttributes;
  36660. private _emptyTexture;
  36661. private _emptyCubeTexture;
  36662. private _emptyTexture3D;
  36663. private _emptyTexture2DArray;
  36664. /** @hidden */
  36665. _frameHandler: number;
  36666. private _nextFreeTextureSlots;
  36667. private _maxSimultaneousTextures;
  36668. private _activeRequests;
  36669. /** @hidden */
  36670. _transformTextureUrl: Nullable<(url: string) => string>;
  36671. protected get _supportsHardwareTextureRescaling(): boolean;
  36672. private _framebufferDimensionsObject;
  36673. /**
  36674. * sets the object from which width and height will be taken from when getting render width and height
  36675. * Will fallback to the gl object
  36676. * @param dimensions the framebuffer width and height that will be used.
  36677. */
  36678. set framebufferDimensionsObject(dimensions: Nullable<{
  36679. framebufferWidth: number;
  36680. framebufferHeight: number;
  36681. }>);
  36682. /**
  36683. * Gets the current viewport
  36684. */
  36685. get currentViewport(): Nullable<IViewportLike>;
  36686. /**
  36687. * Gets the default empty texture
  36688. */
  36689. get emptyTexture(): InternalTexture;
  36690. /**
  36691. * Gets the default empty 3D texture
  36692. */
  36693. get emptyTexture3D(): InternalTexture;
  36694. /**
  36695. * Gets the default empty 2D array texture
  36696. */
  36697. get emptyTexture2DArray(): InternalTexture;
  36698. /**
  36699. * Gets the default empty cube texture
  36700. */
  36701. get emptyCubeTexture(): InternalTexture;
  36702. /**
  36703. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  36704. */
  36705. readonly premultipliedAlpha: boolean;
  36706. /**
  36707. * Observable event triggered before each texture is initialized
  36708. */
  36709. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  36710. /**
  36711. * Creates a new engine
  36712. * @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
  36713. * @param antialias defines enable antialiasing (default: false)
  36714. * @param options defines further options to be sent to the getContext() function
  36715. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  36716. */
  36717. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  36718. private _rebuildInternalTextures;
  36719. private _rebuildEffects;
  36720. /**
  36721. * Gets a boolean indicating if all created effects are ready
  36722. * @returns true if all effects are ready
  36723. */
  36724. areAllEffectsReady(): boolean;
  36725. protected _rebuildBuffers(): void;
  36726. protected _initGLContext(): void;
  36727. /**
  36728. * Gets version of the current webGL context
  36729. */
  36730. get webGLVersion(): number;
  36731. /**
  36732. * Gets a string identifying the name of the class
  36733. * @returns "Engine" string
  36734. */
  36735. getClassName(): string;
  36736. /**
  36737. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  36738. */
  36739. get isStencilEnable(): boolean;
  36740. /** @hidden */
  36741. _prepareWorkingCanvas(): void;
  36742. /**
  36743. * Reset the texture cache to empty state
  36744. */
  36745. resetTextureCache(): void;
  36746. /**
  36747. * Gets an object containing information about the current webGL context
  36748. * @returns an object containing the vender, the renderer and the version of the current webGL context
  36749. */
  36750. getGlInfo(): {
  36751. vendor: string;
  36752. renderer: string;
  36753. version: string;
  36754. };
  36755. /**
  36756. * Defines the hardware scaling level.
  36757. * By default the hardware scaling level is computed from the window device ratio.
  36758. * 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.
  36759. * @param level defines the level to use
  36760. */
  36761. setHardwareScalingLevel(level: number): void;
  36762. /**
  36763. * Gets the current hardware scaling level.
  36764. * By default the hardware scaling level is computed from the window device ratio.
  36765. * 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.
  36766. * @returns a number indicating the current hardware scaling level
  36767. */
  36768. getHardwareScalingLevel(): number;
  36769. /**
  36770. * Gets the list of loaded textures
  36771. * @returns an array containing all loaded textures
  36772. */
  36773. getLoadedTexturesCache(): InternalTexture[];
  36774. /**
  36775. * Gets the object containing all engine capabilities
  36776. * @returns the EngineCapabilities object
  36777. */
  36778. getCaps(): EngineCapabilities;
  36779. /**
  36780. * stop executing a render loop function and remove it from the execution array
  36781. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  36782. */
  36783. stopRenderLoop(renderFunction?: () => void): void;
  36784. /** @hidden */
  36785. _renderLoop(): void;
  36786. /**
  36787. * Gets the HTML canvas attached with the current webGL context
  36788. * @returns a HTML canvas
  36789. */
  36790. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  36791. /**
  36792. * Gets host window
  36793. * @returns the host window object
  36794. */
  36795. getHostWindow(): Nullable<Window>;
  36796. /**
  36797. * Gets the current render width
  36798. * @param useScreen defines if screen size must be used (or the current render target if any)
  36799. * @returns a number defining the current render width
  36800. */
  36801. getRenderWidth(useScreen?: boolean): number;
  36802. /**
  36803. * Gets the current render height
  36804. * @param useScreen defines if screen size must be used (or the current render target if any)
  36805. * @returns a number defining the current render height
  36806. */
  36807. getRenderHeight(useScreen?: boolean): number;
  36808. /**
  36809. * Can be used to override the current requestAnimationFrame requester.
  36810. * @hidden
  36811. */
  36812. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  36813. /**
  36814. * Register and execute a render loop. The engine can have more than one render function
  36815. * @param renderFunction defines the function to continuously execute
  36816. */
  36817. runRenderLoop(renderFunction: () => void): void;
  36818. /**
  36819. * Clear the current render buffer or the current render target (if any is set up)
  36820. * @param color defines the color to use
  36821. * @param backBuffer defines if the back buffer must be cleared
  36822. * @param depth defines if the depth buffer must be cleared
  36823. * @param stencil defines if the stencil buffer must be cleared
  36824. */
  36825. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  36826. private _viewportCached;
  36827. /** @hidden */
  36828. _viewport(x: number, y: number, width: number, height: number): void;
  36829. /**
  36830. * Set the WebGL's viewport
  36831. * @param viewport defines the viewport element to be used
  36832. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  36833. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  36834. */
  36835. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  36836. /**
  36837. * Begin a new frame
  36838. */
  36839. beginFrame(): void;
  36840. /**
  36841. * Enf the current frame
  36842. */
  36843. endFrame(): void;
  36844. /**
  36845. * Resize the view according to the canvas' size
  36846. */
  36847. resize(): void;
  36848. /**
  36849. * Force a specific size of the canvas
  36850. * @param width defines the new canvas' width
  36851. * @param height defines the new canvas' height
  36852. * @returns true if the size was changed
  36853. */
  36854. setSize(width: number, height: number): boolean;
  36855. /**
  36856. * Binds the frame buffer to the specified texture.
  36857. * @param texture The texture to render to or null for the default canvas
  36858. * @param faceIndex The face of the texture to render to in case of cube texture
  36859. * @param requiredWidth The width of the target to render to
  36860. * @param requiredHeight The height of the target to render to
  36861. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  36862. * @param lodLevel defines the lod level to bind to the frame buffer
  36863. * @param layer defines the 2d array index to bind to frame buffer to
  36864. */
  36865. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  36866. /** @hidden */
  36867. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  36868. /**
  36869. * Unbind the current render target texture from the webGL context
  36870. * @param texture defines the render target texture to unbind
  36871. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  36872. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  36873. */
  36874. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  36875. /**
  36876. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  36877. */
  36878. flushFramebuffer(): void;
  36879. /**
  36880. * Unbind the current render target and bind the default framebuffer
  36881. */
  36882. restoreDefaultFramebuffer(): void;
  36883. /** @hidden */
  36884. protected _resetVertexBufferBinding(): void;
  36885. /**
  36886. * Creates a vertex buffer
  36887. * @param data the data for the vertex buffer
  36888. * @returns the new WebGL static buffer
  36889. */
  36890. createVertexBuffer(data: DataArray): DataBuffer;
  36891. private _createVertexBuffer;
  36892. /**
  36893. * Creates a dynamic vertex buffer
  36894. * @param data the data for the dynamic vertex buffer
  36895. * @returns the new WebGL dynamic buffer
  36896. */
  36897. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  36898. protected _resetIndexBufferBinding(): void;
  36899. /**
  36900. * Creates a new index buffer
  36901. * @param indices defines the content of the index buffer
  36902. * @param updatable defines if the index buffer must be updatable
  36903. * @returns a new webGL buffer
  36904. */
  36905. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  36906. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  36907. /**
  36908. * Bind a webGL buffer to the webGL context
  36909. * @param buffer defines the buffer to bind
  36910. */
  36911. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  36912. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  36913. private bindBuffer;
  36914. /**
  36915. * update the bound buffer with the given data
  36916. * @param data defines the data to update
  36917. */
  36918. updateArrayBuffer(data: Float32Array): void;
  36919. private _vertexAttribPointer;
  36920. /** @hidden */
  36921. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  36922. private _bindVertexBuffersAttributes;
  36923. /**
  36924. * Records a vertex array object
  36925. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  36926. * @param vertexBuffers defines the list of vertex buffers to store
  36927. * @param indexBuffer defines the index buffer to store
  36928. * @param effect defines the effect to store
  36929. * @returns the new vertex array object
  36930. */
  36931. recordVertexArrayObject(vertexBuffers: {
  36932. [key: string]: VertexBuffer;
  36933. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  36934. /**
  36935. * Bind a specific vertex array object
  36936. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  36937. * @param vertexArrayObject defines the vertex array object to bind
  36938. * @param indexBuffer defines the index buffer to bind
  36939. */
  36940. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  36941. /**
  36942. * Bind webGl buffers directly to the webGL context
  36943. * @param vertexBuffer defines the vertex buffer to bind
  36944. * @param indexBuffer defines the index buffer to bind
  36945. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  36946. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  36947. * @param effect defines the effect associated with the vertex buffer
  36948. */
  36949. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  36950. private _unbindVertexArrayObject;
  36951. /**
  36952. * Bind a list of vertex buffers to the webGL context
  36953. * @param vertexBuffers defines the list of vertex buffers to bind
  36954. * @param indexBuffer defines the index buffer to bind
  36955. * @param effect defines the effect associated with the vertex buffers
  36956. */
  36957. bindBuffers(vertexBuffers: {
  36958. [key: string]: Nullable<VertexBuffer>;
  36959. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  36960. /**
  36961. * Unbind all instance attributes
  36962. */
  36963. unbindInstanceAttributes(): void;
  36964. /**
  36965. * Release and free the memory of a vertex array object
  36966. * @param vao defines the vertex array object to delete
  36967. */
  36968. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  36969. /** @hidden */
  36970. _releaseBuffer(buffer: DataBuffer): boolean;
  36971. protected _deleteBuffer(buffer: DataBuffer): void;
  36972. /**
  36973. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  36974. * @param instancesBuffer defines the webGL buffer to update and bind
  36975. * @param data defines the data to store in the buffer
  36976. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  36977. */
  36978. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  36979. /**
  36980. * Bind the content of a webGL buffer used with instantiation
  36981. * @param instancesBuffer defines the webGL buffer to bind
  36982. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  36983. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  36984. */
  36985. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  36986. /**
  36987. * Disable the instance attribute corresponding to the name in parameter
  36988. * @param name defines the name of the attribute to disable
  36989. */
  36990. disableInstanceAttributeByName(name: string): void;
  36991. /**
  36992. * Disable the instance attribute corresponding to the location in parameter
  36993. * @param attributeLocation defines the attribute location of the attribute to disable
  36994. */
  36995. disableInstanceAttribute(attributeLocation: number): void;
  36996. /**
  36997. * Disable the attribute corresponding to the location in parameter
  36998. * @param attributeLocation defines the attribute location of the attribute to disable
  36999. */
  37000. disableAttributeByIndex(attributeLocation: number): void;
  37001. /**
  37002. * Send a draw order
  37003. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  37004. * @param indexStart defines the starting index
  37005. * @param indexCount defines the number of index to draw
  37006. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37007. */
  37008. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  37009. /**
  37010. * Draw a list of points
  37011. * @param verticesStart defines the index of first vertex to draw
  37012. * @param verticesCount defines the count of vertices to draw
  37013. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37014. */
  37015. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  37016. /**
  37017. * Draw a list of unindexed primitives
  37018. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  37019. * @param verticesStart defines the index of first vertex to draw
  37020. * @param verticesCount defines the count of vertices to draw
  37021. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37022. */
  37023. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  37024. /**
  37025. * Draw a list of indexed primitives
  37026. * @param fillMode defines the primitive to use
  37027. * @param indexStart defines the starting index
  37028. * @param indexCount defines the number of index to draw
  37029. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37030. */
  37031. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  37032. /**
  37033. * Draw a list of unindexed primitives
  37034. * @param fillMode defines the primitive to use
  37035. * @param verticesStart defines the index of first vertex to draw
  37036. * @param verticesCount defines the count of vertices to draw
  37037. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37038. */
  37039. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  37040. private _drawMode;
  37041. /** @hidden */
  37042. protected _reportDrawCall(): void;
  37043. /** @hidden */
  37044. _releaseEffect(effect: Effect): void;
  37045. /** @hidden */
  37046. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  37047. /**
  37048. * Create a new effect (used to store vertex/fragment shaders)
  37049. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  37050. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  37051. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  37052. * @param samplers defines an array of string used to represent textures
  37053. * @param defines defines the string containing the defines to use to compile the shaders
  37054. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  37055. * @param onCompiled defines a function to call when the effect creation is successful
  37056. * @param onError defines a function to call when the effect creation has failed
  37057. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  37058. * @returns the new Effect
  37059. */
  37060. 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;
  37061. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  37062. private _compileShader;
  37063. private _compileRawShader;
  37064. /** @hidden */
  37065. _getShaderSource(shader: WebGLShader): Nullable<string>;
  37066. /**
  37067. * Directly creates a webGL program
  37068. * @param pipelineContext defines the pipeline context to attach to
  37069. * @param vertexCode defines the vertex shader code to use
  37070. * @param fragmentCode defines the fragment shader code to use
  37071. * @param context defines the webGL context to use (if not set, the current one will be used)
  37072. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  37073. * @returns the new webGL program
  37074. */
  37075. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37076. /**
  37077. * Creates a webGL program
  37078. * @param pipelineContext defines the pipeline context to attach to
  37079. * @param vertexCode defines the vertex shader code to use
  37080. * @param fragmentCode defines the fragment shader code to use
  37081. * @param defines defines the string containing the defines to use to compile the shaders
  37082. * @param context defines the webGL context to use (if not set, the current one will be used)
  37083. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  37084. * @returns the new webGL program
  37085. */
  37086. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37087. /**
  37088. * Creates a new pipeline context
  37089. * @returns the new pipeline
  37090. */
  37091. createPipelineContext(): IPipelineContext;
  37092. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37093. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  37094. /** @hidden */
  37095. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  37096. /** @hidden */
  37097. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  37098. /** @hidden */
  37099. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  37100. /**
  37101. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  37102. * @param pipelineContext defines the pipeline context to use
  37103. * @param uniformsNames defines the list of uniform names
  37104. * @returns an array of webGL uniform locations
  37105. */
  37106. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  37107. /**
  37108. * Gets the lsit of active attributes for a given webGL program
  37109. * @param pipelineContext defines the pipeline context to use
  37110. * @param attributesNames defines the list of attribute names to get
  37111. * @returns an array of indices indicating the offset of each attribute
  37112. */
  37113. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  37114. /**
  37115. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  37116. * @param effect defines the effect to activate
  37117. */
  37118. enableEffect(effect: Nullable<Effect>): void;
  37119. /**
  37120. * Set the value of an uniform to a number (int)
  37121. * @param uniform defines the webGL uniform location where to store the value
  37122. * @param value defines the int number to store
  37123. */
  37124. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  37125. /**
  37126. * Set the value of an uniform to an array of int32
  37127. * @param uniform defines the webGL uniform location where to store the value
  37128. * @param array defines the array of int32 to store
  37129. */
  37130. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  37131. /**
  37132. * Set the value of an uniform to an array of int32 (stored as vec2)
  37133. * @param uniform defines the webGL uniform location where to store the value
  37134. * @param array defines the array of int32 to store
  37135. */
  37136. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  37137. /**
  37138. * Set the value of an uniform to an array of int32 (stored as vec3)
  37139. * @param uniform defines the webGL uniform location where to store the value
  37140. * @param array defines the array of int32 to store
  37141. */
  37142. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  37143. /**
  37144. * Set the value of an uniform to an array of int32 (stored as vec4)
  37145. * @param uniform defines the webGL uniform location where to store the value
  37146. * @param array defines the array of int32 to store
  37147. */
  37148. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  37149. /**
  37150. * Set the value of an uniform to an array of number
  37151. * @param uniform defines the webGL uniform location where to store the value
  37152. * @param array defines the array of number to store
  37153. */
  37154. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  37155. /**
  37156. * Set the value of an uniform to an array of number (stored as vec2)
  37157. * @param uniform defines the webGL uniform location where to store the value
  37158. * @param array defines the array of number to store
  37159. */
  37160. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  37161. /**
  37162. * Set the value of an uniform to an array of number (stored as vec3)
  37163. * @param uniform defines the webGL uniform location where to store the value
  37164. * @param array defines the array of number to store
  37165. */
  37166. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  37167. /**
  37168. * Set the value of an uniform to an array of number (stored as vec4)
  37169. * @param uniform defines the webGL uniform location where to store the value
  37170. * @param array defines the array of number to store
  37171. */
  37172. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  37173. /**
  37174. * Set the value of an uniform to an array of float32 (stored as matrices)
  37175. * @param uniform defines the webGL uniform location where to store the value
  37176. * @param matrices defines the array of float32 to store
  37177. */
  37178. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  37179. /**
  37180. * Set the value of an uniform to a matrix (3x3)
  37181. * @param uniform defines the webGL uniform location where to store the value
  37182. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  37183. */
  37184. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  37185. /**
  37186. * Set the value of an uniform to a matrix (2x2)
  37187. * @param uniform defines the webGL uniform location where to store the value
  37188. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  37189. */
  37190. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  37191. /**
  37192. * Set the value of an uniform to a number (float)
  37193. * @param uniform defines the webGL uniform location where to store the value
  37194. * @param value defines the float number to store
  37195. */
  37196. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  37197. /**
  37198. * Set the value of an uniform to a vec2
  37199. * @param uniform defines the webGL uniform location where to store the value
  37200. * @param x defines the 1st component of the value
  37201. * @param y defines the 2nd component of the value
  37202. */
  37203. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  37204. /**
  37205. * Set the value of an uniform to a vec3
  37206. * @param uniform defines the webGL uniform location where to store the value
  37207. * @param x defines the 1st component of the value
  37208. * @param y defines the 2nd component of the value
  37209. * @param z defines the 3rd component of the value
  37210. */
  37211. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  37212. /**
  37213. * Set the value of an uniform to a vec4
  37214. * @param uniform defines the webGL uniform location where to store the value
  37215. * @param x defines the 1st component of the value
  37216. * @param y defines the 2nd component of the value
  37217. * @param z defines the 3rd component of the value
  37218. * @param w defines the 4th component of the value
  37219. */
  37220. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  37221. /**
  37222. * Apply all cached states (depth, culling, stencil and alpha)
  37223. */
  37224. applyStates(): void;
  37225. /**
  37226. * Enable or disable color writing
  37227. * @param enable defines the state to set
  37228. */
  37229. setColorWrite(enable: boolean): void;
  37230. /**
  37231. * Gets a boolean indicating if color writing is enabled
  37232. * @returns the current color writing state
  37233. */
  37234. getColorWrite(): boolean;
  37235. /**
  37236. * Gets the depth culling state manager
  37237. */
  37238. get depthCullingState(): DepthCullingState;
  37239. /**
  37240. * Gets the alpha state manager
  37241. */
  37242. get alphaState(): AlphaState;
  37243. /**
  37244. * Gets the stencil state manager
  37245. */
  37246. get stencilState(): StencilState;
  37247. /**
  37248. * Clears the list of texture accessible through engine.
  37249. * This can help preventing texture load conflict due to name collision.
  37250. */
  37251. clearInternalTexturesCache(): void;
  37252. /**
  37253. * Force the entire cache to be cleared
  37254. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  37255. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  37256. */
  37257. wipeCaches(bruteForce?: boolean): void;
  37258. /** @hidden */
  37259. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  37260. min: number;
  37261. mag: number;
  37262. };
  37263. /** @hidden */
  37264. _createTexture(): WebGLTexture;
  37265. /**
  37266. * Usually called from Texture.ts.
  37267. * Passed information to create a WebGLTexture
  37268. * @param url defines a value which contains one of the following:
  37269. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  37270. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  37271. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  37272. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  37273. * @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)
  37274. * @param scene needed for loading to the correct scene
  37275. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  37276. * @param onLoad optional callback to be called upon successful completion
  37277. * @param onError optional callback to be called upon failure
  37278. * @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
  37279. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  37280. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  37281. * @param forcedExtension defines the extension to use to pick the right loader
  37282. * @param mimeType defines an optional mime type
  37283. * @returns a InternalTexture for assignment back into BABYLON.Texture
  37284. */
  37285. 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;
  37286. /**
  37287. * Loads an image as an HTMLImageElement.
  37288. * @param input url string, ArrayBuffer, or Blob to load
  37289. * @param onLoad callback called when the image successfully loads
  37290. * @param onError callback called when the image fails to load
  37291. * @param offlineProvider offline provider for caching
  37292. * @param mimeType optional mime type
  37293. * @returns the HTMLImageElement of the loaded image
  37294. * @hidden
  37295. */
  37296. 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>;
  37297. /**
  37298. * @hidden
  37299. */
  37300. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  37301. private _unpackFlipYCached;
  37302. /**
  37303. * In case you are sharing the context with other applications, it might
  37304. * be interested to not cache the unpack flip y state to ensure a consistent
  37305. * value would be set.
  37306. */
  37307. enableUnpackFlipYCached: boolean;
  37308. /** @hidden */
  37309. _unpackFlipY(value: boolean): void;
  37310. /** @hidden */
  37311. _getUnpackAlignement(): number;
  37312. private _getTextureTarget;
  37313. /**
  37314. * Update the sampling mode of a given texture
  37315. * @param samplingMode defines the required sampling mode
  37316. * @param texture defines the texture to update
  37317. * @param generateMipMaps defines whether to generate mipmaps for the texture
  37318. */
  37319. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  37320. /**
  37321. * Update the sampling mode of a given texture
  37322. * @param texture defines the texture to update
  37323. * @param wrapU defines the texture wrap mode of the u coordinates
  37324. * @param wrapV defines the texture wrap mode of the v coordinates
  37325. * @param wrapR defines the texture wrap mode of the r coordinates
  37326. */
  37327. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  37328. /** @hidden */
  37329. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  37330. width: number;
  37331. height: number;
  37332. layers?: number;
  37333. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  37334. /** @hidden */
  37335. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  37336. /** @hidden */
  37337. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  37338. /**
  37339. * Update a portion of an internal texture
  37340. * @param texture defines the texture to update
  37341. * @param imageData defines the data to store into the texture
  37342. * @param xOffset defines the x coordinates of the update rectangle
  37343. * @param yOffset defines the y coordinates of the update rectangle
  37344. * @param width defines the width of the update rectangle
  37345. * @param height defines the height of the update rectangle
  37346. * @param faceIndex defines the face index if texture is a cube (0 by default)
  37347. * @param lod defines the lod level to update (0 by default)
  37348. */
  37349. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  37350. /** @hidden */
  37351. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  37352. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  37353. private _prepareWebGLTexture;
  37354. /** @hidden */
  37355. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  37356. private _getDepthStencilBuffer;
  37357. /** @hidden */
  37358. _releaseFramebufferObjects(texture: InternalTexture): void;
  37359. /** @hidden */
  37360. _releaseTexture(texture: InternalTexture): void;
  37361. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  37362. protected _setProgram(program: WebGLProgram): void;
  37363. protected _boundUniforms: {
  37364. [key: number]: WebGLUniformLocation;
  37365. };
  37366. /**
  37367. * Binds an effect to the webGL context
  37368. * @param effect defines the effect to bind
  37369. */
  37370. bindSamplers(effect: Effect): void;
  37371. private _activateCurrentTexture;
  37372. /** @hidden */
  37373. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  37374. /** @hidden */
  37375. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  37376. /**
  37377. * Unbind all textures from the webGL context
  37378. */
  37379. unbindAllTextures(): void;
  37380. /**
  37381. * Sets a texture to the according uniform.
  37382. * @param channel The texture channel
  37383. * @param uniform The uniform to set
  37384. * @param texture The texture to apply
  37385. */
  37386. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  37387. private _bindSamplerUniformToChannel;
  37388. private _getTextureWrapMode;
  37389. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  37390. /**
  37391. * Sets an array of texture to the webGL context
  37392. * @param channel defines the channel where the texture array must be set
  37393. * @param uniform defines the associated uniform location
  37394. * @param textures defines the array of textures to bind
  37395. */
  37396. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  37397. /** @hidden */
  37398. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  37399. private _setTextureParameterFloat;
  37400. private _setTextureParameterInteger;
  37401. /**
  37402. * Unbind all vertex attributes from the webGL context
  37403. */
  37404. unbindAllAttributes(): void;
  37405. /**
  37406. * 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
  37407. */
  37408. releaseEffects(): void;
  37409. /**
  37410. * Dispose and release all associated resources
  37411. */
  37412. dispose(): void;
  37413. /**
  37414. * Attach a new callback raised when context lost event is fired
  37415. * @param callback defines the callback to call
  37416. */
  37417. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  37418. /**
  37419. * Attach a new callback raised when context restored event is fired
  37420. * @param callback defines the callback to call
  37421. */
  37422. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  37423. /**
  37424. * Get the current error code of the webGL context
  37425. * @returns the error code
  37426. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  37427. */
  37428. getError(): number;
  37429. private _canRenderToFloatFramebuffer;
  37430. private _canRenderToHalfFloatFramebuffer;
  37431. private _canRenderToFramebuffer;
  37432. /** @hidden */
  37433. _getWebGLTextureType(type: number): number;
  37434. /** @hidden */
  37435. _getInternalFormat(format: number): number;
  37436. /** @hidden */
  37437. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  37438. /** @hidden */
  37439. _getRGBAMultiSampleBufferFormat(type: number): number;
  37440. /** @hidden */
  37441. _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;
  37442. /**
  37443. * Loads a file from a url
  37444. * @param url url to load
  37445. * @param onSuccess callback called when the file successfully loads
  37446. * @param onProgress callback called while file is loading (if the server supports this mode)
  37447. * @param offlineProvider defines the offline provider for caching
  37448. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37449. * @param onError callback called when the file fails to load
  37450. * @returns a file request object
  37451. * @hidden
  37452. */
  37453. 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;
  37454. /**
  37455. * Reads pixels from the current frame buffer. Please note that this function can be slow
  37456. * @param x defines the x coordinate of the rectangle where pixels must be read
  37457. * @param y defines the y coordinate of the rectangle where pixels must be read
  37458. * @param width defines the width of the rectangle where pixels must be read
  37459. * @param height defines the height of the rectangle where pixels must be read
  37460. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  37461. * @returns a Uint8Array containing RGBA colors
  37462. */
  37463. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  37464. private static _isSupported;
  37465. /**
  37466. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  37467. * @returns true if the engine can be created
  37468. * @ignorenaming
  37469. */
  37470. static isSupported(): boolean;
  37471. /**
  37472. * Find the next highest power of two.
  37473. * @param x Number to start search from.
  37474. * @return Next highest power of two.
  37475. */
  37476. static CeilingPOT(x: number): number;
  37477. /**
  37478. * Find the next lowest power of two.
  37479. * @param x Number to start search from.
  37480. * @return Next lowest power of two.
  37481. */
  37482. static FloorPOT(x: number): number;
  37483. /**
  37484. * Find the nearest power of two.
  37485. * @param x Number to start search from.
  37486. * @return Next nearest power of two.
  37487. */
  37488. static NearestPOT(x: number): number;
  37489. /**
  37490. * Get the closest exponent of two
  37491. * @param value defines the value to approximate
  37492. * @param max defines the maximum value to return
  37493. * @param mode defines how to define the closest value
  37494. * @returns closest exponent of two of the given value
  37495. */
  37496. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  37497. /**
  37498. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  37499. * @param func - the function to be called
  37500. * @param requester - the object that will request the next frame. Falls back to window.
  37501. * @returns frame number
  37502. */
  37503. static QueueNewFrame(func: () => void, requester?: any): number;
  37504. /**
  37505. * Gets host document
  37506. * @returns the host document object
  37507. */
  37508. getHostDocument(): Nullable<Document>;
  37509. }
  37510. }
  37511. declare module "babylonjs/Maths/sphericalPolynomial" {
  37512. import { Vector3 } from "babylonjs/Maths/math.vector";
  37513. import { Color3 } from "babylonjs/Maths/math.color";
  37514. /**
  37515. * Class representing spherical harmonics coefficients to the 3rd degree
  37516. */
  37517. export class SphericalHarmonics {
  37518. /**
  37519. * Defines whether or not the harmonics have been prescaled for rendering.
  37520. */
  37521. preScaled: boolean;
  37522. /**
  37523. * The l0,0 coefficients of the spherical harmonics
  37524. */
  37525. l00: Vector3;
  37526. /**
  37527. * The l1,-1 coefficients of the spherical harmonics
  37528. */
  37529. l1_1: Vector3;
  37530. /**
  37531. * The l1,0 coefficients of the spherical harmonics
  37532. */
  37533. l10: Vector3;
  37534. /**
  37535. * The l1,1 coefficients of the spherical harmonics
  37536. */
  37537. l11: Vector3;
  37538. /**
  37539. * The l2,-2 coefficients of the spherical harmonics
  37540. */
  37541. l2_2: Vector3;
  37542. /**
  37543. * The l2,-1 coefficients of the spherical harmonics
  37544. */
  37545. l2_1: Vector3;
  37546. /**
  37547. * The l2,0 coefficients of the spherical harmonics
  37548. */
  37549. l20: Vector3;
  37550. /**
  37551. * The l2,1 coefficients of the spherical harmonics
  37552. */
  37553. l21: Vector3;
  37554. /**
  37555. * The l2,2 coefficients of the spherical harmonics
  37556. */
  37557. l22: Vector3;
  37558. /**
  37559. * Adds a light to the spherical harmonics
  37560. * @param direction the direction of the light
  37561. * @param color the color of the light
  37562. * @param deltaSolidAngle the delta solid angle of the light
  37563. */
  37564. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  37565. /**
  37566. * Scales the spherical harmonics by the given amount
  37567. * @param scale the amount to scale
  37568. */
  37569. scaleInPlace(scale: number): void;
  37570. /**
  37571. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  37572. *
  37573. * ```
  37574. * E_lm = A_l * L_lm
  37575. * ```
  37576. *
  37577. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  37578. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  37579. * the scaling factors are given in equation 9.
  37580. */
  37581. convertIncidentRadianceToIrradiance(): void;
  37582. /**
  37583. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  37584. *
  37585. * ```
  37586. * L = (1/pi) * E * rho
  37587. * ```
  37588. *
  37589. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  37590. */
  37591. convertIrradianceToLambertianRadiance(): void;
  37592. /**
  37593. * Integrates the reconstruction coefficients directly in to the SH preventing further
  37594. * required operations at run time.
  37595. *
  37596. * This is simply done by scaling back the SH with Ylm constants parameter.
  37597. * The trigonometric part being applied by the shader at run time.
  37598. */
  37599. preScaleForRendering(): void;
  37600. /**
  37601. * Constructs a spherical harmonics from an array.
  37602. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  37603. * @returns the spherical harmonics
  37604. */
  37605. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  37606. /**
  37607. * Gets the spherical harmonics from polynomial
  37608. * @param polynomial the spherical polynomial
  37609. * @returns the spherical harmonics
  37610. */
  37611. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  37612. }
  37613. /**
  37614. * Class representing spherical polynomial coefficients to the 3rd degree
  37615. */
  37616. export class SphericalPolynomial {
  37617. private _harmonics;
  37618. /**
  37619. * The spherical harmonics used to create the polynomials.
  37620. */
  37621. get preScaledHarmonics(): SphericalHarmonics;
  37622. /**
  37623. * The x coefficients of the spherical polynomial
  37624. */
  37625. x: Vector3;
  37626. /**
  37627. * The y coefficients of the spherical polynomial
  37628. */
  37629. y: Vector3;
  37630. /**
  37631. * The z coefficients of the spherical polynomial
  37632. */
  37633. z: Vector3;
  37634. /**
  37635. * The xx coefficients of the spherical polynomial
  37636. */
  37637. xx: Vector3;
  37638. /**
  37639. * The yy coefficients of the spherical polynomial
  37640. */
  37641. yy: Vector3;
  37642. /**
  37643. * The zz coefficients of the spherical polynomial
  37644. */
  37645. zz: Vector3;
  37646. /**
  37647. * The xy coefficients of the spherical polynomial
  37648. */
  37649. xy: Vector3;
  37650. /**
  37651. * The yz coefficients of the spherical polynomial
  37652. */
  37653. yz: Vector3;
  37654. /**
  37655. * The zx coefficients of the spherical polynomial
  37656. */
  37657. zx: Vector3;
  37658. /**
  37659. * Adds an ambient color to the spherical polynomial
  37660. * @param color the color to add
  37661. */
  37662. addAmbient(color: Color3): void;
  37663. /**
  37664. * Scales the spherical polynomial by the given amount
  37665. * @param scale the amount to scale
  37666. */
  37667. scaleInPlace(scale: number): void;
  37668. /**
  37669. * Gets the spherical polynomial from harmonics
  37670. * @param harmonics the spherical harmonics
  37671. * @returns the spherical polynomial
  37672. */
  37673. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  37674. /**
  37675. * Constructs a spherical polynomial from an array.
  37676. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  37677. * @returns the spherical polynomial
  37678. */
  37679. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  37680. }
  37681. }
  37682. declare module "babylonjs/Materials/Textures/internalTexture" {
  37683. import { Observable } from "babylonjs/Misc/observable";
  37684. import { Nullable, int } from "babylonjs/types";
  37685. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  37686. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  37687. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  37688. /**
  37689. * Defines the source of the internal texture
  37690. */
  37691. export enum InternalTextureSource {
  37692. /**
  37693. * The source of the texture data is unknown
  37694. */
  37695. Unknown = 0,
  37696. /**
  37697. * Texture data comes from an URL
  37698. */
  37699. Url = 1,
  37700. /**
  37701. * Texture data is only used for temporary storage
  37702. */
  37703. Temp = 2,
  37704. /**
  37705. * Texture data comes from raw data (ArrayBuffer)
  37706. */
  37707. Raw = 3,
  37708. /**
  37709. * Texture content is dynamic (video or dynamic texture)
  37710. */
  37711. Dynamic = 4,
  37712. /**
  37713. * Texture content is generated by rendering to it
  37714. */
  37715. RenderTarget = 5,
  37716. /**
  37717. * Texture content is part of a multi render target process
  37718. */
  37719. MultiRenderTarget = 6,
  37720. /**
  37721. * Texture data comes from a cube data file
  37722. */
  37723. Cube = 7,
  37724. /**
  37725. * Texture data comes from a raw cube data
  37726. */
  37727. CubeRaw = 8,
  37728. /**
  37729. * Texture data come from a prefiltered cube data file
  37730. */
  37731. CubePrefiltered = 9,
  37732. /**
  37733. * Texture content is raw 3D data
  37734. */
  37735. Raw3D = 10,
  37736. /**
  37737. * Texture content is raw 2D array data
  37738. */
  37739. Raw2DArray = 11,
  37740. /**
  37741. * Texture content is a depth texture
  37742. */
  37743. Depth = 12,
  37744. /**
  37745. * Texture data comes from a raw cube data encoded with RGBD
  37746. */
  37747. CubeRawRGBD = 13
  37748. }
  37749. /**
  37750. * Class used to store data associated with WebGL texture data for the engine
  37751. * This class should not be used directly
  37752. */
  37753. export class InternalTexture {
  37754. /** @hidden */
  37755. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  37756. /**
  37757. * Defines if the texture is ready
  37758. */
  37759. isReady: boolean;
  37760. /**
  37761. * Defines if the texture is a cube texture
  37762. */
  37763. isCube: boolean;
  37764. /**
  37765. * Defines if the texture contains 3D data
  37766. */
  37767. is3D: boolean;
  37768. /**
  37769. * Defines if the texture contains 2D array data
  37770. */
  37771. is2DArray: boolean;
  37772. /**
  37773. * Defines if the texture contains multiview data
  37774. */
  37775. isMultiview: boolean;
  37776. /**
  37777. * Gets the URL used to load this texture
  37778. */
  37779. url: string;
  37780. /**
  37781. * Gets the sampling mode of the texture
  37782. */
  37783. samplingMode: number;
  37784. /**
  37785. * Gets a boolean indicating if the texture needs mipmaps generation
  37786. */
  37787. generateMipMaps: boolean;
  37788. /**
  37789. * Gets the number of samples used by the texture (WebGL2+ only)
  37790. */
  37791. samples: number;
  37792. /**
  37793. * Gets the type of the texture (int, float...)
  37794. */
  37795. type: number;
  37796. /**
  37797. * Gets the format of the texture (RGB, RGBA...)
  37798. */
  37799. format: number;
  37800. /**
  37801. * Observable called when the texture is loaded
  37802. */
  37803. onLoadedObservable: Observable<InternalTexture>;
  37804. /**
  37805. * Gets the width of the texture
  37806. */
  37807. width: number;
  37808. /**
  37809. * Gets the height of the texture
  37810. */
  37811. height: number;
  37812. /**
  37813. * Gets the depth of the texture
  37814. */
  37815. depth: number;
  37816. /**
  37817. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  37818. */
  37819. baseWidth: number;
  37820. /**
  37821. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  37822. */
  37823. baseHeight: number;
  37824. /**
  37825. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  37826. */
  37827. baseDepth: number;
  37828. /**
  37829. * Gets a boolean indicating if the texture is inverted on Y axis
  37830. */
  37831. invertY: boolean;
  37832. /** @hidden */
  37833. _invertVScale: boolean;
  37834. /** @hidden */
  37835. _associatedChannel: number;
  37836. /** @hidden */
  37837. _source: InternalTextureSource;
  37838. /** @hidden */
  37839. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  37840. /** @hidden */
  37841. _bufferView: Nullable<ArrayBufferView>;
  37842. /** @hidden */
  37843. _bufferViewArray: Nullable<ArrayBufferView[]>;
  37844. /** @hidden */
  37845. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  37846. /** @hidden */
  37847. _size: number;
  37848. /** @hidden */
  37849. _extension: string;
  37850. /** @hidden */
  37851. _files: Nullable<string[]>;
  37852. /** @hidden */
  37853. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  37854. /** @hidden */
  37855. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  37856. /** @hidden */
  37857. _framebuffer: Nullable<WebGLFramebuffer>;
  37858. /** @hidden */
  37859. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  37860. /** @hidden */
  37861. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  37862. /** @hidden */
  37863. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  37864. /** @hidden */
  37865. _attachments: Nullable<number[]>;
  37866. /** @hidden */
  37867. _textureArray: Nullable<InternalTexture[]>;
  37868. /** @hidden */
  37869. _cachedCoordinatesMode: Nullable<number>;
  37870. /** @hidden */
  37871. _cachedWrapU: Nullable<number>;
  37872. /** @hidden */
  37873. _cachedWrapV: Nullable<number>;
  37874. /** @hidden */
  37875. _cachedWrapR: Nullable<number>;
  37876. /** @hidden */
  37877. _cachedAnisotropicFilteringLevel: Nullable<number>;
  37878. /** @hidden */
  37879. _isDisabled: boolean;
  37880. /** @hidden */
  37881. _compression: Nullable<string>;
  37882. /** @hidden */
  37883. _generateStencilBuffer: boolean;
  37884. /** @hidden */
  37885. _generateDepthBuffer: boolean;
  37886. /** @hidden */
  37887. _comparisonFunction: number;
  37888. /** @hidden */
  37889. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  37890. /** @hidden */
  37891. _lodGenerationScale: number;
  37892. /** @hidden */
  37893. _lodGenerationOffset: number;
  37894. /** @hidden */
  37895. _depthStencilTexture: Nullable<InternalTexture>;
  37896. /** @hidden */
  37897. _colorTextureArray: Nullable<WebGLTexture>;
  37898. /** @hidden */
  37899. _depthStencilTextureArray: Nullable<WebGLTexture>;
  37900. /** @hidden */
  37901. _lodTextureHigh: Nullable<BaseTexture>;
  37902. /** @hidden */
  37903. _lodTextureMid: Nullable<BaseTexture>;
  37904. /** @hidden */
  37905. _lodTextureLow: Nullable<BaseTexture>;
  37906. /** @hidden */
  37907. _isRGBD: boolean;
  37908. /** @hidden */
  37909. _linearSpecularLOD: boolean;
  37910. /** @hidden */
  37911. _irradianceTexture: Nullable<BaseTexture>;
  37912. /** @hidden */
  37913. _webGLTexture: Nullable<WebGLTexture>;
  37914. /** @hidden */
  37915. _references: number;
  37916. private _engine;
  37917. /**
  37918. * Gets the Engine the texture belongs to.
  37919. * @returns The babylon engine
  37920. */
  37921. getEngine(): ThinEngine;
  37922. /**
  37923. * Gets the data source type of the texture
  37924. */
  37925. get source(): InternalTextureSource;
  37926. /**
  37927. * Creates a new InternalTexture
  37928. * @param engine defines the engine to use
  37929. * @param source defines the type of data that will be used
  37930. * @param delayAllocation if the texture allocation should be delayed (default: false)
  37931. */
  37932. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  37933. /**
  37934. * Increments the number of references (ie. the number of Texture that point to it)
  37935. */
  37936. incrementReferences(): void;
  37937. /**
  37938. * Change the size of the texture (not the size of the content)
  37939. * @param width defines the new width
  37940. * @param height defines the new height
  37941. * @param depth defines the new depth (1 by default)
  37942. */
  37943. updateSize(width: int, height: int, depth?: int): void;
  37944. /** @hidden */
  37945. _rebuild(): void;
  37946. /** @hidden */
  37947. _swapAndDie(target: InternalTexture): void;
  37948. /**
  37949. * Dispose the current allocated resources
  37950. */
  37951. dispose(): void;
  37952. }
  37953. }
  37954. declare module "babylonjs/Audio/analyser" {
  37955. import { Scene } from "babylonjs/scene";
  37956. /**
  37957. * Class used to work with sound analyzer using fast fourier transform (FFT)
  37958. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37959. */
  37960. export class Analyser {
  37961. /**
  37962. * Gets or sets the smoothing
  37963. * @ignorenaming
  37964. */
  37965. SMOOTHING: number;
  37966. /**
  37967. * Gets or sets the FFT table size
  37968. * @ignorenaming
  37969. */
  37970. FFT_SIZE: number;
  37971. /**
  37972. * Gets or sets the bar graph amplitude
  37973. * @ignorenaming
  37974. */
  37975. BARGRAPHAMPLITUDE: number;
  37976. /**
  37977. * Gets or sets the position of the debug canvas
  37978. * @ignorenaming
  37979. */
  37980. DEBUGCANVASPOS: {
  37981. x: number;
  37982. y: number;
  37983. };
  37984. /**
  37985. * Gets or sets the debug canvas size
  37986. * @ignorenaming
  37987. */
  37988. DEBUGCANVASSIZE: {
  37989. width: number;
  37990. height: number;
  37991. };
  37992. private _byteFreqs;
  37993. private _byteTime;
  37994. private _floatFreqs;
  37995. private _webAudioAnalyser;
  37996. private _debugCanvas;
  37997. private _debugCanvasContext;
  37998. private _scene;
  37999. private _registerFunc;
  38000. private _audioEngine;
  38001. /**
  38002. * Creates a new analyser
  38003. * @param scene defines hosting scene
  38004. */
  38005. constructor(scene: Scene);
  38006. /**
  38007. * Get the number of data values you will have to play with for the visualization
  38008. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  38009. * @returns a number
  38010. */
  38011. getFrequencyBinCount(): number;
  38012. /**
  38013. * Gets the current frequency data as a byte array
  38014. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  38015. * @returns a Uint8Array
  38016. */
  38017. getByteFrequencyData(): Uint8Array;
  38018. /**
  38019. * Gets the current waveform as a byte array
  38020. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  38021. * @returns a Uint8Array
  38022. */
  38023. getByteTimeDomainData(): Uint8Array;
  38024. /**
  38025. * Gets the current frequency data as a float array
  38026. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  38027. * @returns a Float32Array
  38028. */
  38029. getFloatFrequencyData(): Float32Array;
  38030. /**
  38031. * Renders the debug canvas
  38032. */
  38033. drawDebugCanvas(): void;
  38034. /**
  38035. * Stops rendering the debug canvas and removes it
  38036. */
  38037. stopDebugCanvas(): void;
  38038. /**
  38039. * Connects two audio nodes
  38040. * @param inputAudioNode defines first node to connect
  38041. * @param outputAudioNode defines second node to connect
  38042. */
  38043. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  38044. /**
  38045. * Releases all associated resources
  38046. */
  38047. dispose(): void;
  38048. }
  38049. }
  38050. declare module "babylonjs/Audio/audioEngine" {
  38051. import { IDisposable } from "babylonjs/scene";
  38052. import { Analyser } from "babylonjs/Audio/analyser";
  38053. import { Nullable } from "babylonjs/types";
  38054. import { Observable } from "babylonjs/Misc/observable";
  38055. /**
  38056. * This represents an audio engine and it is responsible
  38057. * to play, synchronize and analyse sounds throughout the application.
  38058. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38059. */
  38060. export interface IAudioEngine extends IDisposable {
  38061. /**
  38062. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  38063. */
  38064. readonly canUseWebAudio: boolean;
  38065. /**
  38066. * Gets the current AudioContext if available.
  38067. */
  38068. readonly audioContext: Nullable<AudioContext>;
  38069. /**
  38070. * The master gain node defines the global audio volume of your audio engine.
  38071. */
  38072. readonly masterGain: GainNode;
  38073. /**
  38074. * Gets whether or not mp3 are supported by your browser.
  38075. */
  38076. readonly isMP3supported: boolean;
  38077. /**
  38078. * Gets whether or not ogg are supported by your browser.
  38079. */
  38080. readonly isOGGsupported: boolean;
  38081. /**
  38082. * Defines if Babylon should emit a warning if WebAudio is not supported.
  38083. * @ignoreNaming
  38084. */
  38085. WarnedWebAudioUnsupported: boolean;
  38086. /**
  38087. * Defines if the audio engine relies on a custom unlocked button.
  38088. * In this case, the embedded button will not be displayed.
  38089. */
  38090. useCustomUnlockedButton: boolean;
  38091. /**
  38092. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  38093. */
  38094. readonly unlocked: boolean;
  38095. /**
  38096. * Event raised when audio has been unlocked on the browser.
  38097. */
  38098. onAudioUnlockedObservable: Observable<AudioEngine>;
  38099. /**
  38100. * Event raised when audio has been locked on the browser.
  38101. */
  38102. onAudioLockedObservable: Observable<AudioEngine>;
  38103. /**
  38104. * Flags the audio engine in Locked state.
  38105. * This happens due to new browser policies preventing audio to autoplay.
  38106. */
  38107. lock(): void;
  38108. /**
  38109. * Unlocks the audio engine once a user action has been done on the dom.
  38110. * This is helpful to resume play once browser policies have been satisfied.
  38111. */
  38112. unlock(): void;
  38113. /**
  38114. * Gets the global volume sets on the master gain.
  38115. * @returns the global volume if set or -1 otherwise
  38116. */
  38117. getGlobalVolume(): number;
  38118. /**
  38119. * Sets the global volume of your experience (sets on the master gain).
  38120. * @param newVolume Defines the new global volume of the application
  38121. */
  38122. setGlobalVolume(newVolume: number): void;
  38123. /**
  38124. * Connect the audio engine to an audio analyser allowing some amazing
  38125. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38126. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38127. * @param analyser The analyser to connect to the engine
  38128. */
  38129. connectToAnalyser(analyser: Analyser): void;
  38130. }
  38131. /**
  38132. * This represents the default audio engine used in babylon.
  38133. * It is responsible to play, synchronize and analyse sounds throughout the application.
  38134. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38135. */
  38136. export class AudioEngine implements IAudioEngine {
  38137. private _audioContext;
  38138. private _audioContextInitialized;
  38139. private _muteButton;
  38140. private _hostElement;
  38141. /**
  38142. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  38143. */
  38144. canUseWebAudio: boolean;
  38145. /**
  38146. * The master gain node defines the global audio volume of your audio engine.
  38147. */
  38148. masterGain: GainNode;
  38149. /**
  38150. * Defines if Babylon should emit a warning if WebAudio is not supported.
  38151. * @ignoreNaming
  38152. */
  38153. WarnedWebAudioUnsupported: boolean;
  38154. /**
  38155. * Gets whether or not mp3 are supported by your browser.
  38156. */
  38157. isMP3supported: boolean;
  38158. /**
  38159. * Gets whether or not ogg are supported by your browser.
  38160. */
  38161. isOGGsupported: boolean;
  38162. /**
  38163. * Gets whether audio has been unlocked on the device.
  38164. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  38165. * a user interaction has happened.
  38166. */
  38167. unlocked: boolean;
  38168. /**
  38169. * Defines if the audio engine relies on a custom unlocked button.
  38170. * In this case, the embedded button will not be displayed.
  38171. */
  38172. useCustomUnlockedButton: boolean;
  38173. /**
  38174. * Event raised when audio has been unlocked on the browser.
  38175. */
  38176. onAudioUnlockedObservable: Observable<AudioEngine>;
  38177. /**
  38178. * Event raised when audio has been locked on the browser.
  38179. */
  38180. onAudioLockedObservable: Observable<AudioEngine>;
  38181. /**
  38182. * Gets the current AudioContext if available.
  38183. */
  38184. get audioContext(): Nullable<AudioContext>;
  38185. private _connectedAnalyser;
  38186. /**
  38187. * Instantiates a new audio engine.
  38188. *
  38189. * There should be only one per page as some browsers restrict the number
  38190. * of audio contexts you can create.
  38191. * @param hostElement defines the host element where to display the mute icon if necessary
  38192. */
  38193. constructor(hostElement?: Nullable<HTMLElement>);
  38194. /**
  38195. * Flags the audio engine in Locked state.
  38196. * This happens due to new browser policies preventing audio to autoplay.
  38197. */
  38198. lock(): void;
  38199. /**
  38200. * Unlocks the audio engine once a user action has been done on the dom.
  38201. * This is helpful to resume play once browser policies have been satisfied.
  38202. */
  38203. unlock(): void;
  38204. private _resumeAudioContext;
  38205. private _initializeAudioContext;
  38206. private _tryToRun;
  38207. private _triggerRunningState;
  38208. private _triggerSuspendedState;
  38209. private _displayMuteButton;
  38210. private _moveButtonToTopLeft;
  38211. private _onResize;
  38212. private _hideMuteButton;
  38213. /**
  38214. * Destroy and release the resources associated with the audio ccontext.
  38215. */
  38216. dispose(): void;
  38217. /**
  38218. * Gets the global volume sets on the master gain.
  38219. * @returns the global volume if set or -1 otherwise
  38220. */
  38221. getGlobalVolume(): number;
  38222. /**
  38223. * Sets the global volume of your experience (sets on the master gain).
  38224. * @param newVolume Defines the new global volume of the application
  38225. */
  38226. setGlobalVolume(newVolume: number): void;
  38227. /**
  38228. * Connect the audio engine to an audio analyser allowing some amazing
  38229. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38230. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38231. * @param analyser The analyser to connect to the engine
  38232. */
  38233. connectToAnalyser(analyser: Analyser): void;
  38234. }
  38235. }
  38236. declare module "babylonjs/Loading/loadingScreen" {
  38237. /**
  38238. * Interface used to present a loading screen while loading a scene
  38239. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38240. */
  38241. export interface ILoadingScreen {
  38242. /**
  38243. * Function called to display the loading screen
  38244. */
  38245. displayLoadingUI: () => void;
  38246. /**
  38247. * Function called to hide the loading screen
  38248. */
  38249. hideLoadingUI: () => void;
  38250. /**
  38251. * Gets or sets the color to use for the background
  38252. */
  38253. loadingUIBackgroundColor: string;
  38254. /**
  38255. * Gets or sets the text to display while loading
  38256. */
  38257. loadingUIText: string;
  38258. }
  38259. /**
  38260. * Class used for the default loading screen
  38261. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38262. */
  38263. export class DefaultLoadingScreen implements ILoadingScreen {
  38264. private _renderingCanvas;
  38265. private _loadingText;
  38266. private _loadingDivBackgroundColor;
  38267. private _loadingDiv;
  38268. private _loadingTextDiv;
  38269. /** Gets or sets the logo url to use for the default loading screen */
  38270. static DefaultLogoUrl: string;
  38271. /** Gets or sets the spinner url to use for the default loading screen */
  38272. static DefaultSpinnerUrl: string;
  38273. /**
  38274. * Creates a new default loading screen
  38275. * @param _renderingCanvas defines the canvas used to render the scene
  38276. * @param _loadingText defines the default text to display
  38277. * @param _loadingDivBackgroundColor defines the default background color
  38278. */
  38279. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  38280. /**
  38281. * Function called to display the loading screen
  38282. */
  38283. displayLoadingUI(): void;
  38284. /**
  38285. * Function called to hide the loading screen
  38286. */
  38287. hideLoadingUI(): void;
  38288. /**
  38289. * Gets or sets the text to display while loading
  38290. */
  38291. set loadingUIText(text: string);
  38292. get loadingUIText(): string;
  38293. /**
  38294. * Gets or sets the color to use for the background
  38295. */
  38296. get loadingUIBackgroundColor(): string;
  38297. set loadingUIBackgroundColor(color: string);
  38298. private _resizeLoadingUI;
  38299. }
  38300. }
  38301. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  38302. /**
  38303. * Interface for any object that can request an animation frame
  38304. */
  38305. export interface ICustomAnimationFrameRequester {
  38306. /**
  38307. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  38308. */
  38309. renderFunction?: Function;
  38310. /**
  38311. * Called to request the next frame to render to
  38312. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  38313. */
  38314. requestAnimationFrame: Function;
  38315. /**
  38316. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  38317. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  38318. */
  38319. requestID?: number;
  38320. }
  38321. }
  38322. declare module "babylonjs/Misc/performanceMonitor" {
  38323. /**
  38324. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  38325. */
  38326. export class PerformanceMonitor {
  38327. private _enabled;
  38328. private _rollingFrameTime;
  38329. private _lastFrameTimeMs;
  38330. /**
  38331. * constructor
  38332. * @param frameSampleSize The number of samples required to saturate the sliding window
  38333. */
  38334. constructor(frameSampleSize?: number);
  38335. /**
  38336. * Samples current frame
  38337. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  38338. */
  38339. sampleFrame(timeMs?: number): void;
  38340. /**
  38341. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38342. */
  38343. get averageFrameTime(): number;
  38344. /**
  38345. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38346. */
  38347. get averageFrameTimeVariance(): number;
  38348. /**
  38349. * Returns the frame time of the most recent frame
  38350. */
  38351. get instantaneousFrameTime(): number;
  38352. /**
  38353. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  38354. */
  38355. get averageFPS(): number;
  38356. /**
  38357. * Returns the average framerate in frames per second using the most recent frame time
  38358. */
  38359. get instantaneousFPS(): number;
  38360. /**
  38361. * Returns true if enough samples have been taken to completely fill the sliding window
  38362. */
  38363. get isSaturated(): boolean;
  38364. /**
  38365. * Enables contributions to the sliding window sample set
  38366. */
  38367. enable(): void;
  38368. /**
  38369. * Disables contributions to the sliding window sample set
  38370. * Samples will not be interpolated over the disabled period
  38371. */
  38372. disable(): void;
  38373. /**
  38374. * Returns true if sampling is enabled
  38375. */
  38376. get isEnabled(): boolean;
  38377. /**
  38378. * Resets performance monitor
  38379. */
  38380. reset(): void;
  38381. }
  38382. /**
  38383. * RollingAverage
  38384. *
  38385. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  38386. */
  38387. export class RollingAverage {
  38388. /**
  38389. * Current average
  38390. */
  38391. average: number;
  38392. /**
  38393. * Current variance
  38394. */
  38395. variance: number;
  38396. protected _samples: Array<number>;
  38397. protected _sampleCount: number;
  38398. protected _pos: number;
  38399. protected _m2: number;
  38400. /**
  38401. * constructor
  38402. * @param length The number of samples required to saturate the sliding window
  38403. */
  38404. constructor(length: number);
  38405. /**
  38406. * Adds a sample to the sample set
  38407. * @param v The sample value
  38408. */
  38409. add(v: number): void;
  38410. /**
  38411. * Returns previously added values or null if outside of history or outside the sliding window domain
  38412. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  38413. * @return Value previously recorded with add() or null if outside of range
  38414. */
  38415. history(i: number): number;
  38416. /**
  38417. * Returns true if enough samples have been taken to completely fill the sliding window
  38418. * @return true if sample-set saturated
  38419. */
  38420. isSaturated(): boolean;
  38421. /**
  38422. * Resets the rolling average (equivalent to 0 samples taken so far)
  38423. */
  38424. reset(): void;
  38425. /**
  38426. * Wraps a value around the sample range boundaries
  38427. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  38428. * @return Wrapped position in sample range
  38429. */
  38430. protected _wrapPosition(i: number): number;
  38431. }
  38432. }
  38433. declare module "babylonjs/Misc/perfCounter" {
  38434. /**
  38435. * This class is used to track a performance counter which is number based.
  38436. * The user has access to many properties which give statistics of different nature.
  38437. *
  38438. * The implementer can track two kinds of Performance Counter: time and count.
  38439. * 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.
  38440. * 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.
  38441. */
  38442. export class PerfCounter {
  38443. /**
  38444. * Gets or sets a global boolean to turn on and off all the counters
  38445. */
  38446. static Enabled: boolean;
  38447. /**
  38448. * Returns the smallest value ever
  38449. */
  38450. get min(): number;
  38451. /**
  38452. * Returns the biggest value ever
  38453. */
  38454. get max(): number;
  38455. /**
  38456. * Returns the average value since the performance counter is running
  38457. */
  38458. get average(): number;
  38459. /**
  38460. * Returns the average value of the last second the counter was monitored
  38461. */
  38462. get lastSecAverage(): number;
  38463. /**
  38464. * Returns the current value
  38465. */
  38466. get current(): number;
  38467. /**
  38468. * Gets the accumulated total
  38469. */
  38470. get total(): number;
  38471. /**
  38472. * Gets the total value count
  38473. */
  38474. get count(): number;
  38475. /**
  38476. * Creates a new counter
  38477. */
  38478. constructor();
  38479. /**
  38480. * Call this method to start monitoring a new frame.
  38481. * 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.
  38482. */
  38483. fetchNewFrame(): void;
  38484. /**
  38485. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  38486. * @param newCount the count value to add to the monitored count
  38487. * @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.
  38488. */
  38489. addCount(newCount: number, fetchResult: boolean): void;
  38490. /**
  38491. * Start monitoring this performance counter
  38492. */
  38493. beginMonitoring(): void;
  38494. /**
  38495. * Compute the time lapsed since the previous beginMonitoring() call.
  38496. * @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
  38497. */
  38498. endMonitoring(newFrame?: boolean): void;
  38499. private _fetchResult;
  38500. private _startMonitoringTime;
  38501. private _min;
  38502. private _max;
  38503. private _average;
  38504. private _current;
  38505. private _totalValueCount;
  38506. private _totalAccumulated;
  38507. private _lastSecAverage;
  38508. private _lastSecAccumulated;
  38509. private _lastSecTime;
  38510. private _lastSecValueCount;
  38511. }
  38512. }
  38513. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  38514. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38515. import { Nullable } from "babylonjs/types";
  38516. module "babylonjs/Engines/thinEngine" {
  38517. interface ThinEngine {
  38518. /** @hidden */
  38519. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  38520. }
  38521. }
  38522. }
  38523. declare module "babylonjs/Engines/engine" {
  38524. import { Observable } from "babylonjs/Misc/observable";
  38525. import { Nullable } from "babylonjs/types";
  38526. import { Scene } from "babylonjs/scene";
  38527. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38528. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  38529. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  38530. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  38531. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  38532. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  38533. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  38534. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  38535. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  38536. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  38537. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  38538. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  38539. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  38540. import "babylonjs/Engines/Extensions/engine.alpha";
  38541. import "babylonjs/Engines/Extensions/engine.readTexture";
  38542. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  38543. import { Material } from "babylonjs/Materials/material";
  38544. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38545. /**
  38546. * Defines the interface used by display changed events
  38547. */
  38548. export interface IDisplayChangedEventArgs {
  38549. /** Gets the vrDisplay object (if any) */
  38550. vrDisplay: Nullable<any>;
  38551. /** Gets a boolean indicating if webVR is supported */
  38552. vrSupported: boolean;
  38553. }
  38554. /**
  38555. * Defines the interface used by objects containing a viewport (like a camera)
  38556. */
  38557. interface IViewportOwnerLike {
  38558. /**
  38559. * Gets or sets the viewport
  38560. */
  38561. viewport: IViewportLike;
  38562. }
  38563. /**
  38564. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  38565. */
  38566. export class Engine extends ThinEngine {
  38567. /** Defines that alpha blending is disabled */
  38568. static readonly ALPHA_DISABLE: number;
  38569. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  38570. static readonly ALPHA_ADD: number;
  38571. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  38572. static readonly ALPHA_COMBINE: number;
  38573. /** Defines that alpha blending to DEST - SRC * DEST */
  38574. static readonly ALPHA_SUBTRACT: number;
  38575. /** Defines that alpha blending to SRC * DEST */
  38576. static readonly ALPHA_MULTIPLY: number;
  38577. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  38578. static readonly ALPHA_MAXIMIZED: number;
  38579. /** Defines that alpha blending to SRC + DEST */
  38580. static readonly ALPHA_ONEONE: number;
  38581. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  38582. static readonly ALPHA_PREMULTIPLIED: number;
  38583. /**
  38584. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  38585. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  38586. */
  38587. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  38588. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  38589. static readonly ALPHA_INTERPOLATE: number;
  38590. /**
  38591. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  38592. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  38593. */
  38594. static readonly ALPHA_SCREENMODE: number;
  38595. /** Defines that the ressource is not delayed*/
  38596. static readonly DELAYLOADSTATE_NONE: number;
  38597. /** Defines that the ressource was successfully delay loaded */
  38598. static readonly DELAYLOADSTATE_LOADED: number;
  38599. /** Defines that the ressource is currently delay loading */
  38600. static readonly DELAYLOADSTATE_LOADING: number;
  38601. /** Defines that the ressource is delayed and has not started loading */
  38602. static readonly DELAYLOADSTATE_NOTLOADED: number;
  38603. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  38604. static readonly NEVER: number;
  38605. /** 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 */
  38606. static readonly ALWAYS: number;
  38607. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  38608. static readonly LESS: number;
  38609. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  38610. static readonly EQUAL: number;
  38611. /** 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 */
  38612. static readonly LEQUAL: number;
  38613. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  38614. static readonly GREATER: number;
  38615. /** 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 */
  38616. static readonly GEQUAL: number;
  38617. /** 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 */
  38618. static readonly NOTEQUAL: number;
  38619. /** Passed to stencilOperation to specify that stencil value must be kept */
  38620. static readonly KEEP: number;
  38621. /** Passed to stencilOperation to specify that stencil value must be replaced */
  38622. static readonly REPLACE: number;
  38623. /** Passed to stencilOperation to specify that stencil value must be incremented */
  38624. static readonly INCR: number;
  38625. /** Passed to stencilOperation to specify that stencil value must be decremented */
  38626. static readonly DECR: number;
  38627. /** Passed to stencilOperation to specify that stencil value must be inverted */
  38628. static readonly INVERT: number;
  38629. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  38630. static readonly INCR_WRAP: number;
  38631. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  38632. static readonly DECR_WRAP: number;
  38633. /** Texture is not repeating outside of 0..1 UVs */
  38634. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  38635. /** Texture is repeating outside of 0..1 UVs */
  38636. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  38637. /** Texture is repeating and mirrored */
  38638. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  38639. /** ALPHA */
  38640. static readonly TEXTUREFORMAT_ALPHA: number;
  38641. /** LUMINANCE */
  38642. static readonly TEXTUREFORMAT_LUMINANCE: number;
  38643. /** LUMINANCE_ALPHA */
  38644. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  38645. /** RGB */
  38646. static readonly TEXTUREFORMAT_RGB: number;
  38647. /** RGBA */
  38648. static readonly TEXTUREFORMAT_RGBA: number;
  38649. /** RED */
  38650. static readonly TEXTUREFORMAT_RED: number;
  38651. /** RED (2nd reference) */
  38652. static readonly TEXTUREFORMAT_R: number;
  38653. /** RG */
  38654. static readonly TEXTUREFORMAT_RG: number;
  38655. /** RED_INTEGER */
  38656. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  38657. /** RED_INTEGER (2nd reference) */
  38658. static readonly TEXTUREFORMAT_R_INTEGER: number;
  38659. /** RG_INTEGER */
  38660. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  38661. /** RGB_INTEGER */
  38662. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  38663. /** RGBA_INTEGER */
  38664. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  38665. /** UNSIGNED_BYTE */
  38666. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  38667. /** UNSIGNED_BYTE (2nd reference) */
  38668. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  38669. /** FLOAT */
  38670. static readonly TEXTURETYPE_FLOAT: number;
  38671. /** HALF_FLOAT */
  38672. static readonly TEXTURETYPE_HALF_FLOAT: number;
  38673. /** BYTE */
  38674. static readonly TEXTURETYPE_BYTE: number;
  38675. /** SHORT */
  38676. static readonly TEXTURETYPE_SHORT: number;
  38677. /** UNSIGNED_SHORT */
  38678. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  38679. /** INT */
  38680. static readonly TEXTURETYPE_INT: number;
  38681. /** UNSIGNED_INT */
  38682. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  38683. /** UNSIGNED_SHORT_4_4_4_4 */
  38684. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  38685. /** UNSIGNED_SHORT_5_5_5_1 */
  38686. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  38687. /** UNSIGNED_SHORT_5_6_5 */
  38688. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  38689. /** UNSIGNED_INT_2_10_10_10_REV */
  38690. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  38691. /** UNSIGNED_INT_24_8 */
  38692. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  38693. /** UNSIGNED_INT_10F_11F_11F_REV */
  38694. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  38695. /** UNSIGNED_INT_5_9_9_9_REV */
  38696. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  38697. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  38698. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  38699. /** nearest is mag = nearest and min = nearest and mip = linear */
  38700. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  38701. /** Bilinear is mag = linear and min = linear and mip = nearest */
  38702. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  38703. /** Trilinear is mag = linear and min = linear and mip = linear */
  38704. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  38705. /** nearest is mag = nearest and min = nearest and mip = linear */
  38706. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  38707. /** Bilinear is mag = linear and min = linear and mip = nearest */
  38708. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  38709. /** Trilinear is mag = linear and min = linear and mip = linear */
  38710. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  38711. /** mag = nearest and min = nearest and mip = nearest */
  38712. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  38713. /** mag = nearest and min = linear and mip = nearest */
  38714. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  38715. /** mag = nearest and min = linear and mip = linear */
  38716. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  38717. /** mag = nearest and min = linear and mip = none */
  38718. static readonly TEXTURE_NEAREST_LINEAR: number;
  38719. /** mag = nearest and min = nearest and mip = none */
  38720. static readonly TEXTURE_NEAREST_NEAREST: number;
  38721. /** mag = linear and min = nearest and mip = nearest */
  38722. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  38723. /** mag = linear and min = nearest and mip = linear */
  38724. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  38725. /** mag = linear and min = linear and mip = none */
  38726. static readonly TEXTURE_LINEAR_LINEAR: number;
  38727. /** mag = linear and min = nearest and mip = none */
  38728. static readonly TEXTURE_LINEAR_NEAREST: number;
  38729. /** Explicit coordinates mode */
  38730. static readonly TEXTURE_EXPLICIT_MODE: number;
  38731. /** Spherical coordinates mode */
  38732. static readonly TEXTURE_SPHERICAL_MODE: number;
  38733. /** Planar coordinates mode */
  38734. static readonly TEXTURE_PLANAR_MODE: number;
  38735. /** Cubic coordinates mode */
  38736. static readonly TEXTURE_CUBIC_MODE: number;
  38737. /** Projection coordinates mode */
  38738. static readonly TEXTURE_PROJECTION_MODE: number;
  38739. /** Skybox coordinates mode */
  38740. static readonly TEXTURE_SKYBOX_MODE: number;
  38741. /** Inverse Cubic coordinates mode */
  38742. static readonly TEXTURE_INVCUBIC_MODE: number;
  38743. /** Equirectangular coordinates mode */
  38744. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  38745. /** Equirectangular Fixed coordinates mode */
  38746. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  38747. /** Equirectangular Fixed Mirrored coordinates mode */
  38748. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  38749. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  38750. static readonly SCALEMODE_FLOOR: number;
  38751. /** Defines that texture rescaling will look for the nearest power of 2 size */
  38752. static readonly SCALEMODE_NEAREST: number;
  38753. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  38754. static readonly SCALEMODE_CEILING: number;
  38755. /**
  38756. * Returns the current npm package of the sdk
  38757. */
  38758. static get NpmPackage(): string;
  38759. /**
  38760. * Returns the current version of the framework
  38761. */
  38762. static get Version(): string;
  38763. /** Gets the list of created engines */
  38764. static get Instances(): Engine[];
  38765. /**
  38766. * Gets the latest created engine
  38767. */
  38768. static get LastCreatedEngine(): Nullable<Engine>;
  38769. /**
  38770. * Gets the latest created scene
  38771. */
  38772. static get LastCreatedScene(): Nullable<Scene>;
  38773. /**
  38774. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  38775. * @param flag defines which part of the materials must be marked as dirty
  38776. * @param predicate defines a predicate used to filter which materials should be affected
  38777. */
  38778. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  38779. /**
  38780. * Method called to create the default loading screen.
  38781. * This can be overriden in your own app.
  38782. * @param canvas The rendering canvas element
  38783. * @returns The loading screen
  38784. */
  38785. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  38786. /**
  38787. * Method called to create the default rescale post process on each engine.
  38788. */
  38789. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  38790. /**
  38791. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  38792. **/
  38793. enableOfflineSupport: boolean;
  38794. /**
  38795. * 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)
  38796. **/
  38797. disableManifestCheck: boolean;
  38798. /**
  38799. * Gets the list of created scenes
  38800. */
  38801. scenes: Scene[];
  38802. /**
  38803. * Event raised when a new scene is created
  38804. */
  38805. onNewSceneAddedObservable: Observable<Scene>;
  38806. /**
  38807. * Gets the list of created postprocesses
  38808. */
  38809. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  38810. /**
  38811. * Gets a boolean indicating if the pointer is currently locked
  38812. */
  38813. isPointerLock: boolean;
  38814. /**
  38815. * Observable event triggered each time the rendering canvas is resized
  38816. */
  38817. onResizeObservable: Observable<Engine>;
  38818. /**
  38819. * Observable event triggered each time the canvas loses focus
  38820. */
  38821. onCanvasBlurObservable: Observable<Engine>;
  38822. /**
  38823. * Observable event triggered each time the canvas gains focus
  38824. */
  38825. onCanvasFocusObservable: Observable<Engine>;
  38826. /**
  38827. * Observable event triggered each time the canvas receives pointerout event
  38828. */
  38829. onCanvasPointerOutObservable: Observable<PointerEvent>;
  38830. /**
  38831. * Observable raised when the engine begins a new frame
  38832. */
  38833. onBeginFrameObservable: Observable<Engine>;
  38834. /**
  38835. * If set, will be used to request the next animation frame for the render loop
  38836. */
  38837. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  38838. /**
  38839. * Observable raised when the engine ends the current frame
  38840. */
  38841. onEndFrameObservable: Observable<Engine>;
  38842. /**
  38843. * Observable raised when the engine is about to compile a shader
  38844. */
  38845. onBeforeShaderCompilationObservable: Observable<Engine>;
  38846. /**
  38847. * Observable raised when the engine has jsut compiled a shader
  38848. */
  38849. onAfterShaderCompilationObservable: Observable<Engine>;
  38850. /**
  38851. * Gets the audio engine
  38852. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38853. * @ignorenaming
  38854. */
  38855. static audioEngine: IAudioEngine;
  38856. /**
  38857. * Default AudioEngine factory responsible of creating the Audio Engine.
  38858. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  38859. */
  38860. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  38861. /**
  38862. * Default offline support factory responsible of creating a tool used to store data locally.
  38863. * By default, this will create a Database object if the workload has been embedded.
  38864. */
  38865. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  38866. private _loadingScreen;
  38867. private _pointerLockRequested;
  38868. private _rescalePostProcess;
  38869. private _deterministicLockstep;
  38870. private _lockstepMaxSteps;
  38871. private _timeStep;
  38872. protected get _supportsHardwareTextureRescaling(): boolean;
  38873. private _fps;
  38874. private _deltaTime;
  38875. /** @hidden */
  38876. _drawCalls: PerfCounter;
  38877. /** 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 */
  38878. canvasTabIndex: number;
  38879. /**
  38880. * Turn this value on if you want to pause FPS computation when in background
  38881. */
  38882. disablePerformanceMonitorInBackground: boolean;
  38883. private _performanceMonitor;
  38884. /**
  38885. * Gets the performance monitor attached to this engine
  38886. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  38887. */
  38888. get performanceMonitor(): PerformanceMonitor;
  38889. private _onFocus;
  38890. private _onBlur;
  38891. private _onCanvasPointerOut;
  38892. private _onCanvasBlur;
  38893. private _onCanvasFocus;
  38894. private _onFullscreenChange;
  38895. private _onPointerLockChange;
  38896. /**
  38897. * Gets the HTML element used to attach event listeners
  38898. * @returns a HTML element
  38899. */
  38900. getInputElement(): Nullable<HTMLElement>;
  38901. /**
  38902. * Creates a new engine
  38903. * @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
  38904. * @param antialias defines enable antialiasing (default: false)
  38905. * @param options defines further options to be sent to the getContext() function
  38906. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  38907. */
  38908. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  38909. /**
  38910. * Gets current aspect ratio
  38911. * @param viewportOwner defines the camera to use to get the aspect ratio
  38912. * @param useScreen defines if screen size must be used (or the current render target if any)
  38913. * @returns a number defining the aspect ratio
  38914. */
  38915. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  38916. /**
  38917. * Gets current screen aspect ratio
  38918. * @returns a number defining the aspect ratio
  38919. */
  38920. getScreenAspectRatio(): number;
  38921. /**
  38922. * Gets the client rect of the HTML canvas attached with the current webGL context
  38923. * @returns a client rectanglee
  38924. */
  38925. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  38926. /**
  38927. * Gets the client rect of the HTML element used for events
  38928. * @returns a client rectanglee
  38929. */
  38930. getInputElementClientRect(): Nullable<ClientRect>;
  38931. /**
  38932. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  38933. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38934. * @returns true if engine is in deterministic lock step mode
  38935. */
  38936. isDeterministicLockStep(): boolean;
  38937. /**
  38938. * Gets the max steps when engine is running in deterministic lock step
  38939. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38940. * @returns the max steps
  38941. */
  38942. getLockstepMaxSteps(): number;
  38943. /**
  38944. * Returns the time in ms between steps when using deterministic lock step.
  38945. * @returns time step in (ms)
  38946. */
  38947. getTimeStep(): number;
  38948. /**
  38949. * Force the mipmap generation for the given render target texture
  38950. * @param texture defines the render target texture to use
  38951. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  38952. */
  38953. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  38954. /** States */
  38955. /**
  38956. * Set various states to the webGL context
  38957. * @param culling defines backface culling state
  38958. * @param zOffset defines the value to apply to zOffset (0 by default)
  38959. * @param force defines if states must be applied even if cache is up to date
  38960. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  38961. */
  38962. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  38963. /**
  38964. * Set the z offset to apply to current rendering
  38965. * @param value defines the offset to apply
  38966. */
  38967. setZOffset(value: number): void;
  38968. /**
  38969. * Gets the current value of the zOffset
  38970. * @returns the current zOffset state
  38971. */
  38972. getZOffset(): number;
  38973. /**
  38974. * Enable or disable depth buffering
  38975. * @param enable defines the state to set
  38976. */
  38977. setDepthBuffer(enable: boolean): void;
  38978. /**
  38979. * Gets a boolean indicating if depth writing is enabled
  38980. * @returns the current depth writing state
  38981. */
  38982. getDepthWrite(): boolean;
  38983. /**
  38984. * Enable or disable depth writing
  38985. * @param enable defines the state to set
  38986. */
  38987. setDepthWrite(enable: boolean): void;
  38988. /**
  38989. * Gets a boolean indicating if stencil buffer is enabled
  38990. * @returns the current stencil buffer state
  38991. */
  38992. getStencilBuffer(): boolean;
  38993. /**
  38994. * Enable or disable the stencil buffer
  38995. * @param enable defines if the stencil buffer must be enabled or disabled
  38996. */
  38997. setStencilBuffer(enable: boolean): void;
  38998. /**
  38999. * Gets the current stencil mask
  39000. * @returns a number defining the new stencil mask to use
  39001. */
  39002. getStencilMask(): number;
  39003. /**
  39004. * Sets the current stencil mask
  39005. * @param mask defines the new stencil mask to use
  39006. */
  39007. setStencilMask(mask: number): void;
  39008. /**
  39009. * Gets the current stencil function
  39010. * @returns a number defining the stencil function to use
  39011. */
  39012. getStencilFunction(): number;
  39013. /**
  39014. * Gets the current stencil reference value
  39015. * @returns a number defining the stencil reference value to use
  39016. */
  39017. getStencilFunctionReference(): number;
  39018. /**
  39019. * Gets the current stencil mask
  39020. * @returns a number defining the stencil mask to use
  39021. */
  39022. getStencilFunctionMask(): number;
  39023. /**
  39024. * Sets the current stencil function
  39025. * @param stencilFunc defines the new stencil function to use
  39026. */
  39027. setStencilFunction(stencilFunc: number): void;
  39028. /**
  39029. * Sets the current stencil reference
  39030. * @param reference defines the new stencil reference to use
  39031. */
  39032. setStencilFunctionReference(reference: number): void;
  39033. /**
  39034. * Sets the current stencil mask
  39035. * @param mask defines the new stencil mask to use
  39036. */
  39037. setStencilFunctionMask(mask: number): void;
  39038. /**
  39039. * Gets the current stencil operation when stencil fails
  39040. * @returns a number defining stencil operation to use when stencil fails
  39041. */
  39042. getStencilOperationFail(): number;
  39043. /**
  39044. * Gets the current stencil operation when depth fails
  39045. * @returns a number defining stencil operation to use when depth fails
  39046. */
  39047. getStencilOperationDepthFail(): number;
  39048. /**
  39049. * Gets the current stencil operation when stencil passes
  39050. * @returns a number defining stencil operation to use when stencil passes
  39051. */
  39052. getStencilOperationPass(): number;
  39053. /**
  39054. * Sets the stencil operation to use when stencil fails
  39055. * @param operation defines the stencil operation to use when stencil fails
  39056. */
  39057. setStencilOperationFail(operation: number): void;
  39058. /**
  39059. * Sets the stencil operation to use when depth fails
  39060. * @param operation defines the stencil operation to use when depth fails
  39061. */
  39062. setStencilOperationDepthFail(operation: number): void;
  39063. /**
  39064. * Sets the stencil operation to use when stencil passes
  39065. * @param operation defines the stencil operation to use when stencil passes
  39066. */
  39067. setStencilOperationPass(operation: number): void;
  39068. /**
  39069. * Sets a boolean indicating if the dithering state is enabled or disabled
  39070. * @param value defines the dithering state
  39071. */
  39072. setDitheringState(value: boolean): void;
  39073. /**
  39074. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  39075. * @param value defines the rasterizer state
  39076. */
  39077. setRasterizerState(value: boolean): void;
  39078. /**
  39079. * Gets the current depth function
  39080. * @returns a number defining the depth function
  39081. */
  39082. getDepthFunction(): Nullable<number>;
  39083. /**
  39084. * Sets the current depth function
  39085. * @param depthFunc defines the function to use
  39086. */
  39087. setDepthFunction(depthFunc: number): void;
  39088. /**
  39089. * Sets the current depth function to GREATER
  39090. */
  39091. setDepthFunctionToGreater(): void;
  39092. /**
  39093. * Sets the current depth function to GEQUAL
  39094. */
  39095. setDepthFunctionToGreaterOrEqual(): void;
  39096. /**
  39097. * Sets the current depth function to LESS
  39098. */
  39099. setDepthFunctionToLess(): void;
  39100. /**
  39101. * Sets the current depth function to LEQUAL
  39102. */
  39103. setDepthFunctionToLessOrEqual(): void;
  39104. private _cachedStencilBuffer;
  39105. private _cachedStencilFunction;
  39106. private _cachedStencilMask;
  39107. private _cachedStencilOperationPass;
  39108. private _cachedStencilOperationFail;
  39109. private _cachedStencilOperationDepthFail;
  39110. private _cachedStencilReference;
  39111. /**
  39112. * Caches the the state of the stencil buffer
  39113. */
  39114. cacheStencilState(): void;
  39115. /**
  39116. * Restores the state of the stencil buffer
  39117. */
  39118. restoreStencilState(): void;
  39119. /**
  39120. * Directly set the WebGL Viewport
  39121. * @param x defines the x coordinate of the viewport (in screen space)
  39122. * @param y defines the y coordinate of the viewport (in screen space)
  39123. * @param width defines the width of the viewport (in screen space)
  39124. * @param height defines the height of the viewport (in screen space)
  39125. * @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
  39126. */
  39127. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  39128. /**
  39129. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  39130. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  39131. * @param y defines the y-coordinate of the corner of the clear rectangle
  39132. * @param width defines the width of the clear rectangle
  39133. * @param height defines the height of the clear rectangle
  39134. * @param clearColor defines the clear color
  39135. */
  39136. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  39137. /**
  39138. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  39139. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  39140. * @param y defines the y-coordinate of the corner of the clear rectangle
  39141. * @param width defines the width of the clear rectangle
  39142. * @param height defines the height of the clear rectangle
  39143. */
  39144. enableScissor(x: number, y: number, width: number, height: number): void;
  39145. /**
  39146. * Disable previously set scissor test rectangle
  39147. */
  39148. disableScissor(): void;
  39149. protected _reportDrawCall(): void;
  39150. /**
  39151. * Initializes a webVR display and starts listening to display change events
  39152. * The onVRDisplayChangedObservable will be notified upon these changes
  39153. * @returns The onVRDisplayChangedObservable
  39154. */
  39155. initWebVR(): Observable<IDisplayChangedEventArgs>;
  39156. /** @hidden */
  39157. _prepareVRComponent(): void;
  39158. /** @hidden */
  39159. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  39160. /** @hidden */
  39161. _submitVRFrame(): void;
  39162. /**
  39163. * Call this function to leave webVR mode
  39164. * Will do nothing if webVR is not supported or if there is no webVR device
  39165. * @see https://doc.babylonjs.com/how_to/webvr_camera
  39166. */
  39167. disableVR(): void;
  39168. /**
  39169. * Gets a boolean indicating that the system is in VR mode and is presenting
  39170. * @returns true if VR mode is engaged
  39171. */
  39172. isVRPresenting(): boolean;
  39173. /** @hidden */
  39174. _requestVRFrame(): void;
  39175. /** @hidden */
  39176. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  39177. /**
  39178. * Gets the source code of the vertex shader associated with a specific webGL program
  39179. * @param program defines the program to use
  39180. * @returns a string containing the source code of the vertex shader associated with the program
  39181. */
  39182. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  39183. /**
  39184. * Gets the source code of the fragment shader associated with a specific webGL program
  39185. * @param program defines the program to use
  39186. * @returns a string containing the source code of the fragment shader associated with the program
  39187. */
  39188. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  39189. /**
  39190. * Sets a depth stencil texture from a render target to the according uniform.
  39191. * @param channel The texture channel
  39192. * @param uniform The uniform to set
  39193. * @param texture The render target texture containing the depth stencil texture to apply
  39194. */
  39195. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  39196. /**
  39197. * Sets a texture to the webGL context from a postprocess
  39198. * @param channel defines the channel to use
  39199. * @param postProcess defines the source postprocess
  39200. */
  39201. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  39202. /**
  39203. * Binds the output of the passed in post process to the texture channel specified
  39204. * @param channel The channel the texture should be bound to
  39205. * @param postProcess The post process which's output should be bound
  39206. */
  39207. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  39208. protected _rebuildBuffers(): void;
  39209. /** @hidden */
  39210. _renderFrame(): void;
  39211. _renderLoop(): void;
  39212. /** @hidden */
  39213. _renderViews(): boolean;
  39214. /**
  39215. * Toggle full screen mode
  39216. * @param requestPointerLock defines if a pointer lock should be requested from the user
  39217. */
  39218. switchFullscreen(requestPointerLock: boolean): void;
  39219. /**
  39220. * Enters full screen mode
  39221. * @param requestPointerLock defines if a pointer lock should be requested from the user
  39222. */
  39223. enterFullscreen(requestPointerLock: boolean): void;
  39224. /**
  39225. * Exits full screen mode
  39226. */
  39227. exitFullscreen(): void;
  39228. /**
  39229. * Enters Pointerlock mode
  39230. */
  39231. enterPointerlock(): void;
  39232. /**
  39233. * Exits Pointerlock mode
  39234. */
  39235. exitPointerlock(): void;
  39236. /**
  39237. * Begin a new frame
  39238. */
  39239. beginFrame(): void;
  39240. /**
  39241. * Enf the current frame
  39242. */
  39243. endFrame(): void;
  39244. resize(): void;
  39245. /**
  39246. * Force a specific size of the canvas
  39247. * @param width defines the new canvas' width
  39248. * @param height defines the new canvas' height
  39249. * @returns true if the size was changed
  39250. */
  39251. setSize(width: number, height: number): boolean;
  39252. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  39253. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39254. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39255. _releaseTexture(texture: InternalTexture): void;
  39256. /**
  39257. * @hidden
  39258. * Rescales a texture
  39259. * @param source input texutre
  39260. * @param destination destination texture
  39261. * @param scene scene to use to render the resize
  39262. * @param internalFormat format to use when resizing
  39263. * @param onComplete callback to be called when resize has completed
  39264. */
  39265. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  39266. /**
  39267. * Gets the current framerate
  39268. * @returns a number representing the framerate
  39269. */
  39270. getFps(): number;
  39271. /**
  39272. * Gets the time spent between current and previous frame
  39273. * @returns a number representing the delta time in ms
  39274. */
  39275. getDeltaTime(): number;
  39276. private _measureFps;
  39277. /** @hidden */
  39278. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  39279. /**
  39280. * Updates the sample count of a render target texture
  39281. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  39282. * @param texture defines the texture to update
  39283. * @param samples defines the sample count to set
  39284. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  39285. */
  39286. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  39287. /**
  39288. * Updates a depth texture Comparison Mode and Function.
  39289. * If the comparison Function is equal to 0, the mode will be set to none.
  39290. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  39291. * @param texture The texture to set the comparison function for
  39292. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  39293. */
  39294. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  39295. /**
  39296. * Creates a webGL buffer to use with instanciation
  39297. * @param capacity defines the size of the buffer
  39298. * @returns the webGL buffer
  39299. */
  39300. createInstancesBuffer(capacity: number): DataBuffer;
  39301. /**
  39302. * Delete a webGL buffer used with instanciation
  39303. * @param buffer defines the webGL buffer to delete
  39304. */
  39305. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  39306. private _clientWaitAsync;
  39307. /** @hidden */
  39308. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  39309. dispose(): void;
  39310. private _disableTouchAction;
  39311. /**
  39312. * Display the loading screen
  39313. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39314. */
  39315. displayLoadingUI(): void;
  39316. /**
  39317. * Hide the loading screen
  39318. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39319. */
  39320. hideLoadingUI(): void;
  39321. /**
  39322. * Gets the current loading screen object
  39323. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39324. */
  39325. get loadingScreen(): ILoadingScreen;
  39326. /**
  39327. * Sets the current loading screen object
  39328. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39329. */
  39330. set loadingScreen(loadingScreen: ILoadingScreen);
  39331. /**
  39332. * Sets the current loading screen text
  39333. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39334. */
  39335. set loadingUIText(text: string);
  39336. /**
  39337. * Sets the current loading screen background color
  39338. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39339. */
  39340. set loadingUIBackgroundColor(color: string);
  39341. /** Pointerlock and fullscreen */
  39342. /**
  39343. * Ask the browser to promote the current element to pointerlock mode
  39344. * @param element defines the DOM element to promote
  39345. */
  39346. static _RequestPointerlock(element: HTMLElement): void;
  39347. /**
  39348. * Asks the browser to exit pointerlock mode
  39349. */
  39350. static _ExitPointerlock(): void;
  39351. /**
  39352. * Ask the browser to promote the current element to fullscreen rendering mode
  39353. * @param element defines the DOM element to promote
  39354. */
  39355. static _RequestFullscreen(element: HTMLElement): void;
  39356. /**
  39357. * Asks the browser to exit fullscreen mode
  39358. */
  39359. static _ExitFullscreen(): void;
  39360. }
  39361. }
  39362. declare module "babylonjs/Engines/engineStore" {
  39363. import { Nullable } from "babylonjs/types";
  39364. import { Engine } from "babylonjs/Engines/engine";
  39365. import { Scene } from "babylonjs/scene";
  39366. /**
  39367. * The engine store class is responsible to hold all the instances of Engine and Scene created
  39368. * during the life time of the application.
  39369. */
  39370. export class EngineStore {
  39371. /** Gets the list of created engines */
  39372. static Instances: import("babylonjs/Engines/engine").Engine[];
  39373. /** @hidden */
  39374. static _LastCreatedScene: Nullable<Scene>;
  39375. /**
  39376. * Gets the latest created engine
  39377. */
  39378. static get LastCreatedEngine(): Nullable<Engine>;
  39379. /**
  39380. * Gets the latest created scene
  39381. */
  39382. static get LastCreatedScene(): Nullable<Scene>;
  39383. /**
  39384. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39385. * @ignorenaming
  39386. */
  39387. static UseFallbackTexture: boolean;
  39388. /**
  39389. * Texture content used if a texture cannot loaded
  39390. * @ignorenaming
  39391. */
  39392. static FallbackTexture: string;
  39393. }
  39394. }
  39395. declare module "babylonjs/Misc/promise" {
  39396. /**
  39397. * Helper class that provides a small promise polyfill
  39398. */
  39399. export class PromisePolyfill {
  39400. /**
  39401. * Static function used to check if the polyfill is required
  39402. * If this is the case then the function will inject the polyfill to window.Promise
  39403. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  39404. */
  39405. static Apply(force?: boolean): void;
  39406. }
  39407. }
  39408. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  39409. /**
  39410. * Interface for screenshot methods with describe argument called `size` as object with options
  39411. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  39412. */
  39413. export interface IScreenshotSize {
  39414. /**
  39415. * number in pixels for canvas height
  39416. */
  39417. height?: number;
  39418. /**
  39419. * multiplier allowing render at a higher or lower resolution
  39420. * If value is defined then height and width will be ignored and taken from camera
  39421. */
  39422. precision?: number;
  39423. /**
  39424. * number in pixels for canvas width
  39425. */
  39426. width?: number;
  39427. }
  39428. }
  39429. declare module "babylonjs/Misc/tools" {
  39430. import { Nullable, float } from "babylonjs/types";
  39431. import { DomManagement } from "babylonjs/Misc/domManagement";
  39432. import { WebRequest } from "babylonjs/Misc/webRequest";
  39433. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  39434. import { ReadFileError } from "babylonjs/Misc/fileTools";
  39435. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  39436. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  39437. import { Camera } from "babylonjs/Cameras/camera";
  39438. import { Engine } from "babylonjs/Engines/engine";
  39439. interface IColor4Like {
  39440. r: float;
  39441. g: float;
  39442. b: float;
  39443. a: float;
  39444. }
  39445. /**
  39446. * Class containing a set of static utilities functions
  39447. */
  39448. export class Tools {
  39449. /**
  39450. * Gets or sets the base URL to use to load assets
  39451. */
  39452. static get BaseUrl(): string;
  39453. static set BaseUrl(value: string);
  39454. /**
  39455. * Enable/Disable Custom HTTP Request Headers globally.
  39456. * default = false
  39457. * @see CustomRequestHeaders
  39458. */
  39459. static UseCustomRequestHeaders: boolean;
  39460. /**
  39461. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  39462. * i.e. when loading files, where the server/service expects an Authorization header
  39463. */
  39464. static CustomRequestHeaders: {
  39465. [key: string]: string;
  39466. };
  39467. /**
  39468. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  39469. */
  39470. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  39471. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  39472. /**
  39473. * Default behaviour for cors in the application.
  39474. * It can be a string if the expected behavior is identical in the entire app.
  39475. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  39476. */
  39477. static get CorsBehavior(): string | ((url: string | string[]) => string);
  39478. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  39479. /**
  39480. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39481. * @ignorenaming
  39482. */
  39483. static get UseFallbackTexture(): boolean;
  39484. static set UseFallbackTexture(value: boolean);
  39485. /**
  39486. * Use this object to register external classes like custom textures or material
  39487. * to allow the laoders to instantiate them
  39488. */
  39489. static get RegisteredExternalClasses(): {
  39490. [key: string]: Object;
  39491. };
  39492. static set RegisteredExternalClasses(classes: {
  39493. [key: string]: Object;
  39494. });
  39495. /**
  39496. * Texture content used if a texture cannot loaded
  39497. * @ignorenaming
  39498. */
  39499. static get fallbackTexture(): string;
  39500. static set fallbackTexture(value: string);
  39501. /**
  39502. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  39503. * @param u defines the coordinate on X axis
  39504. * @param v defines the coordinate on Y axis
  39505. * @param width defines the width of the source data
  39506. * @param height defines the height of the source data
  39507. * @param pixels defines the source byte array
  39508. * @param color defines the output color
  39509. */
  39510. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  39511. /**
  39512. * Interpolates between a and b via alpha
  39513. * @param a The lower value (returned when alpha = 0)
  39514. * @param b The upper value (returned when alpha = 1)
  39515. * @param alpha The interpolation-factor
  39516. * @return The mixed value
  39517. */
  39518. static Mix(a: number, b: number, alpha: number): number;
  39519. /**
  39520. * Tries to instantiate a new object from a given class name
  39521. * @param className defines the class name to instantiate
  39522. * @returns the new object or null if the system was not able to do the instantiation
  39523. */
  39524. static Instantiate(className: string): any;
  39525. /**
  39526. * Provides a slice function that will work even on IE
  39527. * @param data defines the array to slice
  39528. * @param start defines the start of the data (optional)
  39529. * @param end defines the end of the data (optional)
  39530. * @returns the new sliced array
  39531. */
  39532. static Slice<T>(data: T, start?: number, end?: number): T;
  39533. /**
  39534. * Polyfill for setImmediate
  39535. * @param action defines the action to execute after the current execution block
  39536. */
  39537. static SetImmediate(action: () => void): void;
  39538. /**
  39539. * Function indicating if a number is an exponent of 2
  39540. * @param value defines the value to test
  39541. * @returns true if the value is an exponent of 2
  39542. */
  39543. static IsExponentOfTwo(value: number): boolean;
  39544. private static _tmpFloatArray;
  39545. /**
  39546. * Returns the nearest 32-bit single precision float representation of a Number
  39547. * @param value A Number. If the parameter is of a different type, it will get converted
  39548. * to a number or to NaN if it cannot be converted
  39549. * @returns number
  39550. */
  39551. static FloatRound(value: number): number;
  39552. /**
  39553. * Extracts the filename from a path
  39554. * @param path defines the path to use
  39555. * @returns the filename
  39556. */
  39557. static GetFilename(path: string): string;
  39558. /**
  39559. * Extracts the "folder" part of a path (everything before the filename).
  39560. * @param uri The URI to extract the info from
  39561. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  39562. * @returns The "folder" part of the path
  39563. */
  39564. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  39565. /**
  39566. * Extracts text content from a DOM element hierarchy
  39567. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  39568. */
  39569. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  39570. /**
  39571. * Convert an angle in radians to degrees
  39572. * @param angle defines the angle to convert
  39573. * @returns the angle in degrees
  39574. */
  39575. static ToDegrees(angle: number): number;
  39576. /**
  39577. * Convert an angle in degrees to radians
  39578. * @param angle defines the angle to convert
  39579. * @returns the angle in radians
  39580. */
  39581. static ToRadians(angle: number): number;
  39582. /**
  39583. * Returns an array if obj is not an array
  39584. * @param obj defines the object to evaluate as an array
  39585. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  39586. * @returns either obj directly if obj is an array or a new array containing obj
  39587. */
  39588. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  39589. /**
  39590. * Gets the pointer prefix to use
  39591. * @param engine defines the engine we are finding the prefix for
  39592. * @returns "pointer" if touch is enabled. Else returns "mouse"
  39593. */
  39594. static GetPointerPrefix(engine: Engine): string;
  39595. /**
  39596. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  39597. * @param url define the url we are trying
  39598. * @param element define the dom element where to configure the cors policy
  39599. */
  39600. static SetCorsBehavior(url: string | string[], element: {
  39601. crossOrigin: string | null;
  39602. }): void;
  39603. /**
  39604. * Removes unwanted characters from an url
  39605. * @param url defines the url to clean
  39606. * @returns the cleaned url
  39607. */
  39608. static CleanUrl(url: string): string;
  39609. /**
  39610. * Gets or sets a function used to pre-process url before using them to load assets
  39611. */
  39612. static get PreprocessUrl(): (url: string) => string;
  39613. static set PreprocessUrl(processor: (url: string) => string);
  39614. /**
  39615. * Loads an image as an HTMLImageElement.
  39616. * @param input url string, ArrayBuffer, or Blob to load
  39617. * @param onLoad callback called when the image successfully loads
  39618. * @param onError callback called when the image fails to load
  39619. * @param offlineProvider offline provider for caching
  39620. * @param mimeType optional mime type
  39621. * @returns the HTMLImageElement of the loaded image
  39622. */
  39623. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  39624. /**
  39625. * Loads a file from a url
  39626. * @param url url string, ArrayBuffer, or Blob to load
  39627. * @param onSuccess callback called when the file successfully loads
  39628. * @param onProgress callback called while file is loading (if the server supports this mode)
  39629. * @param offlineProvider defines the offline provider for caching
  39630. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39631. * @param onError callback called when the file fails to load
  39632. * @returns a file request object
  39633. */
  39634. 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;
  39635. /**
  39636. * Loads a file from a url
  39637. * @param url the file url to load
  39638. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39639. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  39640. */
  39641. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  39642. /**
  39643. * Load a script (identified by an url). When the url returns, the
  39644. * content of this file is added into a new script element, attached to the DOM (body element)
  39645. * @param scriptUrl defines the url of the script to laod
  39646. * @param onSuccess defines the callback called when the script is loaded
  39647. * @param onError defines the callback to call if an error occurs
  39648. * @param scriptId defines the id of the script element
  39649. */
  39650. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  39651. /**
  39652. * Load an asynchronous script (identified by an url). When the url returns, the
  39653. * content of this file is added into a new script element, attached to the DOM (body element)
  39654. * @param scriptUrl defines the url of the script to laod
  39655. * @param scriptId defines the id of the script element
  39656. * @returns a promise request object
  39657. */
  39658. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  39659. /**
  39660. * Loads a file from a blob
  39661. * @param fileToLoad defines the blob to use
  39662. * @param callback defines the callback to call when data is loaded
  39663. * @param progressCallback defines the callback to call during loading process
  39664. * @returns a file request object
  39665. */
  39666. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  39667. /**
  39668. * Reads a file from a File object
  39669. * @param file defines the file to load
  39670. * @param onSuccess defines the callback to call when data is loaded
  39671. * @param onProgress defines the callback to call during loading process
  39672. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  39673. * @param onError defines the callback to call when an error occurs
  39674. * @returns a file request object
  39675. */
  39676. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  39677. /**
  39678. * Creates a data url from a given string content
  39679. * @param content defines the content to convert
  39680. * @returns the new data url link
  39681. */
  39682. static FileAsURL(content: string): string;
  39683. /**
  39684. * Format the given number to a specific decimal format
  39685. * @param value defines the number to format
  39686. * @param decimals defines the number of decimals to use
  39687. * @returns the formatted string
  39688. */
  39689. static Format(value: number, decimals?: number): string;
  39690. /**
  39691. * Tries to copy an object by duplicating every property
  39692. * @param source defines the source object
  39693. * @param destination defines the target object
  39694. * @param doNotCopyList defines a list of properties to avoid
  39695. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  39696. */
  39697. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  39698. /**
  39699. * Gets a boolean indicating if the given object has no own property
  39700. * @param obj defines the object to test
  39701. * @returns true if object has no own property
  39702. */
  39703. static IsEmpty(obj: any): boolean;
  39704. /**
  39705. * Function used to register events at window level
  39706. * @param windowElement defines the Window object to use
  39707. * @param events defines the events to register
  39708. */
  39709. static RegisterTopRootEvents(windowElement: Window, events: {
  39710. name: string;
  39711. handler: Nullable<(e: FocusEvent) => any>;
  39712. }[]): void;
  39713. /**
  39714. * Function used to unregister events from window level
  39715. * @param windowElement defines the Window object to use
  39716. * @param events defines the events to unregister
  39717. */
  39718. static UnregisterTopRootEvents(windowElement: Window, events: {
  39719. name: string;
  39720. handler: Nullable<(e: FocusEvent) => any>;
  39721. }[]): void;
  39722. /**
  39723. * @ignore
  39724. */
  39725. static _ScreenshotCanvas: HTMLCanvasElement;
  39726. /**
  39727. * Dumps the current bound framebuffer
  39728. * @param width defines the rendering width
  39729. * @param height defines the rendering height
  39730. * @param engine defines the hosting engine
  39731. * @param successCallback defines the callback triggered once the data are available
  39732. * @param mimeType defines the mime type of the result
  39733. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  39734. */
  39735. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39736. /**
  39737. * Converts the canvas data to blob.
  39738. * This acts as a polyfill for browsers not supporting the to blob function.
  39739. * @param canvas Defines the canvas to extract the data from
  39740. * @param successCallback Defines the callback triggered once the data are available
  39741. * @param mimeType Defines the mime type of the result
  39742. */
  39743. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  39744. /**
  39745. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  39746. * @param successCallback defines the callback triggered once the data are available
  39747. * @param mimeType defines the mime type of the result
  39748. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  39749. */
  39750. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39751. /**
  39752. * Downloads a blob in the browser
  39753. * @param blob defines the blob to download
  39754. * @param fileName defines the name of the downloaded file
  39755. */
  39756. static Download(blob: Blob, fileName: string): void;
  39757. /**
  39758. * Captures a screenshot of the current rendering
  39759. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39760. * @param engine defines the rendering engine
  39761. * @param camera defines the source camera
  39762. * @param size This parameter can be set to a single number or to an object with the
  39763. * following (optional) properties: precision, width, height. If a single number is passed,
  39764. * it will be used for both width and height. If an object is passed, the screenshot size
  39765. * will be derived from the parameters. The precision property is a multiplier allowing
  39766. * rendering at a higher or lower resolution
  39767. * @param successCallback defines the callback receives a single parameter which contains the
  39768. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39769. * src parameter of an <img> to display it
  39770. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  39771. * Check your browser for supported MIME types
  39772. */
  39773. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  39774. /**
  39775. * Captures a screenshot of the current rendering
  39776. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39777. * @param engine defines the rendering engine
  39778. * @param camera defines the source camera
  39779. * @param size This parameter can be set to a single number or to an object with the
  39780. * following (optional) properties: precision, width, height. If a single number is passed,
  39781. * it will be used for both width and height. If an object is passed, the screenshot size
  39782. * will be derived from the parameters. The precision property is a multiplier allowing
  39783. * rendering at a higher or lower resolution
  39784. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  39785. * Check your browser for supported MIME types
  39786. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  39787. * to the src parameter of an <img> to display it
  39788. */
  39789. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  39790. /**
  39791. * Generates an image screenshot from the specified camera.
  39792. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39793. * @param engine The engine to use for rendering
  39794. * @param camera The camera to use for rendering
  39795. * @param size This parameter can be set to a single number or to an object with the
  39796. * following (optional) properties: precision, width, height. If a single number is passed,
  39797. * it will be used for both width and height. If an object is passed, the screenshot size
  39798. * will be derived from the parameters. The precision property is a multiplier allowing
  39799. * rendering at a higher or lower resolution
  39800. * @param successCallback The callback receives a single parameter which contains the
  39801. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39802. * src parameter of an <img> to display it
  39803. * @param mimeType The MIME type of the screenshot image (default: image/png).
  39804. * Check your browser for supported MIME types
  39805. * @param samples Texture samples (default: 1)
  39806. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  39807. * @param fileName A name for for the downloaded file.
  39808. */
  39809. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  39810. /**
  39811. * Generates an image screenshot from the specified camera.
  39812. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39813. * @param engine The engine to use for rendering
  39814. * @param camera The camera to use for rendering
  39815. * @param size This parameter can be set to a single number or to an object with the
  39816. * following (optional) properties: precision, width, height. If a single number is passed,
  39817. * it will be used for both width and height. If an object is passed, the screenshot size
  39818. * will be derived from the parameters. The precision property is a multiplier allowing
  39819. * rendering at a higher or lower resolution
  39820. * @param mimeType The MIME type of the screenshot image (default: image/png).
  39821. * Check your browser for supported MIME types
  39822. * @param samples Texture samples (default: 1)
  39823. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  39824. * @param fileName A name for for the downloaded file.
  39825. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  39826. * to the src parameter of an <img> to display it
  39827. */
  39828. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  39829. /**
  39830. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  39831. * Be aware Math.random() could cause collisions, but:
  39832. * "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"
  39833. * @returns a pseudo random id
  39834. */
  39835. static RandomId(): string;
  39836. /**
  39837. * Test if the given uri is a base64 string
  39838. * @param uri The uri to test
  39839. * @return True if the uri is a base64 string or false otherwise
  39840. */
  39841. static IsBase64(uri: string): boolean;
  39842. /**
  39843. * Decode the given base64 uri.
  39844. * @param uri The uri to decode
  39845. * @return The decoded base64 data.
  39846. */
  39847. static DecodeBase64(uri: string): ArrayBuffer;
  39848. /**
  39849. * Gets the absolute url.
  39850. * @param url the input url
  39851. * @return the absolute url
  39852. */
  39853. static GetAbsoluteUrl(url: string): string;
  39854. /**
  39855. * No log
  39856. */
  39857. static readonly NoneLogLevel: number;
  39858. /**
  39859. * Only message logs
  39860. */
  39861. static readonly MessageLogLevel: number;
  39862. /**
  39863. * Only warning logs
  39864. */
  39865. static readonly WarningLogLevel: number;
  39866. /**
  39867. * Only error logs
  39868. */
  39869. static readonly ErrorLogLevel: number;
  39870. /**
  39871. * All logs
  39872. */
  39873. static readonly AllLogLevel: number;
  39874. /**
  39875. * Gets a value indicating the number of loading errors
  39876. * @ignorenaming
  39877. */
  39878. static get errorsCount(): number;
  39879. /**
  39880. * Callback called when a new log is added
  39881. */
  39882. static OnNewCacheEntry: (entry: string) => void;
  39883. /**
  39884. * Log a message to the console
  39885. * @param message defines the message to log
  39886. */
  39887. static Log(message: string): void;
  39888. /**
  39889. * Write a warning message to the console
  39890. * @param message defines the message to log
  39891. */
  39892. static Warn(message: string): void;
  39893. /**
  39894. * Write an error message to the console
  39895. * @param message defines the message to log
  39896. */
  39897. static Error(message: string): void;
  39898. /**
  39899. * Gets current log cache (list of logs)
  39900. */
  39901. static get LogCache(): string;
  39902. /**
  39903. * Clears the log cache
  39904. */
  39905. static ClearLogCache(): void;
  39906. /**
  39907. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  39908. */
  39909. static set LogLevels(level: number);
  39910. /**
  39911. * Checks if the window object exists
  39912. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  39913. */
  39914. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  39915. /**
  39916. * No performance log
  39917. */
  39918. static readonly PerformanceNoneLogLevel: number;
  39919. /**
  39920. * Use user marks to log performance
  39921. */
  39922. static readonly PerformanceUserMarkLogLevel: number;
  39923. /**
  39924. * Log performance to the console
  39925. */
  39926. static readonly PerformanceConsoleLogLevel: number;
  39927. private static _performance;
  39928. /**
  39929. * Sets the current performance log level
  39930. */
  39931. static set PerformanceLogLevel(level: number);
  39932. private static _StartPerformanceCounterDisabled;
  39933. private static _EndPerformanceCounterDisabled;
  39934. private static _StartUserMark;
  39935. private static _EndUserMark;
  39936. private static _StartPerformanceConsole;
  39937. private static _EndPerformanceConsole;
  39938. /**
  39939. * Starts a performance counter
  39940. */
  39941. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  39942. /**
  39943. * Ends a specific performance coutner
  39944. */
  39945. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  39946. /**
  39947. * Gets either window.performance.now() if supported or Date.now() else
  39948. */
  39949. static get Now(): number;
  39950. /**
  39951. * This method will return the name of the class used to create the instance of the given object.
  39952. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  39953. * @param object the object to get the class name from
  39954. * @param isType defines if the object is actually a type
  39955. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  39956. */
  39957. static GetClassName(object: any, isType?: boolean): string;
  39958. /**
  39959. * Gets the first element of an array satisfying a given predicate
  39960. * @param array defines the array to browse
  39961. * @param predicate defines the predicate to use
  39962. * @returns null if not found or the element
  39963. */
  39964. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  39965. /**
  39966. * This method will return the name of the full name of the class, including its owning module (if any).
  39967. * 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).
  39968. * @param object the object to get the class name from
  39969. * @param isType defines if the object is actually a type
  39970. * @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.
  39971. * @ignorenaming
  39972. */
  39973. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  39974. /**
  39975. * Returns a promise that resolves after the given amount of time.
  39976. * @param delay Number of milliseconds to delay
  39977. * @returns Promise that resolves after the given amount of time
  39978. */
  39979. static DelayAsync(delay: number): Promise<void>;
  39980. /**
  39981. * Utility function to detect if the current user agent is Safari
  39982. * @returns whether or not the current user agent is safari
  39983. */
  39984. static IsSafari(): boolean;
  39985. }
  39986. /**
  39987. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  39988. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  39989. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  39990. * @param name The name of the class, case should be preserved
  39991. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  39992. */
  39993. export function className(name: string, module?: string): (target: Object) => void;
  39994. /**
  39995. * An implementation of a loop for asynchronous functions.
  39996. */
  39997. export class AsyncLoop {
  39998. /**
  39999. * Defines the number of iterations for the loop
  40000. */
  40001. iterations: number;
  40002. /**
  40003. * Defines the current index of the loop.
  40004. */
  40005. index: number;
  40006. private _done;
  40007. private _fn;
  40008. private _successCallback;
  40009. /**
  40010. * Constructor.
  40011. * @param iterations the number of iterations.
  40012. * @param func the function to run each iteration
  40013. * @param successCallback the callback that will be called upon succesful execution
  40014. * @param offset starting offset.
  40015. */
  40016. constructor(
  40017. /**
  40018. * Defines the number of iterations for the loop
  40019. */
  40020. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  40021. /**
  40022. * Execute the next iteration. Must be called after the last iteration was finished.
  40023. */
  40024. executeNext(): void;
  40025. /**
  40026. * Break the loop and run the success callback.
  40027. */
  40028. breakLoop(): void;
  40029. /**
  40030. * Create and run an async loop.
  40031. * @param iterations the number of iterations.
  40032. * @param fn the function to run each iteration
  40033. * @param successCallback the callback that will be called upon succesful execution
  40034. * @param offset starting offset.
  40035. * @returns the created async loop object
  40036. */
  40037. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  40038. /**
  40039. * A for-loop that will run a given number of iterations synchronous and the rest async.
  40040. * @param iterations total number of iterations
  40041. * @param syncedIterations number of synchronous iterations in each async iteration.
  40042. * @param fn the function to call each iteration.
  40043. * @param callback a success call back that will be called when iterating stops.
  40044. * @param breakFunction a break condition (optional)
  40045. * @param timeout timeout settings for the setTimeout function. default - 0.
  40046. * @returns the created async loop object
  40047. */
  40048. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  40049. }
  40050. }
  40051. declare module "babylonjs/Misc/stringDictionary" {
  40052. import { Nullable } from "babylonjs/types";
  40053. /**
  40054. * This class implement a typical dictionary using a string as key and the generic type T as value.
  40055. * The underlying implementation relies on an associative array to ensure the best performances.
  40056. * The value can be anything including 'null' but except 'undefined'
  40057. */
  40058. export class StringDictionary<T> {
  40059. /**
  40060. * This will clear this dictionary and copy the content from the 'source' one.
  40061. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  40062. * @param source the dictionary to take the content from and copy to this dictionary
  40063. */
  40064. copyFrom(source: StringDictionary<T>): void;
  40065. /**
  40066. * Get a value based from its key
  40067. * @param key the given key to get the matching value from
  40068. * @return the value if found, otherwise undefined is returned
  40069. */
  40070. get(key: string): T | undefined;
  40071. /**
  40072. * Get a value from its key or add it if it doesn't exist.
  40073. * This method will ensure you that a given key/data will be present in the dictionary.
  40074. * @param key the given key to get the matching value from
  40075. * @param factory the factory that will create the value if the key is not present in the dictionary.
  40076. * The factory will only be invoked if there's no data for the given key.
  40077. * @return the value corresponding to the key.
  40078. */
  40079. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  40080. /**
  40081. * Get a value from its key if present in the dictionary otherwise add it
  40082. * @param key the key to get the value from
  40083. * @param val if there's no such key/value pair in the dictionary add it with this value
  40084. * @return the value corresponding to the key
  40085. */
  40086. getOrAdd(key: string, val: T): T;
  40087. /**
  40088. * Check if there's a given key in the dictionary
  40089. * @param key the key to check for
  40090. * @return true if the key is present, false otherwise
  40091. */
  40092. contains(key: string): boolean;
  40093. /**
  40094. * Add a new key and its corresponding value
  40095. * @param key the key to add
  40096. * @param value the value corresponding to the key
  40097. * @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
  40098. */
  40099. add(key: string, value: T): boolean;
  40100. /**
  40101. * Update a specific value associated to a key
  40102. * @param key defines the key to use
  40103. * @param value defines the value to store
  40104. * @returns true if the value was updated (or false if the key was not found)
  40105. */
  40106. set(key: string, value: T): boolean;
  40107. /**
  40108. * Get the element of the given key and remove it from the dictionary
  40109. * @param key defines the key to search
  40110. * @returns the value associated with the key or null if not found
  40111. */
  40112. getAndRemove(key: string): Nullable<T>;
  40113. /**
  40114. * Remove a key/value from the dictionary.
  40115. * @param key the key to remove
  40116. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  40117. */
  40118. remove(key: string): boolean;
  40119. /**
  40120. * Clear the whole content of the dictionary
  40121. */
  40122. clear(): void;
  40123. /**
  40124. * Gets the current count
  40125. */
  40126. get count(): number;
  40127. /**
  40128. * Execute a callback on each key/val of the dictionary.
  40129. * Note that you can remove any element in this dictionary in the callback implementation
  40130. * @param callback the callback to execute on a given key/value pair
  40131. */
  40132. forEach(callback: (key: string, val: T) => void): void;
  40133. /**
  40134. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  40135. * If the callback returns null or undefined the method will iterate to the next key/value pair
  40136. * Note that you can remove any element in this dictionary in the callback implementation
  40137. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  40138. * @returns the first item
  40139. */
  40140. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  40141. private _count;
  40142. private _data;
  40143. }
  40144. }
  40145. declare module "babylonjs/Collisions/collisionCoordinator" {
  40146. import { Nullable } from "babylonjs/types";
  40147. import { Scene } from "babylonjs/scene";
  40148. import { Vector3 } from "babylonjs/Maths/math.vector";
  40149. import { Collider } from "babylonjs/Collisions/collider";
  40150. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40151. /** @hidden */
  40152. export interface ICollisionCoordinator {
  40153. createCollider(): Collider;
  40154. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  40155. init(scene: Scene): void;
  40156. }
  40157. /** @hidden */
  40158. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  40159. private _scene;
  40160. private _scaledPosition;
  40161. private _scaledVelocity;
  40162. private _finalPosition;
  40163. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  40164. createCollider(): Collider;
  40165. init(scene: Scene): void;
  40166. private _collideWithWorld;
  40167. }
  40168. }
  40169. declare module "babylonjs/Inputs/scene.inputManager" {
  40170. import { Nullable } from "babylonjs/types";
  40171. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40172. import { Vector2 } from "babylonjs/Maths/math.vector";
  40173. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40174. import { Scene } from "babylonjs/scene";
  40175. /**
  40176. * Class used to manage all inputs for the scene.
  40177. */
  40178. export class InputManager {
  40179. /** The distance in pixel that you have to move to prevent some events */
  40180. static DragMovementThreshold: number;
  40181. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  40182. static LongPressDelay: number;
  40183. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  40184. static DoubleClickDelay: number;
  40185. /** If you need to check double click without raising a single click at first click, enable this flag */
  40186. static ExclusiveDoubleClickMode: boolean;
  40187. /** 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. */
  40188. private _alreadyAttached;
  40189. private _wheelEventName;
  40190. private _onPointerMove;
  40191. private _onPointerDown;
  40192. private _onPointerUp;
  40193. private _initClickEvent;
  40194. private _initActionManager;
  40195. private _delayedSimpleClick;
  40196. private _delayedSimpleClickTimeout;
  40197. private _previousDelayedSimpleClickTimeout;
  40198. private _meshPickProceed;
  40199. private _previousButtonPressed;
  40200. private _currentPickResult;
  40201. private _previousPickResult;
  40202. private _totalPointersPressed;
  40203. private _doubleClickOccured;
  40204. private _pointerOverMesh;
  40205. private _pickedDownMesh;
  40206. private _pickedUpMesh;
  40207. private _pointerX;
  40208. private _pointerY;
  40209. private _unTranslatedPointerX;
  40210. private _unTranslatedPointerY;
  40211. private _startingPointerPosition;
  40212. private _previousStartingPointerPosition;
  40213. private _startingPointerTime;
  40214. private _previousStartingPointerTime;
  40215. private _pointerCaptures;
  40216. private _onKeyDown;
  40217. private _onKeyUp;
  40218. private _onCanvasFocusObserver;
  40219. private _onCanvasBlurObserver;
  40220. private _scene;
  40221. /**
  40222. * Creates a new InputManager
  40223. * @param scene defines the hosting scene
  40224. */
  40225. constructor(scene: Scene);
  40226. /**
  40227. * Gets the mesh that is currently under the pointer
  40228. */
  40229. get meshUnderPointer(): Nullable<AbstractMesh>;
  40230. /**
  40231. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  40232. */
  40233. get unTranslatedPointer(): Vector2;
  40234. /**
  40235. * Gets or sets the current on-screen X position of the pointer
  40236. */
  40237. get pointerX(): number;
  40238. set pointerX(value: number);
  40239. /**
  40240. * Gets or sets the current on-screen Y position of the pointer
  40241. */
  40242. get pointerY(): number;
  40243. set pointerY(value: number);
  40244. private _updatePointerPosition;
  40245. private _processPointerMove;
  40246. private _setRayOnPointerInfo;
  40247. private _checkPrePointerObservable;
  40248. /**
  40249. * Use this method to simulate a pointer move on a mesh
  40250. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40251. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40252. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40253. */
  40254. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  40255. /**
  40256. * Use this method to simulate a pointer down on a mesh
  40257. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40258. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40259. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40260. */
  40261. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  40262. private _processPointerDown;
  40263. /** @hidden */
  40264. _isPointerSwiping(): boolean;
  40265. /**
  40266. * Use this method to simulate a pointer up on a mesh
  40267. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40268. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40269. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40270. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40271. */
  40272. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  40273. private _processPointerUp;
  40274. /**
  40275. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40276. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40277. * @returns true if the pointer was captured
  40278. */
  40279. isPointerCaptured(pointerId?: number): boolean;
  40280. /**
  40281. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40282. * @param attachUp defines if you want to attach events to pointerup
  40283. * @param attachDown defines if you want to attach events to pointerdown
  40284. * @param attachMove defines if you want to attach events to pointermove
  40285. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  40286. */
  40287. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  40288. /**
  40289. * Detaches all event handlers
  40290. */
  40291. detachControl(): void;
  40292. /**
  40293. * Force the value of meshUnderPointer
  40294. * @param mesh defines the mesh to use
  40295. */
  40296. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  40297. /**
  40298. * Gets the mesh under the pointer
  40299. * @returns a Mesh or null if no mesh is under the pointer
  40300. */
  40301. getPointerOverMesh(): Nullable<AbstractMesh>;
  40302. }
  40303. }
  40304. declare module "babylonjs/Animations/animationGroup" {
  40305. import { Animatable } from "babylonjs/Animations/animatable";
  40306. import { Animation } from "babylonjs/Animations/animation";
  40307. import { Scene, IDisposable } from "babylonjs/scene";
  40308. import { Observable } from "babylonjs/Misc/observable";
  40309. import { Nullable } from "babylonjs/types";
  40310. import "babylonjs/Animations/animatable";
  40311. /**
  40312. * This class defines the direct association between an animation and a target
  40313. */
  40314. export class TargetedAnimation {
  40315. /**
  40316. * Animation to perform
  40317. */
  40318. animation: Animation;
  40319. /**
  40320. * Target to animate
  40321. */
  40322. target: any;
  40323. /**
  40324. * Returns the string "TargetedAnimation"
  40325. * @returns "TargetedAnimation"
  40326. */
  40327. getClassName(): string;
  40328. /**
  40329. * Serialize the object
  40330. * @returns the JSON object representing the current entity
  40331. */
  40332. serialize(): any;
  40333. }
  40334. /**
  40335. * Use this class to create coordinated animations on multiple targets
  40336. */
  40337. export class AnimationGroup implements IDisposable {
  40338. /** The name of the animation group */
  40339. name: string;
  40340. private _scene;
  40341. private _targetedAnimations;
  40342. private _animatables;
  40343. private _from;
  40344. private _to;
  40345. private _isStarted;
  40346. private _isPaused;
  40347. private _speedRatio;
  40348. private _loopAnimation;
  40349. private _isAdditive;
  40350. /**
  40351. * Gets or sets the unique id of the node
  40352. */
  40353. uniqueId: number;
  40354. /**
  40355. * This observable will notify when one animation have ended
  40356. */
  40357. onAnimationEndObservable: Observable<TargetedAnimation>;
  40358. /**
  40359. * Observer raised when one animation loops
  40360. */
  40361. onAnimationLoopObservable: Observable<TargetedAnimation>;
  40362. /**
  40363. * Observer raised when all animations have looped
  40364. */
  40365. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  40366. /**
  40367. * This observable will notify when all animations have ended.
  40368. */
  40369. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  40370. /**
  40371. * This observable will notify when all animations have paused.
  40372. */
  40373. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  40374. /**
  40375. * This observable will notify when all animations are playing.
  40376. */
  40377. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  40378. /**
  40379. * Gets the first frame
  40380. */
  40381. get from(): number;
  40382. /**
  40383. * Gets the last frame
  40384. */
  40385. get to(): number;
  40386. /**
  40387. * Define if the animations are started
  40388. */
  40389. get isStarted(): boolean;
  40390. /**
  40391. * Gets a value indicating that the current group is playing
  40392. */
  40393. get isPlaying(): boolean;
  40394. /**
  40395. * Gets or sets the speed ratio to use for all animations
  40396. */
  40397. get speedRatio(): number;
  40398. /**
  40399. * Gets or sets the speed ratio to use for all animations
  40400. */
  40401. set speedRatio(value: number);
  40402. /**
  40403. * Gets or sets if all animations should loop or not
  40404. */
  40405. get loopAnimation(): boolean;
  40406. set loopAnimation(value: boolean);
  40407. /**
  40408. * Gets or sets if all animations should be evaluated additively
  40409. */
  40410. get isAdditive(): boolean;
  40411. set isAdditive(value: boolean);
  40412. /**
  40413. * Gets the targeted animations for this animation group
  40414. */
  40415. get targetedAnimations(): Array<TargetedAnimation>;
  40416. /**
  40417. * returning the list of animatables controlled by this animation group.
  40418. */
  40419. get animatables(): Array<Animatable>;
  40420. /**
  40421. * Gets the list of target animations
  40422. */
  40423. get children(): TargetedAnimation[];
  40424. /**
  40425. * Instantiates a new Animation Group.
  40426. * This helps managing several animations at once.
  40427. * @see https://doc.babylonjs.com/how_to/group
  40428. * @param name Defines the name of the group
  40429. * @param scene Defines the scene the group belongs to
  40430. */
  40431. constructor(
  40432. /** The name of the animation group */
  40433. name: string, scene?: Nullable<Scene>);
  40434. /**
  40435. * Add an animation (with its target) in the group
  40436. * @param animation defines the animation we want to add
  40437. * @param target defines the target of the animation
  40438. * @returns the TargetedAnimation object
  40439. */
  40440. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  40441. /**
  40442. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  40443. * It can add constant keys at begin or end
  40444. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  40445. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  40446. * @returns the animation group
  40447. */
  40448. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  40449. private _animationLoopCount;
  40450. private _animationLoopFlags;
  40451. private _processLoop;
  40452. /**
  40453. * Start all animations on given targets
  40454. * @param loop defines if animations must loop
  40455. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  40456. * @param from defines the from key (optional)
  40457. * @param to defines the to key (optional)
  40458. * @param isAdditive defines the additive state for the resulting animatables (optional)
  40459. * @returns the current animation group
  40460. */
  40461. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  40462. /**
  40463. * Pause all animations
  40464. * @returns the animation group
  40465. */
  40466. pause(): AnimationGroup;
  40467. /**
  40468. * Play all animations to initial state
  40469. * This function will start() the animations if they were not started or will restart() them if they were paused
  40470. * @param loop defines if animations must loop
  40471. * @returns the animation group
  40472. */
  40473. play(loop?: boolean): AnimationGroup;
  40474. /**
  40475. * Reset all animations to initial state
  40476. * @returns the animation group
  40477. */
  40478. reset(): AnimationGroup;
  40479. /**
  40480. * Restart animations from key 0
  40481. * @returns the animation group
  40482. */
  40483. restart(): AnimationGroup;
  40484. /**
  40485. * Stop all animations
  40486. * @returns the animation group
  40487. */
  40488. stop(): AnimationGroup;
  40489. /**
  40490. * Set animation weight for all animatables
  40491. * @param weight defines the weight to use
  40492. * @return the animationGroup
  40493. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  40494. */
  40495. setWeightForAllAnimatables(weight: number): AnimationGroup;
  40496. /**
  40497. * Synchronize and normalize all animatables with a source animatable
  40498. * @param root defines the root animatable to synchronize with
  40499. * @return the animationGroup
  40500. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  40501. */
  40502. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  40503. /**
  40504. * Goes to a specific frame in this animation group
  40505. * @param frame the frame number to go to
  40506. * @return the animationGroup
  40507. */
  40508. goToFrame(frame: number): AnimationGroup;
  40509. /**
  40510. * Dispose all associated resources
  40511. */
  40512. dispose(): void;
  40513. private _checkAnimationGroupEnded;
  40514. /**
  40515. * Clone the current animation group and returns a copy
  40516. * @param newName defines the name of the new group
  40517. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  40518. * @returns the new aniamtion group
  40519. */
  40520. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  40521. /**
  40522. * Serializes the animationGroup to an object
  40523. * @returns Serialized object
  40524. */
  40525. serialize(): any;
  40526. /**
  40527. * Returns a new AnimationGroup object parsed from the source provided.
  40528. * @param parsedAnimationGroup defines the source
  40529. * @param scene defines the scene that will receive the animationGroup
  40530. * @returns a new AnimationGroup
  40531. */
  40532. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  40533. /**
  40534. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  40535. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  40536. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  40537. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  40538. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  40539. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  40540. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  40541. */
  40542. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  40543. /**
  40544. * Returns the string "AnimationGroup"
  40545. * @returns "AnimationGroup"
  40546. */
  40547. getClassName(): string;
  40548. /**
  40549. * Creates a detailled string about the object
  40550. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  40551. * @returns a string representing the object
  40552. */
  40553. toString(fullDetails?: boolean): string;
  40554. }
  40555. }
  40556. declare module "babylonjs/scene" {
  40557. import { Nullable } from "babylonjs/types";
  40558. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  40559. import { Observable } from "babylonjs/Misc/observable";
  40560. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  40561. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  40562. import { Geometry } from "babylonjs/Meshes/geometry";
  40563. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40564. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40565. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40566. import { Mesh } from "babylonjs/Meshes/mesh";
  40567. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  40568. import { Bone } from "babylonjs/Bones/bone";
  40569. import { Skeleton } from "babylonjs/Bones/skeleton";
  40570. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  40571. import { Camera } from "babylonjs/Cameras/camera";
  40572. import { AbstractScene } from "babylonjs/abstractScene";
  40573. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40574. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40575. import { Material } from "babylonjs/Materials/material";
  40576. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  40577. import { Effect } from "babylonjs/Materials/effect";
  40578. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  40579. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  40580. import { Light } from "babylonjs/Lights/light";
  40581. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40582. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  40583. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  40584. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  40585. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  40586. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  40587. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  40588. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  40589. import { Engine } from "babylonjs/Engines/engine";
  40590. import { Node } from "babylonjs/node";
  40591. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  40592. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  40593. import { WebRequest } from "babylonjs/Misc/webRequest";
  40594. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  40595. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  40596. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  40597. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  40598. import { Plane } from "babylonjs/Maths/math.plane";
  40599. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  40600. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  40601. import { Ray } from "babylonjs/Culling/ray";
  40602. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  40603. import { Animation } from "babylonjs/Animations/animation";
  40604. import { Animatable } from "babylonjs/Animations/animatable";
  40605. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  40606. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  40607. import { Collider } from "babylonjs/Collisions/collider";
  40608. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40609. /**
  40610. * Define an interface for all classes that will hold resources
  40611. */
  40612. export interface IDisposable {
  40613. /**
  40614. * Releases all held resources
  40615. */
  40616. dispose(): void;
  40617. }
  40618. /** Interface defining initialization parameters for Scene class */
  40619. export interface SceneOptions {
  40620. /**
  40621. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  40622. * It will improve performance when the number of geometries becomes important.
  40623. */
  40624. useGeometryUniqueIdsMap?: boolean;
  40625. /**
  40626. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  40627. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  40628. */
  40629. useMaterialMeshMap?: boolean;
  40630. /**
  40631. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  40632. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  40633. */
  40634. useClonedMeshMap?: boolean;
  40635. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  40636. virtual?: boolean;
  40637. }
  40638. /**
  40639. * Represents a scene to be rendered by the engine.
  40640. * @see https://doc.babylonjs.com/features/scene
  40641. */
  40642. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  40643. /** The fog is deactivated */
  40644. static readonly FOGMODE_NONE: number;
  40645. /** The fog density is following an exponential function */
  40646. static readonly FOGMODE_EXP: number;
  40647. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  40648. static readonly FOGMODE_EXP2: number;
  40649. /** The fog density is following a linear function. */
  40650. static readonly FOGMODE_LINEAR: number;
  40651. /**
  40652. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  40653. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40654. */
  40655. static MinDeltaTime: number;
  40656. /**
  40657. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  40658. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40659. */
  40660. static MaxDeltaTime: number;
  40661. /**
  40662. * Factory used to create the default material.
  40663. * @param name The name of the material to create
  40664. * @param scene The scene to create the material for
  40665. * @returns The default material
  40666. */
  40667. static DefaultMaterialFactory(scene: Scene): Material;
  40668. /**
  40669. * Factory used to create the a collision coordinator.
  40670. * @returns The collision coordinator
  40671. */
  40672. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  40673. /** @hidden */
  40674. _inputManager: InputManager;
  40675. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  40676. cameraToUseForPointers: Nullable<Camera>;
  40677. /** @hidden */
  40678. readonly _isScene: boolean;
  40679. /** @hidden */
  40680. _blockEntityCollection: boolean;
  40681. /**
  40682. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  40683. */
  40684. autoClear: boolean;
  40685. /**
  40686. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  40687. */
  40688. autoClearDepthAndStencil: boolean;
  40689. /**
  40690. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  40691. */
  40692. clearColor: Color4;
  40693. /**
  40694. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  40695. */
  40696. ambientColor: Color3;
  40697. /**
  40698. * This is use to store the default BRDF lookup for PBR materials in your scene.
  40699. * It should only be one of the following (if not the default embedded one):
  40700. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  40701. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  40702. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  40703. * The material properties need to be setup according to the type of texture in use.
  40704. */
  40705. environmentBRDFTexture: BaseTexture;
  40706. /** @hidden */
  40707. protected _environmentTexture: Nullable<BaseTexture>;
  40708. /**
  40709. * Texture used in all pbr material as the reflection texture.
  40710. * As in the majority of the scene they are the same (exception for multi room and so on),
  40711. * this is easier to reference from here than from all the materials.
  40712. */
  40713. get environmentTexture(): Nullable<BaseTexture>;
  40714. /**
  40715. * Texture used in all pbr material as the reflection texture.
  40716. * As in the majority of the scene they are the same (exception for multi room and so on),
  40717. * this is easier to set here than in all the materials.
  40718. */
  40719. set environmentTexture(value: Nullable<BaseTexture>);
  40720. /** @hidden */
  40721. protected _environmentIntensity: number;
  40722. /**
  40723. * Intensity of the environment in all pbr material.
  40724. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  40725. * As in the majority of the scene they are the same (exception for multi room and so on),
  40726. * this is easier to reference from here than from all the materials.
  40727. */
  40728. get environmentIntensity(): number;
  40729. /**
  40730. * Intensity of the environment in all pbr material.
  40731. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  40732. * As in the majority of the scene they are the same (exception for multi room and so on),
  40733. * this is easier to set here than in all the materials.
  40734. */
  40735. set environmentIntensity(value: number);
  40736. /** @hidden */
  40737. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40738. /**
  40739. * Default image processing configuration used either in the rendering
  40740. * Forward main pass or through the imageProcessingPostProcess if present.
  40741. * As in the majority of the scene they are the same (exception for multi camera),
  40742. * this is easier to reference from here than from all the materials and post process.
  40743. *
  40744. * No setter as we it is a shared configuration, you can set the values instead.
  40745. */
  40746. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  40747. private _forceWireframe;
  40748. /**
  40749. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  40750. */
  40751. set forceWireframe(value: boolean);
  40752. get forceWireframe(): boolean;
  40753. private _skipFrustumClipping;
  40754. /**
  40755. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  40756. */
  40757. set skipFrustumClipping(value: boolean);
  40758. get skipFrustumClipping(): boolean;
  40759. private _forcePointsCloud;
  40760. /**
  40761. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  40762. */
  40763. set forcePointsCloud(value: boolean);
  40764. get forcePointsCloud(): boolean;
  40765. /**
  40766. * Gets or sets the active clipplane 1
  40767. */
  40768. clipPlane: Nullable<Plane>;
  40769. /**
  40770. * Gets or sets the active clipplane 2
  40771. */
  40772. clipPlane2: Nullable<Plane>;
  40773. /**
  40774. * Gets or sets the active clipplane 3
  40775. */
  40776. clipPlane3: Nullable<Plane>;
  40777. /**
  40778. * Gets or sets the active clipplane 4
  40779. */
  40780. clipPlane4: Nullable<Plane>;
  40781. /**
  40782. * Gets or sets the active clipplane 5
  40783. */
  40784. clipPlane5: Nullable<Plane>;
  40785. /**
  40786. * Gets or sets the active clipplane 6
  40787. */
  40788. clipPlane6: Nullable<Plane>;
  40789. /**
  40790. * Gets or sets a boolean indicating if animations are enabled
  40791. */
  40792. animationsEnabled: boolean;
  40793. private _animationPropertiesOverride;
  40794. /**
  40795. * Gets or sets the animation properties override
  40796. */
  40797. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  40798. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  40799. /**
  40800. * Gets or sets a boolean indicating if a constant deltatime has to be used
  40801. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  40802. */
  40803. useConstantAnimationDeltaTime: boolean;
  40804. /**
  40805. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  40806. * Please note that it requires to run a ray cast through the scene on every frame
  40807. */
  40808. constantlyUpdateMeshUnderPointer: boolean;
  40809. /**
  40810. * Defines the HTML cursor to use when hovering over interactive elements
  40811. */
  40812. hoverCursor: string;
  40813. /**
  40814. * Defines the HTML default cursor to use (empty by default)
  40815. */
  40816. defaultCursor: string;
  40817. /**
  40818. * Defines whether cursors are handled by the scene.
  40819. */
  40820. doNotHandleCursors: boolean;
  40821. /**
  40822. * This is used to call preventDefault() on pointer down
  40823. * in order to block unwanted artifacts like system double clicks
  40824. */
  40825. preventDefaultOnPointerDown: boolean;
  40826. /**
  40827. * This is used to call preventDefault() on pointer up
  40828. * in order to block unwanted artifacts like system double clicks
  40829. */
  40830. preventDefaultOnPointerUp: boolean;
  40831. /**
  40832. * Gets or sets user defined metadata
  40833. */
  40834. metadata: any;
  40835. /**
  40836. * For internal use only. Please do not use.
  40837. */
  40838. reservedDataStore: any;
  40839. /**
  40840. * Gets the name of the plugin used to load this scene (null by default)
  40841. */
  40842. loadingPluginName: string;
  40843. /**
  40844. * Use this array to add regular expressions used to disable offline support for specific urls
  40845. */
  40846. disableOfflineSupportExceptionRules: RegExp[];
  40847. /**
  40848. * An event triggered when the scene is disposed.
  40849. */
  40850. onDisposeObservable: Observable<Scene>;
  40851. private _onDisposeObserver;
  40852. /** Sets a function to be executed when this scene is disposed. */
  40853. set onDispose(callback: () => void);
  40854. /**
  40855. * An event triggered before rendering the scene (right after animations and physics)
  40856. */
  40857. onBeforeRenderObservable: Observable<Scene>;
  40858. private _onBeforeRenderObserver;
  40859. /** Sets a function to be executed before rendering this scene */
  40860. set beforeRender(callback: Nullable<() => void>);
  40861. /**
  40862. * An event triggered after rendering the scene
  40863. */
  40864. onAfterRenderObservable: Observable<Scene>;
  40865. /**
  40866. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  40867. */
  40868. onAfterRenderCameraObservable: Observable<Camera>;
  40869. private _onAfterRenderObserver;
  40870. /** Sets a function to be executed after rendering this scene */
  40871. set afterRender(callback: Nullable<() => void>);
  40872. /**
  40873. * An event triggered before animating the scene
  40874. */
  40875. onBeforeAnimationsObservable: Observable<Scene>;
  40876. /**
  40877. * An event triggered after animations processing
  40878. */
  40879. onAfterAnimationsObservable: Observable<Scene>;
  40880. /**
  40881. * An event triggered before draw calls are ready to be sent
  40882. */
  40883. onBeforeDrawPhaseObservable: Observable<Scene>;
  40884. /**
  40885. * An event triggered after draw calls have been sent
  40886. */
  40887. onAfterDrawPhaseObservable: Observable<Scene>;
  40888. /**
  40889. * An event triggered when the scene is ready
  40890. */
  40891. onReadyObservable: Observable<Scene>;
  40892. /**
  40893. * An event triggered before rendering a camera
  40894. */
  40895. onBeforeCameraRenderObservable: Observable<Camera>;
  40896. private _onBeforeCameraRenderObserver;
  40897. /** Sets a function to be executed before rendering a camera*/
  40898. set beforeCameraRender(callback: () => void);
  40899. /**
  40900. * An event triggered after rendering a camera
  40901. */
  40902. onAfterCameraRenderObservable: Observable<Camera>;
  40903. private _onAfterCameraRenderObserver;
  40904. /** Sets a function to be executed after rendering a camera*/
  40905. set afterCameraRender(callback: () => void);
  40906. /**
  40907. * An event triggered when active meshes evaluation is about to start
  40908. */
  40909. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  40910. /**
  40911. * An event triggered when active meshes evaluation is done
  40912. */
  40913. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  40914. /**
  40915. * An event triggered when particles rendering is about to start
  40916. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  40917. */
  40918. onBeforeParticlesRenderingObservable: Observable<Scene>;
  40919. /**
  40920. * An event triggered when particles rendering is done
  40921. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  40922. */
  40923. onAfterParticlesRenderingObservable: Observable<Scene>;
  40924. /**
  40925. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  40926. */
  40927. onDataLoadedObservable: Observable<Scene>;
  40928. /**
  40929. * An event triggered when a camera is created
  40930. */
  40931. onNewCameraAddedObservable: Observable<Camera>;
  40932. /**
  40933. * An event triggered when a camera is removed
  40934. */
  40935. onCameraRemovedObservable: Observable<Camera>;
  40936. /**
  40937. * An event triggered when a light is created
  40938. */
  40939. onNewLightAddedObservable: Observable<Light>;
  40940. /**
  40941. * An event triggered when a light is removed
  40942. */
  40943. onLightRemovedObservable: Observable<Light>;
  40944. /**
  40945. * An event triggered when a geometry is created
  40946. */
  40947. onNewGeometryAddedObservable: Observable<Geometry>;
  40948. /**
  40949. * An event triggered when a geometry is removed
  40950. */
  40951. onGeometryRemovedObservable: Observable<Geometry>;
  40952. /**
  40953. * An event triggered when a transform node is created
  40954. */
  40955. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  40956. /**
  40957. * An event triggered when a transform node is removed
  40958. */
  40959. onTransformNodeRemovedObservable: Observable<TransformNode>;
  40960. /**
  40961. * An event triggered when a mesh is created
  40962. */
  40963. onNewMeshAddedObservable: Observable<AbstractMesh>;
  40964. /**
  40965. * An event triggered when a mesh is removed
  40966. */
  40967. onMeshRemovedObservable: Observable<AbstractMesh>;
  40968. /**
  40969. * An event triggered when a skeleton is created
  40970. */
  40971. onNewSkeletonAddedObservable: Observable<Skeleton>;
  40972. /**
  40973. * An event triggered when a skeleton is removed
  40974. */
  40975. onSkeletonRemovedObservable: Observable<Skeleton>;
  40976. /**
  40977. * An event triggered when a material is created
  40978. */
  40979. onNewMaterialAddedObservable: Observable<Material>;
  40980. /**
  40981. * An event triggered when a material is removed
  40982. */
  40983. onMaterialRemovedObservable: Observable<Material>;
  40984. /**
  40985. * An event triggered when a texture is created
  40986. */
  40987. onNewTextureAddedObservable: Observable<BaseTexture>;
  40988. /**
  40989. * An event triggered when a texture is removed
  40990. */
  40991. onTextureRemovedObservable: Observable<BaseTexture>;
  40992. /**
  40993. * An event triggered when render targets are about to be rendered
  40994. * Can happen multiple times per frame.
  40995. */
  40996. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  40997. /**
  40998. * An event triggered when render targets were rendered.
  40999. * Can happen multiple times per frame.
  41000. */
  41001. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  41002. /**
  41003. * An event triggered before calculating deterministic simulation step
  41004. */
  41005. onBeforeStepObservable: Observable<Scene>;
  41006. /**
  41007. * An event triggered after calculating deterministic simulation step
  41008. */
  41009. onAfterStepObservable: Observable<Scene>;
  41010. /**
  41011. * An event triggered when the activeCamera property is updated
  41012. */
  41013. onActiveCameraChanged: Observable<Scene>;
  41014. /**
  41015. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  41016. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  41017. * 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)
  41018. */
  41019. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  41020. /**
  41021. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  41022. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  41023. * 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)
  41024. */
  41025. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  41026. /**
  41027. * This Observable will when a mesh has been imported into the scene.
  41028. */
  41029. onMeshImportedObservable: Observable<AbstractMesh>;
  41030. /**
  41031. * This Observable will when an animation file has been imported into the scene.
  41032. */
  41033. onAnimationFileImportedObservable: Observable<Scene>;
  41034. /**
  41035. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  41036. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  41037. */
  41038. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  41039. /** @hidden */
  41040. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  41041. /**
  41042. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  41043. */
  41044. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  41045. /**
  41046. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  41047. */
  41048. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  41049. /**
  41050. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  41051. */
  41052. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  41053. /** Callback called when a pointer move is detected */
  41054. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  41055. /** Callback called when a pointer down is detected */
  41056. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  41057. /** Callback called when a pointer up is detected */
  41058. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  41059. /** Callback called when a pointer pick is detected */
  41060. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  41061. /**
  41062. * 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).
  41063. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  41064. */
  41065. onPrePointerObservable: Observable<PointerInfoPre>;
  41066. /**
  41067. * Observable event triggered each time an input event is received from the rendering canvas
  41068. */
  41069. onPointerObservable: Observable<PointerInfo>;
  41070. /**
  41071. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  41072. */
  41073. get unTranslatedPointer(): Vector2;
  41074. /**
  41075. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  41076. */
  41077. static get DragMovementThreshold(): number;
  41078. static set DragMovementThreshold(value: number);
  41079. /**
  41080. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  41081. */
  41082. static get LongPressDelay(): number;
  41083. static set LongPressDelay(value: number);
  41084. /**
  41085. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  41086. */
  41087. static get DoubleClickDelay(): number;
  41088. static set DoubleClickDelay(value: number);
  41089. /** If you need to check double click without raising a single click at first click, enable this flag */
  41090. static get ExclusiveDoubleClickMode(): boolean;
  41091. static set ExclusiveDoubleClickMode(value: boolean);
  41092. /** @hidden */
  41093. _mirroredCameraPosition: Nullable<Vector3>;
  41094. /**
  41095. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  41096. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  41097. */
  41098. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  41099. /**
  41100. * Observable event triggered each time an keyboard event is received from the hosting window
  41101. */
  41102. onKeyboardObservable: Observable<KeyboardInfo>;
  41103. private _useRightHandedSystem;
  41104. /**
  41105. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  41106. */
  41107. set useRightHandedSystem(value: boolean);
  41108. get useRightHandedSystem(): boolean;
  41109. private _timeAccumulator;
  41110. private _currentStepId;
  41111. private _currentInternalStep;
  41112. /**
  41113. * Sets the step Id used by deterministic lock step
  41114. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41115. * @param newStepId defines the step Id
  41116. */
  41117. setStepId(newStepId: number): void;
  41118. /**
  41119. * Gets the step Id used by deterministic lock step
  41120. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41121. * @returns the step Id
  41122. */
  41123. getStepId(): number;
  41124. /**
  41125. * Gets the internal step used by deterministic lock step
  41126. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41127. * @returns the internal step
  41128. */
  41129. getInternalStep(): number;
  41130. private _fogEnabled;
  41131. /**
  41132. * Gets or sets a boolean indicating if fog is enabled on this scene
  41133. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41134. * (Default is true)
  41135. */
  41136. set fogEnabled(value: boolean);
  41137. get fogEnabled(): boolean;
  41138. private _fogMode;
  41139. /**
  41140. * Gets or sets the fog mode to use
  41141. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41142. * | mode | value |
  41143. * | --- | --- |
  41144. * | FOGMODE_NONE | 0 |
  41145. * | FOGMODE_EXP | 1 |
  41146. * | FOGMODE_EXP2 | 2 |
  41147. * | FOGMODE_LINEAR | 3 |
  41148. */
  41149. set fogMode(value: number);
  41150. get fogMode(): number;
  41151. /**
  41152. * Gets or sets the fog color to use
  41153. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41154. * (Default is Color3(0.2, 0.2, 0.3))
  41155. */
  41156. fogColor: Color3;
  41157. /**
  41158. * Gets or sets the fog density to use
  41159. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41160. * (Default is 0.1)
  41161. */
  41162. fogDensity: number;
  41163. /**
  41164. * Gets or sets the fog start distance to use
  41165. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41166. * (Default is 0)
  41167. */
  41168. fogStart: number;
  41169. /**
  41170. * Gets or sets the fog end distance to use
  41171. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41172. * (Default is 1000)
  41173. */
  41174. fogEnd: number;
  41175. /**
  41176. * Flag indicating that the frame buffer binding is handled by another component
  41177. */
  41178. prePass: boolean;
  41179. private _shadowsEnabled;
  41180. /**
  41181. * Gets or sets a boolean indicating if shadows are enabled on this scene
  41182. */
  41183. set shadowsEnabled(value: boolean);
  41184. get shadowsEnabled(): boolean;
  41185. private _lightsEnabled;
  41186. /**
  41187. * Gets or sets a boolean indicating if lights are enabled on this scene
  41188. */
  41189. set lightsEnabled(value: boolean);
  41190. get lightsEnabled(): boolean;
  41191. /** All of the active cameras added to this scene. */
  41192. activeCameras: Camera[];
  41193. /** @hidden */
  41194. _activeCamera: Nullable<Camera>;
  41195. /** Gets or sets the current active camera */
  41196. get activeCamera(): Nullable<Camera>;
  41197. set activeCamera(value: Nullable<Camera>);
  41198. private _defaultMaterial;
  41199. /** The default material used on meshes when no material is affected */
  41200. get defaultMaterial(): Material;
  41201. /** The default material used on meshes when no material is affected */
  41202. set defaultMaterial(value: Material);
  41203. private _texturesEnabled;
  41204. /**
  41205. * Gets or sets a boolean indicating if textures are enabled on this scene
  41206. */
  41207. set texturesEnabled(value: boolean);
  41208. get texturesEnabled(): boolean;
  41209. /**
  41210. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  41211. */
  41212. physicsEnabled: boolean;
  41213. /**
  41214. * Gets or sets a boolean indicating if particles are enabled on this scene
  41215. */
  41216. particlesEnabled: boolean;
  41217. /**
  41218. * Gets or sets a boolean indicating if sprites are enabled on this scene
  41219. */
  41220. spritesEnabled: boolean;
  41221. private _skeletonsEnabled;
  41222. /**
  41223. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  41224. */
  41225. set skeletonsEnabled(value: boolean);
  41226. get skeletonsEnabled(): boolean;
  41227. /**
  41228. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  41229. */
  41230. lensFlaresEnabled: boolean;
  41231. /**
  41232. * Gets or sets a boolean indicating if collisions are enabled on this scene
  41233. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  41234. */
  41235. collisionsEnabled: boolean;
  41236. private _collisionCoordinator;
  41237. /** @hidden */
  41238. get collisionCoordinator(): ICollisionCoordinator;
  41239. /**
  41240. * Defines the gravity applied to this scene (used only for collisions)
  41241. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  41242. */
  41243. gravity: Vector3;
  41244. /**
  41245. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  41246. */
  41247. postProcessesEnabled: boolean;
  41248. /**
  41249. * Gets the current postprocess manager
  41250. */
  41251. postProcessManager: PostProcessManager;
  41252. /**
  41253. * Gets or sets a boolean indicating if render targets are enabled on this scene
  41254. */
  41255. renderTargetsEnabled: boolean;
  41256. /**
  41257. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  41258. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  41259. */
  41260. dumpNextRenderTargets: boolean;
  41261. /**
  41262. * The list of user defined render targets added to the scene
  41263. */
  41264. customRenderTargets: RenderTargetTexture[];
  41265. /**
  41266. * Defines if texture loading must be delayed
  41267. * If true, textures will only be loaded when they need to be rendered
  41268. */
  41269. useDelayedTextureLoading: boolean;
  41270. /**
  41271. * Gets the list of meshes imported to the scene through SceneLoader
  41272. */
  41273. importedMeshesFiles: String[];
  41274. /**
  41275. * Gets or sets a boolean indicating if probes are enabled on this scene
  41276. */
  41277. probesEnabled: boolean;
  41278. /**
  41279. * Gets or sets the current offline provider to use to store scene data
  41280. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  41281. */
  41282. offlineProvider: IOfflineProvider;
  41283. /**
  41284. * Gets or sets the action manager associated with the scene
  41285. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  41286. */
  41287. actionManager: AbstractActionManager;
  41288. private _meshesForIntersections;
  41289. /**
  41290. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  41291. */
  41292. proceduralTexturesEnabled: boolean;
  41293. private _engine;
  41294. private _totalVertices;
  41295. /** @hidden */
  41296. _activeIndices: PerfCounter;
  41297. /** @hidden */
  41298. _activeParticles: PerfCounter;
  41299. /** @hidden */
  41300. _activeBones: PerfCounter;
  41301. private _animationRatio;
  41302. /** @hidden */
  41303. _animationTimeLast: number;
  41304. /** @hidden */
  41305. _animationTime: number;
  41306. /**
  41307. * Gets or sets a general scale for animation speed
  41308. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  41309. */
  41310. animationTimeScale: number;
  41311. /** @hidden */
  41312. _cachedMaterial: Nullable<Material>;
  41313. /** @hidden */
  41314. _cachedEffect: Nullable<Effect>;
  41315. /** @hidden */
  41316. _cachedVisibility: Nullable<number>;
  41317. private _renderId;
  41318. private _frameId;
  41319. private _executeWhenReadyTimeoutId;
  41320. private _intermediateRendering;
  41321. private _viewUpdateFlag;
  41322. private _projectionUpdateFlag;
  41323. /** @hidden */
  41324. _toBeDisposed: Nullable<IDisposable>[];
  41325. private _activeRequests;
  41326. /** @hidden */
  41327. _pendingData: any[];
  41328. private _isDisposed;
  41329. /**
  41330. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  41331. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  41332. */
  41333. dispatchAllSubMeshesOfActiveMeshes: boolean;
  41334. private _activeMeshes;
  41335. private _processedMaterials;
  41336. private _renderTargets;
  41337. /** @hidden */
  41338. _activeParticleSystems: SmartArray<IParticleSystem>;
  41339. private _activeSkeletons;
  41340. private _softwareSkinnedMeshes;
  41341. private _renderingManager;
  41342. /** @hidden */
  41343. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  41344. private _transformMatrix;
  41345. private _sceneUbo;
  41346. /** @hidden */
  41347. _viewMatrix: Matrix;
  41348. private _projectionMatrix;
  41349. /** @hidden */
  41350. _forcedViewPosition: Nullable<Vector3>;
  41351. /** @hidden */
  41352. _frustumPlanes: Plane[];
  41353. /**
  41354. * Gets the list of frustum planes (built from the active camera)
  41355. */
  41356. get frustumPlanes(): Plane[];
  41357. /**
  41358. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  41359. * This is useful if there are more lights that the maximum simulteanous authorized
  41360. */
  41361. requireLightSorting: boolean;
  41362. /** @hidden */
  41363. readonly useMaterialMeshMap: boolean;
  41364. /** @hidden */
  41365. readonly useClonedMeshMap: boolean;
  41366. private _externalData;
  41367. private _uid;
  41368. /**
  41369. * @hidden
  41370. * Backing store of defined scene components.
  41371. */
  41372. _components: ISceneComponent[];
  41373. /**
  41374. * @hidden
  41375. * Backing store of defined scene components.
  41376. */
  41377. _serializableComponents: ISceneSerializableComponent[];
  41378. /**
  41379. * List of components to register on the next registration step.
  41380. */
  41381. private _transientComponents;
  41382. /**
  41383. * Registers the transient components if needed.
  41384. */
  41385. private _registerTransientComponents;
  41386. /**
  41387. * @hidden
  41388. * Add a component to the scene.
  41389. * Note that the ccomponent could be registered on th next frame if this is called after
  41390. * the register component stage.
  41391. * @param component Defines the component to add to the scene
  41392. */
  41393. _addComponent(component: ISceneComponent): void;
  41394. /**
  41395. * @hidden
  41396. * Gets a component from the scene.
  41397. * @param name defines the name of the component to retrieve
  41398. * @returns the component or null if not present
  41399. */
  41400. _getComponent(name: string): Nullable<ISceneComponent>;
  41401. /**
  41402. * @hidden
  41403. * Defines the actions happening before camera updates.
  41404. */
  41405. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  41406. /**
  41407. * @hidden
  41408. * Defines the actions happening before clear the canvas.
  41409. */
  41410. _beforeClearStage: Stage<SimpleStageAction>;
  41411. /**
  41412. * @hidden
  41413. * Defines the actions when collecting render targets for the frame.
  41414. */
  41415. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  41416. /**
  41417. * @hidden
  41418. * Defines the actions happening for one camera in the frame.
  41419. */
  41420. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  41421. /**
  41422. * @hidden
  41423. * Defines the actions happening during the per mesh ready checks.
  41424. */
  41425. _isReadyForMeshStage: Stage<MeshStageAction>;
  41426. /**
  41427. * @hidden
  41428. * Defines the actions happening before evaluate active mesh checks.
  41429. */
  41430. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  41431. /**
  41432. * @hidden
  41433. * Defines the actions happening during the evaluate sub mesh checks.
  41434. */
  41435. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  41436. /**
  41437. * @hidden
  41438. * Defines the actions happening during the active mesh stage.
  41439. */
  41440. _activeMeshStage: Stage<ActiveMeshStageAction>;
  41441. /**
  41442. * @hidden
  41443. * Defines the actions happening during the per camera render target step.
  41444. */
  41445. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  41446. /**
  41447. * @hidden
  41448. * Defines the actions happening just before the active camera is drawing.
  41449. */
  41450. _beforeCameraDrawStage: Stage<CameraStageAction>;
  41451. /**
  41452. * @hidden
  41453. * Defines the actions happening just before a render target is drawing.
  41454. */
  41455. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  41456. /**
  41457. * @hidden
  41458. * Defines the actions happening just before a rendering group is drawing.
  41459. */
  41460. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  41461. /**
  41462. * @hidden
  41463. * Defines the actions happening just before a mesh is drawing.
  41464. */
  41465. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  41466. /**
  41467. * @hidden
  41468. * Defines the actions happening just after a mesh has been drawn.
  41469. */
  41470. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  41471. /**
  41472. * @hidden
  41473. * Defines the actions happening just after a rendering group has been drawn.
  41474. */
  41475. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  41476. /**
  41477. * @hidden
  41478. * Defines the actions happening just after the active camera has been drawn.
  41479. */
  41480. _afterCameraDrawStage: Stage<CameraStageAction>;
  41481. /**
  41482. * @hidden
  41483. * Defines the actions happening just after a render target has been drawn.
  41484. */
  41485. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  41486. /**
  41487. * @hidden
  41488. * Defines the actions happening just after rendering all cameras and computing intersections.
  41489. */
  41490. _afterRenderStage: Stage<SimpleStageAction>;
  41491. /**
  41492. * @hidden
  41493. * Defines the actions happening when a pointer move event happens.
  41494. */
  41495. _pointerMoveStage: Stage<PointerMoveStageAction>;
  41496. /**
  41497. * @hidden
  41498. * Defines the actions happening when a pointer down event happens.
  41499. */
  41500. _pointerDownStage: Stage<PointerUpDownStageAction>;
  41501. /**
  41502. * @hidden
  41503. * Defines the actions happening when a pointer up event happens.
  41504. */
  41505. _pointerUpStage: Stage<PointerUpDownStageAction>;
  41506. /**
  41507. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  41508. */
  41509. private geometriesByUniqueId;
  41510. /**
  41511. * Creates a new Scene
  41512. * @param engine defines the engine to use to render this scene
  41513. * @param options defines the scene options
  41514. */
  41515. constructor(engine: Engine, options?: SceneOptions);
  41516. /**
  41517. * Gets a string identifying the name of the class
  41518. * @returns "Scene" string
  41519. */
  41520. getClassName(): string;
  41521. private _defaultMeshCandidates;
  41522. /**
  41523. * @hidden
  41524. */
  41525. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41526. private _defaultSubMeshCandidates;
  41527. /**
  41528. * @hidden
  41529. */
  41530. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41531. /**
  41532. * Sets the default candidate providers for the scene.
  41533. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  41534. * and getCollidingSubMeshCandidates to their default function
  41535. */
  41536. setDefaultCandidateProviders(): void;
  41537. /**
  41538. * Gets the mesh that is currently under the pointer
  41539. */
  41540. get meshUnderPointer(): Nullable<AbstractMesh>;
  41541. /**
  41542. * Gets or sets the current on-screen X position of the pointer
  41543. */
  41544. get pointerX(): number;
  41545. set pointerX(value: number);
  41546. /**
  41547. * Gets or sets the current on-screen Y position of the pointer
  41548. */
  41549. get pointerY(): number;
  41550. set pointerY(value: number);
  41551. /**
  41552. * Gets the cached material (ie. the latest rendered one)
  41553. * @returns the cached material
  41554. */
  41555. getCachedMaterial(): Nullable<Material>;
  41556. /**
  41557. * Gets the cached effect (ie. the latest rendered one)
  41558. * @returns the cached effect
  41559. */
  41560. getCachedEffect(): Nullable<Effect>;
  41561. /**
  41562. * Gets the cached visibility state (ie. the latest rendered one)
  41563. * @returns the cached visibility state
  41564. */
  41565. getCachedVisibility(): Nullable<number>;
  41566. /**
  41567. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  41568. * @param material defines the current material
  41569. * @param effect defines the current effect
  41570. * @param visibility defines the current visibility state
  41571. * @returns true if one parameter is not cached
  41572. */
  41573. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  41574. /**
  41575. * Gets the engine associated with the scene
  41576. * @returns an Engine
  41577. */
  41578. getEngine(): Engine;
  41579. /**
  41580. * Gets the total number of vertices rendered per frame
  41581. * @returns the total number of vertices rendered per frame
  41582. */
  41583. getTotalVertices(): number;
  41584. /**
  41585. * Gets the performance counter for total vertices
  41586. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41587. */
  41588. get totalVerticesPerfCounter(): PerfCounter;
  41589. /**
  41590. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  41591. * @returns the total number of active indices rendered per frame
  41592. */
  41593. getActiveIndices(): number;
  41594. /**
  41595. * Gets the performance counter for active indices
  41596. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41597. */
  41598. get totalActiveIndicesPerfCounter(): PerfCounter;
  41599. /**
  41600. * Gets the total number of active particles rendered per frame
  41601. * @returns the total number of active particles rendered per frame
  41602. */
  41603. getActiveParticles(): number;
  41604. /**
  41605. * Gets the performance counter for active particles
  41606. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41607. */
  41608. get activeParticlesPerfCounter(): PerfCounter;
  41609. /**
  41610. * Gets the total number of active bones rendered per frame
  41611. * @returns the total number of active bones rendered per frame
  41612. */
  41613. getActiveBones(): number;
  41614. /**
  41615. * Gets the performance counter for active bones
  41616. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41617. */
  41618. get activeBonesPerfCounter(): PerfCounter;
  41619. /**
  41620. * Gets the array of active meshes
  41621. * @returns an array of AbstractMesh
  41622. */
  41623. getActiveMeshes(): SmartArray<AbstractMesh>;
  41624. /**
  41625. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  41626. * @returns a number
  41627. */
  41628. getAnimationRatio(): number;
  41629. /**
  41630. * Gets an unique Id for the current render phase
  41631. * @returns a number
  41632. */
  41633. getRenderId(): number;
  41634. /**
  41635. * Gets an unique Id for the current frame
  41636. * @returns a number
  41637. */
  41638. getFrameId(): number;
  41639. /** Call this function if you want to manually increment the render Id*/
  41640. incrementRenderId(): void;
  41641. private _createUbo;
  41642. /**
  41643. * Use this method to simulate a pointer move on a mesh
  41644. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41645. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41646. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41647. * @returns the current scene
  41648. */
  41649. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  41650. /**
  41651. * Use this method to simulate a pointer down on a mesh
  41652. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41653. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41654. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41655. * @returns the current scene
  41656. */
  41657. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  41658. /**
  41659. * Use this method to simulate a pointer up on a mesh
  41660. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41661. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41662. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41663. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  41664. * @returns the current scene
  41665. */
  41666. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  41667. /**
  41668. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  41669. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  41670. * @returns true if the pointer was captured
  41671. */
  41672. isPointerCaptured(pointerId?: number): boolean;
  41673. /**
  41674. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  41675. * @param attachUp defines if you want to attach events to pointerup
  41676. * @param attachDown defines if you want to attach events to pointerdown
  41677. * @param attachMove defines if you want to attach events to pointermove
  41678. */
  41679. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  41680. /** Detaches all event handlers*/
  41681. detachControl(): void;
  41682. /**
  41683. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  41684. * Delay loaded resources are not taking in account
  41685. * @return true if all required resources are ready
  41686. */
  41687. isReady(): boolean;
  41688. /** Resets all cached information relative to material (including effect and visibility) */
  41689. resetCachedMaterial(): void;
  41690. /**
  41691. * Registers a function to be called before every frame render
  41692. * @param func defines the function to register
  41693. */
  41694. registerBeforeRender(func: () => void): void;
  41695. /**
  41696. * Unregisters a function called before every frame render
  41697. * @param func defines the function to unregister
  41698. */
  41699. unregisterBeforeRender(func: () => void): void;
  41700. /**
  41701. * Registers a function to be called after every frame render
  41702. * @param func defines the function to register
  41703. */
  41704. registerAfterRender(func: () => void): void;
  41705. /**
  41706. * Unregisters a function called after every frame render
  41707. * @param func defines the function to unregister
  41708. */
  41709. unregisterAfterRender(func: () => void): void;
  41710. private _executeOnceBeforeRender;
  41711. /**
  41712. * The provided function will run before render once and will be disposed afterwards.
  41713. * A timeout delay can be provided so that the function will be executed in N ms.
  41714. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  41715. * @param func The function to be executed.
  41716. * @param timeout optional delay in ms
  41717. */
  41718. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  41719. /** @hidden */
  41720. _addPendingData(data: any): void;
  41721. /** @hidden */
  41722. _removePendingData(data: any): void;
  41723. /**
  41724. * Returns the number of items waiting to be loaded
  41725. * @returns the number of items waiting to be loaded
  41726. */
  41727. getWaitingItemsCount(): number;
  41728. /**
  41729. * Returns a boolean indicating if the scene is still loading data
  41730. */
  41731. get isLoading(): boolean;
  41732. /**
  41733. * Registers a function to be executed when the scene is ready
  41734. * @param {Function} func - the function to be executed
  41735. */
  41736. executeWhenReady(func: () => void): void;
  41737. /**
  41738. * Returns a promise that resolves when the scene is ready
  41739. * @returns A promise that resolves when the scene is ready
  41740. */
  41741. whenReadyAsync(): Promise<void>;
  41742. /** @hidden */
  41743. _checkIsReady(): void;
  41744. /**
  41745. * Gets all animatable attached to the scene
  41746. */
  41747. get animatables(): Animatable[];
  41748. /**
  41749. * Resets the last animation time frame.
  41750. * Useful to override when animations start running when loading a scene for the first time.
  41751. */
  41752. resetLastAnimationTimeFrame(): void;
  41753. /**
  41754. * Gets the current view matrix
  41755. * @returns a Matrix
  41756. */
  41757. getViewMatrix(): Matrix;
  41758. /**
  41759. * Gets the current projection matrix
  41760. * @returns a Matrix
  41761. */
  41762. getProjectionMatrix(): Matrix;
  41763. /**
  41764. * Gets the current transform matrix
  41765. * @returns a Matrix made of View * Projection
  41766. */
  41767. getTransformMatrix(): Matrix;
  41768. /**
  41769. * Sets the current transform matrix
  41770. * @param viewL defines the View matrix to use
  41771. * @param projectionL defines the Projection matrix to use
  41772. * @param viewR defines the right View matrix to use (if provided)
  41773. * @param projectionR defines the right Projection matrix to use (if provided)
  41774. */
  41775. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  41776. /**
  41777. * Gets the uniform buffer used to store scene data
  41778. * @returns a UniformBuffer
  41779. */
  41780. getSceneUniformBuffer(): UniformBuffer;
  41781. /**
  41782. * Gets an unique (relatively to the current scene) Id
  41783. * @returns an unique number for the scene
  41784. */
  41785. getUniqueId(): number;
  41786. /**
  41787. * Add a mesh to the list of scene's meshes
  41788. * @param newMesh defines the mesh to add
  41789. * @param recursive if all child meshes should also be added to the scene
  41790. */
  41791. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  41792. /**
  41793. * Remove a mesh for the list of scene's meshes
  41794. * @param toRemove defines the mesh to remove
  41795. * @param recursive if all child meshes should also be removed from the scene
  41796. * @returns the index where the mesh was in the mesh list
  41797. */
  41798. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  41799. /**
  41800. * Add a transform node to the list of scene's transform nodes
  41801. * @param newTransformNode defines the transform node to add
  41802. */
  41803. addTransformNode(newTransformNode: TransformNode): void;
  41804. /**
  41805. * Remove a transform node for the list of scene's transform nodes
  41806. * @param toRemove defines the transform node to remove
  41807. * @returns the index where the transform node was in the transform node list
  41808. */
  41809. removeTransformNode(toRemove: TransformNode): number;
  41810. /**
  41811. * Remove a skeleton for the list of scene's skeletons
  41812. * @param toRemove defines the skeleton to remove
  41813. * @returns the index where the skeleton was in the skeleton list
  41814. */
  41815. removeSkeleton(toRemove: Skeleton): number;
  41816. /**
  41817. * Remove a morph target for the list of scene's morph targets
  41818. * @param toRemove defines the morph target to remove
  41819. * @returns the index where the morph target was in the morph target list
  41820. */
  41821. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  41822. /**
  41823. * Remove a light for the list of scene's lights
  41824. * @param toRemove defines the light to remove
  41825. * @returns the index where the light was in the light list
  41826. */
  41827. removeLight(toRemove: Light): number;
  41828. /**
  41829. * Remove a camera for the list of scene's cameras
  41830. * @param toRemove defines the camera to remove
  41831. * @returns the index where the camera was in the camera list
  41832. */
  41833. removeCamera(toRemove: Camera): number;
  41834. /**
  41835. * Remove a particle system for the list of scene's particle systems
  41836. * @param toRemove defines the particle system to remove
  41837. * @returns the index where the particle system was in the particle system list
  41838. */
  41839. removeParticleSystem(toRemove: IParticleSystem): number;
  41840. /**
  41841. * Remove a animation for the list of scene's animations
  41842. * @param toRemove defines the animation to remove
  41843. * @returns the index where the animation was in the animation list
  41844. */
  41845. removeAnimation(toRemove: Animation): number;
  41846. /**
  41847. * Will stop the animation of the given target
  41848. * @param target - the target
  41849. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  41850. * @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)
  41851. */
  41852. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  41853. /**
  41854. * Removes the given animation group from this scene.
  41855. * @param toRemove The animation group to remove
  41856. * @returns The index of the removed animation group
  41857. */
  41858. removeAnimationGroup(toRemove: AnimationGroup): number;
  41859. /**
  41860. * Removes the given multi-material from this scene.
  41861. * @param toRemove The multi-material to remove
  41862. * @returns The index of the removed multi-material
  41863. */
  41864. removeMultiMaterial(toRemove: MultiMaterial): number;
  41865. /**
  41866. * Removes the given material from this scene.
  41867. * @param toRemove The material to remove
  41868. * @returns The index of the removed material
  41869. */
  41870. removeMaterial(toRemove: Material): number;
  41871. /**
  41872. * Removes the given action manager from this scene.
  41873. * @param toRemove The action manager to remove
  41874. * @returns The index of the removed action manager
  41875. */
  41876. removeActionManager(toRemove: AbstractActionManager): number;
  41877. /**
  41878. * Removes the given texture from this scene.
  41879. * @param toRemove The texture to remove
  41880. * @returns The index of the removed texture
  41881. */
  41882. removeTexture(toRemove: BaseTexture): number;
  41883. /**
  41884. * Adds the given light to this scene
  41885. * @param newLight The light to add
  41886. */
  41887. addLight(newLight: Light): void;
  41888. /**
  41889. * Sorts the list list based on light priorities
  41890. */
  41891. sortLightsByPriority(): void;
  41892. /**
  41893. * Adds the given camera to this scene
  41894. * @param newCamera The camera to add
  41895. */
  41896. addCamera(newCamera: Camera): void;
  41897. /**
  41898. * Adds the given skeleton to this scene
  41899. * @param newSkeleton The skeleton to add
  41900. */
  41901. addSkeleton(newSkeleton: Skeleton): void;
  41902. /**
  41903. * Adds the given particle system to this scene
  41904. * @param newParticleSystem The particle system to add
  41905. */
  41906. addParticleSystem(newParticleSystem: IParticleSystem): void;
  41907. /**
  41908. * Adds the given animation to this scene
  41909. * @param newAnimation The animation to add
  41910. */
  41911. addAnimation(newAnimation: Animation): void;
  41912. /**
  41913. * Adds the given animation group to this scene.
  41914. * @param newAnimationGroup The animation group to add
  41915. */
  41916. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  41917. /**
  41918. * Adds the given multi-material to this scene
  41919. * @param newMultiMaterial The multi-material to add
  41920. */
  41921. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  41922. /**
  41923. * Adds the given material to this scene
  41924. * @param newMaterial The material to add
  41925. */
  41926. addMaterial(newMaterial: Material): void;
  41927. /**
  41928. * Adds the given morph target to this scene
  41929. * @param newMorphTargetManager The morph target to add
  41930. */
  41931. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  41932. /**
  41933. * Adds the given geometry to this scene
  41934. * @param newGeometry The geometry to add
  41935. */
  41936. addGeometry(newGeometry: Geometry): void;
  41937. /**
  41938. * Adds the given action manager to this scene
  41939. * @param newActionManager The action manager to add
  41940. */
  41941. addActionManager(newActionManager: AbstractActionManager): void;
  41942. /**
  41943. * Adds the given texture to this scene.
  41944. * @param newTexture The texture to add
  41945. */
  41946. addTexture(newTexture: BaseTexture): void;
  41947. /**
  41948. * Switch active camera
  41949. * @param newCamera defines the new active camera
  41950. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  41951. */
  41952. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  41953. /**
  41954. * sets the active camera of the scene using its ID
  41955. * @param id defines the camera's ID
  41956. * @return the new active camera or null if none found.
  41957. */
  41958. setActiveCameraByID(id: string): Nullable<Camera>;
  41959. /**
  41960. * sets the active camera of the scene using its name
  41961. * @param name defines the camera's name
  41962. * @returns the new active camera or null if none found.
  41963. */
  41964. setActiveCameraByName(name: string): Nullable<Camera>;
  41965. /**
  41966. * get an animation group using its name
  41967. * @param name defines the material's name
  41968. * @return the animation group or null if none found.
  41969. */
  41970. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  41971. /**
  41972. * Get a material using its unique id
  41973. * @param uniqueId defines the material's unique id
  41974. * @return the material or null if none found.
  41975. */
  41976. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  41977. /**
  41978. * get a material using its id
  41979. * @param id defines the material's ID
  41980. * @return the material or null if none found.
  41981. */
  41982. getMaterialByID(id: string): Nullable<Material>;
  41983. /**
  41984. * Gets a the last added material using a given id
  41985. * @param id defines the material's ID
  41986. * @return the last material with the given id or null if none found.
  41987. */
  41988. getLastMaterialByID(id: string): Nullable<Material>;
  41989. /**
  41990. * Gets a material using its name
  41991. * @param name defines the material's name
  41992. * @return the material or null if none found.
  41993. */
  41994. getMaterialByName(name: string): Nullable<Material>;
  41995. /**
  41996. * Get a texture using its unique id
  41997. * @param uniqueId defines the texture's unique id
  41998. * @return the texture or null if none found.
  41999. */
  42000. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  42001. /**
  42002. * Gets a camera using its id
  42003. * @param id defines the id to look for
  42004. * @returns the camera or null if not found
  42005. */
  42006. getCameraByID(id: string): Nullable<Camera>;
  42007. /**
  42008. * Gets a camera using its unique id
  42009. * @param uniqueId defines the unique id to look for
  42010. * @returns the camera or null if not found
  42011. */
  42012. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  42013. /**
  42014. * Gets a camera using its name
  42015. * @param name defines the camera's name
  42016. * @return the camera or null if none found.
  42017. */
  42018. getCameraByName(name: string): Nullable<Camera>;
  42019. /**
  42020. * Gets a bone using its id
  42021. * @param id defines the bone's id
  42022. * @return the bone or null if not found
  42023. */
  42024. getBoneByID(id: string): Nullable<Bone>;
  42025. /**
  42026. * Gets a bone using its id
  42027. * @param name defines the bone's name
  42028. * @return the bone or null if not found
  42029. */
  42030. getBoneByName(name: string): Nullable<Bone>;
  42031. /**
  42032. * Gets a light node using its name
  42033. * @param name defines the the light's name
  42034. * @return the light or null if none found.
  42035. */
  42036. getLightByName(name: string): Nullable<Light>;
  42037. /**
  42038. * Gets a light node using its id
  42039. * @param id defines the light's id
  42040. * @return the light or null if none found.
  42041. */
  42042. getLightByID(id: string): Nullable<Light>;
  42043. /**
  42044. * Gets a light node using its scene-generated unique ID
  42045. * @param uniqueId defines the light's unique id
  42046. * @return the light or null if none found.
  42047. */
  42048. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  42049. /**
  42050. * Gets a particle system by id
  42051. * @param id defines the particle system id
  42052. * @return the corresponding system or null if none found
  42053. */
  42054. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  42055. /**
  42056. * Gets a geometry using its ID
  42057. * @param id defines the geometry's id
  42058. * @return the geometry or null if none found.
  42059. */
  42060. getGeometryByID(id: string): Nullable<Geometry>;
  42061. private _getGeometryByUniqueID;
  42062. /**
  42063. * Add a new geometry to this scene
  42064. * @param geometry defines the geometry to be added to the scene.
  42065. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  42066. * @return a boolean defining if the geometry was added or not
  42067. */
  42068. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  42069. /**
  42070. * Removes an existing geometry
  42071. * @param geometry defines the geometry to be removed from the scene
  42072. * @return a boolean defining if the geometry was removed or not
  42073. */
  42074. removeGeometry(geometry: Geometry): boolean;
  42075. /**
  42076. * Gets the list of geometries attached to the scene
  42077. * @returns an array of Geometry
  42078. */
  42079. getGeometries(): Geometry[];
  42080. /**
  42081. * Gets the first added mesh found of a given ID
  42082. * @param id defines the id to search for
  42083. * @return the mesh found or null if not found at all
  42084. */
  42085. getMeshByID(id: string): Nullable<AbstractMesh>;
  42086. /**
  42087. * Gets a list of meshes using their id
  42088. * @param id defines the id to search for
  42089. * @returns a list of meshes
  42090. */
  42091. getMeshesByID(id: string): Array<AbstractMesh>;
  42092. /**
  42093. * Gets the first added transform node found of a given ID
  42094. * @param id defines the id to search for
  42095. * @return the found transform node or null if not found at all.
  42096. */
  42097. getTransformNodeByID(id: string): Nullable<TransformNode>;
  42098. /**
  42099. * Gets a transform node with its auto-generated unique id
  42100. * @param uniqueId efines the unique id to search for
  42101. * @return the found transform node or null if not found at all.
  42102. */
  42103. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  42104. /**
  42105. * Gets a list of transform nodes using their id
  42106. * @param id defines the id to search for
  42107. * @returns a list of transform nodes
  42108. */
  42109. getTransformNodesByID(id: string): Array<TransformNode>;
  42110. /**
  42111. * Gets a mesh with its auto-generated unique id
  42112. * @param uniqueId defines the unique id to search for
  42113. * @return the found mesh or null if not found at all.
  42114. */
  42115. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  42116. /**
  42117. * Gets a the last added mesh using a given id
  42118. * @param id defines the id to search for
  42119. * @return the found mesh or null if not found at all.
  42120. */
  42121. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  42122. /**
  42123. * Gets a the last added node (Mesh, Camera, Light) using a given id
  42124. * @param id defines the id to search for
  42125. * @return the found node or null if not found at all
  42126. */
  42127. getLastEntryByID(id: string): Nullable<Node>;
  42128. /**
  42129. * Gets a node (Mesh, Camera, Light) using a given id
  42130. * @param id defines the id to search for
  42131. * @return the found node or null if not found at all
  42132. */
  42133. getNodeByID(id: string): Nullable<Node>;
  42134. /**
  42135. * Gets a node (Mesh, Camera, Light) using a given name
  42136. * @param name defines the name to search for
  42137. * @return the found node or null if not found at all.
  42138. */
  42139. getNodeByName(name: string): Nullable<Node>;
  42140. /**
  42141. * Gets a mesh using a given name
  42142. * @param name defines the name to search for
  42143. * @return the found mesh or null if not found at all.
  42144. */
  42145. getMeshByName(name: string): Nullable<AbstractMesh>;
  42146. /**
  42147. * Gets a transform node using a given name
  42148. * @param name defines the name to search for
  42149. * @return the found transform node or null if not found at all.
  42150. */
  42151. getTransformNodeByName(name: string): Nullable<TransformNode>;
  42152. /**
  42153. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  42154. * @param id defines the id to search for
  42155. * @return the found skeleton or null if not found at all.
  42156. */
  42157. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  42158. /**
  42159. * Gets a skeleton using a given auto generated unique id
  42160. * @param uniqueId defines the unique id to search for
  42161. * @return the found skeleton or null if not found at all.
  42162. */
  42163. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  42164. /**
  42165. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  42166. * @param id defines the id to search for
  42167. * @return the found skeleton or null if not found at all.
  42168. */
  42169. getSkeletonById(id: string): Nullable<Skeleton>;
  42170. /**
  42171. * Gets a skeleton using a given name
  42172. * @param name defines the name to search for
  42173. * @return the found skeleton or null if not found at all.
  42174. */
  42175. getSkeletonByName(name: string): Nullable<Skeleton>;
  42176. /**
  42177. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  42178. * @param id defines the id to search for
  42179. * @return the found morph target manager or null if not found at all.
  42180. */
  42181. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  42182. /**
  42183. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  42184. * @param id defines the id to search for
  42185. * @return the found morph target or null if not found at all.
  42186. */
  42187. getMorphTargetById(id: string): Nullable<MorphTarget>;
  42188. /**
  42189. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  42190. * @param name defines the name to search for
  42191. * @return the found morph target or null if not found at all.
  42192. */
  42193. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  42194. /**
  42195. * Gets a post process using a given name (if many are found, this function will pick the first one)
  42196. * @param name defines the name to search for
  42197. * @return the found post process or null if not found at all.
  42198. */
  42199. getPostProcessByName(name: string): Nullable<PostProcess>;
  42200. /**
  42201. * Gets a boolean indicating if the given mesh is active
  42202. * @param mesh defines the mesh to look for
  42203. * @returns true if the mesh is in the active list
  42204. */
  42205. isActiveMesh(mesh: AbstractMesh): boolean;
  42206. /**
  42207. * Return a unique id as a string which can serve as an identifier for the scene
  42208. */
  42209. get uid(): string;
  42210. /**
  42211. * Add an externaly attached data from its key.
  42212. * This method call will fail and return false, if such key already exists.
  42213. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  42214. * @param key the unique key that identifies the data
  42215. * @param data the data object to associate to the key for this Engine instance
  42216. * @return true if no such key were already present and the data was added successfully, false otherwise
  42217. */
  42218. addExternalData<T>(key: string, data: T): boolean;
  42219. /**
  42220. * Get an externaly attached data from its key
  42221. * @param key the unique key that identifies the data
  42222. * @return the associated data, if present (can be null), or undefined if not present
  42223. */
  42224. getExternalData<T>(key: string): Nullable<T>;
  42225. /**
  42226. * Get an externaly attached data from its key, create it using a factory if it's not already present
  42227. * @param key the unique key that identifies the data
  42228. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  42229. * @return the associated data, can be null if the factory returned null.
  42230. */
  42231. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  42232. /**
  42233. * Remove an externaly attached data from the Engine instance
  42234. * @param key the unique key that identifies the data
  42235. * @return true if the data was successfully removed, false if it doesn't exist
  42236. */
  42237. removeExternalData(key: string): boolean;
  42238. private _evaluateSubMesh;
  42239. /**
  42240. * Clear the processed materials smart array preventing retention point in material dispose.
  42241. */
  42242. freeProcessedMaterials(): void;
  42243. private _preventFreeActiveMeshesAndRenderingGroups;
  42244. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  42245. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  42246. * when disposing several meshes in a row or a hierarchy of meshes.
  42247. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  42248. */
  42249. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  42250. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  42251. /**
  42252. * Clear the active meshes smart array preventing retention point in mesh dispose.
  42253. */
  42254. freeActiveMeshes(): void;
  42255. /**
  42256. * Clear the info related to rendering groups preventing retention points during dispose.
  42257. */
  42258. freeRenderingGroups(): void;
  42259. /** @hidden */
  42260. _isInIntermediateRendering(): boolean;
  42261. /**
  42262. * Lambda returning the list of potentially active meshes.
  42263. */
  42264. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  42265. /**
  42266. * Lambda returning the list of potentially active sub meshes.
  42267. */
  42268. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  42269. /**
  42270. * Lambda returning the list of potentially intersecting sub meshes.
  42271. */
  42272. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  42273. /**
  42274. * Lambda returning the list of potentially colliding sub meshes.
  42275. */
  42276. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  42277. private _activeMeshesFrozen;
  42278. private _skipEvaluateActiveMeshesCompletely;
  42279. /**
  42280. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  42281. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  42282. * @returns the current scene
  42283. */
  42284. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  42285. /**
  42286. * Use this function to restart evaluating active meshes on every frame
  42287. * @returns the current scene
  42288. */
  42289. unfreezeActiveMeshes(): Scene;
  42290. private _evaluateActiveMeshes;
  42291. private _activeMesh;
  42292. /**
  42293. * Update the transform matrix to update from the current active camera
  42294. * @param force defines a boolean used to force the update even if cache is up to date
  42295. */
  42296. updateTransformMatrix(force?: boolean): void;
  42297. private _bindFrameBuffer;
  42298. /** @hidden */
  42299. _allowPostProcessClearColor: boolean;
  42300. /** @hidden */
  42301. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  42302. private _processSubCameras;
  42303. private _checkIntersections;
  42304. /** @hidden */
  42305. _advancePhysicsEngineStep(step: number): void;
  42306. /**
  42307. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  42308. */
  42309. getDeterministicFrameTime: () => number;
  42310. /** @hidden */
  42311. _animate(): void;
  42312. /** Execute all animations (for a frame) */
  42313. animate(): void;
  42314. /**
  42315. * Render the scene
  42316. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  42317. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  42318. */
  42319. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  42320. /**
  42321. * Freeze all materials
  42322. * A frozen material will not be updatable but should be faster to render
  42323. */
  42324. freezeMaterials(): void;
  42325. /**
  42326. * Unfreeze all materials
  42327. * A frozen material will not be updatable but should be faster to render
  42328. */
  42329. unfreezeMaterials(): void;
  42330. /**
  42331. * Releases all held ressources
  42332. */
  42333. dispose(): void;
  42334. /**
  42335. * Gets if the scene is already disposed
  42336. */
  42337. get isDisposed(): boolean;
  42338. /**
  42339. * Call this function to reduce memory footprint of the scene.
  42340. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  42341. */
  42342. clearCachedVertexData(): void;
  42343. /**
  42344. * This function will remove the local cached buffer data from texture.
  42345. * It will save memory but will prevent the texture from being rebuilt
  42346. */
  42347. cleanCachedTextureBuffer(): void;
  42348. /**
  42349. * Get the world extend vectors with an optional filter
  42350. *
  42351. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  42352. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  42353. */
  42354. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  42355. min: Vector3;
  42356. max: Vector3;
  42357. };
  42358. /**
  42359. * Creates a ray that can be used to pick in the scene
  42360. * @param x defines the x coordinate of the origin (on-screen)
  42361. * @param y defines the y coordinate of the origin (on-screen)
  42362. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  42363. * @param camera defines the camera to use for the picking
  42364. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  42365. * @returns a Ray
  42366. */
  42367. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  42368. /**
  42369. * Creates a ray that can be used to pick in the scene
  42370. * @param x defines the x coordinate of the origin (on-screen)
  42371. * @param y defines the y coordinate of the origin (on-screen)
  42372. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  42373. * @param result defines the ray where to store the picking ray
  42374. * @param camera defines the camera to use for the picking
  42375. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  42376. * @returns the current scene
  42377. */
  42378. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  42379. /**
  42380. * Creates a ray that can be used to pick in the scene
  42381. * @param x defines the x coordinate of the origin (on-screen)
  42382. * @param y defines the y coordinate of the origin (on-screen)
  42383. * @param camera defines the camera to use for the picking
  42384. * @returns a Ray
  42385. */
  42386. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  42387. /**
  42388. * Creates a ray that can be used to pick in the scene
  42389. * @param x defines the x coordinate of the origin (on-screen)
  42390. * @param y defines the y coordinate of the origin (on-screen)
  42391. * @param result defines the ray where to store the picking ray
  42392. * @param camera defines the camera to use for the picking
  42393. * @returns the current scene
  42394. */
  42395. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  42396. /** Launch a ray to try to pick a mesh in the scene
  42397. * @param x position on screen
  42398. * @param y position on screen
  42399. * @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
  42400. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42401. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42402. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42403. * @returns a PickingInfo
  42404. */
  42405. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  42406. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  42407. * @param x position on screen
  42408. * @param y position on screen
  42409. * @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
  42410. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42411. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42412. * @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)
  42413. */
  42414. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  42415. /** Use the given ray to pick a mesh in the scene
  42416. * @param ray The ray to use to pick meshes
  42417. * @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
  42418. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42419. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42420. * @returns a PickingInfo
  42421. */
  42422. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  42423. /**
  42424. * Launch a ray to try to pick a mesh in the scene
  42425. * @param x X position on screen
  42426. * @param y Y position on screen
  42427. * @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
  42428. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42429. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42430. * @returns an array of PickingInfo
  42431. */
  42432. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  42433. /**
  42434. * Launch a ray to try to pick a mesh in the scene
  42435. * @param ray Ray to use
  42436. * @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
  42437. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42438. * @returns an array of PickingInfo
  42439. */
  42440. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  42441. /**
  42442. * Force the value of meshUnderPointer
  42443. * @param mesh defines the mesh to use
  42444. */
  42445. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  42446. /**
  42447. * Gets the mesh under the pointer
  42448. * @returns a Mesh or null if no mesh is under the pointer
  42449. */
  42450. getPointerOverMesh(): Nullable<AbstractMesh>;
  42451. /** @hidden */
  42452. _rebuildGeometries(): void;
  42453. /** @hidden */
  42454. _rebuildTextures(): void;
  42455. private _getByTags;
  42456. /**
  42457. * Get a list of meshes by tags
  42458. * @param tagsQuery defines the tags query to use
  42459. * @param forEach defines a predicate used to filter results
  42460. * @returns an array of Mesh
  42461. */
  42462. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  42463. /**
  42464. * Get a list of cameras by tags
  42465. * @param tagsQuery defines the tags query to use
  42466. * @param forEach defines a predicate used to filter results
  42467. * @returns an array of Camera
  42468. */
  42469. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  42470. /**
  42471. * Get a list of lights by tags
  42472. * @param tagsQuery defines the tags query to use
  42473. * @param forEach defines a predicate used to filter results
  42474. * @returns an array of Light
  42475. */
  42476. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  42477. /**
  42478. * Get a list of materials by tags
  42479. * @param tagsQuery defines the tags query to use
  42480. * @param forEach defines a predicate used to filter results
  42481. * @returns an array of Material
  42482. */
  42483. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  42484. /**
  42485. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  42486. * This allowed control for front to back rendering or reversly depending of the special needs.
  42487. *
  42488. * @param renderingGroupId The rendering group id corresponding to its index
  42489. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  42490. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  42491. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  42492. */
  42493. 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;
  42494. /**
  42495. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  42496. *
  42497. * @param renderingGroupId The rendering group id corresponding to its index
  42498. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  42499. * @param depth Automatically clears depth between groups if true and autoClear is true.
  42500. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  42501. */
  42502. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  42503. /**
  42504. * Gets the current auto clear configuration for one rendering group of the rendering
  42505. * manager.
  42506. * @param index the rendering group index to get the information for
  42507. * @returns The auto clear setup for the requested rendering group
  42508. */
  42509. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  42510. private _blockMaterialDirtyMechanism;
  42511. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  42512. get blockMaterialDirtyMechanism(): boolean;
  42513. set blockMaterialDirtyMechanism(value: boolean);
  42514. /**
  42515. * Will flag all materials as dirty to trigger new shader compilation
  42516. * @param flag defines the flag used to specify which material part must be marked as dirty
  42517. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  42518. */
  42519. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  42520. /** @hidden */
  42521. _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;
  42522. /** @hidden */
  42523. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42524. /** @hidden */
  42525. _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;
  42526. /** @hidden */
  42527. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  42528. /** @hidden */
  42529. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  42530. /** @hidden */
  42531. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42532. }
  42533. }
  42534. declare module "babylonjs/assetContainer" {
  42535. import { AbstractScene } from "babylonjs/abstractScene";
  42536. import { Scene } from "babylonjs/scene";
  42537. import { Mesh } from "babylonjs/Meshes/mesh";
  42538. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42539. import { Skeleton } from "babylonjs/Bones/skeleton";
  42540. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42541. import { Animatable } from "babylonjs/Animations/animatable";
  42542. import { Nullable } from "babylonjs/types";
  42543. import { Node } from "babylonjs/node";
  42544. /**
  42545. * Set of assets to keep when moving a scene into an asset container.
  42546. */
  42547. export class KeepAssets extends AbstractScene {
  42548. }
  42549. /**
  42550. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  42551. */
  42552. export class InstantiatedEntries {
  42553. /**
  42554. * List of new root nodes (eg. nodes with no parent)
  42555. */
  42556. rootNodes: TransformNode[];
  42557. /**
  42558. * List of new skeletons
  42559. */
  42560. skeletons: Skeleton[];
  42561. /**
  42562. * List of new animation groups
  42563. */
  42564. animationGroups: AnimationGroup[];
  42565. }
  42566. /**
  42567. * Container with a set of assets that can be added or removed from a scene.
  42568. */
  42569. export class AssetContainer extends AbstractScene {
  42570. private _wasAddedToScene;
  42571. /**
  42572. * The scene the AssetContainer belongs to.
  42573. */
  42574. scene: Scene;
  42575. /**
  42576. * Instantiates an AssetContainer.
  42577. * @param scene The scene the AssetContainer belongs to.
  42578. */
  42579. constructor(scene: Scene);
  42580. /**
  42581. * Instantiate or clone all meshes and add the new ones to the scene.
  42582. * Skeletons and animation groups will all be cloned
  42583. * @param nameFunction defines an optional function used to get new names for clones
  42584. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  42585. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  42586. */
  42587. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  42588. /**
  42589. * Adds all the assets from the container to the scene.
  42590. */
  42591. addAllToScene(): void;
  42592. /**
  42593. * Removes all the assets in the container from the scene
  42594. */
  42595. removeAllFromScene(): void;
  42596. /**
  42597. * Disposes all the assets in the container
  42598. */
  42599. dispose(): void;
  42600. private _moveAssets;
  42601. /**
  42602. * Removes all the assets contained in the scene and adds them to the container.
  42603. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  42604. */
  42605. moveAllFromScene(keepAssets?: KeepAssets): void;
  42606. /**
  42607. * 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.
  42608. * @returns the root mesh
  42609. */
  42610. createRootMesh(): Mesh;
  42611. /**
  42612. * Merge animations (direct and animation groups) from this asset container into a scene
  42613. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42614. * @param animatables set of animatables to retarget to a node from the scene
  42615. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  42616. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  42617. */
  42618. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  42619. }
  42620. }
  42621. declare module "babylonjs/abstractScene" {
  42622. import { Scene } from "babylonjs/scene";
  42623. import { Nullable } from "babylonjs/types";
  42624. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42625. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42626. import { Geometry } from "babylonjs/Meshes/geometry";
  42627. import { Skeleton } from "babylonjs/Bones/skeleton";
  42628. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  42629. import { AssetContainer } from "babylonjs/assetContainer";
  42630. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42631. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42632. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42633. import { Material } from "babylonjs/Materials/material";
  42634. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  42635. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  42636. import { Camera } from "babylonjs/Cameras/camera";
  42637. import { Light } from "babylonjs/Lights/light";
  42638. import { Node } from "babylonjs/node";
  42639. import { Animation } from "babylonjs/Animations/animation";
  42640. /**
  42641. * Defines how the parser contract is defined.
  42642. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  42643. */
  42644. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  42645. /**
  42646. * Defines how the individual parser contract is defined.
  42647. * These parser can parse an individual asset
  42648. */
  42649. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  42650. /**
  42651. * Base class of the scene acting as a container for the different elements composing a scene.
  42652. * This class is dynamically extended by the different components of the scene increasing
  42653. * flexibility and reducing coupling
  42654. */
  42655. export abstract class AbstractScene {
  42656. /**
  42657. * Stores the list of available parsers in the application.
  42658. */
  42659. private static _BabylonFileParsers;
  42660. /**
  42661. * Stores the list of available individual parsers in the application.
  42662. */
  42663. private static _IndividualBabylonFileParsers;
  42664. /**
  42665. * Adds a parser in the list of available ones
  42666. * @param name Defines the name of the parser
  42667. * @param parser Defines the parser to add
  42668. */
  42669. static AddParser(name: string, parser: BabylonFileParser): void;
  42670. /**
  42671. * Gets a general parser from the list of avaialble ones
  42672. * @param name Defines the name of the parser
  42673. * @returns the requested parser or null
  42674. */
  42675. static GetParser(name: string): Nullable<BabylonFileParser>;
  42676. /**
  42677. * Adds n individual parser in the list of available ones
  42678. * @param name Defines the name of the parser
  42679. * @param parser Defines the parser to add
  42680. */
  42681. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  42682. /**
  42683. * Gets an individual parser from the list of avaialble ones
  42684. * @param name Defines the name of the parser
  42685. * @returns the requested parser or null
  42686. */
  42687. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  42688. /**
  42689. * Parser json data and populate both a scene and its associated container object
  42690. * @param jsonData Defines the data to parse
  42691. * @param scene Defines the scene to parse the data for
  42692. * @param container Defines the container attached to the parsing sequence
  42693. * @param rootUrl Defines the root url of the data
  42694. */
  42695. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  42696. /**
  42697. * Gets the list of root nodes (ie. nodes with no parent)
  42698. */
  42699. rootNodes: Node[];
  42700. /** All of the cameras added to this scene
  42701. * @see https://doc.babylonjs.com/babylon101/cameras
  42702. */
  42703. cameras: Camera[];
  42704. /**
  42705. * All of the lights added to this scene
  42706. * @see https://doc.babylonjs.com/babylon101/lights
  42707. */
  42708. lights: Light[];
  42709. /**
  42710. * All of the (abstract) meshes added to this scene
  42711. */
  42712. meshes: AbstractMesh[];
  42713. /**
  42714. * The list of skeletons added to the scene
  42715. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  42716. */
  42717. skeletons: Skeleton[];
  42718. /**
  42719. * All of the particle systems added to this scene
  42720. * @see https://doc.babylonjs.com/babylon101/particles
  42721. */
  42722. particleSystems: IParticleSystem[];
  42723. /**
  42724. * Gets a list of Animations associated with the scene
  42725. */
  42726. animations: Animation[];
  42727. /**
  42728. * All of the animation groups added to this scene
  42729. * @see https://doc.babylonjs.com/how_to/group
  42730. */
  42731. animationGroups: AnimationGroup[];
  42732. /**
  42733. * All of the multi-materials added to this scene
  42734. * @see https://doc.babylonjs.com/how_to/multi_materials
  42735. */
  42736. multiMaterials: MultiMaterial[];
  42737. /**
  42738. * All of the materials added to this scene
  42739. * In the context of a Scene, it is not supposed to be modified manually.
  42740. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  42741. * Note also that the order of the Material within the array is not significant and might change.
  42742. * @see https://doc.babylonjs.com/babylon101/materials
  42743. */
  42744. materials: Material[];
  42745. /**
  42746. * The list of morph target managers added to the scene
  42747. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  42748. */
  42749. morphTargetManagers: MorphTargetManager[];
  42750. /**
  42751. * The list of geometries used in the scene.
  42752. */
  42753. geometries: Geometry[];
  42754. /**
  42755. * All of the tranform nodes added to this scene
  42756. * In the context of a Scene, it is not supposed to be modified manually.
  42757. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  42758. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  42759. * @see https://doc.babylonjs.com/how_to/transformnode
  42760. */
  42761. transformNodes: TransformNode[];
  42762. /**
  42763. * ActionManagers available on the scene.
  42764. */
  42765. actionManagers: AbstractActionManager[];
  42766. /**
  42767. * Textures to keep.
  42768. */
  42769. textures: BaseTexture[];
  42770. /**
  42771. * Environment texture for the scene
  42772. */
  42773. environmentTexture: Nullable<BaseTexture>;
  42774. /**
  42775. * The list of postprocesses added to the scene
  42776. */
  42777. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  42778. /**
  42779. * @returns all meshes, lights, cameras, transformNodes and bones
  42780. */
  42781. getNodes(): Array<Node>;
  42782. }
  42783. }
  42784. declare module "babylonjs/Audio/sound" {
  42785. import { Observable } from "babylonjs/Misc/observable";
  42786. import { Vector3 } from "babylonjs/Maths/math.vector";
  42787. import { Nullable } from "babylonjs/types";
  42788. import { Scene } from "babylonjs/scene";
  42789. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42790. /**
  42791. * Interface used to define options for Sound class
  42792. */
  42793. export interface ISoundOptions {
  42794. /**
  42795. * Does the sound autoplay once loaded.
  42796. */
  42797. autoplay?: boolean;
  42798. /**
  42799. * Does the sound loop after it finishes playing once.
  42800. */
  42801. loop?: boolean;
  42802. /**
  42803. * Sound's volume
  42804. */
  42805. volume?: number;
  42806. /**
  42807. * Is it a spatial sound?
  42808. */
  42809. spatialSound?: boolean;
  42810. /**
  42811. * Maximum distance to hear that sound
  42812. */
  42813. maxDistance?: number;
  42814. /**
  42815. * Uses user defined attenuation function
  42816. */
  42817. useCustomAttenuation?: boolean;
  42818. /**
  42819. * Define the roll off factor of spatial sounds.
  42820. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42821. */
  42822. rolloffFactor?: number;
  42823. /**
  42824. * Define the reference distance the sound should be heard perfectly.
  42825. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42826. */
  42827. refDistance?: number;
  42828. /**
  42829. * Define the distance attenuation model the sound will follow.
  42830. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42831. */
  42832. distanceModel?: string;
  42833. /**
  42834. * Defines the playback speed (1 by default)
  42835. */
  42836. playbackRate?: number;
  42837. /**
  42838. * Defines if the sound is from a streaming source
  42839. */
  42840. streaming?: boolean;
  42841. /**
  42842. * Defines an optional length (in seconds) inside the sound file
  42843. */
  42844. length?: number;
  42845. /**
  42846. * Defines an optional offset (in seconds) inside the sound file
  42847. */
  42848. offset?: number;
  42849. /**
  42850. * If true, URLs will not be required to state the audio file codec to use.
  42851. */
  42852. skipCodecCheck?: boolean;
  42853. }
  42854. /**
  42855. * Defines a sound that can be played in the application.
  42856. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  42857. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42858. */
  42859. export class Sound {
  42860. /**
  42861. * The name of the sound in the scene.
  42862. */
  42863. name: string;
  42864. /**
  42865. * Does the sound autoplay once loaded.
  42866. */
  42867. autoplay: boolean;
  42868. /**
  42869. * Does the sound loop after it finishes playing once.
  42870. */
  42871. loop: boolean;
  42872. /**
  42873. * Does the sound use a custom attenuation curve to simulate the falloff
  42874. * happening when the source gets further away from the camera.
  42875. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  42876. */
  42877. useCustomAttenuation: boolean;
  42878. /**
  42879. * The sound track id this sound belongs to.
  42880. */
  42881. soundTrackId: number;
  42882. /**
  42883. * Is this sound currently played.
  42884. */
  42885. isPlaying: boolean;
  42886. /**
  42887. * Is this sound currently paused.
  42888. */
  42889. isPaused: boolean;
  42890. /**
  42891. * Does this sound enables spatial sound.
  42892. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42893. */
  42894. spatialSound: boolean;
  42895. /**
  42896. * Define the reference distance the sound should be heard perfectly.
  42897. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42898. */
  42899. refDistance: number;
  42900. /**
  42901. * Define the roll off factor of spatial sounds.
  42902. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42903. */
  42904. rolloffFactor: number;
  42905. /**
  42906. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  42907. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42908. */
  42909. maxDistance: number;
  42910. /**
  42911. * Define the distance attenuation model the sound will follow.
  42912. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42913. */
  42914. distanceModel: string;
  42915. /**
  42916. * @hidden
  42917. * Back Compat
  42918. **/
  42919. onended: () => any;
  42920. /**
  42921. * Gets or sets an object used to store user defined information for the sound.
  42922. */
  42923. metadata: any;
  42924. /**
  42925. * Observable event when the current playing sound finishes.
  42926. */
  42927. onEndedObservable: Observable<Sound>;
  42928. private _panningModel;
  42929. private _playbackRate;
  42930. private _streaming;
  42931. private _startTime;
  42932. private _startOffset;
  42933. private _position;
  42934. /** @hidden */
  42935. _positionInEmitterSpace: boolean;
  42936. private _localDirection;
  42937. private _volume;
  42938. private _isReadyToPlay;
  42939. private _isDirectional;
  42940. private _readyToPlayCallback;
  42941. private _audioBuffer;
  42942. private _soundSource;
  42943. private _streamingSource;
  42944. private _soundPanner;
  42945. private _soundGain;
  42946. private _inputAudioNode;
  42947. private _outputAudioNode;
  42948. private _coneInnerAngle;
  42949. private _coneOuterAngle;
  42950. private _coneOuterGain;
  42951. private _scene;
  42952. private _connectedTransformNode;
  42953. private _customAttenuationFunction;
  42954. private _registerFunc;
  42955. private _isOutputConnected;
  42956. private _htmlAudioElement;
  42957. private _urlType;
  42958. private _length?;
  42959. private _offset?;
  42960. /** @hidden */
  42961. static _SceneComponentInitialization: (scene: Scene) => void;
  42962. /**
  42963. * Create a sound and attach it to a scene
  42964. * @param name Name of your sound
  42965. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  42966. * @param scene defines the scene the sound belongs to
  42967. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  42968. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  42969. */
  42970. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  42971. /**
  42972. * Release the sound and its associated resources
  42973. */
  42974. dispose(): void;
  42975. /**
  42976. * Gets if the sounds is ready to be played or not.
  42977. * @returns true if ready, otherwise false
  42978. */
  42979. isReady(): boolean;
  42980. private _soundLoaded;
  42981. /**
  42982. * Sets the data of the sound from an audiobuffer
  42983. * @param audioBuffer The audioBuffer containing the data
  42984. */
  42985. setAudioBuffer(audioBuffer: AudioBuffer): void;
  42986. /**
  42987. * Updates the current sounds options such as maxdistance, loop...
  42988. * @param options A JSON object containing values named as the object properties
  42989. */
  42990. updateOptions(options: ISoundOptions): void;
  42991. private _createSpatialParameters;
  42992. private _updateSpatialParameters;
  42993. /**
  42994. * Switch the panning model to HRTF:
  42995. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  42996. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42997. */
  42998. switchPanningModelToHRTF(): void;
  42999. /**
  43000. * Switch the panning model to Equal Power:
  43001. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  43002. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43003. */
  43004. switchPanningModelToEqualPower(): void;
  43005. private _switchPanningModel;
  43006. /**
  43007. * Connect this sound to a sound track audio node like gain...
  43008. * @param soundTrackAudioNode the sound track audio node to connect to
  43009. */
  43010. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  43011. /**
  43012. * Transform this sound into a directional source
  43013. * @param coneInnerAngle Size of the inner cone in degree
  43014. * @param coneOuterAngle Size of the outer cone in degree
  43015. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  43016. */
  43017. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  43018. /**
  43019. * Gets or sets the inner angle for the directional cone.
  43020. */
  43021. get directionalConeInnerAngle(): number;
  43022. /**
  43023. * Gets or sets the inner angle for the directional cone.
  43024. */
  43025. set directionalConeInnerAngle(value: number);
  43026. /**
  43027. * Gets or sets the outer angle for the directional cone.
  43028. */
  43029. get directionalConeOuterAngle(): number;
  43030. /**
  43031. * Gets or sets the outer angle for the directional cone.
  43032. */
  43033. set directionalConeOuterAngle(value: number);
  43034. /**
  43035. * Sets the position of the emitter if spatial sound is enabled
  43036. * @param newPosition Defines the new posisiton
  43037. */
  43038. setPosition(newPosition: Vector3): void;
  43039. /**
  43040. * Sets the local direction of the emitter if spatial sound is enabled
  43041. * @param newLocalDirection Defines the new local direction
  43042. */
  43043. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  43044. private _updateDirection;
  43045. /** @hidden */
  43046. updateDistanceFromListener(): void;
  43047. /**
  43048. * Sets a new custom attenuation function for the sound.
  43049. * @param callback Defines the function used for the attenuation
  43050. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  43051. */
  43052. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  43053. /**
  43054. * Play the sound
  43055. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  43056. * @param offset (optional) Start the sound at a specific time in seconds
  43057. * @param length (optional) Sound duration (in seconds)
  43058. */
  43059. play(time?: number, offset?: number, length?: number): void;
  43060. private _onended;
  43061. /**
  43062. * Stop the sound
  43063. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  43064. */
  43065. stop(time?: number): void;
  43066. /**
  43067. * Put the sound in pause
  43068. */
  43069. pause(): void;
  43070. /**
  43071. * Sets a dedicated volume for this sounds
  43072. * @param newVolume Define the new volume of the sound
  43073. * @param time Define time for gradual change to new volume
  43074. */
  43075. setVolume(newVolume: number, time?: number): void;
  43076. /**
  43077. * Set the sound play back rate
  43078. * @param newPlaybackRate Define the playback rate the sound should be played at
  43079. */
  43080. setPlaybackRate(newPlaybackRate: number): void;
  43081. /**
  43082. * Gets the volume of the sound.
  43083. * @returns the volume of the sound
  43084. */
  43085. getVolume(): number;
  43086. /**
  43087. * Attach the sound to a dedicated mesh
  43088. * @param transformNode The transform node to connect the sound with
  43089. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  43090. */
  43091. attachToMesh(transformNode: TransformNode): void;
  43092. /**
  43093. * Detach the sound from the previously attached mesh
  43094. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  43095. */
  43096. detachFromMesh(): void;
  43097. private _onRegisterAfterWorldMatrixUpdate;
  43098. /**
  43099. * Clone the current sound in the scene.
  43100. * @returns the new sound clone
  43101. */
  43102. clone(): Nullable<Sound>;
  43103. /**
  43104. * Gets the current underlying audio buffer containing the data
  43105. * @returns the audio buffer
  43106. */
  43107. getAudioBuffer(): Nullable<AudioBuffer>;
  43108. /**
  43109. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  43110. * @returns the source node
  43111. */
  43112. getSoundSource(): Nullable<AudioBufferSourceNode>;
  43113. /**
  43114. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  43115. * @returns the gain node
  43116. */
  43117. getSoundGain(): Nullable<GainNode>;
  43118. /**
  43119. * Serializes the Sound in a JSON representation
  43120. * @returns the JSON representation of the sound
  43121. */
  43122. serialize(): any;
  43123. /**
  43124. * Parse a JSON representation of a sound to innstantiate in a given scene
  43125. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  43126. * @param scene Define the scene the new parsed sound should be created in
  43127. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  43128. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  43129. * @returns the newly parsed sound
  43130. */
  43131. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  43132. }
  43133. }
  43134. declare module "babylonjs/Actions/directAudioActions" {
  43135. import { Action } from "babylonjs/Actions/action";
  43136. import { Condition } from "babylonjs/Actions/condition";
  43137. import { Sound } from "babylonjs/Audio/sound";
  43138. /**
  43139. * This defines an action helpful to play a defined sound on a triggered action.
  43140. */
  43141. export class PlaySoundAction extends Action {
  43142. private _sound;
  43143. /**
  43144. * Instantiate the action
  43145. * @param triggerOptions defines the trigger options
  43146. * @param sound defines the sound to play
  43147. * @param condition defines the trigger related conditions
  43148. */
  43149. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  43150. /** @hidden */
  43151. _prepare(): void;
  43152. /**
  43153. * Execute the action and play the sound.
  43154. */
  43155. execute(): void;
  43156. /**
  43157. * Serializes the actions and its related information.
  43158. * @param parent defines the object to serialize in
  43159. * @returns the serialized object
  43160. */
  43161. serialize(parent: any): any;
  43162. }
  43163. /**
  43164. * This defines an action helpful to stop a defined sound on a triggered action.
  43165. */
  43166. export class StopSoundAction extends Action {
  43167. private _sound;
  43168. /**
  43169. * Instantiate the action
  43170. * @param triggerOptions defines the trigger options
  43171. * @param sound defines the sound to stop
  43172. * @param condition defines the trigger related conditions
  43173. */
  43174. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  43175. /** @hidden */
  43176. _prepare(): void;
  43177. /**
  43178. * Execute the action and stop the sound.
  43179. */
  43180. execute(): void;
  43181. /**
  43182. * Serializes the actions and its related information.
  43183. * @param parent defines the object to serialize in
  43184. * @returns the serialized object
  43185. */
  43186. serialize(parent: any): any;
  43187. }
  43188. }
  43189. declare module "babylonjs/Actions/interpolateValueAction" {
  43190. import { Action } from "babylonjs/Actions/action";
  43191. import { Condition } from "babylonjs/Actions/condition";
  43192. import { Observable } from "babylonjs/Misc/observable";
  43193. /**
  43194. * This defines an action responsible to change the value of a property
  43195. * by interpolating between its current value and the newly set one once triggered.
  43196. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  43197. */
  43198. export class InterpolateValueAction extends Action {
  43199. /**
  43200. * Defines the path of the property where the value should be interpolated
  43201. */
  43202. propertyPath: string;
  43203. /**
  43204. * Defines the target value at the end of the interpolation.
  43205. */
  43206. value: any;
  43207. /**
  43208. * Defines the time it will take for the property to interpolate to the value.
  43209. */
  43210. duration: number;
  43211. /**
  43212. * Defines if the other scene animations should be stopped when the action has been triggered
  43213. */
  43214. stopOtherAnimations?: boolean;
  43215. /**
  43216. * Defines a callback raised once the interpolation animation has been done.
  43217. */
  43218. onInterpolationDone?: () => void;
  43219. /**
  43220. * Observable triggered once the interpolation animation has been done.
  43221. */
  43222. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  43223. private _target;
  43224. private _effectiveTarget;
  43225. private _property;
  43226. /**
  43227. * Instantiate the action
  43228. * @param triggerOptions defines the trigger options
  43229. * @param target defines the object containing the value to interpolate
  43230. * @param propertyPath defines the path to the property in the target object
  43231. * @param value defines the target value at the end of the interpolation
  43232. * @param duration deines the time it will take for the property to interpolate to the value.
  43233. * @param condition defines the trigger related conditions
  43234. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  43235. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  43236. */
  43237. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  43238. /** @hidden */
  43239. _prepare(): void;
  43240. /**
  43241. * Execute the action starts the value interpolation.
  43242. */
  43243. execute(): void;
  43244. /**
  43245. * Serializes the actions and its related information.
  43246. * @param parent defines the object to serialize in
  43247. * @returns the serialized object
  43248. */
  43249. serialize(parent: any): any;
  43250. }
  43251. }
  43252. declare module "babylonjs/Actions/index" {
  43253. export * from "babylonjs/Actions/abstractActionManager";
  43254. export * from "babylonjs/Actions/action";
  43255. export * from "babylonjs/Actions/actionEvent";
  43256. export * from "babylonjs/Actions/actionManager";
  43257. export * from "babylonjs/Actions/condition";
  43258. export * from "babylonjs/Actions/directActions";
  43259. export * from "babylonjs/Actions/directAudioActions";
  43260. export * from "babylonjs/Actions/interpolateValueAction";
  43261. }
  43262. declare module "babylonjs/Animations/index" {
  43263. export * from "babylonjs/Animations/animatable";
  43264. export * from "babylonjs/Animations/animation";
  43265. export * from "babylonjs/Animations/animationGroup";
  43266. export * from "babylonjs/Animations/animationPropertiesOverride";
  43267. export * from "babylonjs/Animations/easing";
  43268. export * from "babylonjs/Animations/runtimeAnimation";
  43269. export * from "babylonjs/Animations/animationEvent";
  43270. export * from "babylonjs/Animations/animationGroup";
  43271. export * from "babylonjs/Animations/animationKey";
  43272. export * from "babylonjs/Animations/animationRange";
  43273. export * from "babylonjs/Animations/animatable.interface";
  43274. }
  43275. declare module "babylonjs/Audio/soundTrack" {
  43276. import { Sound } from "babylonjs/Audio/sound";
  43277. import { Analyser } from "babylonjs/Audio/analyser";
  43278. import { Scene } from "babylonjs/scene";
  43279. /**
  43280. * Options allowed during the creation of a sound track.
  43281. */
  43282. export interface ISoundTrackOptions {
  43283. /**
  43284. * The volume the sound track should take during creation
  43285. */
  43286. volume?: number;
  43287. /**
  43288. * Define if the sound track is the main sound track of the scene
  43289. */
  43290. mainTrack?: boolean;
  43291. }
  43292. /**
  43293. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  43294. * It will be also used in a future release to apply effects on a specific track.
  43295. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  43296. */
  43297. export class SoundTrack {
  43298. /**
  43299. * The unique identifier of the sound track in the scene.
  43300. */
  43301. id: number;
  43302. /**
  43303. * The list of sounds included in the sound track.
  43304. */
  43305. soundCollection: Array<Sound>;
  43306. private _outputAudioNode;
  43307. private _scene;
  43308. private _connectedAnalyser;
  43309. private _options;
  43310. private _isInitialized;
  43311. /**
  43312. * Creates a new sound track.
  43313. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  43314. * @param scene Define the scene the sound track belongs to
  43315. * @param options
  43316. */
  43317. constructor(scene: Scene, options?: ISoundTrackOptions);
  43318. private _initializeSoundTrackAudioGraph;
  43319. /**
  43320. * Release the sound track and its associated resources
  43321. */
  43322. dispose(): void;
  43323. /**
  43324. * Adds a sound to this sound track
  43325. * @param sound define the cound to add
  43326. * @ignoreNaming
  43327. */
  43328. AddSound(sound: Sound): void;
  43329. /**
  43330. * Removes a sound to this sound track
  43331. * @param sound define the cound to remove
  43332. * @ignoreNaming
  43333. */
  43334. RemoveSound(sound: Sound): void;
  43335. /**
  43336. * Set a global volume for the full sound track.
  43337. * @param newVolume Define the new volume of the sound track
  43338. */
  43339. setVolume(newVolume: number): void;
  43340. /**
  43341. * Switch the panning model to HRTF:
  43342. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  43343. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43344. */
  43345. switchPanningModelToHRTF(): void;
  43346. /**
  43347. * Switch the panning model to Equal Power:
  43348. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  43349. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43350. */
  43351. switchPanningModelToEqualPower(): void;
  43352. /**
  43353. * Connect the sound track to an audio analyser allowing some amazing
  43354. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  43355. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  43356. * @param analyser The analyser to connect to the engine
  43357. */
  43358. connectToAnalyser(analyser: Analyser): void;
  43359. }
  43360. }
  43361. declare module "babylonjs/Audio/audioSceneComponent" {
  43362. import { Sound } from "babylonjs/Audio/sound";
  43363. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  43364. import { Nullable } from "babylonjs/types";
  43365. import { Vector3 } from "babylonjs/Maths/math.vector";
  43366. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  43367. import { Scene } from "babylonjs/scene";
  43368. import { AbstractScene } from "babylonjs/abstractScene";
  43369. import "babylonjs/Audio/audioEngine";
  43370. module "babylonjs/abstractScene" {
  43371. interface AbstractScene {
  43372. /**
  43373. * The list of sounds used in the scene.
  43374. */
  43375. sounds: Nullable<Array<Sound>>;
  43376. }
  43377. }
  43378. module "babylonjs/scene" {
  43379. interface Scene {
  43380. /**
  43381. * @hidden
  43382. * Backing field
  43383. */
  43384. _mainSoundTrack: SoundTrack;
  43385. /**
  43386. * The main sound track played by the scene.
  43387. * It cotains your primary collection of sounds.
  43388. */
  43389. mainSoundTrack: SoundTrack;
  43390. /**
  43391. * The list of sound tracks added to the scene
  43392. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43393. */
  43394. soundTracks: Nullable<Array<SoundTrack>>;
  43395. /**
  43396. * Gets a sound using a given name
  43397. * @param name defines the name to search for
  43398. * @return the found sound or null if not found at all.
  43399. */
  43400. getSoundByName(name: string): Nullable<Sound>;
  43401. /**
  43402. * Gets or sets if audio support is enabled
  43403. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43404. */
  43405. audioEnabled: boolean;
  43406. /**
  43407. * Gets or sets if audio will be output to headphones
  43408. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43409. */
  43410. headphone: boolean;
  43411. /**
  43412. * Gets or sets custom audio listener position provider
  43413. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43414. */
  43415. audioListenerPositionProvider: Nullable<() => Vector3>;
  43416. /**
  43417. * Gets or sets a refresh rate when using 3D audio positioning
  43418. */
  43419. audioPositioningRefreshRate: number;
  43420. }
  43421. }
  43422. /**
  43423. * Defines the sound scene component responsible to manage any sounds
  43424. * in a given scene.
  43425. */
  43426. export class AudioSceneComponent implements ISceneSerializableComponent {
  43427. /**
  43428. * The component name helpfull to identify the component in the list of scene components.
  43429. */
  43430. readonly name: string;
  43431. /**
  43432. * The scene the component belongs to.
  43433. */
  43434. scene: Scene;
  43435. private _audioEnabled;
  43436. /**
  43437. * Gets whether audio is enabled or not.
  43438. * Please use related enable/disable method to switch state.
  43439. */
  43440. get audioEnabled(): boolean;
  43441. private _headphone;
  43442. /**
  43443. * Gets whether audio is outputing to headphone or not.
  43444. * Please use the according Switch methods to change output.
  43445. */
  43446. get headphone(): boolean;
  43447. /**
  43448. * Gets or sets a refresh rate when using 3D audio positioning
  43449. */
  43450. audioPositioningRefreshRate: number;
  43451. private _audioListenerPositionProvider;
  43452. /**
  43453. * Gets the current audio listener position provider
  43454. */
  43455. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  43456. /**
  43457. * Sets a custom listener position for all sounds in the scene
  43458. * By default, this is the position of the first active camera
  43459. */
  43460. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  43461. /**
  43462. * Creates a new instance of the component for the given scene
  43463. * @param scene Defines the scene to register the component in
  43464. */
  43465. constructor(scene: Scene);
  43466. /**
  43467. * Registers the component in a given scene
  43468. */
  43469. register(): void;
  43470. /**
  43471. * Rebuilds the elements related to this component in case of
  43472. * context lost for instance.
  43473. */
  43474. rebuild(): void;
  43475. /**
  43476. * Serializes the component data to the specified json object
  43477. * @param serializationObject The object to serialize to
  43478. */
  43479. serialize(serializationObject: any): void;
  43480. /**
  43481. * Adds all the elements from the container to the scene
  43482. * @param container the container holding the elements
  43483. */
  43484. addFromContainer(container: AbstractScene): void;
  43485. /**
  43486. * Removes all the elements in the container from the scene
  43487. * @param container contains the elements to remove
  43488. * @param dispose if the removed element should be disposed (default: false)
  43489. */
  43490. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  43491. /**
  43492. * Disposes the component and the associated ressources.
  43493. */
  43494. dispose(): void;
  43495. /**
  43496. * Disables audio in the associated scene.
  43497. */
  43498. disableAudio(): void;
  43499. /**
  43500. * Enables audio in the associated scene.
  43501. */
  43502. enableAudio(): void;
  43503. /**
  43504. * Switch audio to headphone output.
  43505. */
  43506. switchAudioModeForHeadphones(): void;
  43507. /**
  43508. * Switch audio to normal speakers.
  43509. */
  43510. switchAudioModeForNormalSpeakers(): void;
  43511. private _cachedCameraDirection;
  43512. private _cachedCameraPosition;
  43513. private _lastCheck;
  43514. private _afterRender;
  43515. }
  43516. }
  43517. declare module "babylonjs/Audio/weightedsound" {
  43518. import { Sound } from "babylonjs/Audio/sound";
  43519. /**
  43520. * Wraps one or more Sound objects and selects one with random weight for playback.
  43521. */
  43522. export class WeightedSound {
  43523. /** When true a Sound will be selected and played when the current playing Sound completes. */
  43524. loop: boolean;
  43525. private _coneInnerAngle;
  43526. private _coneOuterAngle;
  43527. private _volume;
  43528. /** A Sound is currently playing. */
  43529. isPlaying: boolean;
  43530. /** A Sound is currently paused. */
  43531. isPaused: boolean;
  43532. private _sounds;
  43533. private _weights;
  43534. private _currentIndex?;
  43535. /**
  43536. * Creates a new WeightedSound from the list of sounds given.
  43537. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  43538. * @param sounds Array of Sounds that will be selected from.
  43539. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  43540. */
  43541. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  43542. /**
  43543. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  43544. */
  43545. get directionalConeInnerAngle(): number;
  43546. /**
  43547. * The size of cone in degress for a directional sound in which there will be no attenuation.
  43548. */
  43549. set directionalConeInnerAngle(value: number);
  43550. /**
  43551. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  43552. * Listener angles between innerAngle and outerAngle will falloff linearly.
  43553. */
  43554. get directionalConeOuterAngle(): number;
  43555. /**
  43556. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  43557. * Listener angles between innerAngle and outerAngle will falloff linearly.
  43558. */
  43559. set directionalConeOuterAngle(value: number);
  43560. /**
  43561. * Playback volume.
  43562. */
  43563. get volume(): number;
  43564. /**
  43565. * Playback volume.
  43566. */
  43567. set volume(value: number);
  43568. private _onended;
  43569. /**
  43570. * Suspend playback
  43571. */
  43572. pause(): void;
  43573. /**
  43574. * Stop playback
  43575. */
  43576. stop(): void;
  43577. /**
  43578. * Start playback.
  43579. * @param startOffset Position the clip head at a specific time in seconds.
  43580. */
  43581. play(startOffset?: number): void;
  43582. }
  43583. }
  43584. declare module "babylonjs/Audio/index" {
  43585. export * from "babylonjs/Audio/analyser";
  43586. export * from "babylonjs/Audio/audioEngine";
  43587. export * from "babylonjs/Audio/audioSceneComponent";
  43588. export * from "babylonjs/Audio/sound";
  43589. export * from "babylonjs/Audio/soundTrack";
  43590. export * from "babylonjs/Audio/weightedsound";
  43591. }
  43592. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  43593. import { Behavior } from "babylonjs/Behaviors/behavior";
  43594. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43595. import { BackEase } from "babylonjs/Animations/easing";
  43596. /**
  43597. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  43598. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43599. */
  43600. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  43601. /**
  43602. * Gets the name of the behavior.
  43603. */
  43604. get name(): string;
  43605. /**
  43606. * The easing function used by animations
  43607. */
  43608. static EasingFunction: BackEase;
  43609. /**
  43610. * The easing mode used by animations
  43611. */
  43612. static EasingMode: number;
  43613. /**
  43614. * The duration of the animation, in milliseconds
  43615. */
  43616. transitionDuration: number;
  43617. /**
  43618. * Length of the distance animated by the transition when lower radius is reached
  43619. */
  43620. lowerRadiusTransitionRange: number;
  43621. /**
  43622. * Length of the distance animated by the transition when upper radius is reached
  43623. */
  43624. upperRadiusTransitionRange: number;
  43625. private _autoTransitionRange;
  43626. /**
  43627. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  43628. */
  43629. get autoTransitionRange(): boolean;
  43630. /**
  43631. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  43632. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  43633. */
  43634. set autoTransitionRange(value: boolean);
  43635. private _attachedCamera;
  43636. private _onAfterCheckInputsObserver;
  43637. private _onMeshTargetChangedObserver;
  43638. /**
  43639. * Initializes the behavior.
  43640. */
  43641. init(): void;
  43642. /**
  43643. * Attaches the behavior to its arc rotate camera.
  43644. * @param camera Defines the camera to attach the behavior to
  43645. */
  43646. attach(camera: ArcRotateCamera): void;
  43647. /**
  43648. * Detaches the behavior from its current arc rotate camera.
  43649. */
  43650. detach(): void;
  43651. private _radiusIsAnimating;
  43652. private _radiusBounceTransition;
  43653. private _animatables;
  43654. private _cachedWheelPrecision;
  43655. /**
  43656. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  43657. * @param radiusLimit The limit to check against.
  43658. * @return Bool to indicate if at limit.
  43659. */
  43660. private _isRadiusAtLimit;
  43661. /**
  43662. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  43663. * @param radiusDelta The delta by which to animate to. Can be negative.
  43664. */
  43665. private _applyBoundRadiusAnimation;
  43666. /**
  43667. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  43668. */
  43669. protected _clearAnimationLocks(): void;
  43670. /**
  43671. * Stops and removes all animations that have been applied to the camera
  43672. */
  43673. stopAllAnimations(): void;
  43674. }
  43675. }
  43676. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  43677. import { Behavior } from "babylonjs/Behaviors/behavior";
  43678. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43679. import { ExponentialEase } from "babylonjs/Animations/easing";
  43680. import { Nullable } from "babylonjs/types";
  43681. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43682. import { Vector3 } from "babylonjs/Maths/math.vector";
  43683. /**
  43684. * 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.
  43685. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43686. */
  43687. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  43688. /**
  43689. * Gets the name of the behavior.
  43690. */
  43691. get name(): string;
  43692. private _mode;
  43693. private _radiusScale;
  43694. private _positionScale;
  43695. private _defaultElevation;
  43696. private _elevationReturnTime;
  43697. private _elevationReturnWaitTime;
  43698. private _zoomStopsAnimation;
  43699. private _framingTime;
  43700. /**
  43701. * The easing function used by animations
  43702. */
  43703. static EasingFunction: ExponentialEase;
  43704. /**
  43705. * The easing mode used by animations
  43706. */
  43707. static EasingMode: number;
  43708. /**
  43709. * Sets the current mode used by the behavior
  43710. */
  43711. set mode(mode: number);
  43712. /**
  43713. * Gets current mode used by the behavior.
  43714. */
  43715. get mode(): number;
  43716. /**
  43717. * Sets the scale applied to the radius (1 by default)
  43718. */
  43719. set radiusScale(radius: number);
  43720. /**
  43721. * Gets the scale applied to the radius
  43722. */
  43723. get radiusScale(): number;
  43724. /**
  43725. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  43726. */
  43727. set positionScale(scale: number);
  43728. /**
  43729. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  43730. */
  43731. get positionScale(): number;
  43732. /**
  43733. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  43734. * behaviour is triggered, in radians.
  43735. */
  43736. set defaultElevation(elevation: number);
  43737. /**
  43738. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  43739. * behaviour is triggered, in radians.
  43740. */
  43741. get defaultElevation(): number;
  43742. /**
  43743. * Sets the time (in milliseconds) taken to return to the default beta position.
  43744. * Negative value indicates camera should not return to default.
  43745. */
  43746. set elevationReturnTime(speed: number);
  43747. /**
  43748. * Gets the time (in milliseconds) taken to return to the default beta position.
  43749. * Negative value indicates camera should not return to default.
  43750. */
  43751. get elevationReturnTime(): number;
  43752. /**
  43753. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  43754. */
  43755. set elevationReturnWaitTime(time: number);
  43756. /**
  43757. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  43758. */
  43759. get elevationReturnWaitTime(): number;
  43760. /**
  43761. * Sets the flag that indicates if user zooming should stop animation.
  43762. */
  43763. set zoomStopsAnimation(flag: boolean);
  43764. /**
  43765. * Gets the flag that indicates if user zooming should stop animation.
  43766. */
  43767. get zoomStopsAnimation(): boolean;
  43768. /**
  43769. * Sets the transition time when framing the mesh, in milliseconds
  43770. */
  43771. set framingTime(time: number);
  43772. /**
  43773. * Gets the transition time when framing the mesh, in milliseconds
  43774. */
  43775. get framingTime(): number;
  43776. /**
  43777. * Define if the behavior should automatically change the configured
  43778. * camera limits and sensibilities.
  43779. */
  43780. autoCorrectCameraLimitsAndSensibility: boolean;
  43781. private _onPrePointerObservableObserver;
  43782. private _onAfterCheckInputsObserver;
  43783. private _onMeshTargetChangedObserver;
  43784. private _attachedCamera;
  43785. private _isPointerDown;
  43786. private _lastInteractionTime;
  43787. /**
  43788. * Initializes the behavior.
  43789. */
  43790. init(): void;
  43791. /**
  43792. * Attaches the behavior to its arc rotate camera.
  43793. * @param camera Defines the camera to attach the behavior to
  43794. */
  43795. attach(camera: ArcRotateCamera): void;
  43796. /**
  43797. * Detaches the behavior from its current arc rotate camera.
  43798. */
  43799. detach(): void;
  43800. private _animatables;
  43801. private _betaIsAnimating;
  43802. private _betaTransition;
  43803. private _radiusTransition;
  43804. private _vectorTransition;
  43805. /**
  43806. * Targets the given mesh and updates zoom level accordingly.
  43807. * @param mesh The mesh to target.
  43808. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  43809. * @param onAnimationEnd Callback triggered at the end of the framing animation
  43810. */
  43811. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  43812. /**
  43813. * Targets the given mesh with its children and updates zoom level accordingly.
  43814. * @param mesh The mesh to target.
  43815. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  43816. * @param onAnimationEnd Callback triggered at the end of the framing animation
  43817. */
  43818. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  43819. /**
  43820. * Targets the given meshes with their children and updates zoom level accordingly.
  43821. * @param meshes The mesh to target.
  43822. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  43823. * @param onAnimationEnd Callback triggered at the end of the framing animation
  43824. */
  43825. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  43826. /**
  43827. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  43828. * @param minimumWorld Determines the smaller position of the bounding box extend
  43829. * @param maximumWorld Determines the bigger position of the bounding box extend
  43830. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  43831. * @param onAnimationEnd Callback triggered at the end of the framing animation
  43832. */
  43833. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  43834. /**
  43835. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  43836. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  43837. * frustum width.
  43838. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  43839. * to fully enclose the mesh in the viewing frustum.
  43840. */
  43841. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  43842. /**
  43843. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  43844. * is automatically returned to its default position (expected to be above ground plane).
  43845. */
  43846. private _maintainCameraAboveGround;
  43847. /**
  43848. * Returns the frustum slope based on the canvas ratio and camera FOV
  43849. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  43850. */
  43851. private _getFrustumSlope;
  43852. /**
  43853. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  43854. */
  43855. private _clearAnimationLocks;
  43856. /**
  43857. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  43858. */
  43859. private _applyUserInteraction;
  43860. /**
  43861. * Stops and removes all animations that have been applied to the camera
  43862. */
  43863. stopAllAnimations(): void;
  43864. /**
  43865. * Gets a value indicating if the user is moving the camera
  43866. */
  43867. get isUserIsMoving(): boolean;
  43868. /**
  43869. * The camera can move all the way towards the mesh.
  43870. */
  43871. static IgnoreBoundsSizeMode: number;
  43872. /**
  43873. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  43874. */
  43875. static FitFrustumSidesMode: number;
  43876. }
  43877. }
  43878. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  43879. import { Nullable } from "babylonjs/types";
  43880. import { Camera } from "babylonjs/Cameras/camera";
  43881. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  43882. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  43883. /**
  43884. * Base class for Camera Pointer Inputs.
  43885. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  43886. * for example usage.
  43887. */
  43888. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  43889. /**
  43890. * Defines the camera the input is attached to.
  43891. */
  43892. abstract camera: Camera;
  43893. /**
  43894. * Whether keyboard modifier keys are pressed at time of last mouse event.
  43895. */
  43896. protected _altKey: boolean;
  43897. protected _ctrlKey: boolean;
  43898. protected _metaKey: boolean;
  43899. protected _shiftKey: boolean;
  43900. /**
  43901. * Which mouse buttons were pressed at time of last mouse event.
  43902. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  43903. */
  43904. protected _buttonsPressed: number;
  43905. /**
  43906. * Defines the buttons associated with the input to handle camera move.
  43907. */
  43908. buttons: number[];
  43909. /**
  43910. * Attach the input controls to a specific dom element to get the input from.
  43911. * @param element Defines the element the controls should be listened from
  43912. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43913. */
  43914. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43915. /**
  43916. * Detach the current controls from the specified dom element.
  43917. * @param element Defines the element to stop listening the inputs from
  43918. */
  43919. detachControl(element: Nullable<HTMLElement>): void;
  43920. /**
  43921. * Gets the class name of the current input.
  43922. * @returns the class name
  43923. */
  43924. getClassName(): string;
  43925. /**
  43926. * Get the friendly name associated with the input class.
  43927. * @returns the input friendly name
  43928. */
  43929. getSimpleName(): string;
  43930. /**
  43931. * Called on pointer POINTERDOUBLETAP event.
  43932. * Override this method to provide functionality on POINTERDOUBLETAP event.
  43933. */
  43934. protected onDoubleTap(type: string): void;
  43935. /**
  43936. * Called on pointer POINTERMOVE event if only a single touch is active.
  43937. * Override this method to provide functionality.
  43938. */
  43939. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  43940. /**
  43941. * Called on pointer POINTERMOVE event if multiple touches are active.
  43942. * Override this method to provide functionality.
  43943. */
  43944. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  43945. /**
  43946. * Called on JS contextmenu event.
  43947. * Override this method to provide functionality.
  43948. */
  43949. protected onContextMenu(evt: PointerEvent): void;
  43950. /**
  43951. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  43952. * press.
  43953. * Override this method to provide functionality.
  43954. */
  43955. protected onButtonDown(evt: PointerEvent): void;
  43956. /**
  43957. * Called each time a new POINTERUP event occurs. Ie, for each button
  43958. * release.
  43959. * Override this method to provide functionality.
  43960. */
  43961. protected onButtonUp(evt: PointerEvent): void;
  43962. /**
  43963. * Called when window becomes inactive.
  43964. * Override this method to provide functionality.
  43965. */
  43966. protected onLostFocus(): void;
  43967. private _pointerInput;
  43968. private _observer;
  43969. private _onLostFocus;
  43970. private pointA;
  43971. private pointB;
  43972. }
  43973. }
  43974. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  43975. import { Nullable } from "babylonjs/types";
  43976. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43977. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  43978. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  43979. /**
  43980. * Manage the pointers inputs to control an arc rotate camera.
  43981. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43982. */
  43983. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  43984. /**
  43985. * Defines the camera the input is attached to.
  43986. */
  43987. camera: ArcRotateCamera;
  43988. /**
  43989. * Gets the class name of the current input.
  43990. * @returns the class name
  43991. */
  43992. getClassName(): string;
  43993. /**
  43994. * Defines the buttons associated with the input to handle camera move.
  43995. */
  43996. buttons: number[];
  43997. /**
  43998. * Defines the pointer angular sensibility along the X axis or how fast is
  43999. * the camera rotating.
  44000. */
  44001. angularSensibilityX: number;
  44002. /**
  44003. * Defines the pointer angular sensibility along the Y axis or how fast is
  44004. * the camera rotating.
  44005. */
  44006. angularSensibilityY: number;
  44007. /**
  44008. * Defines the pointer pinch precision or how fast is the camera zooming.
  44009. */
  44010. pinchPrecision: number;
  44011. /**
  44012. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  44013. * from 0.
  44014. * It defines the percentage of current camera.radius to use as delta when
  44015. * pinch zoom is used.
  44016. */
  44017. pinchDeltaPercentage: number;
  44018. /**
  44019. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  44020. * that any object in the plane at the camera's target point will scale
  44021. * perfectly with finger motion.
  44022. * Overrides pinchDeltaPercentage and pinchPrecision.
  44023. */
  44024. useNaturalPinchZoom: boolean;
  44025. /**
  44026. * Defines the pointer panning sensibility or how fast is the camera moving.
  44027. */
  44028. panningSensibility: number;
  44029. /**
  44030. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  44031. */
  44032. multiTouchPanning: boolean;
  44033. /**
  44034. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  44035. * zoom (pinch) through multitouch.
  44036. */
  44037. multiTouchPanAndZoom: boolean;
  44038. /**
  44039. * Revers pinch action direction.
  44040. */
  44041. pinchInwards: boolean;
  44042. private _isPanClick;
  44043. private _twoFingerActivityCount;
  44044. private _isPinching;
  44045. /**
  44046. * Called on pointer POINTERMOVE event if only a single touch is active.
  44047. */
  44048. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44049. /**
  44050. * Called on pointer POINTERDOUBLETAP event.
  44051. */
  44052. protected onDoubleTap(type: string): void;
  44053. /**
  44054. * Called on pointer POINTERMOVE event if multiple touches are active.
  44055. */
  44056. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44057. /**
  44058. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  44059. * press.
  44060. */
  44061. protected onButtonDown(evt: PointerEvent): void;
  44062. /**
  44063. * Called each time a new POINTERUP event occurs. Ie, for each button
  44064. * release.
  44065. */
  44066. protected onButtonUp(evt: PointerEvent): void;
  44067. /**
  44068. * Called when window becomes inactive.
  44069. */
  44070. protected onLostFocus(): void;
  44071. }
  44072. }
  44073. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  44074. import { Nullable } from "babylonjs/types";
  44075. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44076. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44077. /**
  44078. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  44079. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44080. */
  44081. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  44082. /**
  44083. * Defines the camera the input is attached to.
  44084. */
  44085. camera: ArcRotateCamera;
  44086. /**
  44087. * Defines the list of key codes associated with the up action (increase alpha)
  44088. */
  44089. keysUp: number[];
  44090. /**
  44091. * Defines the list of key codes associated with the down action (decrease alpha)
  44092. */
  44093. keysDown: number[];
  44094. /**
  44095. * Defines the list of key codes associated with the left action (increase beta)
  44096. */
  44097. keysLeft: number[];
  44098. /**
  44099. * Defines the list of key codes associated with the right action (decrease beta)
  44100. */
  44101. keysRight: number[];
  44102. /**
  44103. * Defines the list of key codes associated with the reset action.
  44104. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  44105. */
  44106. keysReset: number[];
  44107. /**
  44108. * Defines the panning sensibility of the inputs.
  44109. * (How fast is the camera panning)
  44110. */
  44111. panningSensibility: number;
  44112. /**
  44113. * Defines the zooming sensibility of the inputs.
  44114. * (How fast is the camera zooming)
  44115. */
  44116. zoomingSensibility: number;
  44117. /**
  44118. * Defines whether maintaining the alt key down switch the movement mode from
  44119. * orientation to zoom.
  44120. */
  44121. useAltToZoom: boolean;
  44122. /**
  44123. * Rotation speed of the camera
  44124. */
  44125. angularSpeed: number;
  44126. private _keys;
  44127. private _ctrlPressed;
  44128. private _altPressed;
  44129. private _onCanvasBlurObserver;
  44130. private _onKeyboardObserver;
  44131. private _engine;
  44132. private _scene;
  44133. /**
  44134. * Attach the input controls to a specific dom element to get the input from.
  44135. * @param element Defines the element the controls should be listened from
  44136. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44137. */
  44138. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44139. /**
  44140. * Detach the current controls from the specified dom element.
  44141. * @param element Defines the element to stop listening the inputs from
  44142. */
  44143. detachControl(element: Nullable<HTMLElement>): void;
  44144. /**
  44145. * Update the current camera state depending on the inputs that have been used this frame.
  44146. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44147. */
  44148. checkInputs(): void;
  44149. /**
  44150. * Gets the class name of the current intput.
  44151. * @returns the class name
  44152. */
  44153. getClassName(): string;
  44154. /**
  44155. * Get the friendly name associated with the input class.
  44156. * @returns the input friendly name
  44157. */
  44158. getSimpleName(): string;
  44159. }
  44160. }
  44161. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  44162. import { Nullable } from "babylonjs/types";
  44163. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44164. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44165. /**
  44166. * Manage the mouse wheel inputs to control an arc rotate camera.
  44167. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44168. */
  44169. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  44170. /**
  44171. * Defines the camera the input is attached to.
  44172. */
  44173. camera: ArcRotateCamera;
  44174. /**
  44175. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  44176. */
  44177. wheelPrecision: number;
  44178. /**
  44179. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  44180. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  44181. */
  44182. wheelDeltaPercentage: number;
  44183. private _wheel;
  44184. private _observer;
  44185. private computeDeltaFromMouseWheelLegacyEvent;
  44186. /**
  44187. * Attach the input controls to a specific dom element to get the input from.
  44188. * @param element Defines the element the controls should be listened from
  44189. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44190. */
  44191. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44192. /**
  44193. * Detach the current controls from the specified dom element.
  44194. * @param element Defines the element to stop listening the inputs from
  44195. */
  44196. detachControl(element: Nullable<HTMLElement>): void;
  44197. /**
  44198. * Gets the class name of the current intput.
  44199. * @returns the class name
  44200. */
  44201. getClassName(): string;
  44202. /**
  44203. * Get the friendly name associated with the input class.
  44204. * @returns the input friendly name
  44205. */
  44206. getSimpleName(): string;
  44207. }
  44208. }
  44209. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  44210. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44211. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  44212. /**
  44213. * Default Inputs manager for the ArcRotateCamera.
  44214. * It groups all the default supported inputs for ease of use.
  44215. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44216. */
  44217. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  44218. /**
  44219. * Instantiates a new ArcRotateCameraInputsManager.
  44220. * @param camera Defines the camera the inputs belong to
  44221. */
  44222. constructor(camera: ArcRotateCamera);
  44223. /**
  44224. * Add mouse wheel input support to the input manager.
  44225. * @returns the current input manager
  44226. */
  44227. addMouseWheel(): ArcRotateCameraInputsManager;
  44228. /**
  44229. * Add pointers input support to the input manager.
  44230. * @returns the current input manager
  44231. */
  44232. addPointers(): ArcRotateCameraInputsManager;
  44233. /**
  44234. * Add keyboard input support to the input manager.
  44235. * @returns the current input manager
  44236. */
  44237. addKeyboard(): ArcRotateCameraInputsManager;
  44238. }
  44239. }
  44240. declare module "babylonjs/Cameras/arcRotateCamera" {
  44241. import { Observable } from "babylonjs/Misc/observable";
  44242. import { Nullable } from "babylonjs/types";
  44243. import { Scene } from "babylonjs/scene";
  44244. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  44245. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44246. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  44247. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  44248. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  44249. import { Camera } from "babylonjs/Cameras/camera";
  44250. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  44251. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  44252. import { Collider } from "babylonjs/Collisions/collider";
  44253. /**
  44254. * This represents an orbital type of camera.
  44255. *
  44256. * 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.
  44257. * 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.
  44258. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  44259. */
  44260. export class ArcRotateCamera extends TargetCamera {
  44261. /**
  44262. * Defines the rotation angle of the camera along the longitudinal axis.
  44263. */
  44264. alpha: number;
  44265. /**
  44266. * Defines the rotation angle of the camera along the latitudinal axis.
  44267. */
  44268. beta: number;
  44269. /**
  44270. * Defines the radius of the camera from it s target point.
  44271. */
  44272. radius: number;
  44273. protected _target: Vector3;
  44274. protected _targetHost: Nullable<AbstractMesh>;
  44275. /**
  44276. * Defines the target point of the camera.
  44277. * The camera looks towards it form the radius distance.
  44278. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  44279. */
  44280. get target(): Vector3;
  44281. set target(value: Vector3);
  44282. /**
  44283. * Define the current local position of the camera in the scene
  44284. */
  44285. get position(): Vector3;
  44286. set position(newPosition: Vector3);
  44287. protected _upVector: Vector3;
  44288. protected _upToYMatrix: Matrix;
  44289. protected _YToUpMatrix: Matrix;
  44290. /**
  44291. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  44292. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  44293. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  44294. */
  44295. set upVector(vec: Vector3);
  44296. get upVector(): Vector3;
  44297. /**
  44298. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  44299. */
  44300. setMatUp(): void;
  44301. /**
  44302. * Current inertia value on the longitudinal axis.
  44303. * The bigger this number the longer it will take for the camera to stop.
  44304. */
  44305. inertialAlphaOffset: number;
  44306. /**
  44307. * Current inertia value on the latitudinal axis.
  44308. * The bigger this number the longer it will take for the camera to stop.
  44309. */
  44310. inertialBetaOffset: number;
  44311. /**
  44312. * Current inertia value on the radius axis.
  44313. * The bigger this number the longer it will take for the camera to stop.
  44314. */
  44315. inertialRadiusOffset: number;
  44316. /**
  44317. * Minimum allowed angle on the longitudinal axis.
  44318. * This can help limiting how the Camera is able to move in the scene.
  44319. */
  44320. lowerAlphaLimit: Nullable<number>;
  44321. /**
  44322. * Maximum allowed angle on the longitudinal axis.
  44323. * This can help limiting how the Camera is able to move in the scene.
  44324. */
  44325. upperAlphaLimit: Nullable<number>;
  44326. /**
  44327. * Minimum allowed angle on the latitudinal axis.
  44328. * This can help limiting how the Camera is able to move in the scene.
  44329. */
  44330. lowerBetaLimit: number;
  44331. /**
  44332. * Maximum allowed angle on the latitudinal axis.
  44333. * This can help limiting how the Camera is able to move in the scene.
  44334. */
  44335. upperBetaLimit: number;
  44336. /**
  44337. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  44338. * This can help limiting how the Camera is able to move in the scene.
  44339. */
  44340. lowerRadiusLimit: Nullable<number>;
  44341. /**
  44342. * Maximum allowed distance of the camera to the target (The camera can not get further).
  44343. * This can help limiting how the Camera is able to move in the scene.
  44344. */
  44345. upperRadiusLimit: Nullable<number>;
  44346. /**
  44347. * Defines the current inertia value used during panning of the camera along the X axis.
  44348. */
  44349. inertialPanningX: number;
  44350. /**
  44351. * Defines the current inertia value used during panning of the camera along the Y axis.
  44352. */
  44353. inertialPanningY: number;
  44354. /**
  44355. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  44356. * Basically if your fingers moves away from more than this distance you will be considered
  44357. * in pinch mode.
  44358. */
  44359. pinchToPanMaxDistance: number;
  44360. /**
  44361. * Defines the maximum distance the camera can pan.
  44362. * This could help keeping the cammera always in your scene.
  44363. */
  44364. panningDistanceLimit: Nullable<number>;
  44365. /**
  44366. * Defines the target of the camera before paning.
  44367. */
  44368. panningOriginTarget: Vector3;
  44369. /**
  44370. * Defines the value of the inertia used during panning.
  44371. * 0 would mean stop inertia and one would mean no decelleration at all.
  44372. */
  44373. panningInertia: number;
  44374. /**
  44375. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  44376. */
  44377. get angularSensibilityX(): number;
  44378. set angularSensibilityX(value: number);
  44379. /**
  44380. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  44381. */
  44382. get angularSensibilityY(): number;
  44383. set angularSensibilityY(value: number);
  44384. /**
  44385. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  44386. */
  44387. get pinchPrecision(): number;
  44388. set pinchPrecision(value: number);
  44389. /**
  44390. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  44391. * It will be used instead of pinchDeltaPrecision if different from 0.
  44392. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  44393. */
  44394. get pinchDeltaPercentage(): number;
  44395. set pinchDeltaPercentage(value: number);
  44396. /**
  44397. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  44398. * and pinch delta percentage.
  44399. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  44400. * that any object in the plane at the camera's target point will scale
  44401. * perfectly with finger motion.
  44402. */
  44403. get useNaturalPinchZoom(): boolean;
  44404. set useNaturalPinchZoom(value: boolean);
  44405. /**
  44406. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  44407. */
  44408. get panningSensibility(): number;
  44409. set panningSensibility(value: number);
  44410. /**
  44411. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  44412. */
  44413. get keysUp(): number[];
  44414. set keysUp(value: number[]);
  44415. /**
  44416. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  44417. */
  44418. get keysDown(): number[];
  44419. set keysDown(value: number[]);
  44420. /**
  44421. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  44422. */
  44423. get keysLeft(): number[];
  44424. set keysLeft(value: number[]);
  44425. /**
  44426. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  44427. */
  44428. get keysRight(): number[];
  44429. set keysRight(value: number[]);
  44430. /**
  44431. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  44432. */
  44433. get wheelPrecision(): number;
  44434. set wheelPrecision(value: number);
  44435. /**
  44436. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  44437. * It will be used instead of pinchDeltaPrecision if different from 0.
  44438. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  44439. */
  44440. get wheelDeltaPercentage(): number;
  44441. set wheelDeltaPercentage(value: number);
  44442. /**
  44443. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  44444. */
  44445. zoomOnFactor: number;
  44446. /**
  44447. * Defines a screen offset for the camera position.
  44448. */
  44449. targetScreenOffset: Vector2;
  44450. /**
  44451. * Allows the camera to be completely reversed.
  44452. * If false the camera can not arrive upside down.
  44453. */
  44454. allowUpsideDown: boolean;
  44455. /**
  44456. * Define if double tap/click is used to restore the previously saved state of the camera.
  44457. */
  44458. useInputToRestoreState: boolean;
  44459. /** @hidden */
  44460. _viewMatrix: Matrix;
  44461. /** @hidden */
  44462. _useCtrlForPanning: boolean;
  44463. /** @hidden */
  44464. _panningMouseButton: number;
  44465. /**
  44466. * Defines the input associated to the camera.
  44467. */
  44468. inputs: ArcRotateCameraInputsManager;
  44469. /** @hidden */
  44470. _reset: () => void;
  44471. /**
  44472. * Defines the allowed panning axis.
  44473. */
  44474. panningAxis: Vector3;
  44475. protected _localDirection: Vector3;
  44476. protected _transformedDirection: Vector3;
  44477. private _bouncingBehavior;
  44478. /**
  44479. * Gets the bouncing behavior of the camera if it has been enabled.
  44480. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  44481. */
  44482. get bouncingBehavior(): Nullable<BouncingBehavior>;
  44483. /**
  44484. * Defines if the bouncing behavior of the camera is enabled on the camera.
  44485. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  44486. */
  44487. get useBouncingBehavior(): boolean;
  44488. set useBouncingBehavior(value: boolean);
  44489. private _framingBehavior;
  44490. /**
  44491. * Gets the framing behavior of the camera if it has been enabled.
  44492. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  44493. */
  44494. get framingBehavior(): Nullable<FramingBehavior>;
  44495. /**
  44496. * Defines if the framing behavior of the camera is enabled on the camera.
  44497. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  44498. */
  44499. get useFramingBehavior(): boolean;
  44500. set useFramingBehavior(value: boolean);
  44501. private _autoRotationBehavior;
  44502. /**
  44503. * Gets the auto rotation behavior of the camera if it has been enabled.
  44504. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44505. */
  44506. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  44507. /**
  44508. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  44509. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44510. */
  44511. get useAutoRotationBehavior(): boolean;
  44512. set useAutoRotationBehavior(value: boolean);
  44513. /**
  44514. * Observable triggered when the mesh target has been changed on the camera.
  44515. */
  44516. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  44517. /**
  44518. * Event raised when the camera is colliding with a mesh.
  44519. */
  44520. onCollide: (collidedMesh: AbstractMesh) => void;
  44521. /**
  44522. * Defines whether the camera should check collision with the objects oh the scene.
  44523. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  44524. */
  44525. checkCollisions: boolean;
  44526. /**
  44527. * Defines the collision radius of the camera.
  44528. * This simulates a sphere around the camera.
  44529. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  44530. */
  44531. collisionRadius: Vector3;
  44532. protected _collider: Collider;
  44533. protected _previousPosition: Vector3;
  44534. protected _collisionVelocity: Vector3;
  44535. protected _newPosition: Vector3;
  44536. protected _previousAlpha: number;
  44537. protected _previousBeta: number;
  44538. protected _previousRadius: number;
  44539. protected _collisionTriggered: boolean;
  44540. protected _targetBoundingCenter: Nullable<Vector3>;
  44541. private _computationVector;
  44542. /**
  44543. * Instantiates a new ArcRotateCamera in a given scene
  44544. * @param name Defines the name of the camera
  44545. * @param alpha Defines the camera rotation along the logitudinal axis
  44546. * @param beta Defines the camera rotation along the latitudinal axis
  44547. * @param radius Defines the camera distance from its target
  44548. * @param target Defines the camera target
  44549. * @param scene Defines the scene the camera belongs to
  44550. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  44551. */
  44552. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44553. /** @hidden */
  44554. _initCache(): void;
  44555. /** @hidden */
  44556. _updateCache(ignoreParentClass?: boolean): void;
  44557. protected _getTargetPosition(): Vector3;
  44558. private _storedAlpha;
  44559. private _storedBeta;
  44560. private _storedRadius;
  44561. private _storedTarget;
  44562. private _storedTargetScreenOffset;
  44563. /**
  44564. * Stores the current state of the camera (alpha, beta, radius and target)
  44565. * @returns the camera itself
  44566. */
  44567. storeState(): Camera;
  44568. /**
  44569. * @hidden
  44570. * Restored camera state. You must call storeState() first
  44571. */
  44572. _restoreStateValues(): boolean;
  44573. /** @hidden */
  44574. _isSynchronizedViewMatrix(): boolean;
  44575. /**
  44576. * Attached controls to the current camera.
  44577. * @param element Defines the element the controls should be listened from
  44578. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44579. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  44580. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  44581. */
  44582. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  44583. /**
  44584. * Detach the current controls from the camera.
  44585. * The camera will stop reacting to inputs.
  44586. * @param element Defines the element to stop listening the inputs from
  44587. */
  44588. detachControl(element: HTMLElement): void;
  44589. /** @hidden */
  44590. _checkInputs(): void;
  44591. protected _checkLimits(): void;
  44592. /**
  44593. * Rebuilds angles (alpha, beta) and radius from the give position and target
  44594. */
  44595. rebuildAnglesAndRadius(): void;
  44596. /**
  44597. * Use a position to define the current camera related information like alpha, beta and radius
  44598. * @param position Defines the position to set the camera at
  44599. */
  44600. setPosition(position: Vector3): void;
  44601. /**
  44602. * Defines the target the camera should look at.
  44603. * This will automatically adapt alpha beta and radius to fit within the new target.
  44604. * @param target Defines the new target as a Vector or a mesh
  44605. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  44606. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  44607. */
  44608. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  44609. /** @hidden */
  44610. _getViewMatrix(): Matrix;
  44611. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  44612. /**
  44613. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  44614. * @param meshes Defines the mesh to zoom on
  44615. * @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)
  44616. */
  44617. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  44618. /**
  44619. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  44620. * The target will be changed but the radius
  44621. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  44622. * @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)
  44623. */
  44624. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  44625. min: Vector3;
  44626. max: Vector3;
  44627. distance: number;
  44628. }, doNotUpdateMaxZ?: boolean): void;
  44629. /**
  44630. * @override
  44631. * Override Camera.createRigCamera
  44632. */
  44633. createRigCamera(name: string, cameraIndex: number): Camera;
  44634. /**
  44635. * @hidden
  44636. * @override
  44637. * Override Camera._updateRigCameras
  44638. */
  44639. _updateRigCameras(): void;
  44640. /**
  44641. * Destroy the camera and release the current resources hold by it.
  44642. */
  44643. dispose(): void;
  44644. /**
  44645. * Gets the current object class name.
  44646. * @return the class name
  44647. */
  44648. getClassName(): string;
  44649. }
  44650. }
  44651. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  44652. import { Behavior } from "babylonjs/Behaviors/behavior";
  44653. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44654. /**
  44655. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  44656. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44657. */
  44658. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  44659. /**
  44660. * Gets the name of the behavior.
  44661. */
  44662. get name(): string;
  44663. private _zoomStopsAnimation;
  44664. private _idleRotationSpeed;
  44665. private _idleRotationWaitTime;
  44666. private _idleRotationSpinupTime;
  44667. /**
  44668. * Sets the flag that indicates if user zooming should stop animation.
  44669. */
  44670. set zoomStopsAnimation(flag: boolean);
  44671. /**
  44672. * Gets the flag that indicates if user zooming should stop animation.
  44673. */
  44674. get zoomStopsAnimation(): boolean;
  44675. /**
  44676. * Sets the default speed at which the camera rotates around the model.
  44677. */
  44678. set idleRotationSpeed(speed: number);
  44679. /**
  44680. * Gets the default speed at which the camera rotates around the model.
  44681. */
  44682. get idleRotationSpeed(): number;
  44683. /**
  44684. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  44685. */
  44686. set idleRotationWaitTime(time: number);
  44687. /**
  44688. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  44689. */
  44690. get idleRotationWaitTime(): number;
  44691. /**
  44692. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  44693. */
  44694. set idleRotationSpinupTime(time: number);
  44695. /**
  44696. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  44697. */
  44698. get idleRotationSpinupTime(): number;
  44699. /**
  44700. * Gets a value indicating if the camera is currently rotating because of this behavior
  44701. */
  44702. get rotationInProgress(): boolean;
  44703. private _onPrePointerObservableObserver;
  44704. private _onAfterCheckInputsObserver;
  44705. private _attachedCamera;
  44706. private _isPointerDown;
  44707. private _lastFrameTime;
  44708. private _lastInteractionTime;
  44709. private _cameraRotationSpeed;
  44710. /**
  44711. * Initializes the behavior.
  44712. */
  44713. init(): void;
  44714. /**
  44715. * Attaches the behavior to its arc rotate camera.
  44716. * @param camera Defines the camera to attach the behavior to
  44717. */
  44718. attach(camera: ArcRotateCamera): void;
  44719. /**
  44720. * Detaches the behavior from its current arc rotate camera.
  44721. */
  44722. detach(): void;
  44723. /**
  44724. * Returns true if user is scrolling.
  44725. * @return true if user is scrolling.
  44726. */
  44727. private _userIsZooming;
  44728. private _lastFrameRadius;
  44729. private _shouldAnimationStopForInteraction;
  44730. /**
  44731. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  44732. */
  44733. private _applyUserInteraction;
  44734. private _userIsMoving;
  44735. }
  44736. }
  44737. declare module "babylonjs/Behaviors/Cameras/index" {
  44738. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  44739. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  44740. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  44741. }
  44742. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  44743. import { Mesh } from "babylonjs/Meshes/mesh";
  44744. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44745. import { Behavior } from "babylonjs/Behaviors/behavior";
  44746. /**
  44747. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  44748. */
  44749. export class AttachToBoxBehavior implements Behavior<Mesh> {
  44750. private ui;
  44751. /**
  44752. * The name of the behavior
  44753. */
  44754. name: string;
  44755. /**
  44756. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  44757. */
  44758. distanceAwayFromFace: number;
  44759. /**
  44760. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  44761. */
  44762. distanceAwayFromBottomOfFace: number;
  44763. private _faceVectors;
  44764. private _target;
  44765. private _scene;
  44766. private _onRenderObserver;
  44767. private _tmpMatrix;
  44768. private _tmpVector;
  44769. /**
  44770. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  44771. * @param ui The transform node that should be attched to the mesh
  44772. */
  44773. constructor(ui: TransformNode);
  44774. /**
  44775. * Initializes the behavior
  44776. */
  44777. init(): void;
  44778. private _closestFace;
  44779. private _zeroVector;
  44780. private _lookAtTmpMatrix;
  44781. private _lookAtToRef;
  44782. /**
  44783. * Attaches the AttachToBoxBehavior to the passed in mesh
  44784. * @param target The mesh that the specified node will be attached to
  44785. */
  44786. attach(target: Mesh): void;
  44787. /**
  44788. * Detaches the behavior from the mesh
  44789. */
  44790. detach(): void;
  44791. }
  44792. }
  44793. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  44794. import { Behavior } from "babylonjs/Behaviors/behavior";
  44795. import { Mesh } from "babylonjs/Meshes/mesh";
  44796. /**
  44797. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  44798. */
  44799. export class FadeInOutBehavior implements Behavior<Mesh> {
  44800. /**
  44801. * Time in milliseconds to delay before fading in (Default: 0)
  44802. */
  44803. delay: number;
  44804. /**
  44805. * Time in milliseconds for the mesh to fade in (Default: 300)
  44806. */
  44807. fadeInTime: number;
  44808. private _millisecondsPerFrame;
  44809. private _hovered;
  44810. private _hoverValue;
  44811. private _ownerNode;
  44812. /**
  44813. * Instatiates the FadeInOutBehavior
  44814. */
  44815. constructor();
  44816. /**
  44817. * The name of the behavior
  44818. */
  44819. get name(): string;
  44820. /**
  44821. * Initializes the behavior
  44822. */
  44823. init(): void;
  44824. /**
  44825. * Attaches the fade behavior on the passed in mesh
  44826. * @param ownerNode The mesh that will be faded in/out once attached
  44827. */
  44828. attach(ownerNode: Mesh): void;
  44829. /**
  44830. * Detaches the behavior from the mesh
  44831. */
  44832. detach(): void;
  44833. /**
  44834. * Triggers the mesh to begin fading in or out
  44835. * @param value if the object should fade in or out (true to fade in)
  44836. */
  44837. fadeIn(value: boolean): void;
  44838. private _update;
  44839. private _setAllVisibility;
  44840. }
  44841. }
  44842. declare module "babylonjs/Misc/pivotTools" {
  44843. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44844. /**
  44845. * Class containing a set of static utilities functions for managing Pivots
  44846. * @hidden
  44847. */
  44848. export class PivotTools {
  44849. private static _PivotCached;
  44850. private static _OldPivotPoint;
  44851. private static _PivotTranslation;
  44852. private static _PivotTmpVector;
  44853. /** @hidden */
  44854. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  44855. /** @hidden */
  44856. static _RestorePivotPoint(mesh: AbstractMesh): void;
  44857. }
  44858. }
  44859. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  44860. import { Scene } from "babylonjs/scene";
  44861. import { Vector4 } from "babylonjs/Maths/math.vector";
  44862. import { Mesh } from "babylonjs/Meshes/mesh";
  44863. import { Nullable } from "babylonjs/types";
  44864. import { Plane } from "babylonjs/Maths/math.plane";
  44865. /**
  44866. * Class containing static functions to help procedurally build meshes
  44867. */
  44868. export class PlaneBuilder {
  44869. /**
  44870. * Creates a plane mesh
  44871. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  44872. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  44873. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  44874. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44875. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44876. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44877. * @param name defines the name of the mesh
  44878. * @param options defines the options used to create the mesh
  44879. * @param scene defines the hosting scene
  44880. * @returns the plane mesh
  44881. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  44882. */
  44883. static CreatePlane(name: string, options: {
  44884. size?: number;
  44885. width?: number;
  44886. height?: number;
  44887. sideOrientation?: number;
  44888. frontUVs?: Vector4;
  44889. backUVs?: Vector4;
  44890. updatable?: boolean;
  44891. sourcePlane?: Plane;
  44892. }, scene?: Nullable<Scene>): Mesh;
  44893. }
  44894. }
  44895. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  44896. import { Behavior } from "babylonjs/Behaviors/behavior";
  44897. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44898. import { Observable } from "babylonjs/Misc/observable";
  44899. import { Vector3 } from "babylonjs/Maths/math.vector";
  44900. import { Ray } from "babylonjs/Culling/ray";
  44901. import "babylonjs/Meshes/Builders/planeBuilder";
  44902. /**
  44903. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  44904. */
  44905. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  44906. private static _AnyMouseID;
  44907. /**
  44908. * Abstract mesh the behavior is set on
  44909. */
  44910. attachedNode: AbstractMesh;
  44911. private _dragPlane;
  44912. private _scene;
  44913. private _pointerObserver;
  44914. private _beforeRenderObserver;
  44915. private static _planeScene;
  44916. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  44917. /**
  44918. * 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)
  44919. */
  44920. maxDragAngle: number;
  44921. /**
  44922. * @hidden
  44923. */
  44924. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  44925. /**
  44926. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  44927. */
  44928. currentDraggingPointerID: number;
  44929. /**
  44930. * The last position where the pointer hit the drag plane in world space
  44931. */
  44932. lastDragPosition: Vector3;
  44933. /**
  44934. * If the behavior is currently in a dragging state
  44935. */
  44936. dragging: boolean;
  44937. /**
  44938. * 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)
  44939. */
  44940. dragDeltaRatio: number;
  44941. /**
  44942. * If the drag plane orientation should be updated during the dragging (Default: true)
  44943. */
  44944. updateDragPlane: boolean;
  44945. private _debugMode;
  44946. private _moving;
  44947. /**
  44948. * Fires each time the attached mesh is dragged with the pointer
  44949. * * delta between last drag position and current drag position in world space
  44950. * * dragDistance along the drag axis
  44951. * * dragPlaneNormal normal of the current drag plane used during the drag
  44952. * * dragPlanePoint in world space where the drag intersects the drag plane
  44953. */
  44954. onDragObservable: Observable<{
  44955. delta: Vector3;
  44956. dragPlanePoint: Vector3;
  44957. dragPlaneNormal: Vector3;
  44958. dragDistance: number;
  44959. pointerId: number;
  44960. }>;
  44961. /**
  44962. * Fires each time a drag begins (eg. mouse down on mesh)
  44963. */
  44964. onDragStartObservable: Observable<{
  44965. dragPlanePoint: Vector3;
  44966. pointerId: number;
  44967. }>;
  44968. /**
  44969. * Fires each time a drag ends (eg. mouse release after drag)
  44970. */
  44971. onDragEndObservable: Observable<{
  44972. dragPlanePoint: Vector3;
  44973. pointerId: number;
  44974. }>;
  44975. /**
  44976. * If the attached mesh should be moved when dragged
  44977. */
  44978. moveAttached: boolean;
  44979. /**
  44980. * If the drag behavior will react to drag events (Default: true)
  44981. */
  44982. enabled: boolean;
  44983. /**
  44984. * If pointer events should start and release the drag (Default: true)
  44985. */
  44986. startAndReleaseDragOnPointerEvents: boolean;
  44987. /**
  44988. * If camera controls should be detached during the drag
  44989. */
  44990. detachCameraControls: boolean;
  44991. /**
  44992. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  44993. */
  44994. useObjectOrientationForDragging: boolean;
  44995. private _options;
  44996. /**
  44997. * Gets the options used by the behavior
  44998. */
  44999. get options(): {
  45000. dragAxis?: Vector3;
  45001. dragPlaneNormal?: Vector3;
  45002. };
  45003. /**
  45004. * Sets the options used by the behavior
  45005. */
  45006. set options(options: {
  45007. dragAxis?: Vector3;
  45008. dragPlaneNormal?: Vector3;
  45009. });
  45010. /**
  45011. * Creates a pointer drag behavior that can be attached to a mesh
  45012. * @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)
  45013. */
  45014. constructor(options?: {
  45015. dragAxis?: Vector3;
  45016. dragPlaneNormal?: Vector3;
  45017. });
  45018. /**
  45019. * Predicate to determine if it is valid to move the object to a new position when it is moved
  45020. */
  45021. validateDrag: (targetPosition: Vector3) => boolean;
  45022. /**
  45023. * The name of the behavior
  45024. */
  45025. get name(): string;
  45026. /**
  45027. * Initializes the behavior
  45028. */
  45029. init(): void;
  45030. private _tmpVector;
  45031. private _alternatePickedPoint;
  45032. private _worldDragAxis;
  45033. private _targetPosition;
  45034. private _attachedElement;
  45035. /**
  45036. * Attaches the drag behavior the passed in mesh
  45037. * @param ownerNode The mesh that will be dragged around once attached
  45038. * @param predicate Predicate to use for pick filtering
  45039. */
  45040. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  45041. /**
  45042. * Force relase the drag action by code.
  45043. */
  45044. releaseDrag(): void;
  45045. private _startDragRay;
  45046. private _lastPointerRay;
  45047. /**
  45048. * Simulates the start of a pointer drag event on the behavior
  45049. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  45050. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  45051. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  45052. */
  45053. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  45054. private _startDrag;
  45055. private _dragDelta;
  45056. private _moveDrag;
  45057. private _pickWithRayOnDragPlane;
  45058. private _pointA;
  45059. private _pointC;
  45060. private _localAxis;
  45061. private _lookAt;
  45062. private _updateDragPlanePosition;
  45063. /**
  45064. * Detaches the behavior from the mesh
  45065. */
  45066. detach(): void;
  45067. }
  45068. }
  45069. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  45070. import { Mesh } from "babylonjs/Meshes/mesh";
  45071. import { Behavior } from "babylonjs/Behaviors/behavior";
  45072. /**
  45073. * A behavior that when attached to a mesh will allow the mesh to be scaled
  45074. */
  45075. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  45076. private _dragBehaviorA;
  45077. private _dragBehaviorB;
  45078. private _startDistance;
  45079. private _initialScale;
  45080. private _targetScale;
  45081. private _ownerNode;
  45082. private _sceneRenderObserver;
  45083. /**
  45084. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  45085. */
  45086. constructor();
  45087. /**
  45088. * The name of the behavior
  45089. */
  45090. get name(): string;
  45091. /**
  45092. * Initializes the behavior
  45093. */
  45094. init(): void;
  45095. private _getCurrentDistance;
  45096. /**
  45097. * Attaches the scale behavior the passed in mesh
  45098. * @param ownerNode The mesh that will be scaled around once attached
  45099. */
  45100. attach(ownerNode: Mesh): void;
  45101. /**
  45102. * Detaches the behavior from the mesh
  45103. */
  45104. detach(): void;
  45105. }
  45106. }
  45107. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  45108. import { Behavior } from "babylonjs/Behaviors/behavior";
  45109. import { Mesh } from "babylonjs/Meshes/mesh";
  45110. import { Observable } from "babylonjs/Misc/observable";
  45111. /**
  45112. * 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
  45113. */
  45114. export class SixDofDragBehavior implements Behavior<Mesh> {
  45115. private static _virtualScene;
  45116. private _ownerNode;
  45117. private _sceneRenderObserver;
  45118. private _scene;
  45119. private _targetPosition;
  45120. private _virtualOriginMesh;
  45121. private _virtualDragMesh;
  45122. private _pointerObserver;
  45123. private _moving;
  45124. private _startingOrientation;
  45125. private _attachedElement;
  45126. /**
  45127. * 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)
  45128. */
  45129. private zDragFactor;
  45130. /**
  45131. * If the object should rotate to face the drag origin
  45132. */
  45133. rotateDraggedObject: boolean;
  45134. /**
  45135. * If the behavior is currently in a dragging state
  45136. */
  45137. dragging: boolean;
  45138. /**
  45139. * 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)
  45140. */
  45141. dragDeltaRatio: number;
  45142. /**
  45143. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  45144. */
  45145. currentDraggingPointerID: number;
  45146. /**
  45147. * If camera controls should be detached during the drag
  45148. */
  45149. detachCameraControls: boolean;
  45150. /**
  45151. * Fires each time a drag starts
  45152. */
  45153. onDragStartObservable: Observable<{}>;
  45154. /**
  45155. * Fires each time a drag ends (eg. mouse release after drag)
  45156. */
  45157. onDragEndObservable: Observable<{}>;
  45158. /**
  45159. * 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
  45160. */
  45161. constructor();
  45162. /**
  45163. * The name of the behavior
  45164. */
  45165. get name(): string;
  45166. /**
  45167. * Initializes the behavior
  45168. */
  45169. init(): void;
  45170. /**
  45171. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  45172. */
  45173. private get _pointerCamera();
  45174. /**
  45175. * Attaches the scale behavior the passed in mesh
  45176. * @param ownerNode The mesh that will be scaled around once attached
  45177. */
  45178. attach(ownerNode: Mesh): void;
  45179. /**
  45180. * Detaches the behavior from the mesh
  45181. */
  45182. detach(): void;
  45183. }
  45184. }
  45185. declare module "babylonjs/Behaviors/Meshes/index" {
  45186. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  45187. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  45188. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  45189. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45190. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  45191. }
  45192. declare module "babylonjs/Behaviors/index" {
  45193. export * from "babylonjs/Behaviors/behavior";
  45194. export * from "babylonjs/Behaviors/Cameras/index";
  45195. export * from "babylonjs/Behaviors/Meshes/index";
  45196. }
  45197. declare module "babylonjs/Bones/boneIKController" {
  45198. import { Bone } from "babylonjs/Bones/bone";
  45199. import { Vector3 } from "babylonjs/Maths/math.vector";
  45200. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45201. import { Nullable } from "babylonjs/types";
  45202. /**
  45203. * Class used to apply inverse kinematics to bones
  45204. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  45205. */
  45206. export class BoneIKController {
  45207. private static _tmpVecs;
  45208. private static _tmpQuat;
  45209. private static _tmpMats;
  45210. /**
  45211. * Gets or sets the target mesh
  45212. */
  45213. targetMesh: AbstractMesh;
  45214. /** Gets or sets the mesh used as pole */
  45215. poleTargetMesh: AbstractMesh;
  45216. /**
  45217. * Gets or sets the bone used as pole
  45218. */
  45219. poleTargetBone: Nullable<Bone>;
  45220. /**
  45221. * Gets or sets the target position
  45222. */
  45223. targetPosition: Vector3;
  45224. /**
  45225. * Gets or sets the pole target position
  45226. */
  45227. poleTargetPosition: Vector3;
  45228. /**
  45229. * Gets or sets the pole target local offset
  45230. */
  45231. poleTargetLocalOffset: Vector3;
  45232. /**
  45233. * Gets or sets the pole angle
  45234. */
  45235. poleAngle: number;
  45236. /**
  45237. * Gets or sets the mesh associated with the controller
  45238. */
  45239. mesh: AbstractMesh;
  45240. /**
  45241. * 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)
  45242. */
  45243. slerpAmount: number;
  45244. private _bone1Quat;
  45245. private _bone1Mat;
  45246. private _bone2Ang;
  45247. private _bone1;
  45248. private _bone2;
  45249. private _bone1Length;
  45250. private _bone2Length;
  45251. private _maxAngle;
  45252. private _maxReach;
  45253. private _rightHandedSystem;
  45254. private _bendAxis;
  45255. private _slerping;
  45256. private _adjustRoll;
  45257. /**
  45258. * Gets or sets maximum allowed angle
  45259. */
  45260. get maxAngle(): number;
  45261. set maxAngle(value: number);
  45262. /**
  45263. * Creates a new BoneIKController
  45264. * @param mesh defines the mesh to control
  45265. * @param bone defines the bone to control
  45266. * @param options defines options to set up the controller
  45267. */
  45268. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  45269. targetMesh?: AbstractMesh;
  45270. poleTargetMesh?: AbstractMesh;
  45271. poleTargetBone?: Bone;
  45272. poleTargetLocalOffset?: Vector3;
  45273. poleAngle?: number;
  45274. bendAxis?: Vector3;
  45275. maxAngle?: number;
  45276. slerpAmount?: number;
  45277. });
  45278. private _setMaxAngle;
  45279. /**
  45280. * Force the controller to update the bones
  45281. */
  45282. update(): void;
  45283. }
  45284. }
  45285. declare module "babylonjs/Bones/boneLookController" {
  45286. import { Vector3 } from "babylonjs/Maths/math.vector";
  45287. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45288. import { Bone } from "babylonjs/Bones/bone";
  45289. import { Space } from "babylonjs/Maths/math.axis";
  45290. /**
  45291. * Class used to make a bone look toward a point in space
  45292. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  45293. */
  45294. export class BoneLookController {
  45295. private static _tmpVecs;
  45296. private static _tmpQuat;
  45297. private static _tmpMats;
  45298. /**
  45299. * The target Vector3 that the bone will look at
  45300. */
  45301. target: Vector3;
  45302. /**
  45303. * The mesh that the bone is attached to
  45304. */
  45305. mesh: AbstractMesh;
  45306. /**
  45307. * The bone that will be looking to the target
  45308. */
  45309. bone: Bone;
  45310. /**
  45311. * The up axis of the coordinate system that is used when the bone is rotated
  45312. */
  45313. upAxis: Vector3;
  45314. /**
  45315. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  45316. */
  45317. upAxisSpace: Space;
  45318. /**
  45319. * Used to make an adjustment to the yaw of the bone
  45320. */
  45321. adjustYaw: number;
  45322. /**
  45323. * Used to make an adjustment to the pitch of the bone
  45324. */
  45325. adjustPitch: number;
  45326. /**
  45327. * Used to make an adjustment to the roll of the bone
  45328. */
  45329. adjustRoll: number;
  45330. /**
  45331. * 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)
  45332. */
  45333. slerpAmount: number;
  45334. private _minYaw;
  45335. private _maxYaw;
  45336. private _minPitch;
  45337. private _maxPitch;
  45338. private _minYawSin;
  45339. private _minYawCos;
  45340. private _maxYawSin;
  45341. private _maxYawCos;
  45342. private _midYawConstraint;
  45343. private _minPitchTan;
  45344. private _maxPitchTan;
  45345. private _boneQuat;
  45346. private _slerping;
  45347. private _transformYawPitch;
  45348. private _transformYawPitchInv;
  45349. private _firstFrameSkipped;
  45350. private _yawRange;
  45351. private _fowardAxis;
  45352. /**
  45353. * Gets or sets the minimum yaw angle that the bone can look to
  45354. */
  45355. get minYaw(): number;
  45356. set minYaw(value: number);
  45357. /**
  45358. * Gets or sets the maximum yaw angle that the bone can look to
  45359. */
  45360. get maxYaw(): number;
  45361. set maxYaw(value: number);
  45362. /**
  45363. * Gets or sets the minimum pitch angle that the bone can look to
  45364. */
  45365. get minPitch(): number;
  45366. set minPitch(value: number);
  45367. /**
  45368. * Gets or sets the maximum pitch angle that the bone can look to
  45369. */
  45370. get maxPitch(): number;
  45371. set maxPitch(value: number);
  45372. /**
  45373. * Create a BoneLookController
  45374. * @param mesh the mesh that the bone belongs to
  45375. * @param bone the bone that will be looking to the target
  45376. * @param target the target Vector3 to look at
  45377. * @param options optional settings:
  45378. * * maxYaw: the maximum angle the bone will yaw to
  45379. * * minYaw: the minimum angle the bone will yaw to
  45380. * * maxPitch: the maximum angle the bone will pitch to
  45381. * * minPitch: the minimum angle the bone will yaw to
  45382. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  45383. * * upAxis: the up axis of the coordinate system
  45384. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  45385. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  45386. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  45387. * * adjustYaw: used to make an adjustment to the yaw of the bone
  45388. * * adjustPitch: used to make an adjustment to the pitch of the bone
  45389. * * adjustRoll: used to make an adjustment to the roll of the bone
  45390. **/
  45391. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  45392. maxYaw?: number;
  45393. minYaw?: number;
  45394. maxPitch?: number;
  45395. minPitch?: number;
  45396. slerpAmount?: number;
  45397. upAxis?: Vector3;
  45398. upAxisSpace?: Space;
  45399. yawAxis?: Vector3;
  45400. pitchAxis?: Vector3;
  45401. adjustYaw?: number;
  45402. adjustPitch?: number;
  45403. adjustRoll?: number;
  45404. });
  45405. /**
  45406. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  45407. */
  45408. update(): void;
  45409. private _getAngleDiff;
  45410. private _getAngleBetween;
  45411. private _isAngleBetween;
  45412. }
  45413. }
  45414. declare module "babylonjs/Bones/index" {
  45415. export * from "babylonjs/Bones/bone";
  45416. export * from "babylonjs/Bones/boneIKController";
  45417. export * from "babylonjs/Bones/boneLookController";
  45418. export * from "babylonjs/Bones/skeleton";
  45419. }
  45420. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  45421. import { Nullable } from "babylonjs/types";
  45422. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  45423. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45424. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  45425. /**
  45426. * Manage the gamepad inputs to control an arc rotate camera.
  45427. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45428. */
  45429. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  45430. /**
  45431. * Defines the camera the input is attached to.
  45432. */
  45433. camera: ArcRotateCamera;
  45434. /**
  45435. * Defines the gamepad the input is gathering event from.
  45436. */
  45437. gamepad: Nullable<Gamepad>;
  45438. /**
  45439. * Defines the gamepad rotation sensiblity.
  45440. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45441. */
  45442. gamepadRotationSensibility: number;
  45443. /**
  45444. * Defines the gamepad move sensiblity.
  45445. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45446. */
  45447. gamepadMoveSensibility: number;
  45448. private _yAxisScale;
  45449. /**
  45450. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  45451. */
  45452. get invertYAxis(): boolean;
  45453. set invertYAxis(value: boolean);
  45454. private _onGamepadConnectedObserver;
  45455. private _onGamepadDisconnectedObserver;
  45456. /**
  45457. * Attach the input controls to a specific dom element to get the input from.
  45458. * @param element Defines the element the controls should be listened from
  45459. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45460. */
  45461. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45462. /**
  45463. * Detach the current controls from the specified dom element.
  45464. * @param element Defines the element to stop listening the inputs from
  45465. */
  45466. detachControl(element: Nullable<HTMLElement>): void;
  45467. /**
  45468. * Update the current camera state depending on the inputs that have been used this frame.
  45469. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45470. */
  45471. checkInputs(): void;
  45472. /**
  45473. * Gets the class name of the current intput.
  45474. * @returns the class name
  45475. */
  45476. getClassName(): string;
  45477. /**
  45478. * Get the friendly name associated with the input class.
  45479. * @returns the input friendly name
  45480. */
  45481. getSimpleName(): string;
  45482. }
  45483. }
  45484. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  45485. import { Nullable } from "babylonjs/types";
  45486. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  45487. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45488. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  45489. interface ArcRotateCameraInputsManager {
  45490. /**
  45491. * Add orientation input support to the input manager.
  45492. * @returns the current input manager
  45493. */
  45494. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  45495. }
  45496. }
  45497. /**
  45498. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  45499. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45500. */
  45501. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  45502. /**
  45503. * Defines the camera the input is attached to.
  45504. */
  45505. camera: ArcRotateCamera;
  45506. /**
  45507. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  45508. */
  45509. alphaCorrection: number;
  45510. /**
  45511. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  45512. */
  45513. gammaCorrection: number;
  45514. private _alpha;
  45515. private _gamma;
  45516. private _dirty;
  45517. private _deviceOrientationHandler;
  45518. /**
  45519. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  45520. */
  45521. constructor();
  45522. /**
  45523. * Attach the input controls to a specific dom element to get the input from.
  45524. * @param element Defines the element the controls should be listened from
  45525. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45526. */
  45527. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45528. /** @hidden */
  45529. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  45530. /**
  45531. * Update the current camera state depending on the inputs that have been used this frame.
  45532. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45533. */
  45534. checkInputs(): void;
  45535. /**
  45536. * Detach the current controls from the specified dom element.
  45537. * @param element Defines the element to stop listening the inputs from
  45538. */
  45539. detachControl(element: Nullable<HTMLElement>): void;
  45540. /**
  45541. * Gets the class name of the current intput.
  45542. * @returns the class name
  45543. */
  45544. getClassName(): string;
  45545. /**
  45546. * Get the friendly name associated with the input class.
  45547. * @returns the input friendly name
  45548. */
  45549. getSimpleName(): string;
  45550. }
  45551. }
  45552. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  45553. import { Nullable } from "babylonjs/types";
  45554. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45555. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  45556. /**
  45557. * Listen to mouse events to control the camera.
  45558. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45559. */
  45560. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  45561. /**
  45562. * Defines the camera the input is attached to.
  45563. */
  45564. camera: FlyCamera;
  45565. /**
  45566. * Defines if touch is enabled. (Default is true.)
  45567. */
  45568. touchEnabled: boolean;
  45569. /**
  45570. * Defines the buttons associated with the input to handle camera rotation.
  45571. */
  45572. buttons: number[];
  45573. /**
  45574. * Assign buttons for Yaw control.
  45575. */
  45576. buttonsYaw: number[];
  45577. /**
  45578. * Assign buttons for Pitch control.
  45579. */
  45580. buttonsPitch: number[];
  45581. /**
  45582. * Assign buttons for Roll control.
  45583. */
  45584. buttonsRoll: number[];
  45585. /**
  45586. * Detect if any button is being pressed while mouse is moved.
  45587. * -1 = Mouse locked.
  45588. * 0 = Left button.
  45589. * 1 = Middle Button.
  45590. * 2 = Right Button.
  45591. */
  45592. activeButton: number;
  45593. /**
  45594. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  45595. * Higher values reduce its sensitivity.
  45596. */
  45597. angularSensibility: number;
  45598. private _mousemoveCallback;
  45599. private _observer;
  45600. private _rollObserver;
  45601. private previousPosition;
  45602. private noPreventDefault;
  45603. private element;
  45604. /**
  45605. * Listen to mouse events to control the camera.
  45606. * @param touchEnabled Define if touch is enabled. (Default is true.)
  45607. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45608. */
  45609. constructor(touchEnabled?: boolean);
  45610. /**
  45611. * Attach the mouse control to the HTML DOM element.
  45612. * @param element Defines the element that listens to the input events.
  45613. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  45614. */
  45615. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45616. /**
  45617. * Detach the current controls from the specified dom element.
  45618. * @param element Defines the element to stop listening the inputs from
  45619. */
  45620. detachControl(element: Nullable<HTMLElement>): void;
  45621. /**
  45622. * Gets the class name of the current input.
  45623. * @returns the class name.
  45624. */
  45625. getClassName(): string;
  45626. /**
  45627. * Get the friendly name associated with the input class.
  45628. * @returns the input's friendly name.
  45629. */
  45630. getSimpleName(): string;
  45631. private _pointerInput;
  45632. private _onMouseMove;
  45633. /**
  45634. * Rotate camera by mouse offset.
  45635. */
  45636. private rotateCamera;
  45637. }
  45638. }
  45639. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  45640. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  45641. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  45642. /**
  45643. * Default Inputs manager for the FlyCamera.
  45644. * It groups all the default supported inputs for ease of use.
  45645. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45646. */
  45647. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  45648. /**
  45649. * Instantiates a new FlyCameraInputsManager.
  45650. * @param camera Defines the camera the inputs belong to.
  45651. */
  45652. constructor(camera: FlyCamera);
  45653. /**
  45654. * Add keyboard input support to the input manager.
  45655. * @returns the new FlyCameraKeyboardMoveInput().
  45656. */
  45657. addKeyboard(): FlyCameraInputsManager;
  45658. /**
  45659. * Add mouse input support to the input manager.
  45660. * @param touchEnabled Enable touch screen support.
  45661. * @returns the new FlyCameraMouseInput().
  45662. */
  45663. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  45664. }
  45665. }
  45666. declare module "babylonjs/Cameras/flyCamera" {
  45667. import { Scene } from "babylonjs/scene";
  45668. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  45669. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45670. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  45671. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  45672. /**
  45673. * This is a flying camera, designed for 3D movement and rotation in all directions,
  45674. * such as in a 3D Space Shooter or a Flight Simulator.
  45675. */
  45676. export class FlyCamera extends TargetCamera {
  45677. /**
  45678. * Define the collision ellipsoid of the camera.
  45679. * This is helpful for simulating a camera body, like a player's body.
  45680. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  45681. */
  45682. ellipsoid: Vector3;
  45683. /**
  45684. * Define an offset for the position of the ellipsoid around the camera.
  45685. * This can be helpful if the camera is attached away from the player's body center,
  45686. * such as at its head.
  45687. */
  45688. ellipsoidOffset: Vector3;
  45689. /**
  45690. * Enable or disable collisions of the camera with the rest of the scene objects.
  45691. */
  45692. checkCollisions: boolean;
  45693. /**
  45694. * Enable or disable gravity on the camera.
  45695. */
  45696. applyGravity: boolean;
  45697. /**
  45698. * Define the current direction the camera is moving to.
  45699. */
  45700. cameraDirection: Vector3;
  45701. /**
  45702. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  45703. * This overrides and empties cameraRotation.
  45704. */
  45705. rotationQuaternion: Quaternion;
  45706. /**
  45707. * Track Roll to maintain the wanted Rolling when looking around.
  45708. */
  45709. _trackRoll: number;
  45710. /**
  45711. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  45712. */
  45713. rollCorrect: number;
  45714. /**
  45715. * Mimic a banked turn, Rolling the camera when Yawing.
  45716. * It's recommended to use rollCorrect = 10 for faster banking correction.
  45717. */
  45718. bankedTurn: boolean;
  45719. /**
  45720. * Limit in radians for how much Roll banking will add. (Default: 90°)
  45721. */
  45722. bankedTurnLimit: number;
  45723. /**
  45724. * Value of 0 disables the banked Roll.
  45725. * Value of 1 is equal to the Yaw angle in radians.
  45726. */
  45727. bankedTurnMultiplier: number;
  45728. /**
  45729. * The inputs manager loads all the input sources, such as keyboard and mouse.
  45730. */
  45731. inputs: FlyCameraInputsManager;
  45732. /**
  45733. * Gets the input sensibility for mouse input.
  45734. * Higher values reduce sensitivity.
  45735. */
  45736. get angularSensibility(): number;
  45737. /**
  45738. * Sets the input sensibility for a mouse input.
  45739. * Higher values reduce sensitivity.
  45740. */
  45741. set angularSensibility(value: number);
  45742. /**
  45743. * Get the keys for camera movement forward.
  45744. */
  45745. get keysForward(): number[];
  45746. /**
  45747. * Set the keys for camera movement forward.
  45748. */
  45749. set keysForward(value: number[]);
  45750. /**
  45751. * Get the keys for camera movement backward.
  45752. */
  45753. get keysBackward(): number[];
  45754. set keysBackward(value: number[]);
  45755. /**
  45756. * Get the keys for camera movement up.
  45757. */
  45758. get keysUp(): number[];
  45759. /**
  45760. * Set the keys for camera movement up.
  45761. */
  45762. set keysUp(value: number[]);
  45763. /**
  45764. * Get the keys for camera movement down.
  45765. */
  45766. get keysDown(): number[];
  45767. /**
  45768. * Set the keys for camera movement down.
  45769. */
  45770. set keysDown(value: number[]);
  45771. /**
  45772. * Get the keys for camera movement left.
  45773. */
  45774. get keysLeft(): number[];
  45775. /**
  45776. * Set the keys for camera movement left.
  45777. */
  45778. set keysLeft(value: number[]);
  45779. /**
  45780. * Set the keys for camera movement right.
  45781. */
  45782. get keysRight(): number[];
  45783. /**
  45784. * Set the keys for camera movement right.
  45785. */
  45786. set keysRight(value: number[]);
  45787. /**
  45788. * Event raised when the camera collides with a mesh in the scene.
  45789. */
  45790. onCollide: (collidedMesh: AbstractMesh) => void;
  45791. private _collider;
  45792. private _needMoveForGravity;
  45793. private _oldPosition;
  45794. private _diffPosition;
  45795. private _newPosition;
  45796. /** @hidden */
  45797. _localDirection: Vector3;
  45798. /** @hidden */
  45799. _transformedDirection: Vector3;
  45800. /**
  45801. * Instantiates a FlyCamera.
  45802. * This is a flying camera, designed for 3D movement and rotation in all directions,
  45803. * such as in a 3D Space Shooter or a Flight Simulator.
  45804. * @param name Define the name of the camera in the scene.
  45805. * @param position Define the starting position of the camera in the scene.
  45806. * @param scene Define the scene the camera belongs to.
  45807. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  45808. */
  45809. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  45810. /**
  45811. * Attach a control to the HTML DOM element.
  45812. * @param element Defines the element that listens to the input events.
  45813. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  45814. */
  45815. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45816. /**
  45817. * Detach a control from the HTML DOM element.
  45818. * The camera will stop reacting to that input.
  45819. * @param element Defines the element that listens to the input events.
  45820. */
  45821. detachControl(element: HTMLElement): void;
  45822. private _collisionMask;
  45823. /**
  45824. * Get the mask that the camera ignores in collision events.
  45825. */
  45826. get collisionMask(): number;
  45827. /**
  45828. * Set the mask that the camera ignores in collision events.
  45829. */
  45830. set collisionMask(mask: number);
  45831. /** @hidden */
  45832. _collideWithWorld(displacement: Vector3): void;
  45833. /** @hidden */
  45834. private _onCollisionPositionChange;
  45835. /** @hidden */
  45836. _checkInputs(): void;
  45837. /** @hidden */
  45838. _decideIfNeedsToMove(): boolean;
  45839. /** @hidden */
  45840. _updatePosition(): void;
  45841. /**
  45842. * Restore the Roll to its target value at the rate specified.
  45843. * @param rate - Higher means slower restoring.
  45844. * @hidden
  45845. */
  45846. restoreRoll(rate: number): void;
  45847. /**
  45848. * Destroy the camera and release the current resources held by it.
  45849. */
  45850. dispose(): void;
  45851. /**
  45852. * Get the current object class name.
  45853. * @returns the class name.
  45854. */
  45855. getClassName(): string;
  45856. }
  45857. }
  45858. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  45859. import { Nullable } from "babylonjs/types";
  45860. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45861. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  45862. /**
  45863. * Listen to keyboard events to control the camera.
  45864. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45865. */
  45866. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  45867. /**
  45868. * Defines the camera the input is attached to.
  45869. */
  45870. camera: FlyCamera;
  45871. /**
  45872. * The list of keyboard keys used to control the forward move of the camera.
  45873. */
  45874. keysForward: number[];
  45875. /**
  45876. * The list of keyboard keys used to control the backward move of the camera.
  45877. */
  45878. keysBackward: number[];
  45879. /**
  45880. * The list of keyboard keys used to control the forward move of the camera.
  45881. */
  45882. keysUp: number[];
  45883. /**
  45884. * The list of keyboard keys used to control the backward move of the camera.
  45885. */
  45886. keysDown: number[];
  45887. /**
  45888. * The list of keyboard keys used to control the right strafe move of the camera.
  45889. */
  45890. keysRight: number[];
  45891. /**
  45892. * The list of keyboard keys used to control the left strafe move of the camera.
  45893. */
  45894. keysLeft: number[];
  45895. private _keys;
  45896. private _onCanvasBlurObserver;
  45897. private _onKeyboardObserver;
  45898. private _engine;
  45899. private _scene;
  45900. /**
  45901. * Attach the input controls to a specific dom element to get the input from.
  45902. * @param element Defines the element the controls should be listened from
  45903. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45904. */
  45905. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45906. /**
  45907. * Detach the current controls from the specified dom element.
  45908. * @param element Defines the element to stop listening the inputs from
  45909. */
  45910. detachControl(element: Nullable<HTMLElement>): void;
  45911. /**
  45912. * Gets the class name of the current intput.
  45913. * @returns the class name
  45914. */
  45915. getClassName(): string;
  45916. /** @hidden */
  45917. _onLostFocus(e: FocusEvent): void;
  45918. /**
  45919. * Get the friendly name associated with the input class.
  45920. * @returns the input friendly name
  45921. */
  45922. getSimpleName(): string;
  45923. /**
  45924. * Update the current camera state depending on the inputs that have been used this frame.
  45925. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45926. */
  45927. checkInputs(): void;
  45928. }
  45929. }
  45930. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  45931. import { Nullable } from "babylonjs/types";
  45932. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  45933. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45934. /**
  45935. * Manage the mouse wheel inputs to control a follow camera.
  45936. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45937. */
  45938. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  45939. /**
  45940. * Defines the camera the input is attached to.
  45941. */
  45942. camera: FollowCamera;
  45943. /**
  45944. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  45945. */
  45946. axisControlRadius: boolean;
  45947. /**
  45948. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  45949. */
  45950. axisControlHeight: boolean;
  45951. /**
  45952. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  45953. */
  45954. axisControlRotation: boolean;
  45955. /**
  45956. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  45957. * relation to mouseWheel events.
  45958. */
  45959. wheelPrecision: number;
  45960. /**
  45961. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  45962. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  45963. */
  45964. wheelDeltaPercentage: number;
  45965. private _wheel;
  45966. private _observer;
  45967. /**
  45968. * Attach the input controls to a specific dom element to get the input from.
  45969. * @param element Defines the element the controls should be listened from
  45970. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45971. */
  45972. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45973. /**
  45974. * Detach the current controls from the specified dom element.
  45975. * @param element Defines the element to stop listening the inputs from
  45976. */
  45977. detachControl(element: Nullable<HTMLElement>): void;
  45978. /**
  45979. * Gets the class name of the current intput.
  45980. * @returns the class name
  45981. */
  45982. getClassName(): string;
  45983. /**
  45984. * Get the friendly name associated with the input class.
  45985. * @returns the input friendly name
  45986. */
  45987. getSimpleName(): string;
  45988. }
  45989. }
  45990. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  45991. import { Nullable } from "babylonjs/types";
  45992. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  45993. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  45994. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  45995. /**
  45996. * Manage the pointers inputs to control an follow camera.
  45997. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45998. */
  45999. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  46000. /**
  46001. * Defines the camera the input is attached to.
  46002. */
  46003. camera: FollowCamera;
  46004. /**
  46005. * Gets the class name of the current input.
  46006. * @returns the class name
  46007. */
  46008. getClassName(): string;
  46009. /**
  46010. * Defines the pointer angular sensibility along the X axis or how fast is
  46011. * the camera rotating.
  46012. * A negative number will reverse the axis direction.
  46013. */
  46014. angularSensibilityX: number;
  46015. /**
  46016. * Defines the pointer angular sensibility along the Y axis or how fast is
  46017. * the camera rotating.
  46018. * A negative number will reverse the axis direction.
  46019. */
  46020. angularSensibilityY: number;
  46021. /**
  46022. * Defines the pointer pinch precision or how fast is the camera zooming.
  46023. * A negative number will reverse the axis direction.
  46024. */
  46025. pinchPrecision: number;
  46026. /**
  46027. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  46028. * from 0.
  46029. * It defines the percentage of current camera.radius to use as delta when
  46030. * pinch zoom is used.
  46031. */
  46032. pinchDeltaPercentage: number;
  46033. /**
  46034. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  46035. */
  46036. axisXControlRadius: boolean;
  46037. /**
  46038. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  46039. */
  46040. axisXControlHeight: boolean;
  46041. /**
  46042. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  46043. */
  46044. axisXControlRotation: boolean;
  46045. /**
  46046. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  46047. */
  46048. axisYControlRadius: boolean;
  46049. /**
  46050. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  46051. */
  46052. axisYControlHeight: boolean;
  46053. /**
  46054. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  46055. */
  46056. axisYControlRotation: boolean;
  46057. /**
  46058. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  46059. */
  46060. axisPinchControlRadius: boolean;
  46061. /**
  46062. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  46063. */
  46064. axisPinchControlHeight: boolean;
  46065. /**
  46066. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  46067. */
  46068. axisPinchControlRotation: boolean;
  46069. /**
  46070. * Log error messages if basic misconfiguration has occurred.
  46071. */
  46072. warningEnable: boolean;
  46073. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  46074. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  46075. private _warningCounter;
  46076. private _warning;
  46077. }
  46078. }
  46079. declare module "babylonjs/Cameras/followCameraInputsManager" {
  46080. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  46081. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46082. /**
  46083. * Default Inputs manager for the FollowCamera.
  46084. * It groups all the default supported inputs for ease of use.
  46085. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46086. */
  46087. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  46088. /**
  46089. * Instantiates a new FollowCameraInputsManager.
  46090. * @param camera Defines the camera the inputs belong to
  46091. */
  46092. constructor(camera: FollowCamera);
  46093. /**
  46094. * Add keyboard input support to the input manager.
  46095. * @returns the current input manager
  46096. */
  46097. addKeyboard(): FollowCameraInputsManager;
  46098. /**
  46099. * Add mouse wheel input support to the input manager.
  46100. * @returns the current input manager
  46101. */
  46102. addMouseWheel(): FollowCameraInputsManager;
  46103. /**
  46104. * Add pointers input support to the input manager.
  46105. * @returns the current input manager
  46106. */
  46107. addPointers(): FollowCameraInputsManager;
  46108. /**
  46109. * Add orientation input support to the input manager.
  46110. * @returns the current input manager
  46111. */
  46112. addVRDeviceOrientation(): FollowCameraInputsManager;
  46113. }
  46114. }
  46115. declare module "babylonjs/Cameras/followCamera" {
  46116. import { Nullable } from "babylonjs/types";
  46117. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  46118. import { Scene } from "babylonjs/scene";
  46119. import { Vector3 } from "babylonjs/Maths/math.vector";
  46120. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46121. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  46122. /**
  46123. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  46124. * an arc rotate version arcFollowCamera are available.
  46125. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46126. */
  46127. export class FollowCamera extends TargetCamera {
  46128. /**
  46129. * Distance the follow camera should follow an object at
  46130. */
  46131. radius: number;
  46132. /**
  46133. * Minimum allowed distance of the camera to the axis of rotation
  46134. * (The camera can not get closer).
  46135. * This can help limiting how the Camera is able to move in the scene.
  46136. */
  46137. lowerRadiusLimit: Nullable<number>;
  46138. /**
  46139. * Maximum allowed distance of the camera to the axis of rotation
  46140. * (The camera can not get further).
  46141. * This can help limiting how the Camera is able to move in the scene.
  46142. */
  46143. upperRadiusLimit: Nullable<number>;
  46144. /**
  46145. * Define a rotation offset between the camera and the object it follows
  46146. */
  46147. rotationOffset: number;
  46148. /**
  46149. * Minimum allowed angle to camera position relative to target object.
  46150. * This can help limiting how the Camera is able to move in the scene.
  46151. */
  46152. lowerRotationOffsetLimit: Nullable<number>;
  46153. /**
  46154. * Maximum allowed angle to camera position relative to target object.
  46155. * This can help limiting how the Camera is able to move in the scene.
  46156. */
  46157. upperRotationOffsetLimit: Nullable<number>;
  46158. /**
  46159. * Define a height offset between the camera and the object it follows.
  46160. * It can help following an object from the top (like a car chaing a plane)
  46161. */
  46162. heightOffset: number;
  46163. /**
  46164. * Minimum allowed height of camera position relative to target object.
  46165. * This can help limiting how the Camera is able to move in the scene.
  46166. */
  46167. lowerHeightOffsetLimit: Nullable<number>;
  46168. /**
  46169. * Maximum allowed height of camera position relative to target object.
  46170. * This can help limiting how the Camera is able to move in the scene.
  46171. */
  46172. upperHeightOffsetLimit: Nullable<number>;
  46173. /**
  46174. * Define how fast the camera can accelerate to follow it s target.
  46175. */
  46176. cameraAcceleration: number;
  46177. /**
  46178. * Define the speed limit of the camera following an object.
  46179. */
  46180. maxCameraSpeed: number;
  46181. /**
  46182. * Define the target of the camera.
  46183. */
  46184. lockedTarget: Nullable<AbstractMesh>;
  46185. /**
  46186. * Defines the input associated with the camera.
  46187. */
  46188. inputs: FollowCameraInputsManager;
  46189. /**
  46190. * Instantiates the follow camera.
  46191. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46192. * @param name Define the name of the camera in the scene
  46193. * @param position Define the position of the camera
  46194. * @param scene Define the scene the camera belong to
  46195. * @param lockedTarget Define the target of the camera
  46196. */
  46197. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  46198. private _follow;
  46199. /**
  46200. * Attached controls to the current camera.
  46201. * @param element Defines the element the controls should be listened from
  46202. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46203. */
  46204. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46205. /**
  46206. * Detach the current controls from the camera.
  46207. * The camera will stop reacting to inputs.
  46208. * @param element Defines the element to stop listening the inputs from
  46209. */
  46210. detachControl(element: HTMLElement): void;
  46211. /** @hidden */
  46212. _checkInputs(): void;
  46213. private _checkLimits;
  46214. /**
  46215. * Gets the camera class name.
  46216. * @returns the class name
  46217. */
  46218. getClassName(): string;
  46219. }
  46220. /**
  46221. * Arc Rotate version of the follow camera.
  46222. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  46223. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46224. */
  46225. export class ArcFollowCamera extends TargetCamera {
  46226. /** The longitudinal angle of the camera */
  46227. alpha: number;
  46228. /** The latitudinal angle of the camera */
  46229. beta: number;
  46230. /** The radius of the camera from its target */
  46231. radius: number;
  46232. private _cartesianCoordinates;
  46233. /** Define the camera target (the mesh it should follow) */
  46234. private _meshTarget;
  46235. /**
  46236. * Instantiates a new ArcFollowCamera
  46237. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46238. * @param name Define the name of the camera
  46239. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  46240. * @param beta Define the rotation angle of the camera around the elevation axis
  46241. * @param radius Define the radius of the camera from its target point
  46242. * @param target Define the target of the camera
  46243. * @param scene Define the scene the camera belongs to
  46244. */
  46245. constructor(name: string,
  46246. /** The longitudinal angle of the camera */
  46247. alpha: number,
  46248. /** The latitudinal angle of the camera */
  46249. beta: number,
  46250. /** The radius of the camera from its target */
  46251. radius: number,
  46252. /** Define the camera target (the mesh it should follow) */
  46253. target: Nullable<AbstractMesh>, scene: Scene);
  46254. private _follow;
  46255. /** @hidden */
  46256. _checkInputs(): void;
  46257. /**
  46258. * Returns the class name of the object.
  46259. * It is mostly used internally for serialization purposes.
  46260. */
  46261. getClassName(): string;
  46262. }
  46263. }
  46264. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  46265. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46266. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46267. import { Nullable } from "babylonjs/types";
  46268. /**
  46269. * Manage the keyboard inputs to control the movement of a follow camera.
  46270. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46271. */
  46272. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  46273. /**
  46274. * Defines the camera the input is attached to.
  46275. */
  46276. camera: FollowCamera;
  46277. /**
  46278. * Defines the list of key codes associated with the up action (increase heightOffset)
  46279. */
  46280. keysHeightOffsetIncr: number[];
  46281. /**
  46282. * Defines the list of key codes associated with the down action (decrease heightOffset)
  46283. */
  46284. keysHeightOffsetDecr: number[];
  46285. /**
  46286. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  46287. */
  46288. keysHeightOffsetModifierAlt: boolean;
  46289. /**
  46290. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  46291. */
  46292. keysHeightOffsetModifierCtrl: boolean;
  46293. /**
  46294. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  46295. */
  46296. keysHeightOffsetModifierShift: boolean;
  46297. /**
  46298. * Defines the list of key codes associated with the left action (increase rotationOffset)
  46299. */
  46300. keysRotationOffsetIncr: number[];
  46301. /**
  46302. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  46303. */
  46304. keysRotationOffsetDecr: number[];
  46305. /**
  46306. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  46307. */
  46308. keysRotationOffsetModifierAlt: boolean;
  46309. /**
  46310. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  46311. */
  46312. keysRotationOffsetModifierCtrl: boolean;
  46313. /**
  46314. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  46315. */
  46316. keysRotationOffsetModifierShift: boolean;
  46317. /**
  46318. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  46319. */
  46320. keysRadiusIncr: number[];
  46321. /**
  46322. * Defines the list of key codes associated with the zoom-out action (increase radius)
  46323. */
  46324. keysRadiusDecr: number[];
  46325. /**
  46326. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  46327. */
  46328. keysRadiusModifierAlt: boolean;
  46329. /**
  46330. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  46331. */
  46332. keysRadiusModifierCtrl: boolean;
  46333. /**
  46334. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  46335. */
  46336. keysRadiusModifierShift: boolean;
  46337. /**
  46338. * Defines the rate of change of heightOffset.
  46339. */
  46340. heightSensibility: number;
  46341. /**
  46342. * Defines the rate of change of rotationOffset.
  46343. */
  46344. rotationSensibility: number;
  46345. /**
  46346. * Defines the rate of change of radius.
  46347. */
  46348. radiusSensibility: number;
  46349. private _keys;
  46350. private _ctrlPressed;
  46351. private _altPressed;
  46352. private _shiftPressed;
  46353. private _onCanvasBlurObserver;
  46354. private _onKeyboardObserver;
  46355. private _engine;
  46356. private _scene;
  46357. /**
  46358. * Attach the input controls to a specific dom element to get the input from.
  46359. * @param element Defines the element the controls should be listened from
  46360. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46361. */
  46362. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46363. /**
  46364. * Detach the current controls from the specified dom element.
  46365. * @param element Defines the element to stop listening the inputs from
  46366. */
  46367. detachControl(element: Nullable<HTMLElement>): void;
  46368. /**
  46369. * Update the current camera state depending on the inputs that have been used this frame.
  46370. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46371. */
  46372. checkInputs(): void;
  46373. /**
  46374. * Gets the class name of the current input.
  46375. * @returns the class name
  46376. */
  46377. getClassName(): string;
  46378. /**
  46379. * Get the friendly name associated with the input class.
  46380. * @returns the input friendly name
  46381. */
  46382. getSimpleName(): string;
  46383. /**
  46384. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46385. * allow modification of the heightOffset value.
  46386. */
  46387. private _modifierHeightOffset;
  46388. /**
  46389. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46390. * allow modification of the rotationOffset value.
  46391. */
  46392. private _modifierRotationOffset;
  46393. /**
  46394. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46395. * allow modification of the radius value.
  46396. */
  46397. private _modifierRadius;
  46398. }
  46399. }
  46400. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  46401. import { Nullable } from "babylonjs/types";
  46402. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46403. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46404. import { Observable } from "babylonjs/Misc/observable";
  46405. module "babylonjs/Cameras/freeCameraInputsManager" {
  46406. interface FreeCameraInputsManager {
  46407. /**
  46408. * @hidden
  46409. */
  46410. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  46411. /**
  46412. * Add orientation input support to the input manager.
  46413. * @returns the current input manager
  46414. */
  46415. addDeviceOrientation(): FreeCameraInputsManager;
  46416. }
  46417. }
  46418. /**
  46419. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  46420. * Screen rotation is taken into account.
  46421. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46422. */
  46423. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  46424. private _camera;
  46425. private _screenOrientationAngle;
  46426. private _constantTranform;
  46427. private _screenQuaternion;
  46428. private _alpha;
  46429. private _beta;
  46430. private _gamma;
  46431. /**
  46432. * Can be used to detect if a device orientation sensor is available on a device
  46433. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  46434. * @returns a promise that will resolve on orientation change
  46435. */
  46436. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  46437. /**
  46438. * @hidden
  46439. */
  46440. _onDeviceOrientationChangedObservable: Observable<void>;
  46441. /**
  46442. * Instantiates a new input
  46443. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46444. */
  46445. constructor();
  46446. /**
  46447. * Define the camera controlled by the input.
  46448. */
  46449. get camera(): FreeCamera;
  46450. set camera(camera: FreeCamera);
  46451. /**
  46452. * Attach the input controls to a specific dom element to get the input from.
  46453. * @param element Defines the element the controls should be listened from
  46454. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46455. */
  46456. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46457. private _orientationChanged;
  46458. private _deviceOrientation;
  46459. /**
  46460. * Detach the current controls from the specified dom element.
  46461. * @param element Defines the element to stop listening the inputs from
  46462. */
  46463. detachControl(element: Nullable<HTMLElement>): void;
  46464. /**
  46465. * Update the current camera state depending on the inputs that have been used this frame.
  46466. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46467. */
  46468. checkInputs(): void;
  46469. /**
  46470. * Gets the class name of the current intput.
  46471. * @returns the class name
  46472. */
  46473. getClassName(): string;
  46474. /**
  46475. * Get the friendly name associated with the input class.
  46476. * @returns the input friendly name
  46477. */
  46478. getSimpleName(): string;
  46479. }
  46480. }
  46481. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  46482. import { Nullable } from "babylonjs/types";
  46483. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46484. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46485. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  46486. /**
  46487. * Manage the gamepad inputs to control a free camera.
  46488. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46489. */
  46490. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  46491. /**
  46492. * Define the camera the input is attached to.
  46493. */
  46494. camera: FreeCamera;
  46495. /**
  46496. * Define the Gamepad controlling the input
  46497. */
  46498. gamepad: Nullable<Gamepad>;
  46499. /**
  46500. * Defines the gamepad rotation sensiblity.
  46501. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  46502. */
  46503. gamepadAngularSensibility: number;
  46504. /**
  46505. * Defines the gamepad move sensiblity.
  46506. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  46507. */
  46508. gamepadMoveSensibility: number;
  46509. private _yAxisScale;
  46510. /**
  46511. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  46512. */
  46513. get invertYAxis(): boolean;
  46514. set invertYAxis(value: boolean);
  46515. private _onGamepadConnectedObserver;
  46516. private _onGamepadDisconnectedObserver;
  46517. private _cameraTransform;
  46518. private _deltaTransform;
  46519. private _vector3;
  46520. private _vector2;
  46521. /**
  46522. * Attach the input controls to a specific dom element to get the input from.
  46523. * @param element Defines the element the controls should be listened from
  46524. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46525. */
  46526. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46527. /**
  46528. * Detach the current controls from the specified dom element.
  46529. * @param element Defines the element to stop listening the inputs from
  46530. */
  46531. detachControl(element: Nullable<HTMLElement>): void;
  46532. /**
  46533. * Update the current camera state depending on the inputs that have been used this frame.
  46534. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46535. */
  46536. checkInputs(): void;
  46537. /**
  46538. * Gets the class name of the current intput.
  46539. * @returns the class name
  46540. */
  46541. getClassName(): string;
  46542. /**
  46543. * Get the friendly name associated with the input class.
  46544. * @returns the input friendly name
  46545. */
  46546. getSimpleName(): string;
  46547. }
  46548. }
  46549. declare module "babylonjs/Misc/virtualJoystick" {
  46550. import { Nullable } from "babylonjs/types";
  46551. import { Vector3 } from "babylonjs/Maths/math.vector";
  46552. /**
  46553. * Defines the potential axis of a Joystick
  46554. */
  46555. export enum JoystickAxis {
  46556. /** X axis */
  46557. X = 0,
  46558. /** Y axis */
  46559. Y = 1,
  46560. /** Z axis */
  46561. Z = 2
  46562. }
  46563. /**
  46564. * Represents the different customization options available
  46565. * for VirtualJoystick
  46566. */
  46567. interface VirtualJoystickCustomizations {
  46568. /**
  46569. * Size of the joystick's puck
  46570. */
  46571. puckSize: number;
  46572. /**
  46573. * Size of the joystick's container
  46574. */
  46575. containerSize: number;
  46576. /**
  46577. * Color of the joystick && puck
  46578. */
  46579. color: string;
  46580. /**
  46581. * Image URL for the joystick's puck
  46582. */
  46583. puckImage?: string;
  46584. /**
  46585. * Image URL for the joystick's container
  46586. */
  46587. containerImage?: string;
  46588. /**
  46589. * Defines the unmoving position of the joystick container
  46590. */
  46591. position?: {
  46592. x: number;
  46593. y: number;
  46594. };
  46595. /**
  46596. * Defines whether or not the joystick container is always visible
  46597. */
  46598. alwaysVisible: boolean;
  46599. /**
  46600. * Defines whether or not to limit the movement of the puck to the joystick's container
  46601. */
  46602. limitToContainer: boolean;
  46603. }
  46604. /**
  46605. * Class used to define virtual joystick (used in touch mode)
  46606. */
  46607. export class VirtualJoystick {
  46608. /**
  46609. * Gets or sets a boolean indicating that left and right values must be inverted
  46610. */
  46611. reverseLeftRight: boolean;
  46612. /**
  46613. * Gets or sets a boolean indicating that up and down values must be inverted
  46614. */
  46615. reverseUpDown: boolean;
  46616. /**
  46617. * Gets the offset value for the position (ie. the change of the position value)
  46618. */
  46619. deltaPosition: Vector3;
  46620. /**
  46621. * Gets a boolean indicating if the virtual joystick was pressed
  46622. */
  46623. pressed: boolean;
  46624. /**
  46625. * Canvas the virtual joystick will render onto, default z-index of this is 5
  46626. */
  46627. static Canvas: Nullable<HTMLCanvasElement>;
  46628. /**
  46629. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  46630. */
  46631. limitToContainer: boolean;
  46632. private static _globalJoystickIndex;
  46633. private static _alwaysVisibleSticks;
  46634. private static vjCanvasContext;
  46635. private static vjCanvasWidth;
  46636. private static vjCanvasHeight;
  46637. private static halfWidth;
  46638. private static _GetDefaultOptions;
  46639. private _action;
  46640. private _axisTargetedByLeftAndRight;
  46641. private _axisTargetedByUpAndDown;
  46642. private _joystickSensibility;
  46643. private _inversedSensibility;
  46644. private _joystickPointerID;
  46645. private _joystickColor;
  46646. private _joystickPointerPos;
  46647. private _joystickPreviousPointerPos;
  46648. private _joystickPointerStartPos;
  46649. private _deltaJoystickVector;
  46650. private _leftJoystick;
  46651. private _touches;
  46652. private _joystickPosition;
  46653. private _alwaysVisible;
  46654. private _puckImage;
  46655. private _containerImage;
  46656. private _joystickPuckSize;
  46657. private _joystickContainerSize;
  46658. private _clearPuckSize;
  46659. private _clearContainerSize;
  46660. private _clearPuckSizeOffset;
  46661. private _clearContainerSizeOffset;
  46662. private _onPointerDownHandlerRef;
  46663. private _onPointerMoveHandlerRef;
  46664. private _onPointerUpHandlerRef;
  46665. private _onResize;
  46666. /**
  46667. * Creates a new virtual joystick
  46668. * @param leftJoystick defines that the joystick is for left hand (false by default)
  46669. * @param customizations Defines the options we want to customize the VirtualJoystick
  46670. */
  46671. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  46672. /**
  46673. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  46674. * @param newJoystickSensibility defines the new sensibility
  46675. */
  46676. setJoystickSensibility(newJoystickSensibility: number): void;
  46677. private _onPointerDown;
  46678. private _onPointerMove;
  46679. private _onPointerUp;
  46680. /**
  46681. * Change the color of the virtual joystick
  46682. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  46683. */
  46684. setJoystickColor(newColor: string): void;
  46685. /**
  46686. * Size of the joystick's container
  46687. */
  46688. set containerSize(newSize: number);
  46689. get containerSize(): number;
  46690. /**
  46691. * Size of the joystick's puck
  46692. */
  46693. set puckSize(newSize: number);
  46694. get puckSize(): number;
  46695. /**
  46696. * Clears the set position of the joystick
  46697. */
  46698. clearPosition(): void;
  46699. /**
  46700. * Defines whether or not the joystick container is always visible
  46701. */
  46702. set alwaysVisible(value: boolean);
  46703. get alwaysVisible(): boolean;
  46704. /**
  46705. * Sets the constant position of the Joystick container
  46706. * @param x X axis coordinate
  46707. * @param y Y axis coordinate
  46708. */
  46709. setPosition(x: number, y: number): void;
  46710. /**
  46711. * Defines a callback to call when the joystick is touched
  46712. * @param action defines the callback
  46713. */
  46714. setActionOnTouch(action: () => any): void;
  46715. /**
  46716. * Defines which axis you'd like to control for left & right
  46717. * @param axis defines the axis to use
  46718. */
  46719. setAxisForLeftRight(axis: JoystickAxis): void;
  46720. /**
  46721. * Defines which axis you'd like to control for up & down
  46722. * @param axis defines the axis to use
  46723. */
  46724. setAxisForUpDown(axis: JoystickAxis): void;
  46725. /**
  46726. * Clears the canvas from the previous puck / container draw
  46727. */
  46728. private _clearPreviousDraw;
  46729. /**
  46730. * Loads `urlPath` to be used for the container's image
  46731. * @param urlPath defines the urlPath of an image to use
  46732. */
  46733. setContainerImage(urlPath: string): void;
  46734. /**
  46735. * Loads `urlPath` to be used for the puck's image
  46736. * @param urlPath defines the urlPath of an image to use
  46737. */
  46738. setPuckImage(urlPath: string): void;
  46739. /**
  46740. * Draws the Virtual Joystick's container
  46741. */
  46742. private _drawContainer;
  46743. /**
  46744. * Draws the Virtual Joystick's puck
  46745. */
  46746. private _drawPuck;
  46747. private _drawVirtualJoystick;
  46748. /**
  46749. * Release internal HTML canvas
  46750. */
  46751. releaseCanvas(): void;
  46752. }
  46753. }
  46754. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  46755. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  46756. import { Nullable } from "babylonjs/types";
  46757. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46758. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46759. module "babylonjs/Cameras/freeCameraInputsManager" {
  46760. interface FreeCameraInputsManager {
  46761. /**
  46762. * Add virtual joystick input support to the input manager.
  46763. * @returns the current input manager
  46764. */
  46765. addVirtualJoystick(): FreeCameraInputsManager;
  46766. }
  46767. }
  46768. /**
  46769. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  46770. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46771. */
  46772. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  46773. /**
  46774. * Defines the camera the input is attached to.
  46775. */
  46776. camera: FreeCamera;
  46777. private _leftjoystick;
  46778. private _rightjoystick;
  46779. /**
  46780. * Gets the left stick of the virtual joystick.
  46781. * @returns The virtual Joystick
  46782. */
  46783. getLeftJoystick(): VirtualJoystick;
  46784. /**
  46785. * Gets the right stick of the virtual joystick.
  46786. * @returns The virtual Joystick
  46787. */
  46788. getRightJoystick(): VirtualJoystick;
  46789. /**
  46790. * Update the current camera state depending on the inputs that have been used this frame.
  46791. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46792. */
  46793. checkInputs(): void;
  46794. /**
  46795. * Attach the input controls to a specific dom element to get the input from.
  46796. * @param element Defines the element the controls should be listened from
  46797. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46798. */
  46799. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46800. /**
  46801. * Detach the current controls from the specified dom element.
  46802. * @param element Defines the element to stop listening the inputs from
  46803. */
  46804. detachControl(element: Nullable<HTMLElement>): void;
  46805. /**
  46806. * Gets the class name of the current intput.
  46807. * @returns the class name
  46808. */
  46809. getClassName(): string;
  46810. /**
  46811. * Get the friendly name associated with the input class.
  46812. * @returns the input friendly name
  46813. */
  46814. getSimpleName(): string;
  46815. }
  46816. }
  46817. declare module "babylonjs/Cameras/Inputs/index" {
  46818. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  46819. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  46820. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  46821. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  46822. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  46823. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  46824. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  46825. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  46826. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  46827. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  46828. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  46829. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  46830. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  46831. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  46832. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  46833. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  46834. }
  46835. declare module "babylonjs/Cameras/touchCamera" {
  46836. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46837. import { Scene } from "babylonjs/scene";
  46838. import { Vector3 } from "babylonjs/Maths/math.vector";
  46839. /**
  46840. * This represents a FPS type of camera controlled by touch.
  46841. * This is like a universal camera minus the Gamepad controls.
  46842. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46843. */
  46844. export class TouchCamera extends FreeCamera {
  46845. /**
  46846. * Defines the touch sensibility for rotation.
  46847. * The higher the faster.
  46848. */
  46849. get touchAngularSensibility(): number;
  46850. set touchAngularSensibility(value: number);
  46851. /**
  46852. * Defines the touch sensibility for move.
  46853. * The higher the faster.
  46854. */
  46855. get touchMoveSensibility(): number;
  46856. set touchMoveSensibility(value: number);
  46857. /**
  46858. * Instantiates a new touch camera.
  46859. * This represents a FPS type of camera controlled by touch.
  46860. * This is like a universal camera minus the Gamepad controls.
  46861. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46862. * @param name Define the name of the camera in the scene
  46863. * @param position Define the start position of the camera in the scene
  46864. * @param scene Define the scene the camera belongs to
  46865. */
  46866. constructor(name: string, position: Vector3, scene: Scene);
  46867. /**
  46868. * Gets the current object class name.
  46869. * @return the class name
  46870. */
  46871. getClassName(): string;
  46872. /** @hidden */
  46873. _setupInputs(): void;
  46874. }
  46875. }
  46876. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  46877. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46878. import { Scene } from "babylonjs/scene";
  46879. import { Vector3 } from "babylonjs/Maths/math.vector";
  46880. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  46881. import { Axis } from "babylonjs/Maths/math.axis";
  46882. /**
  46883. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  46884. * being tilted forward or back and left or right.
  46885. */
  46886. export class DeviceOrientationCamera extends FreeCamera {
  46887. private _initialQuaternion;
  46888. private _quaternionCache;
  46889. private _tmpDragQuaternion;
  46890. private _disablePointerInputWhenUsingDeviceOrientation;
  46891. /**
  46892. * Creates a new device orientation camera
  46893. * @param name The name of the camera
  46894. * @param position The start position camera
  46895. * @param scene The scene the camera belongs to
  46896. */
  46897. constructor(name: string, position: Vector3, scene: Scene);
  46898. /**
  46899. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  46900. */
  46901. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  46902. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  46903. private _dragFactor;
  46904. /**
  46905. * Enabled turning on the y axis when the orientation sensor is active
  46906. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  46907. */
  46908. enableHorizontalDragging(dragFactor?: number): void;
  46909. /**
  46910. * Gets the current instance class name ("DeviceOrientationCamera").
  46911. * This helps avoiding instanceof at run time.
  46912. * @returns the class name
  46913. */
  46914. getClassName(): string;
  46915. /**
  46916. * @hidden
  46917. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  46918. */
  46919. _checkInputs(): void;
  46920. /**
  46921. * Reset the camera to its default orientation on the specified axis only.
  46922. * @param axis The axis to reset
  46923. */
  46924. resetToCurrentRotation(axis?: Axis): void;
  46925. }
  46926. }
  46927. declare module "babylonjs/Gamepads/xboxGamepad" {
  46928. import { Observable } from "babylonjs/Misc/observable";
  46929. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  46930. /**
  46931. * Defines supported buttons for XBox360 compatible gamepads
  46932. */
  46933. export enum Xbox360Button {
  46934. /** A */
  46935. A = 0,
  46936. /** B */
  46937. B = 1,
  46938. /** X */
  46939. X = 2,
  46940. /** Y */
  46941. Y = 3,
  46942. /** Left button */
  46943. LB = 4,
  46944. /** Right button */
  46945. RB = 5,
  46946. /** Back */
  46947. Back = 8,
  46948. /** Start */
  46949. Start = 9,
  46950. /** Left stick */
  46951. LeftStick = 10,
  46952. /** Right stick */
  46953. RightStick = 11
  46954. }
  46955. /** Defines values for XBox360 DPad */
  46956. export enum Xbox360Dpad {
  46957. /** Up */
  46958. Up = 12,
  46959. /** Down */
  46960. Down = 13,
  46961. /** Left */
  46962. Left = 14,
  46963. /** Right */
  46964. Right = 15
  46965. }
  46966. /**
  46967. * Defines a XBox360 gamepad
  46968. */
  46969. export class Xbox360Pad extends Gamepad {
  46970. private _leftTrigger;
  46971. private _rightTrigger;
  46972. private _onlefttriggerchanged;
  46973. private _onrighttriggerchanged;
  46974. private _onbuttondown;
  46975. private _onbuttonup;
  46976. private _ondpaddown;
  46977. private _ondpadup;
  46978. /** Observable raised when a button is pressed */
  46979. onButtonDownObservable: Observable<Xbox360Button>;
  46980. /** Observable raised when a button is released */
  46981. onButtonUpObservable: Observable<Xbox360Button>;
  46982. /** Observable raised when a pad is pressed */
  46983. onPadDownObservable: Observable<Xbox360Dpad>;
  46984. /** Observable raised when a pad is released */
  46985. onPadUpObservable: Observable<Xbox360Dpad>;
  46986. private _buttonA;
  46987. private _buttonB;
  46988. private _buttonX;
  46989. private _buttonY;
  46990. private _buttonBack;
  46991. private _buttonStart;
  46992. private _buttonLB;
  46993. private _buttonRB;
  46994. private _buttonLeftStick;
  46995. private _buttonRightStick;
  46996. private _dPadUp;
  46997. private _dPadDown;
  46998. private _dPadLeft;
  46999. private _dPadRight;
  47000. private _isXboxOnePad;
  47001. /**
  47002. * Creates a new XBox360 gamepad object
  47003. * @param id defines the id of this gamepad
  47004. * @param index defines its index
  47005. * @param gamepad defines the internal HTML gamepad object
  47006. * @param xboxOne defines if it is a XBox One gamepad
  47007. */
  47008. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  47009. /**
  47010. * Defines the callback to call when left trigger is pressed
  47011. * @param callback defines the callback to use
  47012. */
  47013. onlefttriggerchanged(callback: (value: number) => void): void;
  47014. /**
  47015. * Defines the callback to call when right trigger is pressed
  47016. * @param callback defines the callback to use
  47017. */
  47018. onrighttriggerchanged(callback: (value: number) => void): void;
  47019. /**
  47020. * Gets the left trigger value
  47021. */
  47022. get leftTrigger(): number;
  47023. /**
  47024. * Sets the left trigger value
  47025. */
  47026. set leftTrigger(newValue: number);
  47027. /**
  47028. * Gets the right trigger value
  47029. */
  47030. get rightTrigger(): number;
  47031. /**
  47032. * Sets the right trigger value
  47033. */
  47034. set rightTrigger(newValue: number);
  47035. /**
  47036. * Defines the callback to call when a button is pressed
  47037. * @param callback defines the callback to use
  47038. */
  47039. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  47040. /**
  47041. * Defines the callback to call when a button is released
  47042. * @param callback defines the callback to use
  47043. */
  47044. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  47045. /**
  47046. * Defines the callback to call when a pad is pressed
  47047. * @param callback defines the callback to use
  47048. */
  47049. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  47050. /**
  47051. * Defines the callback to call when a pad is released
  47052. * @param callback defines the callback to use
  47053. */
  47054. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  47055. private _setButtonValue;
  47056. private _setDPadValue;
  47057. /**
  47058. * Gets the value of the `A` button
  47059. */
  47060. get buttonA(): number;
  47061. /**
  47062. * Sets the value of the `A` button
  47063. */
  47064. set buttonA(value: number);
  47065. /**
  47066. * Gets the value of the `B` button
  47067. */
  47068. get buttonB(): number;
  47069. /**
  47070. * Sets the value of the `B` button
  47071. */
  47072. set buttonB(value: number);
  47073. /**
  47074. * Gets the value of the `X` button
  47075. */
  47076. get buttonX(): number;
  47077. /**
  47078. * Sets the value of the `X` button
  47079. */
  47080. set buttonX(value: number);
  47081. /**
  47082. * Gets the value of the `Y` button
  47083. */
  47084. get buttonY(): number;
  47085. /**
  47086. * Sets the value of the `Y` button
  47087. */
  47088. set buttonY(value: number);
  47089. /**
  47090. * Gets the value of the `Start` button
  47091. */
  47092. get buttonStart(): number;
  47093. /**
  47094. * Sets the value of the `Start` button
  47095. */
  47096. set buttonStart(value: number);
  47097. /**
  47098. * Gets the value of the `Back` button
  47099. */
  47100. get buttonBack(): number;
  47101. /**
  47102. * Sets the value of the `Back` button
  47103. */
  47104. set buttonBack(value: number);
  47105. /**
  47106. * Gets the value of the `Left` button
  47107. */
  47108. get buttonLB(): number;
  47109. /**
  47110. * Sets the value of the `Left` button
  47111. */
  47112. set buttonLB(value: number);
  47113. /**
  47114. * Gets the value of the `Right` button
  47115. */
  47116. get buttonRB(): number;
  47117. /**
  47118. * Sets the value of the `Right` button
  47119. */
  47120. set buttonRB(value: number);
  47121. /**
  47122. * Gets the value of the Left joystick
  47123. */
  47124. get buttonLeftStick(): number;
  47125. /**
  47126. * Sets the value of the Left joystick
  47127. */
  47128. set buttonLeftStick(value: number);
  47129. /**
  47130. * Gets the value of the Right joystick
  47131. */
  47132. get buttonRightStick(): number;
  47133. /**
  47134. * Sets the value of the Right joystick
  47135. */
  47136. set buttonRightStick(value: number);
  47137. /**
  47138. * Gets the value of D-pad up
  47139. */
  47140. get dPadUp(): number;
  47141. /**
  47142. * Sets the value of D-pad up
  47143. */
  47144. set dPadUp(value: number);
  47145. /**
  47146. * Gets the value of D-pad down
  47147. */
  47148. get dPadDown(): number;
  47149. /**
  47150. * Sets the value of D-pad down
  47151. */
  47152. set dPadDown(value: number);
  47153. /**
  47154. * Gets the value of D-pad left
  47155. */
  47156. get dPadLeft(): number;
  47157. /**
  47158. * Sets the value of D-pad left
  47159. */
  47160. set dPadLeft(value: number);
  47161. /**
  47162. * Gets the value of D-pad right
  47163. */
  47164. get dPadRight(): number;
  47165. /**
  47166. * Sets the value of D-pad right
  47167. */
  47168. set dPadRight(value: number);
  47169. /**
  47170. * Force the gamepad to synchronize with device values
  47171. */
  47172. update(): void;
  47173. /**
  47174. * Disposes the gamepad
  47175. */
  47176. dispose(): void;
  47177. }
  47178. }
  47179. declare module "babylonjs/Gamepads/dualShockGamepad" {
  47180. import { Observable } from "babylonjs/Misc/observable";
  47181. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  47182. /**
  47183. * Defines supported buttons for DualShock compatible gamepads
  47184. */
  47185. export enum DualShockButton {
  47186. /** Cross */
  47187. Cross = 0,
  47188. /** Circle */
  47189. Circle = 1,
  47190. /** Square */
  47191. Square = 2,
  47192. /** Triangle */
  47193. Triangle = 3,
  47194. /** L1 */
  47195. L1 = 4,
  47196. /** R1 */
  47197. R1 = 5,
  47198. /** Share */
  47199. Share = 8,
  47200. /** Options */
  47201. Options = 9,
  47202. /** Left stick */
  47203. LeftStick = 10,
  47204. /** Right stick */
  47205. RightStick = 11
  47206. }
  47207. /** Defines values for DualShock DPad */
  47208. export enum DualShockDpad {
  47209. /** Up */
  47210. Up = 12,
  47211. /** Down */
  47212. Down = 13,
  47213. /** Left */
  47214. Left = 14,
  47215. /** Right */
  47216. Right = 15
  47217. }
  47218. /**
  47219. * Defines a DualShock gamepad
  47220. */
  47221. export class DualShockPad extends Gamepad {
  47222. private _leftTrigger;
  47223. private _rightTrigger;
  47224. private _onlefttriggerchanged;
  47225. private _onrighttriggerchanged;
  47226. private _onbuttondown;
  47227. private _onbuttonup;
  47228. private _ondpaddown;
  47229. private _ondpadup;
  47230. /** Observable raised when a button is pressed */
  47231. onButtonDownObservable: Observable<DualShockButton>;
  47232. /** Observable raised when a button is released */
  47233. onButtonUpObservable: Observable<DualShockButton>;
  47234. /** Observable raised when a pad is pressed */
  47235. onPadDownObservable: Observable<DualShockDpad>;
  47236. /** Observable raised when a pad is released */
  47237. onPadUpObservable: Observable<DualShockDpad>;
  47238. private _buttonCross;
  47239. private _buttonCircle;
  47240. private _buttonSquare;
  47241. private _buttonTriangle;
  47242. private _buttonShare;
  47243. private _buttonOptions;
  47244. private _buttonL1;
  47245. private _buttonR1;
  47246. private _buttonLeftStick;
  47247. private _buttonRightStick;
  47248. private _dPadUp;
  47249. private _dPadDown;
  47250. private _dPadLeft;
  47251. private _dPadRight;
  47252. /**
  47253. * Creates a new DualShock gamepad object
  47254. * @param id defines the id of this gamepad
  47255. * @param index defines its index
  47256. * @param gamepad defines the internal HTML gamepad object
  47257. */
  47258. constructor(id: string, index: number, gamepad: any);
  47259. /**
  47260. * Defines the callback to call when left trigger is pressed
  47261. * @param callback defines the callback to use
  47262. */
  47263. onlefttriggerchanged(callback: (value: number) => void): void;
  47264. /**
  47265. * Defines the callback to call when right trigger is pressed
  47266. * @param callback defines the callback to use
  47267. */
  47268. onrighttriggerchanged(callback: (value: number) => void): void;
  47269. /**
  47270. * Gets the left trigger value
  47271. */
  47272. get leftTrigger(): number;
  47273. /**
  47274. * Sets the left trigger value
  47275. */
  47276. set leftTrigger(newValue: number);
  47277. /**
  47278. * Gets the right trigger value
  47279. */
  47280. get rightTrigger(): number;
  47281. /**
  47282. * Sets the right trigger value
  47283. */
  47284. set rightTrigger(newValue: number);
  47285. /**
  47286. * Defines the callback to call when a button is pressed
  47287. * @param callback defines the callback to use
  47288. */
  47289. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  47290. /**
  47291. * Defines the callback to call when a button is released
  47292. * @param callback defines the callback to use
  47293. */
  47294. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  47295. /**
  47296. * Defines the callback to call when a pad is pressed
  47297. * @param callback defines the callback to use
  47298. */
  47299. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  47300. /**
  47301. * Defines the callback to call when a pad is released
  47302. * @param callback defines the callback to use
  47303. */
  47304. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  47305. private _setButtonValue;
  47306. private _setDPadValue;
  47307. /**
  47308. * Gets the value of the `Cross` button
  47309. */
  47310. get buttonCross(): number;
  47311. /**
  47312. * Sets the value of the `Cross` button
  47313. */
  47314. set buttonCross(value: number);
  47315. /**
  47316. * Gets the value of the `Circle` button
  47317. */
  47318. get buttonCircle(): number;
  47319. /**
  47320. * Sets the value of the `Circle` button
  47321. */
  47322. set buttonCircle(value: number);
  47323. /**
  47324. * Gets the value of the `Square` button
  47325. */
  47326. get buttonSquare(): number;
  47327. /**
  47328. * Sets the value of the `Square` button
  47329. */
  47330. set buttonSquare(value: number);
  47331. /**
  47332. * Gets the value of the `Triangle` button
  47333. */
  47334. get buttonTriangle(): number;
  47335. /**
  47336. * Sets the value of the `Triangle` button
  47337. */
  47338. set buttonTriangle(value: number);
  47339. /**
  47340. * Gets the value of the `Options` button
  47341. */
  47342. get buttonOptions(): number;
  47343. /**
  47344. * Sets the value of the `Options` button
  47345. */
  47346. set buttonOptions(value: number);
  47347. /**
  47348. * Gets the value of the `Share` button
  47349. */
  47350. get buttonShare(): number;
  47351. /**
  47352. * Sets the value of the `Share` button
  47353. */
  47354. set buttonShare(value: number);
  47355. /**
  47356. * Gets the value of the `L1` button
  47357. */
  47358. get buttonL1(): number;
  47359. /**
  47360. * Sets the value of the `L1` button
  47361. */
  47362. set buttonL1(value: number);
  47363. /**
  47364. * Gets the value of the `R1` button
  47365. */
  47366. get buttonR1(): number;
  47367. /**
  47368. * Sets the value of the `R1` button
  47369. */
  47370. set buttonR1(value: number);
  47371. /**
  47372. * Gets the value of the Left joystick
  47373. */
  47374. get buttonLeftStick(): number;
  47375. /**
  47376. * Sets the value of the Left joystick
  47377. */
  47378. set buttonLeftStick(value: number);
  47379. /**
  47380. * Gets the value of the Right joystick
  47381. */
  47382. get buttonRightStick(): number;
  47383. /**
  47384. * Sets the value of the Right joystick
  47385. */
  47386. set buttonRightStick(value: number);
  47387. /**
  47388. * Gets the value of D-pad up
  47389. */
  47390. get dPadUp(): number;
  47391. /**
  47392. * Sets the value of D-pad up
  47393. */
  47394. set dPadUp(value: number);
  47395. /**
  47396. * Gets the value of D-pad down
  47397. */
  47398. get dPadDown(): number;
  47399. /**
  47400. * Sets the value of D-pad down
  47401. */
  47402. set dPadDown(value: number);
  47403. /**
  47404. * Gets the value of D-pad left
  47405. */
  47406. get dPadLeft(): number;
  47407. /**
  47408. * Sets the value of D-pad left
  47409. */
  47410. set dPadLeft(value: number);
  47411. /**
  47412. * Gets the value of D-pad right
  47413. */
  47414. get dPadRight(): number;
  47415. /**
  47416. * Sets the value of D-pad right
  47417. */
  47418. set dPadRight(value: number);
  47419. /**
  47420. * Force the gamepad to synchronize with device values
  47421. */
  47422. update(): void;
  47423. /**
  47424. * Disposes the gamepad
  47425. */
  47426. dispose(): void;
  47427. }
  47428. }
  47429. declare module "babylonjs/Gamepads/gamepadManager" {
  47430. import { Observable } from "babylonjs/Misc/observable";
  47431. import { Nullable } from "babylonjs/types";
  47432. import { Scene } from "babylonjs/scene";
  47433. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  47434. /**
  47435. * Manager for handling gamepads
  47436. */
  47437. export class GamepadManager {
  47438. private _scene?;
  47439. private _babylonGamepads;
  47440. private _oneGamepadConnected;
  47441. /** @hidden */
  47442. _isMonitoring: boolean;
  47443. private _gamepadEventSupported;
  47444. private _gamepadSupport?;
  47445. /**
  47446. * observable to be triggered when the gamepad controller has been connected
  47447. */
  47448. onGamepadConnectedObservable: Observable<Gamepad>;
  47449. /**
  47450. * observable to be triggered when the gamepad controller has been disconnected
  47451. */
  47452. onGamepadDisconnectedObservable: Observable<Gamepad>;
  47453. private _onGamepadConnectedEvent;
  47454. private _onGamepadDisconnectedEvent;
  47455. /**
  47456. * Initializes the gamepad manager
  47457. * @param _scene BabylonJS scene
  47458. */
  47459. constructor(_scene?: Scene | undefined);
  47460. /**
  47461. * The gamepads in the game pad manager
  47462. */
  47463. get gamepads(): Gamepad[];
  47464. /**
  47465. * Get the gamepad controllers based on type
  47466. * @param type The type of gamepad controller
  47467. * @returns Nullable gamepad
  47468. */
  47469. getGamepadByType(type?: number): Nullable<Gamepad>;
  47470. /**
  47471. * Disposes the gamepad manager
  47472. */
  47473. dispose(): void;
  47474. private _addNewGamepad;
  47475. private _startMonitoringGamepads;
  47476. private _stopMonitoringGamepads;
  47477. /** @hidden */
  47478. _checkGamepadsStatus(): void;
  47479. private _updateGamepadObjects;
  47480. }
  47481. }
  47482. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  47483. import { Nullable } from "babylonjs/types";
  47484. import { Scene } from "babylonjs/scene";
  47485. import { ISceneComponent } from "babylonjs/sceneComponent";
  47486. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  47487. module "babylonjs/scene" {
  47488. interface Scene {
  47489. /** @hidden */
  47490. _gamepadManager: Nullable<GamepadManager>;
  47491. /**
  47492. * Gets the gamepad manager associated with the scene
  47493. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  47494. */
  47495. gamepadManager: GamepadManager;
  47496. }
  47497. }
  47498. module "babylonjs/Cameras/freeCameraInputsManager" {
  47499. /**
  47500. * Interface representing a free camera inputs manager
  47501. */
  47502. interface FreeCameraInputsManager {
  47503. /**
  47504. * Adds gamepad input support to the FreeCameraInputsManager.
  47505. * @returns the FreeCameraInputsManager
  47506. */
  47507. addGamepad(): FreeCameraInputsManager;
  47508. }
  47509. }
  47510. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  47511. /**
  47512. * Interface representing an arc rotate camera inputs manager
  47513. */
  47514. interface ArcRotateCameraInputsManager {
  47515. /**
  47516. * Adds gamepad input support to the ArcRotateCamera InputManager.
  47517. * @returns the camera inputs manager
  47518. */
  47519. addGamepad(): ArcRotateCameraInputsManager;
  47520. }
  47521. }
  47522. /**
  47523. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  47524. */
  47525. export class GamepadSystemSceneComponent implements ISceneComponent {
  47526. /**
  47527. * The component name helpfull to identify the component in the list of scene components.
  47528. */
  47529. readonly name: string;
  47530. /**
  47531. * The scene the component belongs to.
  47532. */
  47533. scene: Scene;
  47534. /**
  47535. * Creates a new instance of the component for the given scene
  47536. * @param scene Defines the scene to register the component in
  47537. */
  47538. constructor(scene: Scene);
  47539. /**
  47540. * Registers the component in a given scene
  47541. */
  47542. register(): void;
  47543. /**
  47544. * Rebuilds the elements related to this component in case of
  47545. * context lost for instance.
  47546. */
  47547. rebuild(): void;
  47548. /**
  47549. * Disposes the component and the associated ressources
  47550. */
  47551. dispose(): void;
  47552. private _beforeCameraUpdate;
  47553. }
  47554. }
  47555. declare module "babylonjs/Cameras/universalCamera" {
  47556. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  47557. import { Scene } from "babylonjs/scene";
  47558. import { Vector3 } from "babylonjs/Maths/math.vector";
  47559. import "babylonjs/Gamepads/gamepadSceneComponent";
  47560. /**
  47561. * 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,
  47562. * which still works and will still be found in many Playgrounds.
  47563. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47564. */
  47565. export class UniversalCamera extends TouchCamera {
  47566. /**
  47567. * Defines the gamepad rotation sensiblity.
  47568. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  47569. */
  47570. get gamepadAngularSensibility(): number;
  47571. set gamepadAngularSensibility(value: number);
  47572. /**
  47573. * Defines the gamepad move sensiblity.
  47574. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  47575. */
  47576. get gamepadMoveSensibility(): number;
  47577. set gamepadMoveSensibility(value: number);
  47578. /**
  47579. * 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,
  47580. * which still works and will still be found in many Playgrounds.
  47581. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47582. * @param name Define the name of the camera in the scene
  47583. * @param position Define the start position of the camera in the scene
  47584. * @param scene Define the scene the camera belongs to
  47585. */
  47586. constructor(name: string, position: Vector3, scene: Scene);
  47587. /**
  47588. * Gets the current object class name.
  47589. * @return the class name
  47590. */
  47591. getClassName(): string;
  47592. }
  47593. }
  47594. declare module "babylonjs/Cameras/gamepadCamera" {
  47595. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  47596. import { Scene } from "babylonjs/scene";
  47597. import { Vector3 } from "babylonjs/Maths/math.vector";
  47598. /**
  47599. * This represents a FPS type of camera. This is only here for back compat purpose.
  47600. * Please use the UniversalCamera instead as both are identical.
  47601. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47602. */
  47603. export class GamepadCamera extends UniversalCamera {
  47604. /**
  47605. * Instantiates a new Gamepad Camera
  47606. * This represents a FPS type of camera. This is only here for back compat purpose.
  47607. * Please use the UniversalCamera instead as both are identical.
  47608. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47609. * @param name Define the name of the camera in the scene
  47610. * @param position Define the start position of the camera in the scene
  47611. * @param scene Define the scene the camera belongs to
  47612. */
  47613. constructor(name: string, position: Vector3, scene: Scene);
  47614. /**
  47615. * Gets the current object class name.
  47616. * @return the class name
  47617. */
  47618. getClassName(): string;
  47619. }
  47620. }
  47621. declare module "babylonjs/Shaders/pass.fragment" {
  47622. /** @hidden */
  47623. export var passPixelShader: {
  47624. name: string;
  47625. shader: string;
  47626. };
  47627. }
  47628. declare module "babylonjs/Shaders/passCube.fragment" {
  47629. /** @hidden */
  47630. export var passCubePixelShader: {
  47631. name: string;
  47632. shader: string;
  47633. };
  47634. }
  47635. declare module "babylonjs/PostProcesses/passPostProcess" {
  47636. import { Nullable } from "babylonjs/types";
  47637. import { Camera } from "babylonjs/Cameras/camera";
  47638. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  47639. import { Engine } from "babylonjs/Engines/engine";
  47640. import "babylonjs/Shaders/pass.fragment";
  47641. import "babylonjs/Shaders/passCube.fragment";
  47642. import { Scene } from "babylonjs/scene";
  47643. /**
  47644. * PassPostProcess which produces an output the same as it's input
  47645. */
  47646. export class PassPostProcess extends PostProcess {
  47647. /**
  47648. * Gets a string identifying the name of the class
  47649. * @returns "PassPostProcess" string
  47650. */
  47651. getClassName(): string;
  47652. /**
  47653. * Creates the PassPostProcess
  47654. * @param name The name of the effect.
  47655. * @param options The required width/height ratio to downsize to before computing the render pass.
  47656. * @param camera The camera to apply the render pass to.
  47657. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  47658. * @param engine The engine which the post process will be applied. (default: current engine)
  47659. * @param reusable If the post process can be reused on the same frame. (default: false)
  47660. * @param textureType The type of texture to be used when performing the post processing.
  47661. * @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)
  47662. */
  47663. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  47664. /** @hidden */
  47665. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  47666. }
  47667. /**
  47668. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  47669. */
  47670. export class PassCubePostProcess extends PostProcess {
  47671. private _face;
  47672. /**
  47673. * Gets or sets the cube face to display.
  47674. * * 0 is +X
  47675. * * 1 is -X
  47676. * * 2 is +Y
  47677. * * 3 is -Y
  47678. * * 4 is +Z
  47679. * * 5 is -Z
  47680. */
  47681. get face(): number;
  47682. set face(value: number);
  47683. /**
  47684. * Gets a string identifying the name of the class
  47685. * @returns "PassCubePostProcess" string
  47686. */
  47687. getClassName(): string;
  47688. /**
  47689. * Creates the PassCubePostProcess
  47690. * @param name The name of the effect.
  47691. * @param options The required width/height ratio to downsize to before computing the render pass.
  47692. * @param camera The camera to apply the render pass to.
  47693. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  47694. * @param engine The engine which the post process will be applied. (default: current engine)
  47695. * @param reusable If the post process can be reused on the same frame. (default: false)
  47696. * @param textureType The type of texture to be used when performing the post processing.
  47697. * @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)
  47698. */
  47699. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  47700. /** @hidden */
  47701. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  47702. }
  47703. }
  47704. declare module "babylonjs/Shaders/anaglyph.fragment" {
  47705. /** @hidden */
  47706. export var anaglyphPixelShader: {
  47707. name: string;
  47708. shader: string;
  47709. };
  47710. }
  47711. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  47712. import { Engine } from "babylonjs/Engines/engine";
  47713. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  47714. import { Camera } from "babylonjs/Cameras/camera";
  47715. import "babylonjs/Shaders/anaglyph.fragment";
  47716. /**
  47717. * Postprocess used to generate anaglyphic rendering
  47718. */
  47719. export class AnaglyphPostProcess extends PostProcess {
  47720. private _passedProcess;
  47721. /**
  47722. * Gets a string identifying the name of the class
  47723. * @returns "AnaglyphPostProcess" string
  47724. */
  47725. getClassName(): string;
  47726. /**
  47727. * Creates a new AnaglyphPostProcess
  47728. * @param name defines postprocess name
  47729. * @param options defines creation options or target ratio scale
  47730. * @param rigCameras defines cameras using this postprocess
  47731. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  47732. * @param engine defines hosting engine
  47733. * @param reusable defines if the postprocess will be reused multiple times per frame
  47734. */
  47735. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  47736. }
  47737. }
  47738. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  47739. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  47740. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47741. import { Scene } from "babylonjs/scene";
  47742. import { Vector3 } from "babylonjs/Maths/math.vector";
  47743. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47744. /**
  47745. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  47746. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47747. */
  47748. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  47749. /**
  47750. * Creates a new AnaglyphArcRotateCamera
  47751. * @param name defines camera name
  47752. * @param alpha defines alpha angle (in radians)
  47753. * @param beta defines beta angle (in radians)
  47754. * @param radius defines radius
  47755. * @param target defines camera target
  47756. * @param interaxialDistance defines distance between each color axis
  47757. * @param scene defines the hosting scene
  47758. */
  47759. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  47760. /**
  47761. * Gets camera class name
  47762. * @returns AnaglyphArcRotateCamera
  47763. */
  47764. getClassName(): string;
  47765. }
  47766. }
  47767. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  47768. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47769. import { Scene } from "babylonjs/scene";
  47770. import { Vector3 } from "babylonjs/Maths/math.vector";
  47771. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47772. /**
  47773. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  47774. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47775. */
  47776. export class AnaglyphFreeCamera extends FreeCamera {
  47777. /**
  47778. * Creates a new AnaglyphFreeCamera
  47779. * @param name defines camera name
  47780. * @param position defines initial position
  47781. * @param interaxialDistance defines distance between each color axis
  47782. * @param scene defines the hosting scene
  47783. */
  47784. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  47785. /**
  47786. * Gets camera class name
  47787. * @returns AnaglyphFreeCamera
  47788. */
  47789. getClassName(): string;
  47790. }
  47791. }
  47792. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  47793. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  47794. import { Scene } from "babylonjs/scene";
  47795. import { Vector3 } from "babylonjs/Maths/math.vector";
  47796. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47797. /**
  47798. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  47799. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47800. */
  47801. export class AnaglyphGamepadCamera extends GamepadCamera {
  47802. /**
  47803. * Creates a new AnaglyphGamepadCamera
  47804. * @param name defines camera name
  47805. * @param position defines initial position
  47806. * @param interaxialDistance defines distance between each color axis
  47807. * @param scene defines the hosting scene
  47808. */
  47809. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  47810. /**
  47811. * Gets camera class name
  47812. * @returns AnaglyphGamepadCamera
  47813. */
  47814. getClassName(): string;
  47815. }
  47816. }
  47817. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  47818. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  47819. import { Scene } from "babylonjs/scene";
  47820. import { Vector3 } from "babylonjs/Maths/math.vector";
  47821. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47822. /**
  47823. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  47824. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47825. */
  47826. export class AnaglyphUniversalCamera extends UniversalCamera {
  47827. /**
  47828. * Creates a new AnaglyphUniversalCamera
  47829. * @param name defines camera name
  47830. * @param position defines initial position
  47831. * @param interaxialDistance defines distance between each color axis
  47832. * @param scene defines the hosting scene
  47833. */
  47834. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  47835. /**
  47836. * Gets camera class name
  47837. * @returns AnaglyphUniversalCamera
  47838. */
  47839. getClassName(): string;
  47840. }
  47841. }
  47842. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  47843. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  47844. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47845. import { Scene } from "babylonjs/scene";
  47846. import { Vector3 } from "babylonjs/Maths/math.vector";
  47847. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47848. /**
  47849. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  47850. * @see https://doc.babylonjs.com/features/cameras
  47851. */
  47852. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  47853. /**
  47854. * Creates a new StereoscopicArcRotateCamera
  47855. * @param name defines camera name
  47856. * @param alpha defines alpha angle (in radians)
  47857. * @param beta defines beta angle (in radians)
  47858. * @param radius defines radius
  47859. * @param target defines camera target
  47860. * @param interaxialDistance defines distance between each color axis
  47861. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  47862. * @param scene defines the hosting scene
  47863. */
  47864. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  47865. /**
  47866. * Gets camera class name
  47867. * @returns StereoscopicArcRotateCamera
  47868. */
  47869. getClassName(): string;
  47870. }
  47871. }
  47872. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  47873. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47874. import { Scene } from "babylonjs/scene";
  47875. import { Vector3 } from "babylonjs/Maths/math.vector";
  47876. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47877. /**
  47878. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  47879. * @see https://doc.babylonjs.com/features/cameras
  47880. */
  47881. export class StereoscopicFreeCamera extends FreeCamera {
  47882. /**
  47883. * Creates a new StereoscopicFreeCamera
  47884. * @param name defines camera name
  47885. * @param position defines initial position
  47886. * @param interaxialDistance defines distance between each color axis
  47887. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  47888. * @param scene defines the hosting scene
  47889. */
  47890. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  47891. /**
  47892. * Gets camera class name
  47893. * @returns StereoscopicFreeCamera
  47894. */
  47895. getClassName(): string;
  47896. }
  47897. }
  47898. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  47899. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  47900. import { Scene } from "babylonjs/scene";
  47901. import { Vector3 } from "babylonjs/Maths/math.vector";
  47902. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47903. /**
  47904. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  47905. * @see https://doc.babylonjs.com/features/cameras
  47906. */
  47907. export class StereoscopicGamepadCamera extends GamepadCamera {
  47908. /**
  47909. * Creates a new StereoscopicGamepadCamera
  47910. * @param name defines camera name
  47911. * @param position defines initial position
  47912. * @param interaxialDistance defines distance between each color axis
  47913. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  47914. * @param scene defines the hosting scene
  47915. */
  47916. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  47917. /**
  47918. * Gets camera class name
  47919. * @returns StereoscopicGamepadCamera
  47920. */
  47921. getClassName(): string;
  47922. }
  47923. }
  47924. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  47925. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  47926. import { Scene } from "babylonjs/scene";
  47927. import { Vector3 } from "babylonjs/Maths/math.vector";
  47928. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47929. /**
  47930. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  47931. * @see https://doc.babylonjs.com/features/cameras
  47932. */
  47933. export class StereoscopicUniversalCamera extends UniversalCamera {
  47934. /**
  47935. * Creates a new StereoscopicUniversalCamera
  47936. * @param name defines camera name
  47937. * @param position defines initial position
  47938. * @param interaxialDistance defines distance between each color axis
  47939. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  47940. * @param scene defines the hosting scene
  47941. */
  47942. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  47943. /**
  47944. * Gets camera class name
  47945. * @returns StereoscopicUniversalCamera
  47946. */
  47947. getClassName(): string;
  47948. }
  47949. }
  47950. declare module "babylonjs/Cameras/Stereoscopic/index" {
  47951. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  47952. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  47953. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  47954. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  47955. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  47956. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  47957. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  47958. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  47959. }
  47960. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  47961. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47962. import { Scene } from "babylonjs/scene";
  47963. import { Vector3 } from "babylonjs/Maths/math.vector";
  47964. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  47965. /**
  47966. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  47967. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  47968. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  47969. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  47970. */
  47971. export class VirtualJoysticksCamera extends FreeCamera {
  47972. /**
  47973. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  47974. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  47975. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  47976. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  47977. * @param name Define the name of the camera in the scene
  47978. * @param position Define the start position of the camera in the scene
  47979. * @param scene Define the scene the camera belongs to
  47980. */
  47981. constructor(name: string, position: Vector3, scene: Scene);
  47982. /**
  47983. * Gets the current object class name.
  47984. * @return the class name
  47985. */
  47986. getClassName(): string;
  47987. }
  47988. }
  47989. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  47990. import { Matrix } from "babylonjs/Maths/math.vector";
  47991. /**
  47992. * This represents all the required metrics to create a VR camera.
  47993. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  47994. */
  47995. export class VRCameraMetrics {
  47996. /**
  47997. * Define the horizontal resolution off the screen.
  47998. */
  47999. hResolution: number;
  48000. /**
  48001. * Define the vertical resolution off the screen.
  48002. */
  48003. vResolution: number;
  48004. /**
  48005. * Define the horizontal screen size.
  48006. */
  48007. hScreenSize: number;
  48008. /**
  48009. * Define the vertical screen size.
  48010. */
  48011. vScreenSize: number;
  48012. /**
  48013. * Define the vertical screen center position.
  48014. */
  48015. vScreenCenter: number;
  48016. /**
  48017. * Define the distance of the eyes to the screen.
  48018. */
  48019. eyeToScreenDistance: number;
  48020. /**
  48021. * Define the distance between both lenses
  48022. */
  48023. lensSeparationDistance: number;
  48024. /**
  48025. * Define the distance between both viewer's eyes.
  48026. */
  48027. interpupillaryDistance: number;
  48028. /**
  48029. * Define the distortion factor of the VR postprocess.
  48030. * Please, touch with care.
  48031. */
  48032. distortionK: number[];
  48033. /**
  48034. * Define the chromatic aberration correction factors for the VR post process.
  48035. */
  48036. chromaAbCorrection: number[];
  48037. /**
  48038. * Define the scale factor of the post process.
  48039. * The smaller the better but the slower.
  48040. */
  48041. postProcessScaleFactor: number;
  48042. /**
  48043. * Define an offset for the lens center.
  48044. */
  48045. lensCenterOffset: number;
  48046. /**
  48047. * Define if the current vr camera should compensate the distortion of the lense or not.
  48048. */
  48049. compensateDistortion: boolean;
  48050. /**
  48051. * Defines if multiview should be enabled when rendering (Default: false)
  48052. */
  48053. multiviewEnabled: boolean;
  48054. /**
  48055. * Gets the rendering aspect ratio based on the provided resolutions.
  48056. */
  48057. get aspectRatio(): number;
  48058. /**
  48059. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  48060. */
  48061. get aspectRatioFov(): number;
  48062. /**
  48063. * @hidden
  48064. */
  48065. get leftHMatrix(): Matrix;
  48066. /**
  48067. * @hidden
  48068. */
  48069. get rightHMatrix(): Matrix;
  48070. /**
  48071. * @hidden
  48072. */
  48073. get leftPreViewMatrix(): Matrix;
  48074. /**
  48075. * @hidden
  48076. */
  48077. get rightPreViewMatrix(): Matrix;
  48078. /**
  48079. * Get the default VRMetrics based on the most generic setup.
  48080. * @returns the default vr metrics
  48081. */
  48082. static GetDefault(): VRCameraMetrics;
  48083. }
  48084. }
  48085. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  48086. /** @hidden */
  48087. export var vrDistortionCorrectionPixelShader: {
  48088. name: string;
  48089. shader: string;
  48090. };
  48091. }
  48092. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  48093. import { Camera } from "babylonjs/Cameras/camera";
  48094. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48095. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  48096. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  48097. /**
  48098. * VRDistortionCorrectionPostProcess used for mobile VR
  48099. */
  48100. export class VRDistortionCorrectionPostProcess extends PostProcess {
  48101. private _isRightEye;
  48102. private _distortionFactors;
  48103. private _postProcessScaleFactor;
  48104. private _lensCenterOffset;
  48105. private _scaleIn;
  48106. private _scaleFactor;
  48107. private _lensCenter;
  48108. /**
  48109. * Gets a string identifying the name of the class
  48110. * @returns "VRDistortionCorrectionPostProcess" string
  48111. */
  48112. getClassName(): string;
  48113. /**
  48114. * Initializes the VRDistortionCorrectionPostProcess
  48115. * @param name The name of the effect.
  48116. * @param camera The camera to apply the render pass to.
  48117. * @param isRightEye If this is for the right eye distortion
  48118. * @param vrMetrics All the required metrics for the VR camera
  48119. */
  48120. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  48121. }
  48122. }
  48123. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  48124. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  48125. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48126. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48127. import { Scene } from "babylonjs/scene";
  48128. import { Vector3 } from "babylonjs/Maths/math.vector";
  48129. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  48130. import "babylonjs/Cameras/RigModes/vrRigMode";
  48131. /**
  48132. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  48133. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48134. */
  48135. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  48136. /**
  48137. * Creates a new VRDeviceOrientationArcRotateCamera
  48138. * @param name defines camera name
  48139. * @param alpha defines the camera rotation along the logitudinal axis
  48140. * @param beta defines the camera rotation along the latitudinal axis
  48141. * @param radius defines the camera distance from its target
  48142. * @param target defines the camera target
  48143. * @param scene defines the scene the camera belongs to
  48144. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48145. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48146. */
  48147. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48148. /**
  48149. * Gets camera class name
  48150. * @returns VRDeviceOrientationArcRotateCamera
  48151. */
  48152. getClassName(): string;
  48153. }
  48154. }
  48155. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  48156. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  48157. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48158. import { Scene } from "babylonjs/scene";
  48159. import { Vector3 } from "babylonjs/Maths/math.vector";
  48160. import "babylonjs/Cameras/RigModes/vrRigMode";
  48161. /**
  48162. * Camera used to simulate VR rendering (based on FreeCamera)
  48163. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48164. */
  48165. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  48166. /**
  48167. * Creates a new VRDeviceOrientationFreeCamera
  48168. * @param name defines camera name
  48169. * @param position defines the start position of the camera
  48170. * @param scene defines the scene the camera belongs to
  48171. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48172. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48173. */
  48174. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48175. /**
  48176. * Gets camera class name
  48177. * @returns VRDeviceOrientationFreeCamera
  48178. */
  48179. getClassName(): string;
  48180. }
  48181. }
  48182. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  48183. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  48184. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48185. import { Scene } from "babylonjs/scene";
  48186. import { Vector3 } from "babylonjs/Maths/math.vector";
  48187. import "babylonjs/Gamepads/gamepadSceneComponent";
  48188. /**
  48189. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  48190. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48191. */
  48192. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  48193. /**
  48194. * Creates a new VRDeviceOrientationGamepadCamera
  48195. * @param name defines camera name
  48196. * @param position defines the start position of the camera
  48197. * @param scene defines the scene the camera belongs to
  48198. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48199. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48200. */
  48201. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48202. /**
  48203. * Gets camera class name
  48204. * @returns VRDeviceOrientationGamepadCamera
  48205. */
  48206. getClassName(): string;
  48207. }
  48208. }
  48209. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  48210. import { Scene } from "babylonjs/scene";
  48211. import { Texture } from "babylonjs/Materials/Textures/texture";
  48212. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  48213. /**
  48214. * A class extending Texture allowing drawing on a texture
  48215. * @see https://doc.babylonjs.com/how_to/dynamictexture
  48216. */
  48217. export class DynamicTexture extends Texture {
  48218. private _generateMipMaps;
  48219. private _canvas;
  48220. private _context;
  48221. /**
  48222. * Creates a DynamicTexture
  48223. * @param name defines the name of the texture
  48224. * @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
  48225. * @param scene defines the scene where you want the texture
  48226. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  48227. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  48228. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  48229. */
  48230. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  48231. /**
  48232. * Get the current class name of the texture useful for serialization or dynamic coding.
  48233. * @returns "DynamicTexture"
  48234. */
  48235. getClassName(): string;
  48236. /**
  48237. * Gets the current state of canRescale
  48238. */
  48239. get canRescale(): boolean;
  48240. private _recreate;
  48241. /**
  48242. * Scales the texture
  48243. * @param ratio the scale factor to apply to both width and height
  48244. */
  48245. scale(ratio: number): void;
  48246. /**
  48247. * Resizes the texture
  48248. * @param width the new width
  48249. * @param height the new height
  48250. */
  48251. scaleTo(width: number, height: number): void;
  48252. /**
  48253. * Gets the context of the canvas used by the texture
  48254. * @returns the canvas context of the dynamic texture
  48255. */
  48256. getContext(): CanvasRenderingContext2D;
  48257. /**
  48258. * Clears the texture
  48259. */
  48260. clear(): void;
  48261. /**
  48262. * Updates the texture
  48263. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  48264. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  48265. */
  48266. update(invertY?: boolean, premulAlpha?: boolean): void;
  48267. /**
  48268. * Draws text onto the texture
  48269. * @param text defines the text to be drawn
  48270. * @param x defines the placement of the text from the left
  48271. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  48272. * @param font defines the font to be used with font-style, font-size, font-name
  48273. * @param color defines the color used for the text
  48274. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  48275. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  48276. * @param update defines whether texture is immediately update (default is true)
  48277. */
  48278. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  48279. /**
  48280. * Clones the texture
  48281. * @returns the clone of the texture.
  48282. */
  48283. clone(): DynamicTexture;
  48284. /**
  48285. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  48286. * @returns a serialized dynamic texture object
  48287. */
  48288. serialize(): any;
  48289. private _IsCanvasElement;
  48290. /** @hidden */
  48291. _rebuild(): void;
  48292. }
  48293. }
  48294. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  48295. import { Scene } from "babylonjs/scene";
  48296. import { Color3 } from "babylonjs/Maths/math.color";
  48297. import { Mesh } from "babylonjs/Meshes/mesh";
  48298. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  48299. import { Nullable } from "babylonjs/types";
  48300. /**
  48301. * Class containing static functions to help procedurally build meshes
  48302. */
  48303. export class GroundBuilder {
  48304. /**
  48305. * Creates a ground mesh
  48306. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  48307. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  48308. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48309. * @param name defines the name of the mesh
  48310. * @param options defines the options used to create the mesh
  48311. * @param scene defines the hosting scene
  48312. * @returns the ground mesh
  48313. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  48314. */
  48315. static CreateGround(name: string, options: {
  48316. width?: number;
  48317. height?: number;
  48318. subdivisions?: number;
  48319. subdivisionsX?: number;
  48320. subdivisionsY?: number;
  48321. updatable?: boolean;
  48322. }, scene: any): Mesh;
  48323. /**
  48324. * Creates a tiled ground mesh
  48325. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  48326. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  48327. * * 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
  48328. * * 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
  48329. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48330. * @param name defines the name of the mesh
  48331. * @param options defines the options used to create the mesh
  48332. * @param scene defines the hosting scene
  48333. * @returns the tiled ground mesh
  48334. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  48335. */
  48336. static CreateTiledGround(name: string, options: {
  48337. xmin: number;
  48338. zmin: number;
  48339. xmax: number;
  48340. zmax: number;
  48341. subdivisions?: {
  48342. w: number;
  48343. h: number;
  48344. };
  48345. precision?: {
  48346. w: number;
  48347. h: number;
  48348. };
  48349. updatable?: boolean;
  48350. }, scene?: Nullable<Scene>): Mesh;
  48351. /**
  48352. * Creates a ground mesh from a height map
  48353. * * The parameter `url` sets the URL of the height map image resource.
  48354. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  48355. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  48356. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  48357. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  48358. * * 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.
  48359. * * 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).
  48360. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  48361. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48362. * @param name defines the name of the mesh
  48363. * @param url defines the url to the height map
  48364. * @param options defines the options used to create the mesh
  48365. * @param scene defines the hosting scene
  48366. * @returns the ground mesh
  48367. * @see https://doc.babylonjs.com/babylon101/height_map
  48368. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  48369. */
  48370. static CreateGroundFromHeightMap(name: string, url: string, options: {
  48371. width?: number;
  48372. height?: number;
  48373. subdivisions?: number;
  48374. minHeight?: number;
  48375. maxHeight?: number;
  48376. colorFilter?: Color3;
  48377. alphaFilter?: number;
  48378. updatable?: boolean;
  48379. onReady?: (mesh: GroundMesh) => void;
  48380. }, scene?: Nullable<Scene>): GroundMesh;
  48381. }
  48382. }
  48383. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  48384. import { Vector4 } from "babylonjs/Maths/math.vector";
  48385. import { Mesh } from "babylonjs/Meshes/mesh";
  48386. /**
  48387. * Class containing static functions to help procedurally build meshes
  48388. */
  48389. export class TorusBuilder {
  48390. /**
  48391. * Creates a torus mesh
  48392. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  48393. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  48394. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  48395. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48396. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48397. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48398. * @param name defines the name of the mesh
  48399. * @param options defines the options used to create the mesh
  48400. * @param scene defines the hosting scene
  48401. * @returns the torus mesh
  48402. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  48403. */
  48404. static CreateTorus(name: string, options: {
  48405. diameter?: number;
  48406. thickness?: number;
  48407. tessellation?: number;
  48408. updatable?: boolean;
  48409. sideOrientation?: number;
  48410. frontUVs?: Vector4;
  48411. backUVs?: Vector4;
  48412. }, scene: any): Mesh;
  48413. }
  48414. }
  48415. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  48416. import { Vector4 } from "babylonjs/Maths/math.vector";
  48417. import { Color4 } from "babylonjs/Maths/math.color";
  48418. import { Mesh } from "babylonjs/Meshes/mesh";
  48419. /**
  48420. * Class containing static functions to help procedurally build meshes
  48421. */
  48422. export class CylinderBuilder {
  48423. /**
  48424. * Creates a cylinder or a cone mesh
  48425. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  48426. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  48427. * * 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.
  48428. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  48429. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  48430. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  48431. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  48432. * * 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).
  48433. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  48434. * * 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).
  48435. * * 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
  48436. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  48437. * * 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
  48438. * * 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.
  48439. * * If `enclose` is false, a ring surface is one element.
  48440. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  48441. * * 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
  48442. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48443. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48444. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48445. * @param name defines the name of the mesh
  48446. * @param options defines the options used to create the mesh
  48447. * @param scene defines the hosting scene
  48448. * @returns the cylinder mesh
  48449. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  48450. */
  48451. static CreateCylinder(name: string, options: {
  48452. height?: number;
  48453. diameterTop?: number;
  48454. diameterBottom?: number;
  48455. diameter?: number;
  48456. tessellation?: number;
  48457. subdivisions?: number;
  48458. arc?: number;
  48459. faceColors?: Color4[];
  48460. faceUV?: Vector4[];
  48461. updatable?: boolean;
  48462. hasRings?: boolean;
  48463. enclose?: boolean;
  48464. cap?: number;
  48465. sideOrientation?: number;
  48466. frontUVs?: Vector4;
  48467. backUVs?: Vector4;
  48468. }, scene: any): Mesh;
  48469. }
  48470. }
  48471. declare module "babylonjs/XR/webXRTypes" {
  48472. import { Nullable } from "babylonjs/types";
  48473. import { IDisposable } from "babylonjs/scene";
  48474. /**
  48475. * States of the webXR experience
  48476. */
  48477. export enum WebXRState {
  48478. /**
  48479. * Transitioning to being in XR mode
  48480. */
  48481. ENTERING_XR = 0,
  48482. /**
  48483. * Transitioning to non XR mode
  48484. */
  48485. EXITING_XR = 1,
  48486. /**
  48487. * In XR mode and presenting
  48488. */
  48489. IN_XR = 2,
  48490. /**
  48491. * Not entered XR mode
  48492. */
  48493. NOT_IN_XR = 3
  48494. }
  48495. /**
  48496. * Abstraction of the XR render target
  48497. */
  48498. export interface WebXRRenderTarget extends IDisposable {
  48499. /**
  48500. * xrpresent context of the canvas which can be used to display/mirror xr content
  48501. */
  48502. canvasContext: WebGLRenderingContext;
  48503. /**
  48504. * xr layer for the canvas
  48505. */
  48506. xrLayer: Nullable<XRWebGLLayer>;
  48507. /**
  48508. * Initializes the xr layer for the session
  48509. * @param xrSession xr session
  48510. * @returns a promise that will resolve once the XR Layer has been created
  48511. */
  48512. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  48513. }
  48514. }
  48515. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  48516. import { Nullable } from "babylonjs/types";
  48517. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48518. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48519. import { Observable } from "babylonjs/Misc/observable";
  48520. /**
  48521. * COnfiguration object for WebXR output canvas
  48522. */
  48523. export class WebXRManagedOutputCanvasOptions {
  48524. /**
  48525. * An optional canvas in case you wish to create it yourself and provide it here.
  48526. * If not provided, a new canvas will be created
  48527. */
  48528. canvasElement?: HTMLCanvasElement;
  48529. /**
  48530. * Options for this XR Layer output
  48531. */
  48532. canvasOptions?: XRWebGLLayerOptions;
  48533. /**
  48534. * CSS styling for a newly created canvas (if not provided)
  48535. */
  48536. newCanvasCssStyle?: string;
  48537. /**
  48538. * Get the default values of the configuration object
  48539. * @returns default values of this configuration object
  48540. */
  48541. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  48542. }
  48543. /**
  48544. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  48545. */
  48546. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  48547. private _options;
  48548. private _canvas;
  48549. private _engine;
  48550. private _originalCanvasSize;
  48551. /**
  48552. * Rendering context of the canvas which can be used to display/mirror xr content
  48553. */
  48554. canvasContext: WebGLRenderingContext;
  48555. /**
  48556. * xr layer for the canvas
  48557. */
  48558. xrLayer: Nullable<XRWebGLLayer>;
  48559. /**
  48560. * Obseervers registered here will be triggered when the xr layer was initialized
  48561. */
  48562. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  48563. /**
  48564. * Initializes the canvas to be added/removed upon entering/exiting xr
  48565. * @param _xrSessionManager The XR Session manager
  48566. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  48567. */
  48568. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  48569. /**
  48570. * Disposes of the object
  48571. */
  48572. dispose(): void;
  48573. /**
  48574. * Initializes the xr layer for the session
  48575. * @param xrSession xr session
  48576. * @returns a promise that will resolve once the XR Layer has been created
  48577. */
  48578. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  48579. private _addCanvas;
  48580. private _removeCanvas;
  48581. private _setCanvasSize;
  48582. private _setManagedOutputCanvas;
  48583. }
  48584. }
  48585. declare module "babylonjs/XR/webXRSessionManager" {
  48586. import { Observable } from "babylonjs/Misc/observable";
  48587. import { Nullable } from "babylonjs/types";
  48588. import { IDisposable, Scene } from "babylonjs/scene";
  48589. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48590. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48591. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  48592. /**
  48593. * Manages an XRSession to work with Babylon's engine
  48594. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  48595. */
  48596. export class WebXRSessionManager implements IDisposable {
  48597. /** The scene which the session should be created for */
  48598. scene: Scene;
  48599. private _referenceSpace;
  48600. private _rttProvider;
  48601. private _sessionEnded;
  48602. private _xrNavigator;
  48603. private baseLayer;
  48604. /**
  48605. * The base reference space from which the session started. good if you want to reset your
  48606. * reference space
  48607. */
  48608. baseReferenceSpace: XRReferenceSpace;
  48609. /**
  48610. * Current XR frame
  48611. */
  48612. currentFrame: Nullable<XRFrame>;
  48613. /** WebXR timestamp updated every frame */
  48614. currentTimestamp: number;
  48615. /**
  48616. * Used just in case of a failure to initialize an immersive session.
  48617. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  48618. */
  48619. defaultHeightCompensation: number;
  48620. /**
  48621. * Fires every time a new xrFrame arrives which can be used to update the camera
  48622. */
  48623. onXRFrameObservable: Observable<XRFrame>;
  48624. /**
  48625. * Fires when the reference space changed
  48626. */
  48627. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  48628. /**
  48629. * Fires when the xr session is ended either by the device or manually done
  48630. */
  48631. onXRSessionEnded: Observable<any>;
  48632. /**
  48633. * Fires when the xr session is ended either by the device or manually done
  48634. */
  48635. onXRSessionInit: Observable<XRSession>;
  48636. /**
  48637. * Underlying xr session
  48638. */
  48639. session: XRSession;
  48640. /**
  48641. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  48642. * or get the offset the player is currently at.
  48643. */
  48644. viewerReferenceSpace: XRReferenceSpace;
  48645. /**
  48646. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  48647. * @param scene The scene which the session should be created for
  48648. */
  48649. constructor(
  48650. /** The scene which the session should be created for */
  48651. scene: Scene);
  48652. /**
  48653. * The current reference space used in this session. This reference space can constantly change!
  48654. * It is mainly used to offset the camera's position.
  48655. */
  48656. get referenceSpace(): XRReferenceSpace;
  48657. /**
  48658. * Set a new reference space and triggers the observable
  48659. */
  48660. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  48661. /**
  48662. * Disposes of the session manager
  48663. */
  48664. dispose(): void;
  48665. /**
  48666. * Stops the xrSession and restores the render loop
  48667. * @returns Promise which resolves after it exits XR
  48668. */
  48669. exitXRAsync(): Promise<void>;
  48670. /**
  48671. * Gets the correct render target texture to be rendered this frame for this eye
  48672. * @param eye the eye for which to get the render target
  48673. * @returns the render target for the specified eye
  48674. */
  48675. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  48676. /**
  48677. * Creates a WebXRRenderTarget object for the XR session
  48678. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  48679. * @param options optional options to provide when creating a new render target
  48680. * @returns a WebXR render target to which the session can render
  48681. */
  48682. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  48683. /**
  48684. * Initializes the manager
  48685. * After initialization enterXR can be called to start an XR session
  48686. * @returns Promise which resolves after it is initialized
  48687. */
  48688. initializeAsync(): Promise<void>;
  48689. /**
  48690. * Initializes an xr session
  48691. * @param xrSessionMode mode to initialize
  48692. * @param xrSessionInit defines optional and required values to pass to the session builder
  48693. * @returns a promise which will resolve once the session has been initialized
  48694. */
  48695. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  48696. /**
  48697. * Checks if a session would be supported for the creation options specified
  48698. * @param sessionMode session mode to check if supported eg. immersive-vr
  48699. * @returns A Promise that resolves to true if supported and false if not
  48700. */
  48701. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  48702. /**
  48703. * Resets the reference space to the one started the session
  48704. */
  48705. resetReferenceSpace(): void;
  48706. /**
  48707. * Starts rendering to the xr layer
  48708. */
  48709. runXRRenderLoop(): void;
  48710. /**
  48711. * Sets the reference space on the xr session
  48712. * @param referenceSpaceType space to set
  48713. * @returns a promise that will resolve once the reference space has been set
  48714. */
  48715. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  48716. /**
  48717. * Updates the render state of the session
  48718. * @param state state to set
  48719. * @returns a promise that resolves once the render state has been updated
  48720. */
  48721. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  48722. /**
  48723. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  48724. * @param sessionMode defines the session to test
  48725. * @returns a promise with boolean as final value
  48726. */
  48727. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  48728. private _createRenderTargetTexture;
  48729. }
  48730. }
  48731. declare module "babylonjs/XR/webXRCamera" {
  48732. import { Vector3 } from "babylonjs/Maths/math.vector";
  48733. import { Scene } from "babylonjs/scene";
  48734. import { Camera } from "babylonjs/Cameras/camera";
  48735. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  48736. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48737. import { Observable } from "babylonjs/Misc/observable";
  48738. /**
  48739. * WebXR Camera which holds the views for the xrSession
  48740. * @see https://doc.babylonjs.com/how_to/webxr_camera
  48741. */
  48742. export class WebXRCamera extends FreeCamera {
  48743. private _xrSessionManager;
  48744. private _firstFrame;
  48745. private _referenceQuaternion;
  48746. private _referencedPosition;
  48747. private _xrInvPositionCache;
  48748. private _xrInvQuaternionCache;
  48749. /**
  48750. * Observable raised before camera teleportation
  48751. */
  48752. onBeforeCameraTeleport: Observable<Vector3>;
  48753. /**
  48754. * Observable raised after camera teleportation
  48755. */
  48756. onAfterCameraTeleport: Observable<Vector3>;
  48757. /**
  48758. * Should position compensation execute on first frame.
  48759. * This is used when copying the position from a native (non XR) camera
  48760. */
  48761. compensateOnFirstFrame: boolean;
  48762. /**
  48763. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  48764. * @param name the name of the camera
  48765. * @param scene the scene to add the camera to
  48766. * @param _xrSessionManager a constructed xr session manager
  48767. */
  48768. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  48769. /**
  48770. * Return the user's height, unrelated to the current ground.
  48771. * This will be the y position of this camera, when ground level is 0.
  48772. */
  48773. get realWorldHeight(): number;
  48774. /** @hidden */
  48775. _updateForDualEyeDebugging(): void;
  48776. /**
  48777. * Sets this camera's transformation based on a non-vr camera
  48778. * @param otherCamera the non-vr camera to copy the transformation from
  48779. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  48780. */
  48781. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  48782. /**
  48783. * Gets the current instance class name ("WebXRCamera").
  48784. * @returns the class name
  48785. */
  48786. getClassName(): string;
  48787. private _rotate180;
  48788. private _updateFromXRSession;
  48789. private _updateNumberOfRigCameras;
  48790. private _updateReferenceSpace;
  48791. private _updateReferenceSpaceOffset;
  48792. }
  48793. }
  48794. declare module "babylonjs/XR/webXRFeaturesManager" {
  48795. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48796. import { IDisposable } from "babylonjs/scene";
  48797. /**
  48798. * Defining the interface required for a (webxr) feature
  48799. */
  48800. export interface IWebXRFeature extends IDisposable {
  48801. /**
  48802. * Is this feature attached
  48803. */
  48804. attached: boolean;
  48805. /**
  48806. * Should auto-attach be disabled?
  48807. */
  48808. disableAutoAttach: boolean;
  48809. /**
  48810. * Attach the feature to the session
  48811. * Will usually be called by the features manager
  48812. *
  48813. * @param force should attachment be forced (even when already attached)
  48814. * @returns true if successful.
  48815. */
  48816. attach(force?: boolean): boolean;
  48817. /**
  48818. * Detach the feature from the session
  48819. * Will usually be called by the features manager
  48820. *
  48821. * @returns true if successful.
  48822. */
  48823. detach(): boolean;
  48824. /**
  48825. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  48826. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  48827. *
  48828. * @returns whether or not the feature is compatible in this environment
  48829. */
  48830. isCompatible(): boolean;
  48831. /**
  48832. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  48833. */
  48834. xrNativeFeatureName?: string;
  48835. }
  48836. /**
  48837. * A list of the currently available features without referencing them
  48838. */
  48839. export class WebXRFeatureName {
  48840. /**
  48841. * The name of the anchor system feature
  48842. */
  48843. static ANCHOR_SYSTEM: string;
  48844. /**
  48845. * The name of the background remover feature
  48846. */
  48847. static BACKGROUND_REMOVER: string;
  48848. /**
  48849. * The name of the hit test feature
  48850. */
  48851. static HIT_TEST: string;
  48852. /**
  48853. * physics impostors for xr controllers feature
  48854. */
  48855. static PHYSICS_CONTROLLERS: string;
  48856. /**
  48857. * The name of the plane detection feature
  48858. */
  48859. static PLANE_DETECTION: string;
  48860. /**
  48861. * The name of the pointer selection feature
  48862. */
  48863. static POINTER_SELECTION: string;
  48864. /**
  48865. * The name of the teleportation feature
  48866. */
  48867. static TELEPORTATION: string;
  48868. }
  48869. /**
  48870. * Defining the constructor of a feature. Used to register the modules.
  48871. */
  48872. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  48873. /**
  48874. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  48875. * It is mainly used in AR sessions.
  48876. *
  48877. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  48878. */
  48879. export class WebXRFeaturesManager implements IDisposable {
  48880. private _xrSessionManager;
  48881. private static readonly _AvailableFeatures;
  48882. private _features;
  48883. /**
  48884. * constructs a new features manages.
  48885. *
  48886. * @param _xrSessionManager an instance of WebXRSessionManager
  48887. */
  48888. constructor(_xrSessionManager: WebXRSessionManager);
  48889. /**
  48890. * Used to register a module. After calling this function a developer can use this feature in the scene.
  48891. * Mainly used internally.
  48892. *
  48893. * @param featureName the name of the feature to register
  48894. * @param constructorFunction the function used to construct the module
  48895. * @param version the (babylon) version of the module
  48896. * @param stable is that a stable version of this module
  48897. */
  48898. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  48899. /**
  48900. * Returns a constructor of a specific feature.
  48901. *
  48902. * @param featureName the name of the feature to construct
  48903. * @param version the version of the feature to load
  48904. * @param xrSessionManager the xrSessionManager. Used to construct the module
  48905. * @param options optional options provided to the module.
  48906. * @returns a function that, when called, will return a new instance of this feature
  48907. */
  48908. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  48909. /**
  48910. * Can be used to return the list of features currently registered
  48911. *
  48912. * @returns an Array of available features
  48913. */
  48914. static GetAvailableFeatures(): string[];
  48915. /**
  48916. * Gets the versions available for a specific feature
  48917. * @param featureName the name of the feature
  48918. * @returns an array with the available versions
  48919. */
  48920. static GetAvailableVersions(featureName: string): string[];
  48921. /**
  48922. * Return the latest unstable version of this feature
  48923. * @param featureName the name of the feature to search
  48924. * @returns the version number. if not found will return -1
  48925. */
  48926. static GetLatestVersionOfFeature(featureName: string): number;
  48927. /**
  48928. * Return the latest stable version of this feature
  48929. * @param featureName the name of the feature to search
  48930. * @returns the version number. if not found will return -1
  48931. */
  48932. static GetStableVersionOfFeature(featureName: string): number;
  48933. /**
  48934. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  48935. * Can be used during a session to start a feature
  48936. * @param featureName the name of feature to attach
  48937. */
  48938. attachFeature(featureName: string): void;
  48939. /**
  48940. * Can be used inside a session or when the session ends to detach a specific feature
  48941. * @param featureName the name of the feature to detach
  48942. */
  48943. detachFeature(featureName: string): void;
  48944. /**
  48945. * Used to disable an already-enabled feature
  48946. * The feature will be disposed and will be recreated once enabled.
  48947. * @param featureName the feature to disable
  48948. * @returns true if disable was successful
  48949. */
  48950. disableFeature(featureName: string | {
  48951. Name: string;
  48952. }): boolean;
  48953. /**
  48954. * dispose this features manager
  48955. */
  48956. dispose(): void;
  48957. /**
  48958. * 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.
  48959. * 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.
  48960. *
  48961. * @param featureName the name of the feature to load or the class of the feature
  48962. * @param version optional version to load. if not provided the latest version will be enabled
  48963. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  48964. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  48965. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  48966. * @returns a new constructed feature or throws an error if feature not found.
  48967. */
  48968. enableFeature(featureName: string | {
  48969. Name: string;
  48970. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  48971. /**
  48972. * get the implementation of an enabled feature.
  48973. * @param featureName the name of the feature to load
  48974. * @returns the feature class, if found
  48975. */
  48976. getEnabledFeature(featureName: string): IWebXRFeature;
  48977. /**
  48978. * Get the list of enabled features
  48979. * @returns an array of enabled features
  48980. */
  48981. getEnabledFeatures(): string[];
  48982. /**
  48983. * This function will exten the session creation configuration object with enabled features.
  48984. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  48985. * according to the defined "required" variable, provided during enableFeature call
  48986. * @param xrSessionInit the xr Session init object to extend
  48987. *
  48988. * @returns an extended XRSessionInit object
  48989. */
  48990. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  48991. }
  48992. }
  48993. declare module "babylonjs/XR/webXRExperienceHelper" {
  48994. import { Observable } from "babylonjs/Misc/observable";
  48995. import { IDisposable, Scene } from "babylonjs/scene";
  48996. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48997. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  48998. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48999. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  49000. /**
  49001. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  49002. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  49003. */
  49004. export class WebXRExperienceHelper implements IDisposable {
  49005. private scene;
  49006. private _nonVRCamera;
  49007. private _originalSceneAutoClear;
  49008. private _supported;
  49009. /**
  49010. * Camera used to render xr content
  49011. */
  49012. camera: WebXRCamera;
  49013. /** A features manager for this xr session */
  49014. featuresManager: WebXRFeaturesManager;
  49015. /**
  49016. * Observers registered here will be triggered after the camera's initial transformation is set
  49017. * This can be used to set a different ground level or an extra rotation.
  49018. *
  49019. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  49020. * to the position set after this observable is done executing.
  49021. */
  49022. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  49023. /**
  49024. * Fires when the state of the experience helper has changed
  49025. */
  49026. onStateChangedObservable: Observable<WebXRState>;
  49027. /** Session manager used to keep track of xr session */
  49028. sessionManager: WebXRSessionManager;
  49029. /**
  49030. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  49031. */
  49032. state: WebXRState;
  49033. /**
  49034. * Creates a WebXRExperienceHelper
  49035. * @param scene The scene the helper should be created in
  49036. */
  49037. private constructor();
  49038. /**
  49039. * Creates the experience helper
  49040. * @param scene the scene to attach the experience helper to
  49041. * @returns a promise for the experience helper
  49042. */
  49043. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  49044. /**
  49045. * Disposes of the experience helper
  49046. */
  49047. dispose(): void;
  49048. /**
  49049. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  49050. * @param sessionMode options for the XR session
  49051. * @param referenceSpaceType frame of reference of the XR session
  49052. * @param renderTarget the output canvas that will be used to enter XR mode
  49053. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  49054. * @returns promise that resolves after xr mode has entered
  49055. */
  49056. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  49057. /**
  49058. * Exits XR mode and returns the scene to its original state
  49059. * @returns promise that resolves after xr mode has exited
  49060. */
  49061. exitXRAsync(): Promise<void>;
  49062. private _nonXRToXRCamera;
  49063. private _setState;
  49064. }
  49065. }
  49066. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  49067. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49068. import { Observable } from "babylonjs/Misc/observable";
  49069. import { IDisposable } from "babylonjs/scene";
  49070. /**
  49071. * X-Y values for axes in WebXR
  49072. */
  49073. export interface IWebXRMotionControllerAxesValue {
  49074. /**
  49075. * The value of the x axis
  49076. */
  49077. x: number;
  49078. /**
  49079. * The value of the y-axis
  49080. */
  49081. y: number;
  49082. }
  49083. /**
  49084. * changed / previous values for the values of this component
  49085. */
  49086. export interface IWebXRMotionControllerComponentChangesValues<T> {
  49087. /**
  49088. * current (this frame) value
  49089. */
  49090. current: T;
  49091. /**
  49092. * previous (last change) value
  49093. */
  49094. previous: T;
  49095. }
  49096. /**
  49097. * Represents changes in the component between current frame and last values recorded
  49098. */
  49099. export interface IWebXRMotionControllerComponentChanges {
  49100. /**
  49101. * will be populated with previous and current values if axes changed
  49102. */
  49103. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  49104. /**
  49105. * will be populated with previous and current values if pressed changed
  49106. */
  49107. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  49108. /**
  49109. * will be populated with previous and current values if touched changed
  49110. */
  49111. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  49112. /**
  49113. * will be populated with previous and current values if value changed
  49114. */
  49115. value?: IWebXRMotionControllerComponentChangesValues<number>;
  49116. }
  49117. /**
  49118. * This class represents a single component (for example button or thumbstick) of a motion controller
  49119. */
  49120. export class WebXRControllerComponent implements IDisposable {
  49121. /**
  49122. * the id of this component
  49123. */
  49124. id: string;
  49125. /**
  49126. * the type of the component
  49127. */
  49128. type: MotionControllerComponentType;
  49129. private _buttonIndex;
  49130. private _axesIndices;
  49131. private _axes;
  49132. private _changes;
  49133. private _currentValue;
  49134. private _hasChanges;
  49135. private _pressed;
  49136. private _touched;
  49137. /**
  49138. * button component type
  49139. */
  49140. static BUTTON_TYPE: MotionControllerComponentType;
  49141. /**
  49142. * squeeze component type
  49143. */
  49144. static SQUEEZE_TYPE: MotionControllerComponentType;
  49145. /**
  49146. * Thumbstick component type
  49147. */
  49148. static THUMBSTICK_TYPE: MotionControllerComponentType;
  49149. /**
  49150. * Touchpad component type
  49151. */
  49152. static TOUCHPAD_TYPE: MotionControllerComponentType;
  49153. /**
  49154. * trigger component type
  49155. */
  49156. static TRIGGER_TYPE: MotionControllerComponentType;
  49157. /**
  49158. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  49159. * the axes data changes
  49160. */
  49161. onAxisValueChangedObservable: Observable<{
  49162. x: number;
  49163. y: number;
  49164. }>;
  49165. /**
  49166. * Observers registered here will be triggered when the state of a button changes
  49167. * State change is either pressed / touched / value
  49168. */
  49169. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  49170. /**
  49171. * Creates a new component for a motion controller.
  49172. * It is created by the motion controller itself
  49173. *
  49174. * @param id the id of this component
  49175. * @param type the type of the component
  49176. * @param _buttonIndex index in the buttons array of the gamepad
  49177. * @param _axesIndices indices of the values in the axes array of the gamepad
  49178. */
  49179. constructor(
  49180. /**
  49181. * the id of this component
  49182. */
  49183. id: string,
  49184. /**
  49185. * the type of the component
  49186. */
  49187. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  49188. /**
  49189. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  49190. */
  49191. get axes(): IWebXRMotionControllerAxesValue;
  49192. /**
  49193. * Get the changes. Elements will be populated only if they changed with their previous and current value
  49194. */
  49195. get changes(): IWebXRMotionControllerComponentChanges;
  49196. /**
  49197. * Return whether or not the component changed the last frame
  49198. */
  49199. get hasChanges(): boolean;
  49200. /**
  49201. * is the button currently pressed
  49202. */
  49203. get pressed(): boolean;
  49204. /**
  49205. * is the button currently touched
  49206. */
  49207. get touched(): boolean;
  49208. /**
  49209. * Get the current value of this component
  49210. */
  49211. get value(): number;
  49212. /**
  49213. * Dispose this component
  49214. */
  49215. dispose(): void;
  49216. /**
  49217. * Are there axes correlating to this component
  49218. * @return true is axes data is available
  49219. */
  49220. isAxes(): boolean;
  49221. /**
  49222. * Is this component a button (hence - pressable)
  49223. * @returns true if can be pressed
  49224. */
  49225. isButton(): boolean;
  49226. /**
  49227. * update this component using the gamepad object it is in. Called on every frame
  49228. * @param nativeController the native gamepad controller object
  49229. */
  49230. update(nativeController: IMinimalMotionControllerObject): void;
  49231. }
  49232. }
  49233. declare module "babylonjs/Loading/sceneLoader" {
  49234. import { Observable } from "babylonjs/Misc/observable";
  49235. import { Nullable } from "babylonjs/types";
  49236. import { Scene } from "babylonjs/scene";
  49237. import { Engine } from "babylonjs/Engines/engine";
  49238. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49239. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  49240. import { AssetContainer } from "babylonjs/assetContainer";
  49241. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  49242. import { Skeleton } from "babylonjs/Bones/skeleton";
  49243. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  49244. import { WebRequest } from "babylonjs/Misc/webRequest";
  49245. /**
  49246. * Interface used to represent data loading progression
  49247. */
  49248. export interface ISceneLoaderProgressEvent {
  49249. /**
  49250. * Defines if data length to load can be evaluated
  49251. */
  49252. readonly lengthComputable: boolean;
  49253. /**
  49254. * Defines the loaded data length
  49255. */
  49256. readonly loaded: number;
  49257. /**
  49258. * Defines the data length to load
  49259. */
  49260. readonly total: number;
  49261. }
  49262. /**
  49263. * Interface used by SceneLoader plugins to define supported file extensions
  49264. */
  49265. export interface ISceneLoaderPluginExtensions {
  49266. /**
  49267. * Defines the list of supported extensions
  49268. */
  49269. [extension: string]: {
  49270. isBinary: boolean;
  49271. };
  49272. }
  49273. /**
  49274. * Interface used by SceneLoader plugin factory
  49275. */
  49276. export interface ISceneLoaderPluginFactory {
  49277. /**
  49278. * Defines the name of the factory
  49279. */
  49280. name: string;
  49281. /**
  49282. * Function called to create a new plugin
  49283. * @return the new plugin
  49284. */
  49285. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  49286. /**
  49287. * The callback that returns true if the data can be directly loaded.
  49288. * @param data string containing the file data
  49289. * @returns if the data can be loaded directly
  49290. */
  49291. canDirectLoad?(data: string): boolean;
  49292. }
  49293. /**
  49294. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  49295. */
  49296. export interface ISceneLoaderPluginBase {
  49297. /**
  49298. * The friendly name of this plugin.
  49299. */
  49300. name: string;
  49301. /**
  49302. * The file extensions supported by this plugin.
  49303. */
  49304. extensions: string | ISceneLoaderPluginExtensions;
  49305. /**
  49306. * The callback called when loading from a url.
  49307. * @param scene scene loading this url
  49308. * @param url url to load
  49309. * @param onSuccess callback called when the file successfully loads
  49310. * @param onProgress callback called while file is loading (if the server supports this mode)
  49311. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  49312. * @param onError callback called when the file fails to load
  49313. * @returns a file request object
  49314. */
  49315. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  49316. /**
  49317. * The callback called when loading from a file object.
  49318. * @param scene scene loading this file
  49319. * @param file defines the file to load
  49320. * @param onSuccess defines the callback to call when data is loaded
  49321. * @param onProgress defines the callback to call during loading process
  49322. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  49323. * @param onError defines the callback to call when an error occurs
  49324. * @returns a file request object
  49325. */
  49326. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  49327. /**
  49328. * The callback that returns true if the data can be directly loaded.
  49329. * @param data string containing the file data
  49330. * @returns if the data can be loaded directly
  49331. */
  49332. canDirectLoad?(data: string): boolean;
  49333. /**
  49334. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  49335. * @param scene scene loading this data
  49336. * @param data string containing the data
  49337. * @returns data to pass to the plugin
  49338. */
  49339. directLoad?(scene: Scene, data: string): any;
  49340. /**
  49341. * The callback that allows custom handling of the root url based on the response url.
  49342. * @param rootUrl the original root url
  49343. * @param responseURL the response url if available
  49344. * @returns the new root url
  49345. */
  49346. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  49347. }
  49348. /**
  49349. * Interface used to define a SceneLoader plugin
  49350. */
  49351. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  49352. /**
  49353. * Import meshes into a scene.
  49354. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49355. * @param scene The scene to import into
  49356. * @param data The data to import
  49357. * @param rootUrl The root url for scene and resources
  49358. * @param meshes The meshes array to import into
  49359. * @param particleSystems The particle systems array to import into
  49360. * @param skeletons The skeletons array to import into
  49361. * @param onError The callback when import fails
  49362. * @returns True if successful or false otherwise
  49363. */
  49364. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  49365. /**
  49366. * Load into a scene.
  49367. * @param scene The scene to load into
  49368. * @param data The data to import
  49369. * @param rootUrl The root url for scene and resources
  49370. * @param onError The callback when import fails
  49371. * @returns True if successful or false otherwise
  49372. */
  49373. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  49374. /**
  49375. * Load into an asset container.
  49376. * @param scene The scene to load into
  49377. * @param data The data to import
  49378. * @param rootUrl The root url for scene and resources
  49379. * @param onError The callback when import fails
  49380. * @returns The loaded asset container
  49381. */
  49382. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  49383. }
  49384. /**
  49385. * Interface used to define an async SceneLoader plugin
  49386. */
  49387. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  49388. /**
  49389. * Import meshes into a scene.
  49390. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49391. * @param scene The scene to import into
  49392. * @param data The data to import
  49393. * @param rootUrl The root url for scene and resources
  49394. * @param onProgress The callback when the load progresses
  49395. * @param fileName Defines the name of the file to load
  49396. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  49397. */
  49398. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  49399. meshes: AbstractMesh[];
  49400. particleSystems: IParticleSystem[];
  49401. skeletons: Skeleton[];
  49402. animationGroups: AnimationGroup[];
  49403. }>;
  49404. /**
  49405. * Load into a scene.
  49406. * @param scene The scene to load into
  49407. * @param data The data to import
  49408. * @param rootUrl The root url for scene and resources
  49409. * @param onProgress The callback when the load progresses
  49410. * @param fileName Defines the name of the file to load
  49411. * @returns Nothing
  49412. */
  49413. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  49414. /**
  49415. * Load into an asset container.
  49416. * @param scene The scene to load into
  49417. * @param data The data to import
  49418. * @param rootUrl The root url for scene and resources
  49419. * @param onProgress The callback when the load progresses
  49420. * @param fileName Defines the name of the file to load
  49421. * @returns The loaded asset container
  49422. */
  49423. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  49424. }
  49425. /**
  49426. * Mode that determines how to handle old animation groups before loading new ones.
  49427. */
  49428. export enum SceneLoaderAnimationGroupLoadingMode {
  49429. /**
  49430. * Reset all old animations to initial state then dispose them.
  49431. */
  49432. Clean = 0,
  49433. /**
  49434. * Stop all old animations.
  49435. */
  49436. Stop = 1,
  49437. /**
  49438. * Restart old animations from first frame.
  49439. */
  49440. Sync = 2,
  49441. /**
  49442. * Old animations remains untouched.
  49443. */
  49444. NoSync = 3
  49445. }
  49446. /**
  49447. * Defines a plugin registered by the SceneLoader
  49448. */
  49449. interface IRegisteredPlugin {
  49450. /**
  49451. * Defines the plugin to use
  49452. */
  49453. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  49454. /**
  49455. * Defines if the plugin supports binary data
  49456. */
  49457. isBinary: boolean;
  49458. }
  49459. /**
  49460. * Class used to load scene from various file formats using registered plugins
  49461. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  49462. */
  49463. export class SceneLoader {
  49464. /**
  49465. * No logging while loading
  49466. */
  49467. static readonly NO_LOGGING: number;
  49468. /**
  49469. * Minimal logging while loading
  49470. */
  49471. static readonly MINIMAL_LOGGING: number;
  49472. /**
  49473. * Summary logging while loading
  49474. */
  49475. static readonly SUMMARY_LOGGING: number;
  49476. /**
  49477. * Detailled logging while loading
  49478. */
  49479. static readonly DETAILED_LOGGING: number;
  49480. /**
  49481. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  49482. */
  49483. static get ForceFullSceneLoadingForIncremental(): boolean;
  49484. static set ForceFullSceneLoadingForIncremental(value: boolean);
  49485. /**
  49486. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  49487. */
  49488. static get ShowLoadingScreen(): boolean;
  49489. static set ShowLoadingScreen(value: boolean);
  49490. /**
  49491. * Defines the current logging level (while loading the scene)
  49492. * @ignorenaming
  49493. */
  49494. static get loggingLevel(): number;
  49495. static set loggingLevel(value: number);
  49496. /**
  49497. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  49498. */
  49499. static get CleanBoneMatrixWeights(): boolean;
  49500. static set CleanBoneMatrixWeights(value: boolean);
  49501. /**
  49502. * Event raised when a plugin is used to load a scene
  49503. */
  49504. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  49505. private static _registeredPlugins;
  49506. private static _showingLoadingScreen;
  49507. /**
  49508. * Gets the default plugin (used to load Babylon files)
  49509. * @returns the .babylon plugin
  49510. */
  49511. static GetDefaultPlugin(): IRegisteredPlugin;
  49512. private static _GetPluginForExtension;
  49513. private static _GetPluginForDirectLoad;
  49514. private static _GetPluginForFilename;
  49515. private static _GetDirectLoad;
  49516. private static _LoadData;
  49517. private static _GetFileInfo;
  49518. /**
  49519. * Gets a plugin that can load the given extension
  49520. * @param extension defines the extension to load
  49521. * @returns a plugin or null if none works
  49522. */
  49523. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  49524. /**
  49525. * Gets a boolean indicating that the given extension can be loaded
  49526. * @param extension defines the extension to load
  49527. * @returns true if the extension is supported
  49528. */
  49529. static IsPluginForExtensionAvailable(extension: string): boolean;
  49530. /**
  49531. * Adds a new plugin to the list of registered plugins
  49532. * @param plugin defines the plugin to add
  49533. */
  49534. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  49535. /**
  49536. * Import meshes into a scene
  49537. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49538. * @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)
  49539. * @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)
  49540. * @param scene the instance of BABYLON.Scene to append to
  49541. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  49542. * @param onProgress a callback with a progress event for each file being loaded
  49543. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49544. * @param pluginExtension the extension used to determine the plugin
  49545. * @returns The loaded plugin
  49546. */
  49547. 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>;
  49548. /**
  49549. * Import meshes into a scene
  49550. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49551. * @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)
  49552. * @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)
  49553. * @param scene the instance of BABYLON.Scene to append to
  49554. * @param onProgress a callback with a progress event for each file being loaded
  49555. * @param pluginExtension the extension used to determine the plugin
  49556. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  49557. */
  49558. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  49559. meshes: AbstractMesh[];
  49560. particleSystems: IParticleSystem[];
  49561. skeletons: Skeleton[];
  49562. animationGroups: AnimationGroup[];
  49563. }>;
  49564. /**
  49565. * Load a scene
  49566. * @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)
  49567. * @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)
  49568. * @param engine is the instance of BABYLON.Engine to use to create the scene
  49569. * @param onSuccess a callback with the scene when import succeeds
  49570. * @param onProgress a callback with a progress event for each file being loaded
  49571. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49572. * @param pluginExtension the extension used to determine the plugin
  49573. * @returns The loaded plugin
  49574. */
  49575. 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>;
  49576. /**
  49577. * Load a scene
  49578. * @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)
  49579. * @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)
  49580. * @param engine is the instance of BABYLON.Engine to use to create the scene
  49581. * @param onProgress a callback with a progress event for each file being loaded
  49582. * @param pluginExtension the extension used to determine the plugin
  49583. * @returns The loaded scene
  49584. */
  49585. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  49586. /**
  49587. * Append a scene
  49588. * @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)
  49589. * @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)
  49590. * @param scene is the instance of BABYLON.Scene to append to
  49591. * @param onSuccess a callback with the scene when import succeeds
  49592. * @param onProgress a callback with a progress event for each file being loaded
  49593. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49594. * @param pluginExtension the extension used to determine the plugin
  49595. * @returns The loaded plugin
  49596. */
  49597. 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>;
  49598. /**
  49599. * Append a scene
  49600. * @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)
  49601. * @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)
  49602. * @param scene is the instance of BABYLON.Scene to append to
  49603. * @param onProgress a callback with a progress event for each file being loaded
  49604. * @param pluginExtension the extension used to determine the plugin
  49605. * @returns The given scene
  49606. */
  49607. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  49608. /**
  49609. * Load a scene into an asset container
  49610. * @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)
  49611. * @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)
  49612. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49613. * @param onSuccess a callback with the scene when import succeeds
  49614. * @param onProgress a callback with a progress event for each file being loaded
  49615. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49616. * @param pluginExtension the extension used to determine the plugin
  49617. * @returns The loaded plugin
  49618. */
  49619. 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>;
  49620. /**
  49621. * Load a scene into an asset container
  49622. * @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)
  49623. * @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)
  49624. * @param scene is the instance of Scene to append to
  49625. * @param onProgress a callback with a progress event for each file being loaded
  49626. * @param pluginExtension the extension used to determine the plugin
  49627. * @returns The loaded asset container
  49628. */
  49629. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  49630. /**
  49631. * Import animations from a file into a scene
  49632. * @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)
  49633. * @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)
  49634. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49635. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  49636. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  49637. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  49638. * @param onSuccess a callback with the scene when import succeeds
  49639. * @param onProgress a callback with a progress event for each file being loaded
  49640. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49641. * @param pluginExtension the extension used to determine the plugin
  49642. */
  49643. 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;
  49644. /**
  49645. * Import animations from a file into a scene
  49646. * @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)
  49647. * @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)
  49648. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49649. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  49650. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  49651. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  49652. * @param onSuccess a callback with the scene when import succeeds
  49653. * @param onProgress a callback with a progress event for each file being loaded
  49654. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49655. * @param pluginExtension the extension used to determine the plugin
  49656. * @returns the updated scene with imported animations
  49657. */
  49658. 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>;
  49659. }
  49660. }
  49661. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  49662. import { IDisposable, Scene } from "babylonjs/scene";
  49663. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  49664. import { Observable } from "babylonjs/Misc/observable";
  49665. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49666. import { Nullable } from "babylonjs/types";
  49667. /**
  49668. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  49669. */
  49670. export type MotionControllerHandedness = "none" | "left" | "right";
  49671. /**
  49672. * The type of components available in motion controllers.
  49673. * This is not the name of the component.
  49674. */
  49675. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  49676. /**
  49677. * The state of a controller component
  49678. */
  49679. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  49680. /**
  49681. * The schema of motion controller layout.
  49682. * No object will be initialized using this interface
  49683. * This is used just to define the profile.
  49684. */
  49685. export interface IMotionControllerLayout {
  49686. /**
  49687. * Path to load the assets. Usually relative to the base path
  49688. */
  49689. assetPath: string;
  49690. /**
  49691. * Available components (unsorted)
  49692. */
  49693. components: {
  49694. /**
  49695. * A map of component Ids
  49696. */
  49697. [componentId: string]: {
  49698. /**
  49699. * The type of input the component outputs
  49700. */
  49701. type: MotionControllerComponentType;
  49702. /**
  49703. * The indices of this component in the gamepad object
  49704. */
  49705. gamepadIndices: {
  49706. /**
  49707. * Index of button
  49708. */
  49709. button?: number;
  49710. /**
  49711. * If available, index of x-axis
  49712. */
  49713. xAxis?: number;
  49714. /**
  49715. * If available, index of y-axis
  49716. */
  49717. yAxis?: number;
  49718. };
  49719. /**
  49720. * The mesh's root node name
  49721. */
  49722. rootNodeName: string;
  49723. /**
  49724. * Animation definitions for this model
  49725. */
  49726. visualResponses: {
  49727. [stateKey: string]: {
  49728. /**
  49729. * What property will be animated
  49730. */
  49731. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  49732. /**
  49733. * What states influence this visual response
  49734. */
  49735. states: MotionControllerComponentStateType[];
  49736. /**
  49737. * Type of animation - movement or visibility
  49738. */
  49739. valueNodeProperty: "transform" | "visibility";
  49740. /**
  49741. * Base node name to move. Its position will be calculated according to the min and max nodes
  49742. */
  49743. valueNodeName?: string;
  49744. /**
  49745. * Minimum movement node
  49746. */
  49747. minNodeName?: string;
  49748. /**
  49749. * Max movement node
  49750. */
  49751. maxNodeName?: string;
  49752. };
  49753. };
  49754. /**
  49755. * If touch enabled, what is the name of node to display user feedback
  49756. */
  49757. touchPointNodeName?: string;
  49758. };
  49759. };
  49760. /**
  49761. * Is it xr standard mapping or not
  49762. */
  49763. gamepadMapping: "" | "xr-standard";
  49764. /**
  49765. * Base root node of this entire model
  49766. */
  49767. rootNodeName: string;
  49768. /**
  49769. * Defines the main button component id
  49770. */
  49771. selectComponentId: string;
  49772. }
  49773. /**
  49774. * A definition for the layout map in the input profile
  49775. */
  49776. export interface IMotionControllerLayoutMap {
  49777. /**
  49778. * Layouts with handedness type as a key
  49779. */
  49780. [handedness: string]: IMotionControllerLayout;
  49781. }
  49782. /**
  49783. * The XR Input profile schema
  49784. * Profiles can be found here:
  49785. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  49786. */
  49787. export interface IMotionControllerProfile {
  49788. /**
  49789. * fallback profiles for this profileId
  49790. */
  49791. fallbackProfileIds: string[];
  49792. /**
  49793. * The layout map, with handedness as key
  49794. */
  49795. layouts: IMotionControllerLayoutMap;
  49796. /**
  49797. * The id of this profile
  49798. * correlates to the profile(s) in the xrInput.profiles array
  49799. */
  49800. profileId: string;
  49801. }
  49802. /**
  49803. * A helper-interface for the 3 meshes needed for controller button animation
  49804. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  49805. */
  49806. export interface IMotionControllerButtonMeshMap {
  49807. /**
  49808. * the mesh that defines the pressed value mesh position.
  49809. * This is used to find the max-position of this button
  49810. */
  49811. pressedMesh: AbstractMesh;
  49812. /**
  49813. * the mesh that defines the unpressed value mesh position.
  49814. * This is used to find the min (or initial) position of this button
  49815. */
  49816. unpressedMesh: AbstractMesh;
  49817. /**
  49818. * The mesh that will be changed when value changes
  49819. */
  49820. valueMesh: AbstractMesh;
  49821. }
  49822. /**
  49823. * A helper-interface for the 3 meshes needed for controller axis animation.
  49824. * This will be expanded when touchpad animations are fully supported
  49825. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  49826. */
  49827. export interface IMotionControllerMeshMap {
  49828. /**
  49829. * the mesh that defines the maximum value mesh position.
  49830. */
  49831. maxMesh?: AbstractMesh;
  49832. /**
  49833. * the mesh that defines the minimum value mesh position.
  49834. */
  49835. minMesh?: AbstractMesh;
  49836. /**
  49837. * The mesh that will be changed when axis value changes
  49838. */
  49839. valueMesh: AbstractMesh;
  49840. }
  49841. /**
  49842. * The elements needed for change-detection of the gamepad objects in motion controllers
  49843. */
  49844. export interface IMinimalMotionControllerObject {
  49845. /**
  49846. * Available axes of this controller
  49847. */
  49848. axes: number[];
  49849. /**
  49850. * An array of available buttons
  49851. */
  49852. buttons: Array<{
  49853. /**
  49854. * Value of the button/trigger
  49855. */
  49856. value: number;
  49857. /**
  49858. * If the button/trigger is currently touched
  49859. */
  49860. touched: boolean;
  49861. /**
  49862. * If the button/trigger is currently pressed
  49863. */
  49864. pressed: boolean;
  49865. }>;
  49866. /**
  49867. * EXPERIMENTAL haptic support.
  49868. */
  49869. hapticActuators?: Array<{
  49870. pulse: (value: number, duration: number) => Promise<boolean>;
  49871. }>;
  49872. }
  49873. /**
  49874. * An Abstract Motion controller
  49875. * This class receives an xrInput and a profile layout and uses those to initialize the components
  49876. * Each component has an observable to check for changes in value and state
  49877. */
  49878. export abstract class WebXRAbstractMotionController implements IDisposable {
  49879. protected scene: Scene;
  49880. protected layout: IMotionControllerLayout;
  49881. /**
  49882. * The gamepad object correlating to this controller
  49883. */
  49884. gamepadObject: IMinimalMotionControllerObject;
  49885. /**
  49886. * handedness (left/right/none) of this controller
  49887. */
  49888. handedness: MotionControllerHandedness;
  49889. private _initComponent;
  49890. private _modelReady;
  49891. /**
  49892. * A map of components (WebXRControllerComponent) in this motion controller
  49893. * Components have a ComponentType and can also have both button and axis definitions
  49894. */
  49895. readonly components: {
  49896. [id: string]: WebXRControllerComponent;
  49897. };
  49898. /**
  49899. * Disable the model's animation. Can be set at any time.
  49900. */
  49901. disableAnimation: boolean;
  49902. /**
  49903. * Observers registered here will be triggered when the model of this controller is done loading
  49904. */
  49905. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  49906. /**
  49907. * The profile id of this motion controller
  49908. */
  49909. abstract profileId: string;
  49910. /**
  49911. * The root mesh of the model. It is null if the model was not yet initialized
  49912. */
  49913. rootMesh: Nullable<AbstractMesh>;
  49914. /**
  49915. * constructs a new abstract motion controller
  49916. * @param scene the scene to which the model of the controller will be added
  49917. * @param layout The profile layout to load
  49918. * @param gamepadObject The gamepad object correlating to this controller
  49919. * @param handedness handedness (left/right/none) of this controller
  49920. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  49921. */
  49922. constructor(scene: Scene, layout: IMotionControllerLayout,
  49923. /**
  49924. * The gamepad object correlating to this controller
  49925. */
  49926. gamepadObject: IMinimalMotionControllerObject,
  49927. /**
  49928. * handedness (left/right/none) of this controller
  49929. */
  49930. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  49931. /**
  49932. * Dispose this controller, the model mesh and all its components
  49933. */
  49934. dispose(): void;
  49935. /**
  49936. * Returns all components of specific type
  49937. * @param type the type to search for
  49938. * @return an array of components with this type
  49939. */
  49940. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  49941. /**
  49942. * get a component based an its component id as defined in layout.components
  49943. * @param id the id of the component
  49944. * @returns the component correlates to the id or undefined if not found
  49945. */
  49946. getComponent(id: string): WebXRControllerComponent;
  49947. /**
  49948. * Get the list of components available in this motion controller
  49949. * @returns an array of strings correlating to available components
  49950. */
  49951. getComponentIds(): string[];
  49952. /**
  49953. * Get the first component of specific type
  49954. * @param type type of component to find
  49955. * @return a controller component or null if not found
  49956. */
  49957. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  49958. /**
  49959. * Get the main (Select) component of this controller as defined in the layout
  49960. * @returns the main component of this controller
  49961. */
  49962. getMainComponent(): WebXRControllerComponent;
  49963. /**
  49964. * Loads the model correlating to this controller
  49965. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  49966. * @returns A promise fulfilled with the result of the model loading
  49967. */
  49968. loadModel(): Promise<boolean>;
  49969. /**
  49970. * Update this model using the current XRFrame
  49971. * @param xrFrame the current xr frame to use and update the model
  49972. */
  49973. updateFromXRFrame(xrFrame: XRFrame): void;
  49974. /**
  49975. * Backwards compatibility due to a deeply-integrated typo
  49976. */
  49977. get handness(): XREye;
  49978. /**
  49979. * Pulse (vibrate) this controller
  49980. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  49981. * Consecutive calls to this function will cancel the last pulse call
  49982. *
  49983. * @param value the strength of the pulse in 0.0...1.0 range
  49984. * @param duration Duration of the pulse in milliseconds
  49985. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  49986. * @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
  49987. */
  49988. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  49989. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  49990. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  49991. /**
  49992. * Moves the axis on the controller mesh based on its current state
  49993. * @param axis the index of the axis
  49994. * @param axisValue the value of the axis which determines the meshes new position
  49995. * @hidden
  49996. */
  49997. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  49998. /**
  49999. * Update the model itself with the current frame data
  50000. * @param xrFrame the frame to use for updating the model mesh
  50001. */
  50002. protected updateModel(xrFrame: XRFrame): void;
  50003. /**
  50004. * Get the filename and path for this controller's model
  50005. * @returns a map of filename and path
  50006. */
  50007. protected abstract _getFilenameAndPath(): {
  50008. filename: string;
  50009. path: string;
  50010. };
  50011. /**
  50012. * This function is called before the mesh is loaded. It checks for loading constraints.
  50013. * For example, this function can check if the GLB loader is available
  50014. * If this function returns false, the generic controller will be loaded instead
  50015. * @returns Is the client ready to load the mesh
  50016. */
  50017. protected abstract _getModelLoadingConstraints(): boolean;
  50018. /**
  50019. * This function will be called after the model was successfully loaded and can be used
  50020. * for mesh transformations before it is available for the user
  50021. * @param meshes the loaded meshes
  50022. */
  50023. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  50024. /**
  50025. * Set the root mesh for this controller. Important for the WebXR controller class
  50026. * @param meshes the loaded meshes
  50027. */
  50028. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  50029. /**
  50030. * A function executed each frame that updates the mesh (if needed)
  50031. * @param xrFrame the current xrFrame
  50032. */
  50033. protected abstract _updateModel(xrFrame: XRFrame): void;
  50034. private _getGenericFilenameAndPath;
  50035. private _getGenericParentMesh;
  50036. }
  50037. }
  50038. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  50039. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50040. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50041. import { Scene } from "babylonjs/scene";
  50042. /**
  50043. * A generic trigger-only motion controller for WebXR
  50044. */
  50045. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  50046. /**
  50047. * Static version of the profile id of this controller
  50048. */
  50049. static ProfileId: string;
  50050. profileId: string;
  50051. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  50052. protected _getFilenameAndPath(): {
  50053. filename: string;
  50054. path: string;
  50055. };
  50056. protected _getModelLoadingConstraints(): boolean;
  50057. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  50058. protected _setRootMesh(meshes: AbstractMesh[]): void;
  50059. protected _updateModel(): void;
  50060. }
  50061. }
  50062. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  50063. import { Vector4 } from "babylonjs/Maths/math.vector";
  50064. import { Mesh } from "babylonjs/Meshes/mesh";
  50065. import { Scene } from "babylonjs/scene";
  50066. import { Nullable } from "babylonjs/types";
  50067. /**
  50068. * Class containing static functions to help procedurally build meshes
  50069. */
  50070. export class SphereBuilder {
  50071. /**
  50072. * Creates a sphere mesh
  50073. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  50074. * * 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`)
  50075. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  50076. * * 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
  50077. * * 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)
  50078. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50079. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50080. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50081. * @param name defines the name of the mesh
  50082. * @param options defines the options used to create the mesh
  50083. * @param scene defines the hosting scene
  50084. * @returns the sphere mesh
  50085. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  50086. */
  50087. static CreateSphere(name: string, options: {
  50088. segments?: number;
  50089. diameter?: number;
  50090. diameterX?: number;
  50091. diameterY?: number;
  50092. diameterZ?: number;
  50093. arc?: number;
  50094. slice?: number;
  50095. sideOrientation?: number;
  50096. frontUVs?: Vector4;
  50097. backUVs?: Vector4;
  50098. updatable?: boolean;
  50099. }, scene?: Nullable<Scene>): Mesh;
  50100. }
  50101. }
  50102. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  50103. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50104. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50105. import { Scene } from "babylonjs/scene";
  50106. /**
  50107. * A profiled motion controller has its profile loaded from an online repository.
  50108. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  50109. */
  50110. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  50111. private _repositoryUrl;
  50112. private _buttonMeshMapping;
  50113. private _touchDots;
  50114. /**
  50115. * The profile ID of this controller. Will be populated when the controller initializes.
  50116. */
  50117. profileId: string;
  50118. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  50119. dispose(): void;
  50120. protected _getFilenameAndPath(): {
  50121. filename: string;
  50122. path: string;
  50123. };
  50124. protected _getModelLoadingConstraints(): boolean;
  50125. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  50126. protected _setRootMesh(meshes: AbstractMesh[]): void;
  50127. protected _updateModel(_xrFrame: XRFrame): void;
  50128. }
  50129. }
  50130. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  50131. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50132. import { Scene } from "babylonjs/scene";
  50133. /**
  50134. * A construction function type to create a new controller based on an xrInput object
  50135. */
  50136. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  50137. /**
  50138. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  50139. *
  50140. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  50141. * it should be replaced with auto-loaded controllers.
  50142. *
  50143. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  50144. */
  50145. export class WebXRMotionControllerManager {
  50146. private static _AvailableControllers;
  50147. private static _Fallbacks;
  50148. private static _ProfileLoadingPromises;
  50149. private static _ProfilesList;
  50150. /**
  50151. * The base URL of the online controller repository. Can be changed at any time.
  50152. */
  50153. static BaseRepositoryUrl: string;
  50154. /**
  50155. * Which repository gets priority - local or online
  50156. */
  50157. static PrioritizeOnlineRepository: boolean;
  50158. /**
  50159. * Use the online repository, or use only locally-defined controllers
  50160. */
  50161. static UseOnlineRepository: boolean;
  50162. /**
  50163. * Clear the cache used for profile loading and reload when requested again
  50164. */
  50165. static ClearProfilesCache(): void;
  50166. /**
  50167. * Register the default fallbacks.
  50168. * This function is called automatically when this file is imported.
  50169. */
  50170. static DefaultFallbacks(): void;
  50171. /**
  50172. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  50173. * @param profileId the profile to which a fallback needs to be found
  50174. * @return an array with corresponding fallback profiles
  50175. */
  50176. static FindFallbackWithProfileId(profileId: string): string[];
  50177. /**
  50178. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  50179. * The order of search:
  50180. *
  50181. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  50182. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  50183. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  50184. * 4) return the generic trigger controller if none were found
  50185. *
  50186. * @param xrInput the xrInput to which a new controller is initialized
  50187. * @param scene the scene to which the model will be added
  50188. * @param forceProfile force a certain profile for this controller
  50189. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  50190. */
  50191. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  50192. /**
  50193. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  50194. *
  50195. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  50196. *
  50197. * @param type the profile type to register
  50198. * @param constructFunction the function to be called when loading this profile
  50199. */
  50200. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  50201. /**
  50202. * Register a fallback to a specific profile.
  50203. * @param profileId the profileId that will receive the fallbacks
  50204. * @param fallbacks A list of fallback profiles
  50205. */
  50206. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  50207. /**
  50208. * Will update the list of profiles available in the repository
  50209. * @return a promise that resolves to a map of profiles available online
  50210. */
  50211. static UpdateProfilesList(): Promise<{
  50212. [profile: string]: string;
  50213. }>;
  50214. private static _LoadProfileFromRepository;
  50215. private static _LoadProfilesFromAvailableControllers;
  50216. }
  50217. }
  50218. declare module "babylonjs/XR/webXRInputSource" {
  50219. import { Observable } from "babylonjs/Misc/observable";
  50220. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50221. import { Ray } from "babylonjs/Culling/ray";
  50222. import { Scene } from "babylonjs/scene";
  50223. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50224. /**
  50225. * Configuration options for the WebXR controller creation
  50226. */
  50227. export interface IWebXRControllerOptions {
  50228. /**
  50229. * Should the controller mesh be animated when a user interacts with it
  50230. * The pressed buttons / thumbstick and touchpad animations will be disabled
  50231. */
  50232. disableMotionControllerAnimation?: boolean;
  50233. /**
  50234. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  50235. */
  50236. doNotLoadControllerMesh?: boolean;
  50237. /**
  50238. * Force a specific controller type for this controller.
  50239. * This can be used when creating your own profile or when testing different controllers
  50240. */
  50241. forceControllerProfile?: string;
  50242. /**
  50243. * Defines a rendering group ID for meshes that will be loaded.
  50244. * This is for the default controllers only.
  50245. */
  50246. renderingGroupId?: number;
  50247. }
  50248. /**
  50249. * Represents an XR controller
  50250. */
  50251. export class WebXRInputSource {
  50252. private _scene;
  50253. /** The underlying input source for the controller */
  50254. inputSource: XRInputSource;
  50255. private _options;
  50256. private _tmpVector;
  50257. private _uniqueId;
  50258. /**
  50259. * 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
  50260. */
  50261. grip?: AbstractMesh;
  50262. /**
  50263. * If available, this is the gamepad object related to this controller.
  50264. * Using this object it is possible to get click events and trackpad changes of the
  50265. * webxr controller that is currently being used.
  50266. */
  50267. motionController?: WebXRAbstractMotionController;
  50268. /**
  50269. * Event that fires when the controller is removed/disposed.
  50270. * The object provided as event data is this controller, after associated assets were disposed.
  50271. * uniqueId is still available.
  50272. */
  50273. onDisposeObservable: Observable<WebXRInputSource>;
  50274. /**
  50275. * Will be triggered when the mesh associated with the motion controller is done loading.
  50276. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  50277. * A shortened version of controller -> motion controller -> on mesh loaded.
  50278. */
  50279. onMeshLoadedObservable: Observable<AbstractMesh>;
  50280. /**
  50281. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  50282. */
  50283. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  50284. /**
  50285. * Pointer which can be used to select objects or attach a visible laser to
  50286. */
  50287. pointer: AbstractMesh;
  50288. /**
  50289. * Creates the input source object
  50290. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  50291. * @param _scene the scene which the controller should be associated to
  50292. * @param inputSource the underlying input source for the controller
  50293. * @param _options options for this controller creation
  50294. */
  50295. constructor(_scene: Scene,
  50296. /** The underlying input source for the controller */
  50297. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  50298. /**
  50299. * Get this controllers unique id
  50300. */
  50301. get uniqueId(): string;
  50302. /**
  50303. * Disposes of the object
  50304. */
  50305. dispose(): void;
  50306. /**
  50307. * Gets a world space ray coming from the pointer or grip
  50308. * @param result the resulting ray
  50309. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  50310. */
  50311. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  50312. /**
  50313. * Updates the controller pose based on the given XRFrame
  50314. * @param xrFrame xr frame to update the pose with
  50315. * @param referenceSpace reference space to use
  50316. */
  50317. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  50318. }
  50319. }
  50320. declare module "babylonjs/XR/webXRInput" {
  50321. import { Observable } from "babylonjs/Misc/observable";
  50322. import { IDisposable } from "babylonjs/scene";
  50323. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  50324. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50325. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  50326. /**
  50327. * The schema for initialization options of the XR Input class
  50328. */
  50329. export interface IWebXRInputOptions {
  50330. /**
  50331. * If set to true no model will be automatically loaded
  50332. */
  50333. doNotLoadControllerMeshes?: boolean;
  50334. /**
  50335. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  50336. * If not found, the xr input profile data will be used.
  50337. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  50338. */
  50339. forceInputProfile?: string;
  50340. /**
  50341. * Do not send a request to the controller repository to load the profile.
  50342. *
  50343. * Instead, use the controllers available in babylon itself.
  50344. */
  50345. disableOnlineControllerRepository?: boolean;
  50346. /**
  50347. * A custom URL for the controllers repository
  50348. */
  50349. customControllersRepositoryURL?: string;
  50350. /**
  50351. * Should the controller model's components not move according to the user input
  50352. */
  50353. disableControllerAnimation?: boolean;
  50354. /**
  50355. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  50356. */
  50357. controllerOptions?: IWebXRControllerOptions;
  50358. }
  50359. /**
  50360. * XR input used to track XR inputs such as controllers/rays
  50361. */
  50362. export class WebXRInput implements IDisposable {
  50363. /**
  50364. * the xr session manager for this session
  50365. */
  50366. xrSessionManager: WebXRSessionManager;
  50367. /**
  50368. * the WebXR camera for this session. Mainly used for teleportation
  50369. */
  50370. xrCamera: WebXRCamera;
  50371. private readonly options;
  50372. /**
  50373. * XR controllers being tracked
  50374. */
  50375. controllers: Array<WebXRInputSource>;
  50376. private _frameObserver;
  50377. private _sessionEndedObserver;
  50378. private _sessionInitObserver;
  50379. /**
  50380. * Event when a controller has been connected/added
  50381. */
  50382. onControllerAddedObservable: Observable<WebXRInputSource>;
  50383. /**
  50384. * Event when a controller has been removed/disconnected
  50385. */
  50386. onControllerRemovedObservable: Observable<WebXRInputSource>;
  50387. /**
  50388. * Initializes the WebXRInput
  50389. * @param xrSessionManager the xr session manager for this session
  50390. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  50391. * @param options = initialization options for this xr input
  50392. */
  50393. constructor(
  50394. /**
  50395. * the xr session manager for this session
  50396. */
  50397. xrSessionManager: WebXRSessionManager,
  50398. /**
  50399. * the WebXR camera for this session. Mainly used for teleportation
  50400. */
  50401. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  50402. private _onInputSourcesChange;
  50403. private _addAndRemoveControllers;
  50404. /**
  50405. * Disposes of the object
  50406. */
  50407. dispose(): void;
  50408. }
  50409. }
  50410. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  50411. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  50412. import { Observable, EventState } from "babylonjs/Misc/observable";
  50413. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50414. /**
  50415. * This is the base class for all WebXR features.
  50416. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  50417. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  50418. */
  50419. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  50420. protected _xrSessionManager: WebXRSessionManager;
  50421. private _attached;
  50422. private _removeOnDetach;
  50423. /**
  50424. * Should auto-attach be disabled?
  50425. */
  50426. disableAutoAttach: boolean;
  50427. /**
  50428. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  50429. */
  50430. xrNativeFeatureName: string;
  50431. /**
  50432. * Construct a new (abstract) WebXR feature
  50433. * @param _xrSessionManager the xr session manager for this feature
  50434. */
  50435. constructor(_xrSessionManager: WebXRSessionManager);
  50436. /**
  50437. * Is this feature attached
  50438. */
  50439. get attached(): boolean;
  50440. /**
  50441. * attach this feature
  50442. *
  50443. * @param force should attachment be forced (even when already attached)
  50444. * @returns true if successful, false is failed or already attached
  50445. */
  50446. attach(force?: boolean): boolean;
  50447. /**
  50448. * detach this feature.
  50449. *
  50450. * @returns true if successful, false if failed or already detached
  50451. */
  50452. detach(): boolean;
  50453. /**
  50454. * Dispose this feature and all of the resources attached
  50455. */
  50456. dispose(): void;
  50457. /**
  50458. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  50459. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  50460. *
  50461. * @returns whether or not the feature is compatible in this environment
  50462. */
  50463. isCompatible(): boolean;
  50464. /**
  50465. * This is used to register callbacks that will automatically be removed when detach is called.
  50466. * @param observable the observable to which the observer will be attached
  50467. * @param callback the callback to register
  50468. */
  50469. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  50470. /**
  50471. * Code in this function will be executed on each xrFrame received from the browser.
  50472. * This function will not execute after the feature is detached.
  50473. * @param _xrFrame the current frame
  50474. */
  50475. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  50476. }
  50477. }
  50478. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  50479. import { IDisposable, Scene } from "babylonjs/scene";
  50480. import { Nullable } from "babylonjs/types";
  50481. import { Observable } from "babylonjs/Misc/observable";
  50482. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50483. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  50484. import { Camera } from "babylonjs/Cameras/camera";
  50485. /**
  50486. * Renders a layer on top of an existing scene
  50487. */
  50488. export class UtilityLayerRenderer implements IDisposable {
  50489. /** the original scene that will be rendered on top of */
  50490. originalScene: Scene;
  50491. private _pointerCaptures;
  50492. private _lastPointerEvents;
  50493. private static _DefaultUtilityLayer;
  50494. private static _DefaultKeepDepthUtilityLayer;
  50495. private _sharedGizmoLight;
  50496. private _renderCamera;
  50497. /**
  50498. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  50499. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  50500. * @returns the camera that is used when rendering the utility layer
  50501. */
  50502. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  50503. /**
  50504. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  50505. * @param cam the camera that should be used when rendering the utility layer
  50506. */
  50507. setRenderCamera(cam: Nullable<Camera>): void;
  50508. /**
  50509. * @hidden
  50510. * Light which used by gizmos to get light shading
  50511. */
  50512. _getSharedGizmoLight(): HemisphericLight;
  50513. /**
  50514. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  50515. */
  50516. pickUtilitySceneFirst: boolean;
  50517. /**
  50518. * 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)
  50519. */
  50520. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  50521. /**
  50522. * 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)
  50523. */
  50524. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  50525. /**
  50526. * The scene that is rendered on top of the original scene
  50527. */
  50528. utilityLayerScene: Scene;
  50529. /**
  50530. * If the utility layer should automatically be rendered on top of existing scene
  50531. */
  50532. shouldRender: boolean;
  50533. /**
  50534. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  50535. */
  50536. onlyCheckPointerDownEvents: boolean;
  50537. /**
  50538. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  50539. */
  50540. processAllEvents: boolean;
  50541. /**
  50542. * Observable raised when the pointer move from the utility layer scene to the main scene
  50543. */
  50544. onPointerOutObservable: Observable<number>;
  50545. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  50546. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  50547. private _afterRenderObserver;
  50548. private _sceneDisposeObserver;
  50549. private _originalPointerObserver;
  50550. /**
  50551. * Instantiates a UtilityLayerRenderer
  50552. * @param originalScene the original scene that will be rendered on top of
  50553. * @param handleEvents boolean indicating if the utility layer should handle events
  50554. */
  50555. constructor(
  50556. /** the original scene that will be rendered on top of */
  50557. originalScene: Scene, handleEvents?: boolean);
  50558. private _notifyObservers;
  50559. /**
  50560. * Renders the utility layers scene on top of the original scene
  50561. */
  50562. render(): void;
  50563. /**
  50564. * Disposes of the renderer
  50565. */
  50566. dispose(): void;
  50567. private _updateCamera;
  50568. }
  50569. }
  50570. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  50571. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50572. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50573. import { WebXRInput } from "babylonjs/XR/webXRInput";
  50574. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  50575. import { Scene } from "babylonjs/scene";
  50576. import { Nullable } from "babylonjs/types";
  50577. import { Color3 } from "babylonjs/Maths/math.color";
  50578. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  50579. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  50580. /**
  50581. * Options interface for the pointer selection module
  50582. */
  50583. export interface IWebXRControllerPointerSelectionOptions {
  50584. /**
  50585. * if provided, this scene will be used to render meshes.
  50586. */
  50587. customUtilityLayerScene?: Scene;
  50588. /**
  50589. * 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)
  50590. * If not disabled, the last picked point will be used to execute a pointer up event
  50591. * If disabled, pointer up event will be triggered right after the pointer down event.
  50592. * Used in screen and gaze target ray mode only
  50593. */
  50594. disablePointerUpOnTouchOut: boolean;
  50595. /**
  50596. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  50597. */
  50598. forceGazeMode: boolean;
  50599. /**
  50600. * 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
  50601. * to start a new countdown to the pointer down event.
  50602. * Defaults to 1.
  50603. */
  50604. gazeModePointerMovedFactor?: number;
  50605. /**
  50606. * Different button type to use instead of the main component
  50607. */
  50608. overrideButtonId?: string;
  50609. /**
  50610. * use this rendering group id for the meshes (optional)
  50611. */
  50612. renderingGroupId?: number;
  50613. /**
  50614. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  50615. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  50616. * 3000 means 3 seconds between pointing at something and selecting it
  50617. */
  50618. timeToSelect?: number;
  50619. /**
  50620. * Should meshes created here be added to a utility layer or the main scene
  50621. */
  50622. useUtilityLayer?: boolean;
  50623. /**
  50624. * Optional WebXR camera to be used for gaze selection
  50625. */
  50626. gazeCamera?: WebXRCamera;
  50627. /**
  50628. * the xr input to use with this pointer selection
  50629. */
  50630. xrInput: WebXRInput;
  50631. }
  50632. /**
  50633. * A module that will enable pointer selection for motion controllers of XR Input Sources
  50634. */
  50635. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  50636. private readonly _options;
  50637. private static _idCounter;
  50638. private _attachController;
  50639. private _controllers;
  50640. private _scene;
  50641. private _tmpVectorForPickCompare;
  50642. /**
  50643. * The module's name
  50644. */
  50645. static readonly Name: string;
  50646. /**
  50647. * The (Babylon) version of this module.
  50648. * This is an integer representing the implementation version.
  50649. * This number does not correspond to the WebXR specs version
  50650. */
  50651. static readonly Version: number;
  50652. /**
  50653. * Disable lighting on the laser pointer (so it will always be visible)
  50654. */
  50655. disablePointerLighting: boolean;
  50656. /**
  50657. * Disable lighting on the selection mesh (so it will always be visible)
  50658. */
  50659. disableSelectionMeshLighting: boolean;
  50660. /**
  50661. * Should the laser pointer be displayed
  50662. */
  50663. displayLaserPointer: boolean;
  50664. /**
  50665. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  50666. */
  50667. displaySelectionMesh: boolean;
  50668. /**
  50669. * This color will be set to the laser pointer when selection is triggered
  50670. */
  50671. laserPointerPickedColor: Color3;
  50672. /**
  50673. * Default color of the laser pointer
  50674. */
  50675. laserPointerDefaultColor: Color3;
  50676. /**
  50677. * default color of the selection ring
  50678. */
  50679. selectionMeshDefaultColor: Color3;
  50680. /**
  50681. * This color will be applied to the selection ring when selection is triggered
  50682. */
  50683. selectionMeshPickedColor: Color3;
  50684. /**
  50685. * Optional filter to be used for ray selection. This predicate shares behavior with
  50686. * scene.pointerMovePredicate which takes priority if it is also assigned.
  50687. */
  50688. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  50689. /**
  50690. * constructs a new background remover module
  50691. * @param _xrSessionManager the session manager for this module
  50692. * @param _options read-only options to be used in this module
  50693. */
  50694. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  50695. /**
  50696. * attach this feature
  50697. * Will usually be called by the features manager
  50698. *
  50699. * @returns true if successful.
  50700. */
  50701. attach(): boolean;
  50702. /**
  50703. * detach this feature.
  50704. * Will usually be called by the features manager
  50705. *
  50706. * @returns true if successful.
  50707. */
  50708. detach(): boolean;
  50709. /**
  50710. * Will get the mesh under a specific pointer.
  50711. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  50712. * @param controllerId the controllerId to check
  50713. * @returns The mesh under pointer or null if no mesh is under the pointer
  50714. */
  50715. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  50716. /**
  50717. * Get the xr controller that correlates to the pointer id in the pointer event
  50718. *
  50719. * @param id the pointer id to search for
  50720. * @returns the controller that correlates to this id or null if not found
  50721. */
  50722. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  50723. protected _onXRFrame(_xrFrame: XRFrame): void;
  50724. private _attachGazeMode;
  50725. private _attachScreenRayMode;
  50726. private _attachTrackedPointerRayMode;
  50727. private _convertNormalToDirectionOfRay;
  50728. private _detachController;
  50729. private _generateNewMeshPair;
  50730. private _pickingMoved;
  50731. private _updatePointerDistance;
  50732. /** @hidden */
  50733. get lasterPointerDefaultColor(): Color3;
  50734. }
  50735. }
  50736. declare module "babylonjs/XR/webXREnterExitUI" {
  50737. import { Nullable } from "babylonjs/types";
  50738. import { Observable } from "babylonjs/Misc/observable";
  50739. import { IDisposable, Scene } from "babylonjs/scene";
  50740. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  50741. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  50742. /**
  50743. * Button which can be used to enter a different mode of XR
  50744. */
  50745. export class WebXREnterExitUIButton {
  50746. /** button element */
  50747. element: HTMLElement;
  50748. /** XR initialization options for the button */
  50749. sessionMode: XRSessionMode;
  50750. /** Reference space type */
  50751. referenceSpaceType: XRReferenceSpaceType;
  50752. /**
  50753. * Creates a WebXREnterExitUIButton
  50754. * @param element button element
  50755. * @param sessionMode XR initialization session mode
  50756. * @param referenceSpaceType the type of reference space to be used
  50757. */
  50758. constructor(
  50759. /** button element */
  50760. element: HTMLElement,
  50761. /** XR initialization options for the button */
  50762. sessionMode: XRSessionMode,
  50763. /** Reference space type */
  50764. referenceSpaceType: XRReferenceSpaceType);
  50765. /**
  50766. * Extendable function which can be used to update the button's visuals when the state changes
  50767. * @param activeButton the current active button in the UI
  50768. */
  50769. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  50770. }
  50771. /**
  50772. * Options to create the webXR UI
  50773. */
  50774. export class WebXREnterExitUIOptions {
  50775. /**
  50776. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  50777. */
  50778. customButtons?: Array<WebXREnterExitUIButton>;
  50779. /**
  50780. * A reference space type to use when creating the default button.
  50781. * Default is local-floor
  50782. */
  50783. referenceSpaceType?: XRReferenceSpaceType;
  50784. /**
  50785. * Context to enter xr with
  50786. */
  50787. renderTarget?: Nullable<WebXRRenderTarget>;
  50788. /**
  50789. * A session mode to use when creating the default button.
  50790. * Default is immersive-vr
  50791. */
  50792. sessionMode?: XRSessionMode;
  50793. /**
  50794. * A list of optional features to init the session with
  50795. */
  50796. optionalFeatures?: string[];
  50797. /**
  50798. * A list of optional features to init the session with
  50799. */
  50800. requiredFeatures?: string[];
  50801. }
  50802. /**
  50803. * UI to allow the user to enter/exit XR mode
  50804. */
  50805. export class WebXREnterExitUI implements IDisposable {
  50806. private scene;
  50807. /** version of the options passed to this UI */
  50808. options: WebXREnterExitUIOptions;
  50809. private _activeButton;
  50810. private _buttons;
  50811. private _overlay;
  50812. /**
  50813. * Fired every time the active button is changed.
  50814. *
  50815. * When xr is entered via a button that launches xr that button will be the callback parameter
  50816. *
  50817. * When exiting xr the callback parameter will be null)
  50818. */
  50819. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  50820. /**
  50821. *
  50822. * @param scene babylon scene object to use
  50823. * @param options (read-only) version of the options passed to this UI
  50824. */
  50825. private constructor();
  50826. /**
  50827. * Creates UI to allow the user to enter/exit XR mode
  50828. * @param scene the scene to add the ui to
  50829. * @param helper the xr experience helper to enter/exit xr with
  50830. * @param options options to configure the UI
  50831. * @returns the created ui
  50832. */
  50833. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  50834. /**
  50835. * Disposes of the XR UI component
  50836. */
  50837. dispose(): void;
  50838. private _updateButtons;
  50839. }
  50840. }
  50841. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  50842. import { Vector3 } from "babylonjs/Maths/math.vector";
  50843. import { Color4 } from "babylonjs/Maths/math.color";
  50844. import { Nullable } from "babylonjs/types";
  50845. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  50846. import { Scene } from "babylonjs/scene";
  50847. /**
  50848. * Class containing static functions to help procedurally build meshes
  50849. */
  50850. export class LinesBuilder {
  50851. /**
  50852. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  50853. * * 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
  50854. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  50855. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  50856. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  50857. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  50858. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  50859. * * 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
  50860. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  50861. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50862. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  50863. * @param name defines the name of the new line system
  50864. * @param options defines the options used to create the line system
  50865. * @param scene defines the hosting scene
  50866. * @returns a new line system mesh
  50867. */
  50868. static CreateLineSystem(name: string, options: {
  50869. lines: Vector3[][];
  50870. updatable?: boolean;
  50871. instance?: Nullable<LinesMesh>;
  50872. colors?: Nullable<Color4[][]>;
  50873. useVertexAlpha?: boolean;
  50874. }, scene: Nullable<Scene>): LinesMesh;
  50875. /**
  50876. * Creates a line mesh
  50877. * 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
  50878. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50879. * * The parameter `points` is an array successive Vector3
  50880. * * 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
  50881. * * The optional parameter `colors` is an array of successive Color4, one per line point
  50882. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  50883. * * When updating an instance, remember that only point positions can change, not the number of points
  50884. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50885. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  50886. * @param name defines the name of the new line system
  50887. * @param options defines the options used to create the line system
  50888. * @param scene defines the hosting scene
  50889. * @returns a new line mesh
  50890. */
  50891. static CreateLines(name: string, options: {
  50892. points: Vector3[];
  50893. updatable?: boolean;
  50894. instance?: Nullable<LinesMesh>;
  50895. colors?: Color4[];
  50896. useVertexAlpha?: boolean;
  50897. }, scene?: Nullable<Scene>): LinesMesh;
  50898. /**
  50899. * Creates a dashed line mesh
  50900. * * 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
  50901. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50902. * * The parameter `points` is an array successive Vector3
  50903. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  50904. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  50905. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  50906. * * 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
  50907. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  50908. * * When updating an instance, remember that only point positions can change, not the number of points
  50909. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50910. * @param name defines the name of the mesh
  50911. * @param options defines the options used to create the mesh
  50912. * @param scene defines the hosting scene
  50913. * @returns the dashed line mesh
  50914. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  50915. */
  50916. static CreateDashedLines(name: string, options: {
  50917. points: Vector3[];
  50918. dashSize?: number;
  50919. gapSize?: number;
  50920. dashNb?: number;
  50921. updatable?: boolean;
  50922. instance?: LinesMesh;
  50923. useVertexAlpha?: boolean;
  50924. }, scene?: Nullable<Scene>): LinesMesh;
  50925. }
  50926. }
  50927. declare module "babylonjs/Misc/timer" {
  50928. import { Observable, Observer } from "babylonjs/Misc/observable";
  50929. import { Nullable } from "babylonjs/types";
  50930. import { IDisposable } from "babylonjs/scene";
  50931. /**
  50932. * Construction options for a timer
  50933. */
  50934. export interface ITimerOptions<T> {
  50935. /**
  50936. * Time-to-end
  50937. */
  50938. timeout: number;
  50939. /**
  50940. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  50941. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  50942. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  50943. */
  50944. contextObservable: Observable<T>;
  50945. /**
  50946. * Optional parameters when adding an observer to the observable
  50947. */
  50948. observableParameters?: {
  50949. mask?: number;
  50950. insertFirst?: boolean;
  50951. scope?: any;
  50952. };
  50953. /**
  50954. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  50955. */
  50956. breakCondition?: (data?: ITimerData<T>) => boolean;
  50957. /**
  50958. * Will be triggered when the time condition has met
  50959. */
  50960. onEnded?: (data: ITimerData<any>) => void;
  50961. /**
  50962. * Will be triggered when the break condition has met (prematurely ended)
  50963. */
  50964. onAborted?: (data: ITimerData<any>) => void;
  50965. /**
  50966. * Optional function to execute on each tick (or count)
  50967. */
  50968. onTick?: (data: ITimerData<any>) => void;
  50969. }
  50970. /**
  50971. * An interface defining the data sent by the timer
  50972. */
  50973. export interface ITimerData<T> {
  50974. /**
  50975. * When did it start
  50976. */
  50977. startTime: number;
  50978. /**
  50979. * Time now
  50980. */
  50981. currentTime: number;
  50982. /**
  50983. * Time passed since started
  50984. */
  50985. deltaTime: number;
  50986. /**
  50987. * How much is completed, in [0.0...1.0].
  50988. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  50989. */
  50990. completeRate: number;
  50991. /**
  50992. * What the registered observable sent in the last count
  50993. */
  50994. payload: T;
  50995. }
  50996. /**
  50997. * The current state of the timer
  50998. */
  50999. export enum TimerState {
  51000. /**
  51001. * Timer initialized, not yet started
  51002. */
  51003. INIT = 0,
  51004. /**
  51005. * Timer started and counting
  51006. */
  51007. STARTED = 1,
  51008. /**
  51009. * Timer ended (whether aborted or time reached)
  51010. */
  51011. ENDED = 2
  51012. }
  51013. /**
  51014. * A simple version of the timer. Will take options and start the timer immediately after calling it
  51015. *
  51016. * @param options options with which to initialize this timer
  51017. */
  51018. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  51019. /**
  51020. * An advanced implementation of a timer class
  51021. */
  51022. export class AdvancedTimer<T = any> implements IDisposable {
  51023. /**
  51024. * Will notify each time the timer calculates the remaining time
  51025. */
  51026. onEachCountObservable: Observable<ITimerData<T>>;
  51027. /**
  51028. * Will trigger when the timer was aborted due to the break condition
  51029. */
  51030. onTimerAbortedObservable: Observable<ITimerData<T>>;
  51031. /**
  51032. * Will trigger when the timer ended successfully
  51033. */
  51034. onTimerEndedObservable: Observable<ITimerData<T>>;
  51035. /**
  51036. * Will trigger when the timer state has changed
  51037. */
  51038. onStateChangedObservable: Observable<TimerState>;
  51039. private _observer;
  51040. private _contextObservable;
  51041. private _observableParameters;
  51042. private _startTime;
  51043. private _timer;
  51044. private _state;
  51045. private _breakCondition;
  51046. private _timeToEnd;
  51047. private _breakOnNextTick;
  51048. /**
  51049. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  51050. * @param options construction options for this advanced timer
  51051. */
  51052. constructor(options: ITimerOptions<T>);
  51053. /**
  51054. * set a breaking condition for this timer. Default is to never break during count
  51055. * @param predicate the new break condition. Returns true to break, false otherwise
  51056. */
  51057. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  51058. /**
  51059. * Reset ALL associated observables in this advanced timer
  51060. */
  51061. clearObservables(): void;
  51062. /**
  51063. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  51064. *
  51065. * @param timeToEnd how much time to measure until timer ended
  51066. */
  51067. start(timeToEnd?: number): void;
  51068. /**
  51069. * Will force a stop on the next tick.
  51070. */
  51071. stop(): void;
  51072. /**
  51073. * Dispose this timer, clearing all resources
  51074. */
  51075. dispose(): void;
  51076. private _setState;
  51077. private _tick;
  51078. private _stop;
  51079. }
  51080. }
  51081. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  51082. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  51083. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  51084. import { WebXRInput } from "babylonjs/XR/webXRInput";
  51085. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51086. import { Vector3 } from "babylonjs/Maths/math.vector";
  51087. import { Material } from "babylonjs/Materials/material";
  51088. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  51089. import { Scene } from "babylonjs/scene";
  51090. /**
  51091. * The options container for the teleportation module
  51092. */
  51093. export interface IWebXRTeleportationOptions {
  51094. /**
  51095. * if provided, this scene will be used to render meshes.
  51096. */
  51097. customUtilityLayerScene?: Scene;
  51098. /**
  51099. * Values to configure the default target mesh
  51100. */
  51101. defaultTargetMeshOptions?: {
  51102. /**
  51103. * Fill color of the teleportation area
  51104. */
  51105. teleportationFillColor?: string;
  51106. /**
  51107. * Border color for the teleportation area
  51108. */
  51109. teleportationBorderColor?: string;
  51110. /**
  51111. * Disable the mesh's animation sequence
  51112. */
  51113. disableAnimation?: boolean;
  51114. /**
  51115. * Disable lighting on the material or the ring and arrow
  51116. */
  51117. disableLighting?: boolean;
  51118. /**
  51119. * Override the default material of the torus and arrow
  51120. */
  51121. torusArrowMaterial?: Material;
  51122. };
  51123. /**
  51124. * A list of meshes to use as floor meshes.
  51125. * Meshes can be added and removed after initializing the feature using the
  51126. * addFloorMesh and removeFloorMesh functions
  51127. * If empty, rotation will still work
  51128. */
  51129. floorMeshes?: AbstractMesh[];
  51130. /**
  51131. * use this rendering group id for the meshes (optional)
  51132. */
  51133. renderingGroupId?: number;
  51134. /**
  51135. * Should teleportation move only to snap points
  51136. */
  51137. snapPointsOnly?: boolean;
  51138. /**
  51139. * An array of points to which the teleportation will snap to.
  51140. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  51141. */
  51142. snapPositions?: Vector3[];
  51143. /**
  51144. * How close should the teleportation ray be in order to snap to position.
  51145. * Default to 0.8 units (meters)
  51146. */
  51147. snapToPositionRadius?: number;
  51148. /**
  51149. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  51150. * If you want to support rotation, make sure your mesh has a direction indicator.
  51151. *
  51152. * When left untouched, the default mesh will be initialized.
  51153. */
  51154. teleportationTargetMesh?: AbstractMesh;
  51155. /**
  51156. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  51157. */
  51158. timeToTeleport?: number;
  51159. /**
  51160. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  51161. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  51162. */
  51163. useMainComponentOnly?: boolean;
  51164. /**
  51165. * Should meshes created here be added to a utility layer or the main scene
  51166. */
  51167. useUtilityLayer?: boolean;
  51168. /**
  51169. * Babylon XR Input class for controller
  51170. */
  51171. xrInput: WebXRInput;
  51172. }
  51173. /**
  51174. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  51175. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  51176. * the input of the attached controllers.
  51177. */
  51178. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  51179. private _options;
  51180. private _controllers;
  51181. private _currentTeleportationControllerId;
  51182. private _floorMeshes;
  51183. private _quadraticBezierCurve;
  51184. private _selectionFeature;
  51185. private _snapToPositions;
  51186. private _snappedToPoint;
  51187. private _teleportationRingMaterial?;
  51188. private _tmpRay;
  51189. private _tmpVector;
  51190. /**
  51191. * The module's name
  51192. */
  51193. static readonly Name: string;
  51194. /**
  51195. * The (Babylon) version of this module.
  51196. * This is an integer representing the implementation version.
  51197. * This number does not correspond to the webxr specs version
  51198. */
  51199. static readonly Version: number;
  51200. /**
  51201. * Is movement backwards enabled
  51202. */
  51203. backwardsMovementEnabled: boolean;
  51204. /**
  51205. * Distance to travel when moving backwards
  51206. */
  51207. backwardsTeleportationDistance: number;
  51208. /**
  51209. * The distance from the user to the inspection point in the direction of the controller
  51210. * A higher number will allow the user to move further
  51211. * defaults to 5 (meters, in xr units)
  51212. */
  51213. parabolicCheckRadius: number;
  51214. /**
  51215. * Should the module support parabolic ray on top of direct ray
  51216. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  51217. * Very helpful when moving between floors / different heights
  51218. */
  51219. parabolicRayEnabled: boolean;
  51220. /**
  51221. * How much rotation should be applied when rotating right and left
  51222. */
  51223. rotationAngle: number;
  51224. /**
  51225. * Is rotation enabled when moving forward?
  51226. * Disabling this feature will prevent the user from deciding the direction when teleporting
  51227. */
  51228. rotationEnabled: boolean;
  51229. /**
  51230. * constructs a new anchor system
  51231. * @param _xrSessionManager an instance of WebXRSessionManager
  51232. * @param _options configuration object for this feature
  51233. */
  51234. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  51235. /**
  51236. * Get the snapPointsOnly flag
  51237. */
  51238. get snapPointsOnly(): boolean;
  51239. /**
  51240. * Sets the snapPointsOnly flag
  51241. * @param snapToPoints should teleportation be exclusively to snap points
  51242. */
  51243. set snapPointsOnly(snapToPoints: boolean);
  51244. /**
  51245. * Add a new mesh to the floor meshes array
  51246. * @param mesh the mesh to use as floor mesh
  51247. */
  51248. addFloorMesh(mesh: AbstractMesh): void;
  51249. /**
  51250. * Add a new snap-to point to fix teleportation to this position
  51251. * @param newSnapPoint The new Snap-To point
  51252. */
  51253. addSnapPoint(newSnapPoint: Vector3): void;
  51254. attach(): boolean;
  51255. detach(): boolean;
  51256. dispose(): void;
  51257. /**
  51258. * Remove a mesh from the floor meshes array
  51259. * @param mesh the mesh to remove
  51260. */
  51261. removeFloorMesh(mesh: AbstractMesh): void;
  51262. /**
  51263. * Remove a mesh from the floor meshes array using its name
  51264. * @param name the mesh name to remove
  51265. */
  51266. removeFloorMeshByName(name: string): void;
  51267. /**
  51268. * 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
  51269. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  51270. * @returns was the point found and removed or not
  51271. */
  51272. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  51273. /**
  51274. * This function sets a selection feature that will be disabled when
  51275. * the forward ray is shown and will be reattached when hidden.
  51276. * This is used to remove the selection rays when moving.
  51277. * @param selectionFeature the feature to disable when forward movement is enabled
  51278. */
  51279. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  51280. protected _onXRFrame(_xrFrame: XRFrame): void;
  51281. private _attachController;
  51282. private _createDefaultTargetMesh;
  51283. private _detachController;
  51284. private _findClosestSnapPointWithRadius;
  51285. private _setTargetMeshPosition;
  51286. private _setTargetMeshVisibility;
  51287. private _showParabolicPath;
  51288. private _teleportForward;
  51289. }
  51290. }
  51291. declare module "babylonjs/XR/webXRDefaultExperience" {
  51292. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  51293. import { Scene } from "babylonjs/scene";
  51294. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  51295. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  51296. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  51297. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  51298. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51299. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  51300. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  51301. /**
  51302. * Options for the default xr helper
  51303. */
  51304. export class WebXRDefaultExperienceOptions {
  51305. /**
  51306. * Enable or disable default UI to enter XR
  51307. */
  51308. disableDefaultUI?: boolean;
  51309. /**
  51310. * Should teleportation not initialize. defaults to false.
  51311. */
  51312. disableTeleportation?: boolean;
  51313. /**
  51314. * Floor meshes that will be used for teleport
  51315. */
  51316. floorMeshes?: Array<AbstractMesh>;
  51317. /**
  51318. * If set to true, the first frame will not be used to reset position
  51319. * The first frame is mainly used when copying transformation from the old camera
  51320. * Mainly used in AR
  51321. */
  51322. ignoreNativeCameraTransformation?: boolean;
  51323. /**
  51324. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  51325. */
  51326. inputOptions?: IWebXRInputOptions;
  51327. /**
  51328. * optional configuration for the output canvas
  51329. */
  51330. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  51331. /**
  51332. * optional UI options. This can be used among other to change session mode and reference space type
  51333. */
  51334. uiOptions?: WebXREnterExitUIOptions;
  51335. /**
  51336. * When loading teleportation and pointer select, use stable versions instead of latest.
  51337. */
  51338. useStablePlugins?: boolean;
  51339. /**
  51340. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  51341. */
  51342. renderingGroupId?: number;
  51343. /**
  51344. * A list of optional features to init the session with
  51345. * If set to true, all features we support will be added
  51346. */
  51347. optionalFeatures?: boolean | string[];
  51348. }
  51349. /**
  51350. * Default experience which provides a similar setup to the previous webVRExperience
  51351. */
  51352. export class WebXRDefaultExperience {
  51353. /**
  51354. * Base experience
  51355. */
  51356. baseExperience: WebXRExperienceHelper;
  51357. /**
  51358. * Enables ui for entering/exiting xr
  51359. */
  51360. enterExitUI: WebXREnterExitUI;
  51361. /**
  51362. * Input experience extension
  51363. */
  51364. input: WebXRInput;
  51365. /**
  51366. * Enables laser pointer and selection
  51367. */
  51368. pointerSelection: WebXRControllerPointerSelection;
  51369. /**
  51370. * Default target xr should render to
  51371. */
  51372. renderTarget: WebXRRenderTarget;
  51373. /**
  51374. * Enables teleportation
  51375. */
  51376. teleportation: WebXRMotionControllerTeleportation;
  51377. private constructor();
  51378. /**
  51379. * Creates the default xr experience
  51380. * @param scene scene
  51381. * @param options options for basic configuration
  51382. * @returns resulting WebXRDefaultExperience
  51383. */
  51384. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51385. /**
  51386. * DIsposes of the experience helper
  51387. */
  51388. dispose(): void;
  51389. }
  51390. }
  51391. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  51392. import { Observable } from "babylonjs/Misc/observable";
  51393. import { Nullable } from "babylonjs/types";
  51394. import { Camera } from "babylonjs/Cameras/camera";
  51395. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  51396. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  51397. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  51398. import { Scene } from "babylonjs/scene";
  51399. import { Vector3 } from "babylonjs/Maths/math.vector";
  51400. import { Color3 } from "babylonjs/Maths/math.color";
  51401. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  51402. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51403. import { Mesh } from "babylonjs/Meshes/mesh";
  51404. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  51405. import { EasingFunction } from "babylonjs/Animations/easing";
  51406. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51407. import "babylonjs/Meshes/Builders/groundBuilder";
  51408. import "babylonjs/Meshes/Builders/torusBuilder";
  51409. import "babylonjs/Meshes/Builders/cylinderBuilder";
  51410. import "babylonjs/Gamepads/gamepadSceneComponent";
  51411. import "babylonjs/Animations/animatable";
  51412. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  51413. /**
  51414. * Options to modify the vr teleportation behavior.
  51415. */
  51416. export interface VRTeleportationOptions {
  51417. /**
  51418. * The name of the mesh which should be used as the teleportation floor. (default: null)
  51419. */
  51420. floorMeshName?: string;
  51421. /**
  51422. * A list of meshes to be used as the teleportation floor. (default: empty)
  51423. */
  51424. floorMeshes?: Mesh[];
  51425. /**
  51426. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  51427. */
  51428. teleportationMode?: number;
  51429. /**
  51430. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  51431. */
  51432. teleportationTime?: number;
  51433. /**
  51434. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  51435. */
  51436. teleportationSpeed?: number;
  51437. /**
  51438. * The easing function used in the animation or null for Linear. (default CircleEase)
  51439. */
  51440. easingFunction?: EasingFunction;
  51441. }
  51442. /**
  51443. * Options to modify the vr experience helper's behavior.
  51444. */
  51445. export interface VRExperienceHelperOptions extends WebVROptions {
  51446. /**
  51447. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  51448. */
  51449. createDeviceOrientationCamera?: boolean;
  51450. /**
  51451. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  51452. */
  51453. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  51454. /**
  51455. * Uses the main button on the controller to toggle the laser casted. (default: true)
  51456. */
  51457. laserToggle?: boolean;
  51458. /**
  51459. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  51460. */
  51461. floorMeshes?: Mesh[];
  51462. /**
  51463. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  51464. */
  51465. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  51466. /**
  51467. * Defines if WebXR should be used instead of WebVR (if available)
  51468. */
  51469. useXR?: boolean;
  51470. }
  51471. /**
  51472. * Event containing information after VR has been entered
  51473. */
  51474. export class OnAfterEnteringVRObservableEvent {
  51475. /**
  51476. * If entering vr was successful
  51477. */
  51478. success: boolean;
  51479. }
  51480. /**
  51481. * Helps to quickly add VR support to an existing scene.
  51482. * See https://doc.babylonjs.com/how_to/webvr_helper
  51483. */
  51484. export class VRExperienceHelper {
  51485. /** Options to modify the vr experience helper's behavior. */
  51486. webVROptions: VRExperienceHelperOptions;
  51487. private _scene;
  51488. private _position;
  51489. private _btnVR;
  51490. private _btnVRDisplayed;
  51491. private _webVRsupported;
  51492. private _webVRready;
  51493. private _webVRrequesting;
  51494. private _webVRpresenting;
  51495. private _hasEnteredVR;
  51496. private _fullscreenVRpresenting;
  51497. private _inputElement;
  51498. private _webVRCamera;
  51499. private _vrDeviceOrientationCamera;
  51500. private _deviceOrientationCamera;
  51501. private _existingCamera;
  51502. private _onKeyDown;
  51503. private _onVrDisplayPresentChange;
  51504. private _onVRDisplayChanged;
  51505. private _onVRRequestPresentStart;
  51506. private _onVRRequestPresentComplete;
  51507. /**
  51508. * 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)
  51509. */
  51510. enableGazeEvenWhenNoPointerLock: boolean;
  51511. /**
  51512. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  51513. */
  51514. exitVROnDoubleTap: boolean;
  51515. /**
  51516. * Observable raised right before entering VR.
  51517. */
  51518. onEnteringVRObservable: Observable<VRExperienceHelper>;
  51519. /**
  51520. * Observable raised when entering VR has completed.
  51521. */
  51522. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  51523. /**
  51524. * Observable raised when exiting VR.
  51525. */
  51526. onExitingVRObservable: Observable<VRExperienceHelper>;
  51527. /**
  51528. * Observable raised when controller mesh is loaded.
  51529. */
  51530. onControllerMeshLoadedObservable: Observable<WebVRController>;
  51531. /** Return this.onEnteringVRObservable
  51532. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  51533. */
  51534. get onEnteringVR(): Observable<VRExperienceHelper>;
  51535. /** Return this.onExitingVRObservable
  51536. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  51537. */
  51538. get onExitingVR(): Observable<VRExperienceHelper>;
  51539. /** Return this.onControllerMeshLoadedObservable
  51540. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  51541. */
  51542. get onControllerMeshLoaded(): Observable<WebVRController>;
  51543. private _rayLength;
  51544. private _useCustomVRButton;
  51545. private _teleportationRequested;
  51546. private _teleportActive;
  51547. private _floorMeshName;
  51548. private _floorMeshesCollection;
  51549. private _teleportationMode;
  51550. private _teleportationTime;
  51551. private _teleportationSpeed;
  51552. private _teleportationEasing;
  51553. private _rotationAllowed;
  51554. private _teleportBackwardsVector;
  51555. private _teleportationTarget;
  51556. private _isDefaultTeleportationTarget;
  51557. private _postProcessMove;
  51558. private _teleportationFillColor;
  51559. private _teleportationBorderColor;
  51560. private _rotationAngle;
  51561. private _haloCenter;
  51562. private _cameraGazer;
  51563. private _padSensibilityUp;
  51564. private _padSensibilityDown;
  51565. private _leftController;
  51566. private _rightController;
  51567. private _gazeColor;
  51568. private _laserColor;
  51569. private _pickedLaserColor;
  51570. private _pickedGazeColor;
  51571. /**
  51572. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  51573. */
  51574. onNewMeshSelected: Observable<AbstractMesh>;
  51575. /**
  51576. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  51577. * This observable will provide the mesh and the controller used to select the mesh
  51578. */
  51579. onMeshSelectedWithController: Observable<{
  51580. mesh: AbstractMesh;
  51581. controller: WebVRController;
  51582. }>;
  51583. /**
  51584. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  51585. */
  51586. onNewMeshPicked: Observable<PickingInfo>;
  51587. private _circleEase;
  51588. /**
  51589. * Observable raised before camera teleportation
  51590. */
  51591. onBeforeCameraTeleport: Observable<Vector3>;
  51592. /**
  51593. * Observable raised after camera teleportation
  51594. */
  51595. onAfterCameraTeleport: Observable<Vector3>;
  51596. /**
  51597. * Observable raised when current selected mesh gets unselected
  51598. */
  51599. onSelectedMeshUnselected: Observable<AbstractMesh>;
  51600. private _raySelectionPredicate;
  51601. /**
  51602. * To be optionaly changed by user to define custom ray selection
  51603. */
  51604. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  51605. /**
  51606. * To be optionaly changed by user to define custom selection logic (after ray selection)
  51607. */
  51608. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  51609. /**
  51610. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  51611. */
  51612. teleportationEnabled: boolean;
  51613. private _defaultHeight;
  51614. private _teleportationInitialized;
  51615. private _interactionsEnabled;
  51616. private _interactionsRequested;
  51617. private _displayGaze;
  51618. private _displayLaserPointer;
  51619. /**
  51620. * The mesh used to display where the user is going to teleport.
  51621. */
  51622. get teleportationTarget(): Mesh;
  51623. /**
  51624. * Sets the mesh to be used to display where the user is going to teleport.
  51625. */
  51626. set teleportationTarget(value: Mesh);
  51627. /**
  51628. * 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
  51629. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  51630. * See https://doc.babylonjs.com/resources/baking_transformations
  51631. */
  51632. get gazeTrackerMesh(): Mesh;
  51633. set gazeTrackerMesh(value: Mesh);
  51634. /**
  51635. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  51636. */
  51637. updateGazeTrackerScale: boolean;
  51638. /**
  51639. * If the gaze trackers color should be updated when selecting meshes
  51640. */
  51641. updateGazeTrackerColor: boolean;
  51642. /**
  51643. * If the controller laser color should be updated when selecting meshes
  51644. */
  51645. updateControllerLaserColor: boolean;
  51646. /**
  51647. * The gaze tracking mesh corresponding to the left controller
  51648. */
  51649. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  51650. /**
  51651. * The gaze tracking mesh corresponding to the right controller
  51652. */
  51653. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  51654. /**
  51655. * If the ray of the gaze should be displayed.
  51656. */
  51657. get displayGaze(): boolean;
  51658. /**
  51659. * Sets if the ray of the gaze should be displayed.
  51660. */
  51661. set displayGaze(value: boolean);
  51662. /**
  51663. * If the ray of the LaserPointer should be displayed.
  51664. */
  51665. get displayLaserPointer(): boolean;
  51666. /**
  51667. * Sets if the ray of the LaserPointer should be displayed.
  51668. */
  51669. set displayLaserPointer(value: boolean);
  51670. /**
  51671. * The deviceOrientationCamera used as the camera when not in VR.
  51672. */
  51673. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  51674. /**
  51675. * Based on the current WebVR support, returns the current VR camera used.
  51676. */
  51677. get currentVRCamera(): Nullable<Camera>;
  51678. /**
  51679. * The webVRCamera which is used when in VR.
  51680. */
  51681. get webVRCamera(): WebVRFreeCamera;
  51682. /**
  51683. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  51684. */
  51685. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  51686. /**
  51687. * The html button that is used to trigger entering into VR.
  51688. */
  51689. get vrButton(): Nullable<HTMLButtonElement>;
  51690. private get _teleportationRequestInitiated();
  51691. /**
  51692. * Defines whether or not Pointer lock should be requested when switching to
  51693. * full screen.
  51694. */
  51695. requestPointerLockOnFullScreen: boolean;
  51696. /**
  51697. * If asking to force XR, this will be populated with the default xr experience
  51698. */
  51699. xr: WebXRDefaultExperience;
  51700. /**
  51701. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  51702. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  51703. */
  51704. xrTestDone: boolean;
  51705. /**
  51706. * Instantiates a VRExperienceHelper.
  51707. * Helps to quickly add VR support to an existing scene.
  51708. * @param scene The scene the VRExperienceHelper belongs to.
  51709. * @param webVROptions Options to modify the vr experience helper's behavior.
  51710. */
  51711. constructor(scene: Scene,
  51712. /** Options to modify the vr experience helper's behavior. */
  51713. webVROptions?: VRExperienceHelperOptions);
  51714. private completeVRInit;
  51715. private _onDefaultMeshLoaded;
  51716. private _onResize;
  51717. private _onFullscreenChange;
  51718. /**
  51719. * Gets a value indicating if we are currently in VR mode.
  51720. */
  51721. get isInVRMode(): boolean;
  51722. private onVrDisplayPresentChange;
  51723. private onVRDisplayChanged;
  51724. private moveButtonToBottomRight;
  51725. private displayVRButton;
  51726. private updateButtonVisibility;
  51727. private _cachedAngularSensibility;
  51728. /**
  51729. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  51730. * Otherwise, will use the fullscreen API.
  51731. */
  51732. enterVR(): void;
  51733. /**
  51734. * Attempt to exit VR, or fullscreen.
  51735. */
  51736. exitVR(): void;
  51737. /**
  51738. * The position of the vr experience helper.
  51739. */
  51740. get position(): Vector3;
  51741. /**
  51742. * Sets the position of the vr experience helper.
  51743. */
  51744. set position(value: Vector3);
  51745. /**
  51746. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  51747. */
  51748. enableInteractions(): void;
  51749. private get _noControllerIsActive();
  51750. private beforeRender;
  51751. private _isTeleportationFloor;
  51752. /**
  51753. * Adds a floor mesh to be used for teleportation.
  51754. * @param floorMesh the mesh to be used for teleportation.
  51755. */
  51756. addFloorMesh(floorMesh: Mesh): void;
  51757. /**
  51758. * Removes a floor mesh from being used for teleportation.
  51759. * @param floorMesh the mesh to be removed.
  51760. */
  51761. removeFloorMesh(floorMesh: Mesh): void;
  51762. /**
  51763. * Enables interactions and teleportation using the VR controllers and gaze.
  51764. * @param vrTeleportationOptions options to modify teleportation behavior.
  51765. */
  51766. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  51767. private _onNewGamepadConnected;
  51768. private _tryEnableInteractionOnController;
  51769. private _onNewGamepadDisconnected;
  51770. private _enableInteractionOnController;
  51771. private _checkTeleportWithRay;
  51772. private _checkRotate;
  51773. private _checkTeleportBackwards;
  51774. private _enableTeleportationOnController;
  51775. private _createTeleportationCircles;
  51776. private _displayTeleportationTarget;
  51777. private _hideTeleportationTarget;
  51778. private _rotateCamera;
  51779. private _moveTeleportationSelectorTo;
  51780. private _workingVector;
  51781. private _workingQuaternion;
  51782. private _workingMatrix;
  51783. /**
  51784. * Time Constant Teleportation Mode
  51785. */
  51786. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  51787. /**
  51788. * Speed Constant Teleportation Mode
  51789. */
  51790. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  51791. /**
  51792. * Teleports the users feet to the desired location
  51793. * @param location The location where the user's feet should be placed
  51794. */
  51795. teleportCamera(location: Vector3): void;
  51796. private _convertNormalToDirectionOfRay;
  51797. private _castRayAndSelectObject;
  51798. private _notifySelectedMeshUnselected;
  51799. /**
  51800. * Permanently set new colors for the laser pointer
  51801. * @param color the new laser color
  51802. * @param pickedColor the new laser color when picked mesh detected
  51803. */
  51804. setLaserColor(color: Color3, pickedColor?: Color3): void;
  51805. /**
  51806. * Set lighting enabled / disabled on the laser pointer of both controllers
  51807. * @param enabled should the lighting be enabled on the laser pointer
  51808. */
  51809. setLaserLightingState(enabled?: boolean): void;
  51810. /**
  51811. * Permanently set new colors for the gaze pointer
  51812. * @param color the new gaze color
  51813. * @param pickedColor the new gaze color when picked mesh detected
  51814. */
  51815. setGazeColor(color: Color3, pickedColor?: Color3): void;
  51816. /**
  51817. * Sets the color of the laser ray from the vr controllers.
  51818. * @param color new color for the ray.
  51819. */
  51820. changeLaserColor(color: Color3): void;
  51821. /**
  51822. * Sets the color of the ray from the vr headsets gaze.
  51823. * @param color new color for the ray.
  51824. */
  51825. changeGazeColor(color: Color3): void;
  51826. /**
  51827. * Exits VR and disposes of the vr experience helper
  51828. */
  51829. dispose(): void;
  51830. /**
  51831. * Gets the name of the VRExperienceHelper class
  51832. * @returns "VRExperienceHelper"
  51833. */
  51834. getClassName(): string;
  51835. }
  51836. }
  51837. declare module "babylonjs/Cameras/VR/index" {
  51838. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  51839. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  51840. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  51841. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  51842. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  51843. export * from "babylonjs/Cameras/VR/webVRCamera";
  51844. }
  51845. declare module "babylonjs/Cameras/RigModes/index" {
  51846. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51847. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51848. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  51849. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  51850. }
  51851. declare module "babylonjs/Cameras/index" {
  51852. export * from "babylonjs/Cameras/Inputs/index";
  51853. export * from "babylonjs/Cameras/cameraInputsManager";
  51854. export * from "babylonjs/Cameras/camera";
  51855. export * from "babylonjs/Cameras/targetCamera";
  51856. export * from "babylonjs/Cameras/freeCamera";
  51857. export * from "babylonjs/Cameras/freeCameraInputsManager";
  51858. export * from "babylonjs/Cameras/touchCamera";
  51859. export * from "babylonjs/Cameras/arcRotateCamera";
  51860. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  51861. export * from "babylonjs/Cameras/deviceOrientationCamera";
  51862. export * from "babylonjs/Cameras/flyCamera";
  51863. export * from "babylonjs/Cameras/flyCameraInputsManager";
  51864. export * from "babylonjs/Cameras/followCamera";
  51865. export * from "babylonjs/Cameras/followCameraInputsManager";
  51866. export * from "babylonjs/Cameras/gamepadCamera";
  51867. export * from "babylonjs/Cameras/Stereoscopic/index";
  51868. export * from "babylonjs/Cameras/universalCamera";
  51869. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  51870. export * from "babylonjs/Cameras/VR/index";
  51871. export * from "babylonjs/Cameras/RigModes/index";
  51872. }
  51873. declare module "babylonjs/Collisions/index" {
  51874. export * from "babylonjs/Collisions/collider";
  51875. export * from "babylonjs/Collisions/collisionCoordinator";
  51876. export * from "babylonjs/Collisions/pickingInfo";
  51877. export * from "babylonjs/Collisions/intersectionInfo";
  51878. export * from "babylonjs/Collisions/meshCollisionData";
  51879. }
  51880. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  51881. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  51882. import { Vector3 } from "babylonjs/Maths/math.vector";
  51883. import { Ray } from "babylonjs/Culling/ray";
  51884. import { Plane } from "babylonjs/Maths/math.plane";
  51885. /**
  51886. * Contains an array of blocks representing the octree
  51887. */
  51888. export interface IOctreeContainer<T> {
  51889. /**
  51890. * Blocks within the octree
  51891. */
  51892. blocks: Array<OctreeBlock<T>>;
  51893. }
  51894. /**
  51895. * Class used to store a cell in an octree
  51896. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51897. */
  51898. export class OctreeBlock<T> {
  51899. /**
  51900. * Gets the content of the current block
  51901. */
  51902. entries: T[];
  51903. /**
  51904. * Gets the list of block children
  51905. */
  51906. blocks: Array<OctreeBlock<T>>;
  51907. private _depth;
  51908. private _maxDepth;
  51909. private _capacity;
  51910. private _minPoint;
  51911. private _maxPoint;
  51912. private _boundingVectors;
  51913. private _creationFunc;
  51914. /**
  51915. * Creates a new block
  51916. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  51917. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  51918. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  51919. * @param depth defines the current depth of this block in the octree
  51920. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  51921. * @param creationFunc defines a callback to call when an element is added to the block
  51922. */
  51923. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  51924. /**
  51925. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  51926. */
  51927. get capacity(): number;
  51928. /**
  51929. * Gets the minimum vector (in world space) of the block's bounding box
  51930. */
  51931. get minPoint(): Vector3;
  51932. /**
  51933. * Gets the maximum vector (in world space) of the block's bounding box
  51934. */
  51935. get maxPoint(): Vector3;
  51936. /**
  51937. * Add a new element to this block
  51938. * @param entry defines the element to add
  51939. */
  51940. addEntry(entry: T): void;
  51941. /**
  51942. * Remove an element from this block
  51943. * @param entry defines the element to remove
  51944. */
  51945. removeEntry(entry: T): void;
  51946. /**
  51947. * Add an array of elements to this block
  51948. * @param entries defines the array of elements to add
  51949. */
  51950. addEntries(entries: T[]): void;
  51951. /**
  51952. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  51953. * @param frustumPlanes defines the frustum planes to test
  51954. * @param selection defines the array to store current content if selection is positive
  51955. * @param allowDuplicate defines if the selection array can contains duplicated entries
  51956. */
  51957. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  51958. /**
  51959. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  51960. * @param sphereCenter defines the bounding sphere center
  51961. * @param sphereRadius defines the bounding sphere radius
  51962. * @param selection defines the array to store current content if selection is positive
  51963. * @param allowDuplicate defines if the selection array can contains duplicated entries
  51964. */
  51965. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  51966. /**
  51967. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  51968. * @param ray defines the ray to test with
  51969. * @param selection defines the array to store current content if selection is positive
  51970. */
  51971. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  51972. /**
  51973. * Subdivide the content into child blocks (this block will then be empty)
  51974. */
  51975. createInnerBlocks(): void;
  51976. /**
  51977. * @hidden
  51978. */
  51979. 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;
  51980. }
  51981. }
  51982. declare module "babylonjs/Culling/Octrees/octree" {
  51983. import { SmartArray } from "babylonjs/Misc/smartArray";
  51984. import { Vector3 } from "babylonjs/Maths/math.vector";
  51985. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51986. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51987. import { Ray } from "babylonjs/Culling/ray";
  51988. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  51989. import { Plane } from "babylonjs/Maths/math.plane";
  51990. /**
  51991. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  51992. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51993. */
  51994. export class Octree<T> {
  51995. /** 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.) */
  51996. maxDepth: number;
  51997. /**
  51998. * Blocks within the octree containing objects
  51999. */
  52000. blocks: Array<OctreeBlock<T>>;
  52001. /**
  52002. * Content stored in the octree
  52003. */
  52004. dynamicContent: T[];
  52005. private _maxBlockCapacity;
  52006. private _selectionContent;
  52007. private _creationFunc;
  52008. /**
  52009. * Creates a octree
  52010. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52011. * @param creationFunc function to be used to instatiate the octree
  52012. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  52013. * @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.)
  52014. */
  52015. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  52016. /** 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.) */
  52017. maxDepth?: number);
  52018. /**
  52019. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  52020. * @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);
  52021. * @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);
  52022. * @param entries meshes to be added to the octree blocks
  52023. */
  52024. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  52025. /**
  52026. * Adds a mesh to the octree
  52027. * @param entry Mesh to add to the octree
  52028. */
  52029. addMesh(entry: T): void;
  52030. /**
  52031. * Remove an element from the octree
  52032. * @param entry defines the element to remove
  52033. */
  52034. removeMesh(entry: T): void;
  52035. /**
  52036. * Selects an array of meshes within the frustum
  52037. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  52038. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  52039. * @returns array of meshes within the frustum
  52040. */
  52041. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  52042. /**
  52043. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  52044. * @param sphereCenter defines the bounding sphere center
  52045. * @param sphereRadius defines the bounding sphere radius
  52046. * @param allowDuplicate defines if the selection array can contains duplicated entries
  52047. * @returns an array of objects that intersect the sphere
  52048. */
  52049. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  52050. /**
  52051. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  52052. * @param ray defines the ray to test with
  52053. * @returns array of intersected objects
  52054. */
  52055. intersectsRay(ray: Ray): SmartArray<T>;
  52056. /**
  52057. * Adds a mesh into the octree block if it intersects the block
  52058. */
  52059. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  52060. /**
  52061. * Adds a submesh into the octree block if it intersects the block
  52062. */
  52063. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  52064. }
  52065. }
  52066. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  52067. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  52068. import { Scene } from "babylonjs/scene";
  52069. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52070. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52071. import { Ray } from "babylonjs/Culling/ray";
  52072. import { Octree } from "babylonjs/Culling/Octrees/octree";
  52073. import { Collider } from "babylonjs/Collisions/collider";
  52074. module "babylonjs/scene" {
  52075. interface Scene {
  52076. /**
  52077. * @hidden
  52078. * Backing Filed
  52079. */
  52080. _selectionOctree: Octree<AbstractMesh>;
  52081. /**
  52082. * Gets the octree used to boost mesh selection (picking)
  52083. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52084. */
  52085. selectionOctree: Octree<AbstractMesh>;
  52086. /**
  52087. * Creates or updates the octree used to boost selection (picking)
  52088. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52089. * @param maxCapacity defines the maximum capacity per leaf
  52090. * @param maxDepth defines the maximum depth of the octree
  52091. * @returns an octree of AbstractMesh
  52092. */
  52093. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  52094. }
  52095. }
  52096. module "babylonjs/Meshes/abstractMesh" {
  52097. interface AbstractMesh {
  52098. /**
  52099. * @hidden
  52100. * Backing Field
  52101. */
  52102. _submeshesOctree: Octree<SubMesh>;
  52103. /**
  52104. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  52105. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  52106. * @param maxCapacity defines the maximum size of each block (64 by default)
  52107. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  52108. * @returns the new octree
  52109. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  52110. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52111. */
  52112. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  52113. }
  52114. }
  52115. /**
  52116. * Defines the octree scene component responsible to manage any octrees
  52117. * in a given scene.
  52118. */
  52119. export class OctreeSceneComponent {
  52120. /**
  52121. * The component name help to identify the component in the list of scene components.
  52122. */
  52123. readonly name: string;
  52124. /**
  52125. * The scene the component belongs to.
  52126. */
  52127. scene: Scene;
  52128. /**
  52129. * Indicates if the meshes have been checked to make sure they are isEnabled()
  52130. */
  52131. readonly checksIsEnabled: boolean;
  52132. /**
  52133. * Creates a new instance of the component for the given scene
  52134. * @param scene Defines the scene to register the component in
  52135. */
  52136. constructor(scene: Scene);
  52137. /**
  52138. * Registers the component in a given scene
  52139. */
  52140. register(): void;
  52141. /**
  52142. * Return the list of active meshes
  52143. * @returns the list of active meshes
  52144. */
  52145. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  52146. /**
  52147. * Return the list of active sub meshes
  52148. * @param mesh The mesh to get the candidates sub meshes from
  52149. * @returns the list of active sub meshes
  52150. */
  52151. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  52152. private _tempRay;
  52153. /**
  52154. * Return the list of sub meshes intersecting with a given local ray
  52155. * @param mesh defines the mesh to find the submesh for
  52156. * @param localRay defines the ray in local space
  52157. * @returns the list of intersecting sub meshes
  52158. */
  52159. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  52160. /**
  52161. * Return the list of sub meshes colliding with a collider
  52162. * @param mesh defines the mesh to find the submesh for
  52163. * @param collider defines the collider to evaluate the collision against
  52164. * @returns the list of colliding sub meshes
  52165. */
  52166. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  52167. /**
  52168. * Rebuilds the elements related to this component in case of
  52169. * context lost for instance.
  52170. */
  52171. rebuild(): void;
  52172. /**
  52173. * Disposes the component and the associated ressources.
  52174. */
  52175. dispose(): void;
  52176. }
  52177. }
  52178. declare module "babylonjs/Culling/Octrees/index" {
  52179. export * from "babylonjs/Culling/Octrees/octree";
  52180. export * from "babylonjs/Culling/Octrees/octreeBlock";
  52181. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  52182. }
  52183. declare module "babylonjs/Culling/index" {
  52184. export * from "babylonjs/Culling/boundingBox";
  52185. export * from "babylonjs/Culling/boundingInfo";
  52186. export * from "babylonjs/Culling/boundingSphere";
  52187. export * from "babylonjs/Culling/Octrees/index";
  52188. export * from "babylonjs/Culling/ray";
  52189. }
  52190. declare module "babylonjs/Gizmos/gizmo" {
  52191. import { Nullable } from "babylonjs/types";
  52192. import { IDisposable } from "babylonjs/scene";
  52193. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52194. import { Mesh } from "babylonjs/Meshes/mesh";
  52195. import { Node } from "babylonjs/node";
  52196. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52197. /**
  52198. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  52199. */
  52200. export class Gizmo implements IDisposable {
  52201. /** The utility layer the gizmo will be added to */
  52202. gizmoLayer: UtilityLayerRenderer;
  52203. /**
  52204. * The root mesh of the gizmo
  52205. */
  52206. _rootMesh: Mesh;
  52207. private _attachedMesh;
  52208. private _attachedNode;
  52209. /**
  52210. * Ratio for the scale of the gizmo (Default: 1)
  52211. */
  52212. scaleRatio: number;
  52213. /**
  52214. * If a custom mesh has been set (Default: false)
  52215. */
  52216. protected _customMeshSet: boolean;
  52217. /**
  52218. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  52219. * * When set, interactions will be enabled
  52220. */
  52221. get attachedMesh(): Nullable<AbstractMesh>;
  52222. set attachedMesh(value: Nullable<AbstractMesh>);
  52223. /**
  52224. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  52225. * * When set, interactions will be enabled
  52226. */
  52227. get attachedNode(): Nullable<Node>;
  52228. set attachedNode(value: Nullable<Node>);
  52229. /**
  52230. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  52231. * @param mesh The mesh to replace the default mesh of the gizmo
  52232. */
  52233. setCustomMesh(mesh: Mesh): void;
  52234. /**
  52235. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  52236. */
  52237. updateGizmoRotationToMatchAttachedMesh: boolean;
  52238. /**
  52239. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  52240. */
  52241. updateGizmoPositionToMatchAttachedMesh: boolean;
  52242. /**
  52243. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  52244. */
  52245. updateScale: boolean;
  52246. protected _interactionsEnabled: boolean;
  52247. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52248. private _beforeRenderObserver;
  52249. private _tempQuaternion;
  52250. private _tempVector;
  52251. private _tempVector2;
  52252. /**
  52253. * Creates a gizmo
  52254. * @param gizmoLayer The utility layer the gizmo will be added to
  52255. */
  52256. constructor(
  52257. /** The utility layer the gizmo will be added to */
  52258. gizmoLayer?: UtilityLayerRenderer);
  52259. /**
  52260. * Updates the gizmo to match the attached mesh's position/rotation
  52261. */
  52262. protected _update(): void;
  52263. /**
  52264. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  52265. * @param value Node, TransformNode or mesh
  52266. */
  52267. protected _matrixChanged(): void;
  52268. /**
  52269. * Disposes of the gizmo
  52270. */
  52271. dispose(): void;
  52272. }
  52273. }
  52274. declare module "babylonjs/Gizmos/planeDragGizmo" {
  52275. import { Observable } from "babylonjs/Misc/observable";
  52276. import { Nullable } from "babylonjs/types";
  52277. import { Vector3 } from "babylonjs/Maths/math.vector";
  52278. import { Color3 } from "babylonjs/Maths/math.color";
  52279. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52280. import { Node } from "babylonjs/node";
  52281. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  52282. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52283. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52284. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  52285. import { Scene } from "babylonjs/scene";
  52286. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  52287. /**
  52288. * Single plane drag gizmo
  52289. */
  52290. export class PlaneDragGizmo extends Gizmo {
  52291. /**
  52292. * Drag behavior responsible for the gizmos dragging interactions
  52293. */
  52294. dragBehavior: PointerDragBehavior;
  52295. private _pointerObserver;
  52296. /**
  52297. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52298. */
  52299. snapDistance: number;
  52300. /**
  52301. * Event that fires each time the gizmo snaps to a new location.
  52302. * * snapDistance is the the change in distance
  52303. */
  52304. onSnapObservable: Observable<{
  52305. snapDistance: number;
  52306. }>;
  52307. private _plane;
  52308. private _coloredMaterial;
  52309. private _hoverMaterial;
  52310. private _isEnabled;
  52311. private _parent;
  52312. /** @hidden */
  52313. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  52314. /** @hidden */
  52315. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  52316. /**
  52317. * Creates a PlaneDragGizmo
  52318. * @param gizmoLayer The utility layer the gizmo will be added to
  52319. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  52320. * @param color The color of the gizmo
  52321. */
  52322. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  52323. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52324. /**
  52325. * If the gizmo is enabled
  52326. */
  52327. set isEnabled(value: boolean);
  52328. get isEnabled(): boolean;
  52329. /**
  52330. * Disposes of the gizmo
  52331. */
  52332. dispose(): void;
  52333. }
  52334. }
  52335. declare module "babylonjs/Gizmos/positionGizmo" {
  52336. import { Observable } from "babylonjs/Misc/observable";
  52337. import { Nullable } from "babylonjs/types";
  52338. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52339. import { Node } from "babylonjs/node";
  52340. import { Mesh } from "babylonjs/Meshes/mesh";
  52341. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52342. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  52343. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  52344. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52345. /**
  52346. * Gizmo that enables dragging a mesh along 3 axis
  52347. */
  52348. export class PositionGizmo extends Gizmo {
  52349. /**
  52350. * Internal gizmo used for interactions on the x axis
  52351. */
  52352. xGizmo: AxisDragGizmo;
  52353. /**
  52354. * Internal gizmo used for interactions on the y axis
  52355. */
  52356. yGizmo: AxisDragGizmo;
  52357. /**
  52358. * Internal gizmo used for interactions on the z axis
  52359. */
  52360. zGizmo: AxisDragGizmo;
  52361. /**
  52362. * Internal gizmo used for interactions on the yz plane
  52363. */
  52364. xPlaneGizmo: PlaneDragGizmo;
  52365. /**
  52366. * Internal gizmo used for interactions on the xz plane
  52367. */
  52368. yPlaneGizmo: PlaneDragGizmo;
  52369. /**
  52370. * Internal gizmo used for interactions on the xy plane
  52371. */
  52372. zPlaneGizmo: PlaneDragGizmo;
  52373. /**
  52374. * private variables
  52375. */
  52376. private _meshAttached;
  52377. private _nodeAttached;
  52378. private _updateGizmoRotationToMatchAttachedMesh;
  52379. private _snapDistance;
  52380. private _scaleRatio;
  52381. /** Fires an event when any of it's sub gizmos are dragged */
  52382. onDragStartObservable: Observable<unknown>;
  52383. /** Fires an event when any of it's sub gizmos are released from dragging */
  52384. onDragEndObservable: Observable<unknown>;
  52385. /**
  52386. * If set to true, planar drag is enabled
  52387. */
  52388. private _planarGizmoEnabled;
  52389. get attachedMesh(): Nullable<AbstractMesh>;
  52390. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52391. get attachedNode(): Nullable<Node>;
  52392. set attachedNode(node: Nullable<Node>);
  52393. /**
  52394. * Creates a PositionGizmo
  52395. * @param gizmoLayer The utility layer the gizmo will be added to
  52396. @param thickness display gizmo axis thickness
  52397. */
  52398. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  52399. /**
  52400. * If the planar drag gizmo is enabled
  52401. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  52402. */
  52403. set planarGizmoEnabled(value: boolean);
  52404. get planarGizmoEnabled(): boolean;
  52405. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52406. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52407. /**
  52408. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52409. */
  52410. set snapDistance(value: number);
  52411. get snapDistance(): number;
  52412. /**
  52413. * Ratio for the scale of the gizmo (Default: 1)
  52414. */
  52415. set scaleRatio(value: number);
  52416. get scaleRatio(): number;
  52417. /**
  52418. * Disposes of the gizmo
  52419. */
  52420. dispose(): void;
  52421. /**
  52422. * CustomMeshes are not supported by this gizmo
  52423. * @param mesh The mesh to replace the default mesh of the gizmo
  52424. */
  52425. setCustomMesh(mesh: Mesh): void;
  52426. }
  52427. }
  52428. declare module "babylonjs/Gizmos/axisDragGizmo" {
  52429. import { Observable } from "babylonjs/Misc/observable";
  52430. import { Nullable } from "babylonjs/types";
  52431. import { Vector3 } from "babylonjs/Maths/math.vector";
  52432. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52433. import { Node } from "babylonjs/node";
  52434. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  52435. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52436. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52437. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  52438. import { Scene } from "babylonjs/scene";
  52439. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  52440. import { Color3 } from "babylonjs/Maths/math.color";
  52441. /**
  52442. * Single axis drag gizmo
  52443. */
  52444. export class AxisDragGizmo extends Gizmo {
  52445. /**
  52446. * Drag behavior responsible for the gizmos dragging interactions
  52447. */
  52448. dragBehavior: PointerDragBehavior;
  52449. private _pointerObserver;
  52450. /**
  52451. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52452. */
  52453. snapDistance: number;
  52454. /**
  52455. * Event that fires each time the gizmo snaps to a new location.
  52456. * * snapDistance is the the change in distance
  52457. */
  52458. onSnapObservable: Observable<{
  52459. snapDistance: number;
  52460. }>;
  52461. private _isEnabled;
  52462. private _parent;
  52463. private _arrow;
  52464. private _coloredMaterial;
  52465. private _hoverMaterial;
  52466. /** @hidden */
  52467. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  52468. /** @hidden */
  52469. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  52470. /**
  52471. * Creates an AxisDragGizmo
  52472. * @param gizmoLayer The utility layer the gizmo will be added to
  52473. * @param dragAxis The axis which the gizmo will be able to drag on
  52474. * @param color The color of the gizmo
  52475. * @param thickness display gizmo axis thickness
  52476. */
  52477. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  52478. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52479. /**
  52480. * If the gizmo is enabled
  52481. */
  52482. set isEnabled(value: boolean);
  52483. get isEnabled(): boolean;
  52484. /**
  52485. * Disposes of the gizmo
  52486. */
  52487. dispose(): void;
  52488. }
  52489. }
  52490. declare module "babylonjs/Debug/axesViewer" {
  52491. import { Vector3 } from "babylonjs/Maths/math.vector";
  52492. import { Nullable } from "babylonjs/types";
  52493. import { Scene } from "babylonjs/scene";
  52494. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52495. /**
  52496. * The Axes viewer will show 3 axes in a specific point in space
  52497. */
  52498. export class AxesViewer {
  52499. private _xAxis;
  52500. private _yAxis;
  52501. private _zAxis;
  52502. private _scaleLinesFactor;
  52503. private _instanced;
  52504. /**
  52505. * Gets the hosting scene
  52506. */
  52507. scene: Scene;
  52508. /**
  52509. * Gets or sets a number used to scale line length
  52510. */
  52511. scaleLines: number;
  52512. /** Gets the node hierarchy used to render x-axis */
  52513. get xAxis(): TransformNode;
  52514. /** Gets the node hierarchy used to render y-axis */
  52515. get yAxis(): TransformNode;
  52516. /** Gets the node hierarchy used to render z-axis */
  52517. get zAxis(): TransformNode;
  52518. /**
  52519. * Creates a new AxesViewer
  52520. * @param scene defines the hosting scene
  52521. * @param scaleLines defines a number used to scale line length (1 by default)
  52522. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  52523. * @param xAxis defines the node hierarchy used to render the x-axis
  52524. * @param yAxis defines the node hierarchy used to render the y-axis
  52525. * @param zAxis defines the node hierarchy used to render the z-axis
  52526. */
  52527. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  52528. /**
  52529. * Force the viewer to update
  52530. * @param position defines the position of the viewer
  52531. * @param xaxis defines the x axis of the viewer
  52532. * @param yaxis defines the y axis of the viewer
  52533. * @param zaxis defines the z axis of the viewer
  52534. */
  52535. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  52536. /**
  52537. * Creates an instance of this axes viewer.
  52538. * @returns a new axes viewer with instanced meshes
  52539. */
  52540. createInstance(): AxesViewer;
  52541. /** Releases resources */
  52542. dispose(): void;
  52543. private static _SetRenderingGroupId;
  52544. }
  52545. }
  52546. declare module "babylonjs/Debug/boneAxesViewer" {
  52547. import { Nullable } from "babylonjs/types";
  52548. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  52549. import { Vector3 } from "babylonjs/Maths/math.vector";
  52550. import { Mesh } from "babylonjs/Meshes/mesh";
  52551. import { Bone } from "babylonjs/Bones/bone";
  52552. import { Scene } from "babylonjs/scene";
  52553. /**
  52554. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  52555. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  52556. */
  52557. export class BoneAxesViewer extends AxesViewer {
  52558. /**
  52559. * Gets or sets the target mesh where to display the axes viewer
  52560. */
  52561. mesh: Nullable<Mesh>;
  52562. /**
  52563. * Gets or sets the target bone where to display the axes viewer
  52564. */
  52565. bone: Nullable<Bone>;
  52566. /** Gets current position */
  52567. pos: Vector3;
  52568. /** Gets direction of X axis */
  52569. xaxis: Vector3;
  52570. /** Gets direction of Y axis */
  52571. yaxis: Vector3;
  52572. /** Gets direction of Z axis */
  52573. zaxis: Vector3;
  52574. /**
  52575. * Creates a new BoneAxesViewer
  52576. * @param scene defines the hosting scene
  52577. * @param bone defines the target bone
  52578. * @param mesh defines the target mesh
  52579. * @param scaleLines defines a scaling factor for line length (1 by default)
  52580. */
  52581. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  52582. /**
  52583. * Force the viewer to update
  52584. */
  52585. update(): void;
  52586. /** Releases resources */
  52587. dispose(): void;
  52588. }
  52589. }
  52590. declare module "babylonjs/Debug/debugLayer" {
  52591. import { Scene } from "babylonjs/scene";
  52592. /**
  52593. * Interface used to define scene explorer extensibility option
  52594. */
  52595. export interface IExplorerExtensibilityOption {
  52596. /**
  52597. * Define the option label
  52598. */
  52599. label: string;
  52600. /**
  52601. * Defines the action to execute on click
  52602. */
  52603. action: (entity: any) => void;
  52604. }
  52605. /**
  52606. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  52607. */
  52608. export interface IExplorerExtensibilityGroup {
  52609. /**
  52610. * Defines a predicate to test if a given type mut be extended
  52611. */
  52612. predicate: (entity: any) => boolean;
  52613. /**
  52614. * Gets the list of options added to a type
  52615. */
  52616. entries: IExplorerExtensibilityOption[];
  52617. }
  52618. /**
  52619. * Interface used to define the options to use to create the Inspector
  52620. */
  52621. export interface IInspectorOptions {
  52622. /**
  52623. * Display in overlay mode (default: false)
  52624. */
  52625. overlay?: boolean;
  52626. /**
  52627. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  52628. */
  52629. globalRoot?: HTMLElement;
  52630. /**
  52631. * Display the Scene explorer
  52632. */
  52633. showExplorer?: boolean;
  52634. /**
  52635. * Display the property inspector
  52636. */
  52637. showInspector?: boolean;
  52638. /**
  52639. * Display in embed mode (both panes on the right)
  52640. */
  52641. embedMode?: boolean;
  52642. /**
  52643. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  52644. */
  52645. handleResize?: boolean;
  52646. /**
  52647. * Allow the panes to popup (default: true)
  52648. */
  52649. enablePopup?: boolean;
  52650. /**
  52651. * Allow the panes to be closed by users (default: true)
  52652. */
  52653. enableClose?: boolean;
  52654. /**
  52655. * Optional list of extensibility entries
  52656. */
  52657. explorerExtensibility?: IExplorerExtensibilityGroup[];
  52658. /**
  52659. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  52660. */
  52661. inspectorURL?: string;
  52662. /**
  52663. * Optional initial tab (default to DebugLayerTab.Properties)
  52664. */
  52665. initialTab?: DebugLayerTab;
  52666. }
  52667. module "babylonjs/scene" {
  52668. interface Scene {
  52669. /**
  52670. * @hidden
  52671. * Backing field
  52672. */
  52673. _debugLayer: DebugLayer;
  52674. /**
  52675. * Gets the debug layer (aka Inspector) associated with the scene
  52676. * @see https://doc.babylonjs.com/features/playground_debuglayer
  52677. */
  52678. debugLayer: DebugLayer;
  52679. }
  52680. }
  52681. /**
  52682. * Enum of inspector action tab
  52683. */
  52684. export enum DebugLayerTab {
  52685. /**
  52686. * Properties tag (default)
  52687. */
  52688. Properties = 0,
  52689. /**
  52690. * Debug tab
  52691. */
  52692. Debug = 1,
  52693. /**
  52694. * Statistics tab
  52695. */
  52696. Statistics = 2,
  52697. /**
  52698. * Tools tab
  52699. */
  52700. Tools = 3,
  52701. /**
  52702. * Settings tab
  52703. */
  52704. Settings = 4
  52705. }
  52706. /**
  52707. * The debug layer (aka Inspector) is the go to tool in order to better understand
  52708. * what is happening in your scene
  52709. * @see https://doc.babylonjs.com/features/playground_debuglayer
  52710. */
  52711. export class DebugLayer {
  52712. /**
  52713. * Define the url to get the inspector script from.
  52714. * By default it uses the babylonjs CDN.
  52715. * @ignoreNaming
  52716. */
  52717. static InspectorURL: string;
  52718. private _scene;
  52719. private BJSINSPECTOR;
  52720. private _onPropertyChangedObservable?;
  52721. /**
  52722. * Observable triggered when a property is changed through the inspector.
  52723. */
  52724. get onPropertyChangedObservable(): any;
  52725. /**
  52726. * Instantiates a new debug layer.
  52727. * The debug layer (aka Inspector) is the go to tool in order to better understand
  52728. * what is happening in your scene
  52729. * @see https://doc.babylonjs.com/features/playground_debuglayer
  52730. * @param scene Defines the scene to inspect
  52731. */
  52732. constructor(scene: Scene);
  52733. /** Creates the inspector window. */
  52734. private _createInspector;
  52735. /**
  52736. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  52737. * @param entity defines the entity to select
  52738. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  52739. */
  52740. select(entity: any, lineContainerTitles?: string | string[]): void;
  52741. /** Get the inspector from bundle or global */
  52742. private _getGlobalInspector;
  52743. /**
  52744. * Get if the inspector is visible or not.
  52745. * @returns true if visible otherwise, false
  52746. */
  52747. isVisible(): boolean;
  52748. /**
  52749. * Hide the inspector and close its window.
  52750. */
  52751. hide(): void;
  52752. /**
  52753. * Update the scene in the inspector
  52754. */
  52755. setAsActiveScene(): void;
  52756. /**
  52757. * Launch the debugLayer.
  52758. * @param config Define the configuration of the inspector
  52759. * @return a promise fulfilled when the debug layer is visible
  52760. */
  52761. show(config?: IInspectorOptions): Promise<DebugLayer>;
  52762. }
  52763. }
  52764. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  52765. import { Nullable } from "babylonjs/types";
  52766. import { Scene } from "babylonjs/scene";
  52767. import { Vector4 } from "babylonjs/Maths/math.vector";
  52768. import { Color4 } from "babylonjs/Maths/math.color";
  52769. import { Mesh } from "babylonjs/Meshes/mesh";
  52770. /**
  52771. * Class containing static functions to help procedurally build meshes
  52772. */
  52773. export class BoxBuilder {
  52774. /**
  52775. * Creates a box mesh
  52776. * * The parameter `size` sets the size (float) of each box side (default 1)
  52777. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  52778. * * 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)
  52779. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52780. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52781. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52782. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52783. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  52784. * @param name defines the name of the mesh
  52785. * @param options defines the options used to create the mesh
  52786. * @param scene defines the hosting scene
  52787. * @returns the box mesh
  52788. */
  52789. static CreateBox(name: string, options: {
  52790. size?: number;
  52791. width?: number;
  52792. height?: number;
  52793. depth?: number;
  52794. faceUV?: Vector4[];
  52795. faceColors?: Color4[];
  52796. sideOrientation?: number;
  52797. frontUVs?: Vector4;
  52798. backUVs?: Vector4;
  52799. wrap?: boolean;
  52800. topBaseAt?: number;
  52801. bottomBaseAt?: number;
  52802. updatable?: boolean;
  52803. }, scene?: Nullable<Scene>): Mesh;
  52804. }
  52805. }
  52806. declare module "babylonjs/Debug/physicsViewer" {
  52807. import { Nullable } from "babylonjs/types";
  52808. import { Scene } from "babylonjs/scene";
  52809. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52810. import { Mesh } from "babylonjs/Meshes/mesh";
  52811. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  52812. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52813. /**
  52814. * Used to show the physics impostor around the specific mesh
  52815. */
  52816. export class PhysicsViewer {
  52817. /** @hidden */
  52818. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  52819. /** @hidden */
  52820. protected _meshes: Array<Nullable<AbstractMesh>>;
  52821. /** @hidden */
  52822. protected _scene: Nullable<Scene>;
  52823. /** @hidden */
  52824. protected _numMeshes: number;
  52825. /** @hidden */
  52826. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  52827. private _renderFunction;
  52828. private _utilityLayer;
  52829. private _debugBoxMesh;
  52830. private _debugSphereMesh;
  52831. private _debugCylinderMesh;
  52832. private _debugMaterial;
  52833. private _debugMeshMeshes;
  52834. /**
  52835. * Creates a new PhysicsViewer
  52836. * @param scene defines the hosting scene
  52837. */
  52838. constructor(scene: Scene);
  52839. /** @hidden */
  52840. protected _updateDebugMeshes(): void;
  52841. /**
  52842. * Renders a specified physic impostor
  52843. * @param impostor defines the impostor to render
  52844. * @param targetMesh defines the mesh represented by the impostor
  52845. * @returns the new debug mesh used to render the impostor
  52846. */
  52847. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  52848. /**
  52849. * Hides a specified physic impostor
  52850. * @param impostor defines the impostor to hide
  52851. */
  52852. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  52853. private _getDebugMaterial;
  52854. private _getDebugBoxMesh;
  52855. private _getDebugSphereMesh;
  52856. private _getDebugCylinderMesh;
  52857. private _getDebugMeshMesh;
  52858. private _getDebugMesh;
  52859. /** Releases all resources */
  52860. dispose(): void;
  52861. }
  52862. }
  52863. declare module "babylonjs/Debug/rayHelper" {
  52864. import { Nullable } from "babylonjs/types";
  52865. import { Ray } from "babylonjs/Culling/ray";
  52866. import { Vector3 } from "babylonjs/Maths/math.vector";
  52867. import { Color3 } from "babylonjs/Maths/math.color";
  52868. import { Scene } from "babylonjs/scene";
  52869. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52870. import "babylonjs/Meshes/Builders/linesBuilder";
  52871. /**
  52872. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  52873. * in order to better appreciate the issue one might have.
  52874. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  52875. */
  52876. export class RayHelper {
  52877. /**
  52878. * Defines the ray we are currently tryin to visualize.
  52879. */
  52880. ray: Nullable<Ray>;
  52881. private _renderPoints;
  52882. private _renderLine;
  52883. private _renderFunction;
  52884. private _scene;
  52885. private _onAfterRenderObserver;
  52886. private _onAfterStepObserver;
  52887. private _attachedToMesh;
  52888. private _meshSpaceDirection;
  52889. private _meshSpaceOrigin;
  52890. /**
  52891. * Helper function to create a colored helper in a scene in one line.
  52892. * @param ray Defines the ray we are currently tryin to visualize
  52893. * @param scene Defines the scene the ray is used in
  52894. * @param color Defines the color we want to see the ray in
  52895. * @returns The newly created ray helper.
  52896. */
  52897. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  52898. /**
  52899. * Instantiate a new ray helper.
  52900. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  52901. * in order to better appreciate the issue one might have.
  52902. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  52903. * @param ray Defines the ray we are currently tryin to visualize
  52904. */
  52905. constructor(ray: Ray);
  52906. /**
  52907. * Shows the ray we are willing to debug.
  52908. * @param scene Defines the scene the ray needs to be rendered in
  52909. * @param color Defines the color the ray needs to be rendered in
  52910. */
  52911. show(scene: Scene, color?: Color3): void;
  52912. /**
  52913. * Hides the ray we are debugging.
  52914. */
  52915. hide(): void;
  52916. private _render;
  52917. /**
  52918. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  52919. * @param mesh Defines the mesh we want the helper attached to
  52920. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  52921. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  52922. * @param length Defines the length of the ray
  52923. */
  52924. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  52925. /**
  52926. * Detach the ray helper from the mesh it has previously been attached to.
  52927. */
  52928. detachFromMesh(): void;
  52929. private _updateToMesh;
  52930. /**
  52931. * Dispose the helper and release its associated resources.
  52932. */
  52933. dispose(): void;
  52934. }
  52935. }
  52936. declare module "babylonjs/Debug/ISkeletonViewer" {
  52937. /**
  52938. * Defines the options associated with the creation of a SkeletonViewer.
  52939. */
  52940. export interface ISkeletonViewerOptions {
  52941. /** Should the system pause animations before building the Viewer? */
  52942. pauseAnimations: boolean;
  52943. /** Should the system return the skeleton to rest before building? */
  52944. returnToRest: boolean;
  52945. /** public Display Mode of the Viewer */
  52946. displayMode: number;
  52947. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  52948. displayOptions: ISkeletonViewerDisplayOptions;
  52949. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  52950. computeBonesUsingShaders: boolean;
  52951. }
  52952. /**
  52953. * Defines how to display the various bone meshes for the viewer.
  52954. */
  52955. export interface ISkeletonViewerDisplayOptions {
  52956. /** How far down to start tapering the bone spurs */
  52957. midStep?: number;
  52958. /** How big is the midStep? */
  52959. midStepFactor?: number;
  52960. /** Base for the Sphere Size */
  52961. sphereBaseSize?: number;
  52962. /** The ratio of the sphere to the longest bone in units */
  52963. sphereScaleUnit?: number;
  52964. /** Ratio for the Sphere Size */
  52965. sphereFactor?: number;
  52966. }
  52967. }
  52968. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  52969. import { Nullable } from "babylonjs/types";
  52970. import { Scene } from "babylonjs/scene";
  52971. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  52972. import { Color4 } from "babylonjs/Maths/math.color";
  52973. import { Mesh } from "babylonjs/Meshes/mesh";
  52974. /**
  52975. * Class containing static functions to help procedurally build meshes
  52976. */
  52977. export class RibbonBuilder {
  52978. /**
  52979. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52980. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  52981. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  52982. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  52983. * * 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
  52984. * * 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
  52985. * * 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
  52986. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52987. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52988. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52989. * * 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
  52990. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  52991. * * 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
  52992. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  52993. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52994. * @param name defines the name of the mesh
  52995. * @param options defines the options used to create the mesh
  52996. * @param scene defines the hosting scene
  52997. * @returns the ribbon mesh
  52998. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  52999. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53000. */
  53001. static CreateRibbon(name: string, options: {
  53002. pathArray: Vector3[][];
  53003. closeArray?: boolean;
  53004. closePath?: boolean;
  53005. offset?: number;
  53006. updatable?: boolean;
  53007. sideOrientation?: number;
  53008. frontUVs?: Vector4;
  53009. backUVs?: Vector4;
  53010. instance?: Mesh;
  53011. invertUV?: boolean;
  53012. uvs?: Vector2[];
  53013. colors?: Color4[];
  53014. }, scene?: Nullable<Scene>): Mesh;
  53015. }
  53016. }
  53017. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  53018. import { Nullable } from "babylonjs/types";
  53019. import { Scene } from "babylonjs/scene";
  53020. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  53021. import { Mesh } from "babylonjs/Meshes/mesh";
  53022. /**
  53023. * Class containing static functions to help procedurally build meshes
  53024. */
  53025. export class ShapeBuilder {
  53026. /**
  53027. * 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.
  53028. * * 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.
  53029. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53030. * * 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.
  53031. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  53032. * * 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
  53033. * * 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
  53034. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  53035. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53036. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53037. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  53038. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53039. * @param name defines the name of the mesh
  53040. * @param options defines the options used to create the mesh
  53041. * @param scene defines the hosting scene
  53042. * @returns the extruded shape mesh
  53043. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53044. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53045. */
  53046. static ExtrudeShape(name: string, options: {
  53047. shape: Vector3[];
  53048. path: Vector3[];
  53049. scale?: number;
  53050. rotation?: number;
  53051. cap?: number;
  53052. updatable?: boolean;
  53053. sideOrientation?: number;
  53054. frontUVs?: Vector4;
  53055. backUVs?: Vector4;
  53056. instance?: Mesh;
  53057. invertUV?: boolean;
  53058. }, scene?: Nullable<Scene>): Mesh;
  53059. /**
  53060. * Creates an custom extruded shape mesh.
  53061. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  53062. * * 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.
  53063. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53064. * * 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
  53065. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  53066. * * 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
  53067. * * It must returns a float value that will be the scale value applied to the shape on each path point
  53068. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  53069. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  53070. * * 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
  53071. * * 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
  53072. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  53073. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53074. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53075. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53076. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53077. * @param name defines the name of the mesh
  53078. * @param options defines the options used to create the mesh
  53079. * @param scene defines the hosting scene
  53080. * @returns the custom extruded shape mesh
  53081. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  53082. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53083. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53084. */
  53085. static ExtrudeShapeCustom(name: string, options: {
  53086. shape: Vector3[];
  53087. path: Vector3[];
  53088. scaleFunction?: any;
  53089. rotationFunction?: any;
  53090. ribbonCloseArray?: boolean;
  53091. ribbonClosePath?: boolean;
  53092. cap?: number;
  53093. updatable?: boolean;
  53094. sideOrientation?: number;
  53095. frontUVs?: Vector4;
  53096. backUVs?: Vector4;
  53097. instance?: Mesh;
  53098. invertUV?: boolean;
  53099. }, scene?: Nullable<Scene>): Mesh;
  53100. private static _ExtrudeShapeGeneric;
  53101. }
  53102. }
  53103. declare module "babylonjs/Debug/skeletonViewer" {
  53104. import { Color3 } from "babylonjs/Maths/math.color";
  53105. import { Scene } from "babylonjs/scene";
  53106. import { Nullable } from "babylonjs/types";
  53107. import { Skeleton } from "babylonjs/Bones/skeleton";
  53108. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53109. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  53110. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  53111. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  53112. import { ISkeletonViewerOptions } from "babylonjs/Debug/ISkeletonViewer";
  53113. /**
  53114. * Class used to render a debug view of a given skeleton
  53115. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  53116. */
  53117. export class SkeletonViewer {
  53118. /** defines the skeleton to render */
  53119. skeleton: Skeleton;
  53120. /** defines the mesh attached to the skeleton */
  53121. mesh: AbstractMesh;
  53122. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  53123. autoUpdateBonesMatrices: boolean;
  53124. /** defines the rendering group id to use with the viewer */
  53125. renderingGroupId: number;
  53126. /** is the options for the viewer */
  53127. options: Partial<ISkeletonViewerOptions>;
  53128. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  53129. static readonly DISPLAY_LINES: number;
  53130. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  53131. static readonly DISPLAY_SPHERES: number;
  53132. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  53133. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  53134. /** If SkeletonViewer scene scope. */
  53135. private _scene;
  53136. /** Gets or sets the color used to render the skeleton */
  53137. color: Color3;
  53138. /** Array of the points of the skeleton fo the line view. */
  53139. private _debugLines;
  53140. /** The SkeletonViewers Mesh. */
  53141. private _debugMesh;
  53142. /** If SkeletonViewer is enabled. */
  53143. private _isEnabled;
  53144. /** If SkeletonViewer is ready. */
  53145. private _ready;
  53146. /** SkeletonViewer render observable. */
  53147. private _obs;
  53148. /** The Utility Layer to render the gizmos in. */
  53149. private _utilityLayer;
  53150. private _boneIndices;
  53151. /** Gets the Scene. */
  53152. get scene(): Scene;
  53153. /** Gets the utilityLayer. */
  53154. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  53155. /** Checks Ready Status. */
  53156. get isReady(): Boolean;
  53157. /** Sets Ready Status. */
  53158. set ready(value: boolean);
  53159. /** Gets the debugMesh */
  53160. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  53161. /** Sets the debugMesh */
  53162. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  53163. /** Gets the material */
  53164. get material(): StandardMaterial;
  53165. /** Sets the material */
  53166. set material(value: StandardMaterial);
  53167. /** Gets the material */
  53168. get displayMode(): number;
  53169. /** Sets the material */
  53170. set displayMode(value: number);
  53171. /**
  53172. * Creates a new SkeletonViewer
  53173. * @param skeleton defines the skeleton to render
  53174. * @param mesh defines the mesh attached to the skeleton
  53175. * @param scene defines the hosting scene
  53176. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  53177. * @param renderingGroupId defines the rendering group id to use with the viewer
  53178. * @param options All of the extra constructor options for the SkeletonViewer
  53179. */
  53180. constructor(
  53181. /** defines the skeleton to render */
  53182. skeleton: Skeleton,
  53183. /** defines the mesh attached to the skeleton */
  53184. mesh: AbstractMesh,
  53185. /** The Scene scope*/
  53186. scene: Scene,
  53187. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  53188. autoUpdateBonesMatrices?: boolean,
  53189. /** defines the rendering group id to use with the viewer */
  53190. renderingGroupId?: number,
  53191. /** is the options for the viewer */
  53192. options?: Partial<ISkeletonViewerOptions>);
  53193. /** The Dynamic bindings for the update functions */
  53194. private _bindObs;
  53195. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  53196. update(): void;
  53197. /** Gets or sets a boolean indicating if the viewer is enabled */
  53198. set isEnabled(value: boolean);
  53199. get isEnabled(): boolean;
  53200. private _getBonePosition;
  53201. private _getLinesForBonesWithLength;
  53202. private _getLinesForBonesNoLength;
  53203. /** function to revert the mesh and scene back to the initial state. */
  53204. private _revert;
  53205. /** function to build and bind sphere joint points and spur bone representations. */
  53206. private _buildSpheresAndSpurs;
  53207. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  53208. private _displayLinesUpdate;
  53209. /** Changes the displayMode of the skeleton viewer
  53210. * @param mode The displayMode numerical value
  53211. */
  53212. changeDisplayMode(mode: number): void;
  53213. /** Changes the displayMode of the skeleton viewer
  53214. * @param option String of the option name
  53215. * @param value The numerical option value
  53216. */
  53217. changeDisplayOptions(option: string, value: number): void;
  53218. /** Release associated resources */
  53219. dispose(): void;
  53220. }
  53221. }
  53222. declare module "babylonjs/Debug/index" {
  53223. export * from "babylonjs/Debug/axesViewer";
  53224. export * from "babylonjs/Debug/boneAxesViewer";
  53225. export * from "babylonjs/Debug/debugLayer";
  53226. export * from "babylonjs/Debug/physicsViewer";
  53227. export * from "babylonjs/Debug/rayHelper";
  53228. export * from "babylonjs/Debug/skeletonViewer";
  53229. export * from "babylonjs/Debug/ISkeletonViewer";
  53230. }
  53231. declare module "babylonjs/DeviceInput/InputDevices/deviceEnums" {
  53232. /**
  53233. * Enum for Device Types
  53234. */
  53235. export enum DeviceType {
  53236. /** Generic */
  53237. Generic = 0,
  53238. /** Keyboard */
  53239. Keyboard = 1,
  53240. /** Mouse */
  53241. Mouse = 2,
  53242. /** Touch Pointers */
  53243. Touch = 3,
  53244. /** PS4 Dual Shock */
  53245. DualShock = 4,
  53246. /** Xbox */
  53247. Xbox = 5,
  53248. /** Switch Controller */
  53249. Switch = 6
  53250. }
  53251. /**
  53252. * Enum for All Pointers (Touch/Mouse)
  53253. */
  53254. export enum PointerInput {
  53255. /** Horizontal Axis */
  53256. Horizontal = 0,
  53257. /** Vertical Axis */
  53258. Vertical = 1,
  53259. /** Left Click or Touch */
  53260. LeftClick = 2,
  53261. /** Middle Click */
  53262. MiddleClick = 3,
  53263. /** Right Click */
  53264. RightClick = 4,
  53265. /** Browser Back */
  53266. BrowserBack = 5,
  53267. /** Browser Forward */
  53268. BrowserForward = 6
  53269. }
  53270. /**
  53271. * Enum for Dual Shock Gamepad
  53272. */
  53273. export enum DualShockInput {
  53274. /** Cross */
  53275. Cross = 0,
  53276. /** Circle */
  53277. Circle = 1,
  53278. /** Square */
  53279. Square = 2,
  53280. /** Triangle */
  53281. Triangle = 3,
  53282. /** L1 */
  53283. L1 = 4,
  53284. /** R1 */
  53285. R1 = 5,
  53286. /** L2 */
  53287. L2 = 6,
  53288. /** R2 */
  53289. R2 = 7,
  53290. /** Share */
  53291. Share = 8,
  53292. /** Options */
  53293. Options = 9,
  53294. /** L3 */
  53295. L3 = 10,
  53296. /** R3 */
  53297. R3 = 11,
  53298. /** DPadUp */
  53299. DPadUp = 12,
  53300. /** DPadDown */
  53301. DPadDown = 13,
  53302. /** DPadLeft */
  53303. DPadLeft = 14,
  53304. /** DRight */
  53305. DPadRight = 15,
  53306. /** Home */
  53307. Home = 16,
  53308. /** TouchPad */
  53309. TouchPad = 17,
  53310. /** LStickXAxis */
  53311. LStickXAxis = 18,
  53312. /** LStickYAxis */
  53313. LStickYAxis = 19,
  53314. /** RStickXAxis */
  53315. RStickXAxis = 20,
  53316. /** RStickYAxis */
  53317. RStickYAxis = 21
  53318. }
  53319. /**
  53320. * Enum for Xbox Gamepad
  53321. */
  53322. export enum XboxInput {
  53323. /** A */
  53324. A = 0,
  53325. /** B */
  53326. B = 1,
  53327. /** X */
  53328. X = 2,
  53329. /** Y */
  53330. Y = 3,
  53331. /** LB */
  53332. LB = 4,
  53333. /** RB */
  53334. RB = 5,
  53335. /** LT */
  53336. LT = 6,
  53337. /** RT */
  53338. RT = 7,
  53339. /** Back */
  53340. Back = 8,
  53341. /** Start */
  53342. Start = 9,
  53343. /** LS */
  53344. LS = 10,
  53345. /** RS */
  53346. RS = 11,
  53347. /** DPadUp */
  53348. DPadUp = 12,
  53349. /** DPadDown */
  53350. DPadDown = 13,
  53351. /** DPadLeft */
  53352. DPadLeft = 14,
  53353. /** DRight */
  53354. DPadRight = 15,
  53355. /** Home */
  53356. Home = 16,
  53357. /** LStickXAxis */
  53358. LStickXAxis = 17,
  53359. /** LStickYAxis */
  53360. LStickYAxis = 18,
  53361. /** RStickXAxis */
  53362. RStickXAxis = 19,
  53363. /** RStickYAxis */
  53364. RStickYAxis = 20
  53365. }
  53366. /**
  53367. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  53368. */
  53369. export enum SwitchInput {
  53370. /** B */
  53371. B = 0,
  53372. /** A */
  53373. A = 1,
  53374. /** Y */
  53375. Y = 2,
  53376. /** X */
  53377. X = 3,
  53378. /** L */
  53379. L = 4,
  53380. /** R */
  53381. R = 5,
  53382. /** ZL */
  53383. ZL = 6,
  53384. /** ZR */
  53385. ZR = 7,
  53386. /** Minus */
  53387. Minus = 8,
  53388. /** Plus */
  53389. Plus = 9,
  53390. /** LS */
  53391. LS = 10,
  53392. /** RS */
  53393. RS = 11,
  53394. /** DPadUp */
  53395. DPadUp = 12,
  53396. /** DPadDown */
  53397. DPadDown = 13,
  53398. /** DPadLeft */
  53399. DPadLeft = 14,
  53400. /** DRight */
  53401. DPadRight = 15,
  53402. /** Home */
  53403. Home = 16,
  53404. /** Capture */
  53405. Capture = 17,
  53406. /** LStickXAxis */
  53407. LStickXAxis = 18,
  53408. /** LStickYAxis */
  53409. LStickYAxis = 19,
  53410. /** RStickXAxis */
  53411. RStickXAxis = 20,
  53412. /** RStickYAxis */
  53413. RStickYAxis = 21
  53414. }
  53415. }
  53416. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  53417. import { Engine } from "babylonjs/Engines/engine";
  53418. import { IDisposable } from "babylonjs/scene";
  53419. import { Nullable } from "babylonjs/types";
  53420. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53421. /**
  53422. * This class will take all inputs from Keyboard, Pointer, and
  53423. * any Gamepads and provide a polling system that all devices
  53424. * will use. This class assumes that there will only be one
  53425. * pointer device and one keyboard.
  53426. */
  53427. export class DeviceInputSystem implements IDisposable {
  53428. /**
  53429. * Callback to be triggered when a device is connected
  53430. */
  53431. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  53432. /**
  53433. * Callback to be triggered when a device is disconnected
  53434. */
  53435. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  53436. /**
  53437. * Callback to be triggered when event driven input is updated
  53438. */
  53439. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  53440. private _inputs;
  53441. private _gamepads;
  53442. private _keyboardActive;
  53443. private _pointerActive;
  53444. private _elementToAttachTo;
  53445. private _keyboardDownEvent;
  53446. private _keyboardUpEvent;
  53447. private _pointerMoveEvent;
  53448. private _pointerDownEvent;
  53449. private _pointerUpEvent;
  53450. private _gamepadConnectedEvent;
  53451. private _gamepadDisconnectedEvent;
  53452. private static _MAX_KEYCODES;
  53453. private static _MAX_POINTER_INPUTS;
  53454. private constructor();
  53455. /**
  53456. * Creates a new DeviceInputSystem instance
  53457. * @param engine Engine to pull input element from
  53458. * @returns The new instance
  53459. */
  53460. static Create(engine: Engine): DeviceInputSystem;
  53461. /**
  53462. * Checks for current device input value, given an id and input index
  53463. * @param deviceName Id of connected device
  53464. * @param inputIndex Index of device input
  53465. * @returns Current value of input
  53466. */
  53467. /**
  53468. * Checks for current device input value, given an id and input index
  53469. * @param deviceType Enum specifiying device type
  53470. * @param deviceSlot "Slot" or index that device is referenced in
  53471. * @param inputIndex Id of input to be checked
  53472. * @returns Current value of input
  53473. */
  53474. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  53475. /**
  53476. * Dispose of all the eventlisteners
  53477. */
  53478. dispose(): void;
  53479. /**
  53480. * Add device and inputs to device array
  53481. * @param deviceType Enum specifiying device type
  53482. * @param deviceSlot "Slot" or index that device is referenced in
  53483. * @param numberOfInputs Number of input entries to create for given device
  53484. */
  53485. private _registerDevice;
  53486. /**
  53487. * Given a specific device name, remove that device from the device map
  53488. * @param deviceType Enum specifiying device type
  53489. * @param deviceSlot "Slot" or index that device is referenced in
  53490. */
  53491. private _unregisterDevice;
  53492. /**
  53493. * Handle all actions that come from keyboard interaction
  53494. */
  53495. private _handleKeyActions;
  53496. /**
  53497. * Handle all actions that come from pointer interaction
  53498. */
  53499. private _handlePointerActions;
  53500. /**
  53501. * Handle all actions that come from gamepad interaction
  53502. */
  53503. private _handleGamepadActions;
  53504. /**
  53505. * Update all non-event based devices with each frame
  53506. * @param deviceType Enum specifiying device type
  53507. * @param deviceSlot "Slot" or index that device is referenced in
  53508. * @param inputIndex Id of input to be checked
  53509. */
  53510. private _updateDevice;
  53511. /**
  53512. * Gets DeviceType from the device name
  53513. * @param deviceName Name of Device from DeviceInputSystem
  53514. * @returns DeviceType enum value
  53515. */
  53516. private _getGamepadDeviceType;
  53517. }
  53518. }
  53519. declare module "babylonjs/DeviceInput/InputDevices/deviceTypes" {
  53520. import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53521. /**
  53522. * Type to handle enforcement of inputs
  53523. */
  53524. 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;
  53525. }
  53526. declare module "babylonjs/DeviceInput/InputDevices/deviceSourceManager" {
  53527. import { DeviceInputSystem } from "babylonjs/DeviceInput/deviceInputSystem";
  53528. import { Engine } from "babylonjs/Engines/engine";
  53529. import { IDisposable } from "babylonjs/scene";
  53530. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53531. import { Nullable } from "babylonjs/types";
  53532. import { Observable } from "babylonjs/Misc/observable";
  53533. import { DeviceInput } from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  53534. /**
  53535. * Class that handles all input for a specific device
  53536. */
  53537. export class DeviceSource<T extends DeviceType> {
  53538. /** Type of device */
  53539. readonly deviceType: DeviceType;
  53540. /** "Slot" or index that device is referenced in */
  53541. readonly deviceSlot: number;
  53542. /**
  53543. * Observable to handle device input changes per device
  53544. */
  53545. readonly onInputChangedObservable: Observable<{
  53546. inputIndex: DeviceInput<T>;
  53547. previousState: Nullable<number>;
  53548. currentState: Nullable<number>;
  53549. }>;
  53550. private readonly _deviceInputSystem;
  53551. /**
  53552. * Default Constructor
  53553. * @param deviceInputSystem Reference to DeviceInputSystem
  53554. * @param deviceType Type of device
  53555. * @param deviceSlot "Slot" or index that device is referenced in
  53556. */
  53557. constructor(deviceInputSystem: DeviceInputSystem,
  53558. /** Type of device */
  53559. deviceType: DeviceType,
  53560. /** "Slot" or index that device is referenced in */
  53561. deviceSlot?: number);
  53562. /**
  53563. * Get input for specific input
  53564. * @param inputIndex index of specific input on device
  53565. * @returns Input value from DeviceInputSystem
  53566. */
  53567. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  53568. }
  53569. /**
  53570. * Class to keep track of devices
  53571. */
  53572. export class DeviceSourceManager implements IDisposable {
  53573. /**
  53574. * Observable to be triggered when before a device is connected
  53575. */
  53576. readonly onBeforeDeviceConnectedObservable: Observable<{
  53577. deviceType: DeviceType;
  53578. deviceSlot: number;
  53579. }>;
  53580. /**
  53581. * Observable to be triggered when before a device is disconnected
  53582. */
  53583. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  53584. deviceType: DeviceType;
  53585. deviceSlot: number;
  53586. }>;
  53587. /**
  53588. * Observable to be triggered when after a device is connected
  53589. */
  53590. readonly onAfterDeviceConnectedObservable: Observable<{
  53591. deviceType: DeviceType;
  53592. deviceSlot: number;
  53593. }>;
  53594. /**
  53595. * Observable to be triggered when after a device is disconnected
  53596. */
  53597. readonly onAfterDeviceDisconnectedObservable: Observable<{
  53598. deviceType: DeviceType;
  53599. deviceSlot: number;
  53600. }>;
  53601. private readonly _devices;
  53602. private readonly _firstDevice;
  53603. private readonly _deviceInputSystem;
  53604. /**
  53605. * Default Constructor
  53606. * @param engine engine to pull input element from
  53607. */
  53608. constructor(engine: Engine);
  53609. /**
  53610. * Gets a DeviceSource, given a type and slot
  53611. * @param deviceType Enum specifying device type
  53612. * @param deviceSlot "Slot" or index that device is referenced in
  53613. * @returns DeviceSource object
  53614. */
  53615. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  53616. /**
  53617. * Gets an array of DeviceSource objects for a given device type
  53618. * @param deviceType Enum specifying device type
  53619. * @returns Array of DeviceSource objects
  53620. */
  53621. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  53622. /**
  53623. * Dispose of DeviceInputSystem and other parts
  53624. */
  53625. dispose(): void;
  53626. /**
  53627. * Function to add device name to device list
  53628. * @param deviceType Enum specifying device type
  53629. * @param deviceSlot "Slot" or index that device is referenced in
  53630. */
  53631. private _addDevice;
  53632. /**
  53633. * Function to remove device name to device list
  53634. * @param deviceType Enum specifying device type
  53635. * @param deviceSlot "Slot" or index that device is referenced in
  53636. */
  53637. private _removeDevice;
  53638. /**
  53639. * Updates array storing first connected device of each type
  53640. * @param type Type of Device
  53641. */
  53642. private _updateFirstDevices;
  53643. }
  53644. }
  53645. declare module "babylonjs/DeviceInput/index" {
  53646. export * from "babylonjs/DeviceInput/deviceInputSystem";
  53647. export * from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53648. export * from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  53649. import "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  53650. export * from "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  53651. }
  53652. declare module "babylonjs/Engines/nullEngine" {
  53653. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  53654. import { Engine } from "babylonjs/Engines/engine";
  53655. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  53656. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  53657. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53658. import { Effect } from "babylonjs/Materials/effect";
  53659. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  53660. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  53661. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  53662. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  53663. /**
  53664. * Options to create the null engine
  53665. */
  53666. export class NullEngineOptions {
  53667. /**
  53668. * Render width (Default: 512)
  53669. */
  53670. renderWidth: number;
  53671. /**
  53672. * Render height (Default: 256)
  53673. */
  53674. renderHeight: number;
  53675. /**
  53676. * Texture size (Default: 512)
  53677. */
  53678. textureSize: number;
  53679. /**
  53680. * If delta time between frames should be constant
  53681. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53682. */
  53683. deterministicLockstep: boolean;
  53684. /**
  53685. * Maximum about of steps between frames (Default: 4)
  53686. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53687. */
  53688. lockstepMaxSteps: number;
  53689. /**
  53690. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  53691. */
  53692. useHighPrecisionMatrix?: boolean;
  53693. }
  53694. /**
  53695. * The null engine class provides support for headless version of babylon.js.
  53696. * This can be used in server side scenario or for testing purposes
  53697. */
  53698. export class NullEngine extends Engine {
  53699. private _options;
  53700. /**
  53701. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  53702. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53703. * @returns true if engine is in deterministic lock step mode
  53704. */
  53705. isDeterministicLockStep(): boolean;
  53706. /**
  53707. * Gets the max steps when engine is running in deterministic lock step
  53708. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53709. * @returns the max steps
  53710. */
  53711. getLockstepMaxSteps(): number;
  53712. /**
  53713. * Gets the current hardware scaling level.
  53714. * By default the hardware scaling level is computed from the window device ratio.
  53715. * 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.
  53716. * @returns a number indicating the current hardware scaling level
  53717. */
  53718. getHardwareScalingLevel(): number;
  53719. constructor(options?: NullEngineOptions);
  53720. /**
  53721. * Creates a vertex buffer
  53722. * @param vertices the data for the vertex buffer
  53723. * @returns the new WebGL static buffer
  53724. */
  53725. createVertexBuffer(vertices: FloatArray): DataBuffer;
  53726. /**
  53727. * Creates a new index buffer
  53728. * @param indices defines the content of the index buffer
  53729. * @param updatable defines if the index buffer must be updatable
  53730. * @returns a new webGL buffer
  53731. */
  53732. createIndexBuffer(indices: IndicesArray): DataBuffer;
  53733. /**
  53734. * Clear the current render buffer or the current render target (if any is set up)
  53735. * @param color defines the color to use
  53736. * @param backBuffer defines if the back buffer must be cleared
  53737. * @param depth defines if the depth buffer must be cleared
  53738. * @param stencil defines if the stencil buffer must be cleared
  53739. */
  53740. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  53741. /**
  53742. * Gets the current render width
  53743. * @param useScreen defines if screen size must be used (or the current render target if any)
  53744. * @returns a number defining the current render width
  53745. */
  53746. getRenderWidth(useScreen?: boolean): number;
  53747. /**
  53748. * Gets the current render height
  53749. * @param useScreen defines if screen size must be used (or the current render target if any)
  53750. * @returns a number defining the current render height
  53751. */
  53752. getRenderHeight(useScreen?: boolean): number;
  53753. /**
  53754. * Set the WebGL's viewport
  53755. * @param viewport defines the viewport element to be used
  53756. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  53757. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  53758. */
  53759. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  53760. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  53761. /**
  53762. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  53763. * @param pipelineContext defines the pipeline context to use
  53764. * @param uniformsNames defines the list of uniform names
  53765. * @returns an array of webGL uniform locations
  53766. */
  53767. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  53768. /**
  53769. * Gets the lsit of active attributes for a given webGL program
  53770. * @param pipelineContext defines the pipeline context to use
  53771. * @param attributesNames defines the list of attribute names to get
  53772. * @returns an array of indices indicating the offset of each attribute
  53773. */
  53774. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  53775. /**
  53776. * Binds an effect to the webGL context
  53777. * @param effect defines the effect to bind
  53778. */
  53779. bindSamplers(effect: Effect): void;
  53780. /**
  53781. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  53782. * @param effect defines the effect to activate
  53783. */
  53784. enableEffect(effect: Effect): void;
  53785. /**
  53786. * Set various states to the webGL context
  53787. * @param culling defines backface culling state
  53788. * @param zOffset defines the value to apply to zOffset (0 by default)
  53789. * @param force defines if states must be applied even if cache is up to date
  53790. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  53791. */
  53792. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  53793. /**
  53794. * Set the value of an uniform to an array of int32
  53795. * @param uniform defines the webGL uniform location where to store the value
  53796. * @param array defines the array of int32 to store
  53797. */
  53798. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  53799. /**
  53800. * Set the value of an uniform to an array of int32 (stored as vec2)
  53801. * @param uniform defines the webGL uniform location where to store the value
  53802. * @param array defines the array of int32 to store
  53803. */
  53804. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  53805. /**
  53806. * Set the value of an uniform to an array of int32 (stored as vec3)
  53807. * @param uniform defines the webGL uniform location where to store the value
  53808. * @param array defines the array of int32 to store
  53809. */
  53810. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  53811. /**
  53812. * Set the value of an uniform to an array of int32 (stored as vec4)
  53813. * @param uniform defines the webGL uniform location where to store the value
  53814. * @param array defines the array of int32 to store
  53815. */
  53816. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  53817. /**
  53818. * Set the value of an uniform to an array of float32
  53819. * @param uniform defines the webGL uniform location where to store the value
  53820. * @param array defines the array of float32 to store
  53821. */
  53822. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  53823. /**
  53824. * Set the value of an uniform to an array of float32 (stored as vec2)
  53825. * @param uniform defines the webGL uniform location where to store the value
  53826. * @param array defines the array of float32 to store
  53827. */
  53828. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  53829. /**
  53830. * Set the value of an uniform to an array of float32 (stored as vec3)
  53831. * @param uniform defines the webGL uniform location where to store the value
  53832. * @param array defines the array of float32 to store
  53833. */
  53834. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  53835. /**
  53836. * Set the value of an uniform to an array of float32 (stored as vec4)
  53837. * @param uniform defines the webGL uniform location where to store the value
  53838. * @param array defines the array of float32 to store
  53839. */
  53840. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  53841. /**
  53842. * Set the value of an uniform to an array of number
  53843. * @param uniform defines the webGL uniform location where to store the value
  53844. * @param array defines the array of number to store
  53845. */
  53846. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  53847. /**
  53848. * Set the value of an uniform to an array of number (stored as vec2)
  53849. * @param uniform defines the webGL uniform location where to store the value
  53850. * @param array defines the array of number to store
  53851. */
  53852. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  53853. /**
  53854. * Set the value of an uniform to an array of number (stored as vec3)
  53855. * @param uniform defines the webGL uniform location where to store the value
  53856. * @param array defines the array of number to store
  53857. */
  53858. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  53859. /**
  53860. * Set the value of an uniform to an array of number (stored as vec4)
  53861. * @param uniform defines the webGL uniform location where to store the value
  53862. * @param array defines the array of number to store
  53863. */
  53864. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  53865. /**
  53866. * Set the value of an uniform to an array of float32 (stored as matrices)
  53867. * @param uniform defines the webGL uniform location where to store the value
  53868. * @param matrices defines the array of float32 to store
  53869. */
  53870. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  53871. /**
  53872. * Set the value of an uniform to a matrix (3x3)
  53873. * @param uniform defines the webGL uniform location where to store the value
  53874. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  53875. */
  53876. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  53877. /**
  53878. * Set the value of an uniform to a matrix (2x2)
  53879. * @param uniform defines the webGL uniform location where to store the value
  53880. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  53881. */
  53882. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  53883. /**
  53884. * Set the value of an uniform to a number (float)
  53885. * @param uniform defines the webGL uniform location where to store the value
  53886. * @param value defines the float number to store
  53887. */
  53888. setFloat(uniform: WebGLUniformLocation, value: number): void;
  53889. /**
  53890. * Set the value of an uniform to a vec2
  53891. * @param uniform defines the webGL uniform location where to store the value
  53892. * @param x defines the 1st component of the value
  53893. * @param y defines the 2nd component of the value
  53894. */
  53895. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  53896. /**
  53897. * Set the value of an uniform to a vec3
  53898. * @param uniform defines the webGL uniform location where to store the value
  53899. * @param x defines the 1st component of the value
  53900. * @param y defines the 2nd component of the value
  53901. * @param z defines the 3rd component of the value
  53902. */
  53903. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  53904. /**
  53905. * Set the value of an uniform to a boolean
  53906. * @param uniform defines the webGL uniform location where to store the value
  53907. * @param bool defines the boolean to store
  53908. */
  53909. setBool(uniform: WebGLUniformLocation, bool: number): void;
  53910. /**
  53911. * Set the value of an uniform to a vec4
  53912. * @param uniform defines the webGL uniform location where to store the value
  53913. * @param x defines the 1st component of the value
  53914. * @param y defines the 2nd component of the value
  53915. * @param z defines the 3rd component of the value
  53916. * @param w defines the 4th component of the value
  53917. */
  53918. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  53919. /**
  53920. * Sets the current alpha mode
  53921. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  53922. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  53923. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  53924. */
  53925. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  53926. /**
  53927. * Bind webGl buffers directly to the webGL context
  53928. * @param vertexBuffers defines the vertex buffer to bind
  53929. * @param indexBuffer defines the index buffer to bind
  53930. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  53931. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  53932. * @param effect defines the effect associated with the vertex buffer
  53933. */
  53934. bindBuffers(vertexBuffers: {
  53935. [key: string]: VertexBuffer;
  53936. }, indexBuffer: DataBuffer, effect: Effect): void;
  53937. /**
  53938. * Force the entire cache to be cleared
  53939. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  53940. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  53941. */
  53942. wipeCaches(bruteForce?: boolean): void;
  53943. /**
  53944. * Send a draw order
  53945. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  53946. * @param indexStart defines the starting index
  53947. * @param indexCount defines the number of index to draw
  53948. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53949. */
  53950. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  53951. /**
  53952. * Draw a list of indexed primitives
  53953. * @param fillMode defines the primitive to use
  53954. * @param indexStart defines the starting index
  53955. * @param indexCount defines the number of index to draw
  53956. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53957. */
  53958. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  53959. /**
  53960. * Draw a list of unindexed primitives
  53961. * @param fillMode defines the primitive to use
  53962. * @param verticesStart defines the index of first vertex to draw
  53963. * @param verticesCount defines the count of vertices to draw
  53964. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53965. */
  53966. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  53967. /** @hidden */
  53968. _createTexture(): WebGLTexture;
  53969. /** @hidden */
  53970. _releaseTexture(texture: InternalTexture): void;
  53971. /**
  53972. * Usually called from Texture.ts.
  53973. * Passed information to create a WebGLTexture
  53974. * @param urlArg defines a value which contains one of the following:
  53975. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  53976. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  53977. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  53978. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  53979. * @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)
  53980. * @param scene needed for loading to the correct scene
  53981. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  53982. * @param onLoad optional callback to be called upon successful completion
  53983. * @param onError optional callback to be called upon failure
  53984. * @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
  53985. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  53986. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  53987. * @param forcedExtension defines the extension to use to pick the right loader
  53988. * @param mimeType defines an optional mime type
  53989. * @returns a InternalTexture for assignment back into BABYLON.Texture
  53990. */
  53991. 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;
  53992. /**
  53993. * Creates a new render target texture
  53994. * @param size defines the size of the texture
  53995. * @param options defines the options used to create the texture
  53996. * @returns a new render target texture stored in an InternalTexture
  53997. */
  53998. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  53999. /**
  54000. * Update the sampling mode of a given texture
  54001. * @param samplingMode defines the required sampling mode
  54002. * @param texture defines the texture to update
  54003. */
  54004. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  54005. /**
  54006. * Binds the frame buffer to the specified texture.
  54007. * @param texture The texture to render to or null for the default canvas
  54008. * @param faceIndex The face of the texture to render to in case of cube texture
  54009. * @param requiredWidth The width of the target to render to
  54010. * @param requiredHeight The height of the target to render to
  54011. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  54012. * @param lodLevel defines le lod level to bind to the frame buffer
  54013. */
  54014. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  54015. /**
  54016. * Unbind the current render target texture from the webGL context
  54017. * @param texture defines the render target texture to unbind
  54018. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  54019. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  54020. */
  54021. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  54022. /**
  54023. * Creates a dynamic vertex buffer
  54024. * @param vertices the data for the dynamic vertex buffer
  54025. * @returns the new WebGL dynamic buffer
  54026. */
  54027. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  54028. /**
  54029. * Update the content of a dynamic texture
  54030. * @param texture defines the texture to update
  54031. * @param canvas defines the canvas containing the source
  54032. * @param invertY defines if data must be stored with Y axis inverted
  54033. * @param premulAlpha defines if alpha is stored as premultiplied
  54034. * @param format defines the format of the data
  54035. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  54036. */
  54037. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  54038. /**
  54039. * Gets a boolean indicating if all created effects are ready
  54040. * @returns true if all effects are ready
  54041. */
  54042. areAllEffectsReady(): boolean;
  54043. /**
  54044. * @hidden
  54045. * Get the current error code of the webGL context
  54046. * @returns the error code
  54047. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  54048. */
  54049. getError(): number;
  54050. /** @hidden */
  54051. _getUnpackAlignement(): number;
  54052. /** @hidden */
  54053. _unpackFlipY(value: boolean): void;
  54054. /**
  54055. * Update a dynamic index buffer
  54056. * @param indexBuffer defines the target index buffer
  54057. * @param indices defines the data to update
  54058. * @param offset defines the offset in the target index buffer where update should start
  54059. */
  54060. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  54061. /**
  54062. * Updates a dynamic vertex buffer.
  54063. * @param vertexBuffer the vertex buffer to update
  54064. * @param vertices the data used to update the vertex buffer
  54065. * @param byteOffset the byte offset of the data (optional)
  54066. * @param byteLength the byte length of the data (optional)
  54067. */
  54068. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  54069. /** @hidden */
  54070. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  54071. /** @hidden */
  54072. _bindTexture(channel: number, texture: InternalTexture): void;
  54073. protected _deleteBuffer(buffer: WebGLBuffer): void;
  54074. /**
  54075. * 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
  54076. */
  54077. releaseEffects(): void;
  54078. displayLoadingUI(): void;
  54079. hideLoadingUI(): void;
  54080. /** @hidden */
  54081. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54082. /** @hidden */
  54083. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54084. /** @hidden */
  54085. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54086. /** @hidden */
  54087. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  54088. }
  54089. }
  54090. declare module "babylonjs/Instrumentation/timeToken" {
  54091. import { Nullable } from "babylonjs/types";
  54092. /**
  54093. * @hidden
  54094. **/
  54095. export class _TimeToken {
  54096. _startTimeQuery: Nullable<WebGLQuery>;
  54097. _endTimeQuery: Nullable<WebGLQuery>;
  54098. _timeElapsedQuery: Nullable<WebGLQuery>;
  54099. _timeElapsedQueryEnded: boolean;
  54100. }
  54101. }
  54102. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  54103. import { Nullable, int } from "babylonjs/types";
  54104. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  54105. /** @hidden */
  54106. export class _OcclusionDataStorage {
  54107. /** @hidden */
  54108. occlusionInternalRetryCounter: number;
  54109. /** @hidden */
  54110. isOcclusionQueryInProgress: boolean;
  54111. /** @hidden */
  54112. isOccluded: boolean;
  54113. /** @hidden */
  54114. occlusionRetryCount: number;
  54115. /** @hidden */
  54116. occlusionType: number;
  54117. /** @hidden */
  54118. occlusionQueryAlgorithmType: number;
  54119. }
  54120. module "babylonjs/Engines/engine" {
  54121. interface Engine {
  54122. /**
  54123. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  54124. * @return the new query
  54125. */
  54126. createQuery(): WebGLQuery;
  54127. /**
  54128. * Delete and release a webGL query
  54129. * @param query defines the query to delete
  54130. * @return the current engine
  54131. */
  54132. deleteQuery(query: WebGLQuery): Engine;
  54133. /**
  54134. * Check if a given query has resolved and got its value
  54135. * @param query defines the query to check
  54136. * @returns true if the query got its value
  54137. */
  54138. isQueryResultAvailable(query: WebGLQuery): boolean;
  54139. /**
  54140. * Gets the value of a given query
  54141. * @param query defines the query to check
  54142. * @returns the value of the query
  54143. */
  54144. getQueryResult(query: WebGLQuery): number;
  54145. /**
  54146. * Initiates an occlusion query
  54147. * @param algorithmType defines the algorithm to use
  54148. * @param query defines the query to use
  54149. * @returns the current engine
  54150. * @see https://doc.babylonjs.com/features/occlusionquery
  54151. */
  54152. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  54153. /**
  54154. * Ends an occlusion query
  54155. * @see https://doc.babylonjs.com/features/occlusionquery
  54156. * @param algorithmType defines the algorithm to use
  54157. * @returns the current engine
  54158. */
  54159. endOcclusionQuery(algorithmType: number): Engine;
  54160. /**
  54161. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  54162. * Please note that only one query can be issued at a time
  54163. * @returns a time token used to track the time span
  54164. */
  54165. startTimeQuery(): Nullable<_TimeToken>;
  54166. /**
  54167. * Ends a time query
  54168. * @param token defines the token used to measure the time span
  54169. * @returns the time spent (in ns)
  54170. */
  54171. endTimeQuery(token: _TimeToken): int;
  54172. /** @hidden */
  54173. _currentNonTimestampToken: Nullable<_TimeToken>;
  54174. /** @hidden */
  54175. _createTimeQuery(): WebGLQuery;
  54176. /** @hidden */
  54177. _deleteTimeQuery(query: WebGLQuery): void;
  54178. /** @hidden */
  54179. _getGlAlgorithmType(algorithmType: number): number;
  54180. /** @hidden */
  54181. _getTimeQueryResult(query: WebGLQuery): any;
  54182. /** @hidden */
  54183. _getTimeQueryAvailability(query: WebGLQuery): any;
  54184. }
  54185. }
  54186. module "babylonjs/Meshes/abstractMesh" {
  54187. interface AbstractMesh {
  54188. /**
  54189. * Backing filed
  54190. * @hidden
  54191. */
  54192. __occlusionDataStorage: _OcclusionDataStorage;
  54193. /**
  54194. * Access property
  54195. * @hidden
  54196. */
  54197. _occlusionDataStorage: _OcclusionDataStorage;
  54198. /**
  54199. * 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.
  54200. * The default value is -1 which means don't break the query and wait till the result
  54201. * @see https://doc.babylonjs.com/features/occlusionquery
  54202. */
  54203. occlusionRetryCount: number;
  54204. /**
  54205. * 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:
  54206. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  54207. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  54208. * * 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.
  54209. * @see https://doc.babylonjs.com/features/occlusionquery
  54210. */
  54211. occlusionType: number;
  54212. /**
  54213. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  54214. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  54215. * * 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.
  54216. * @see https://doc.babylonjs.com/features/occlusionquery
  54217. */
  54218. occlusionQueryAlgorithmType: number;
  54219. /**
  54220. * 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
  54221. * @see https://doc.babylonjs.com/features/occlusionquery
  54222. */
  54223. isOccluded: boolean;
  54224. /**
  54225. * Flag to check the progress status of the query
  54226. * @see https://doc.babylonjs.com/features/occlusionquery
  54227. */
  54228. isOcclusionQueryInProgress: boolean;
  54229. }
  54230. }
  54231. }
  54232. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  54233. import { Nullable } from "babylonjs/types";
  54234. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  54235. /** @hidden */
  54236. export var _forceTransformFeedbackToBundle: boolean;
  54237. module "babylonjs/Engines/engine" {
  54238. interface Engine {
  54239. /**
  54240. * Creates a webGL transform feedback object
  54241. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  54242. * @returns the webGL transform feedback object
  54243. */
  54244. createTransformFeedback(): WebGLTransformFeedback;
  54245. /**
  54246. * Delete a webGL transform feedback object
  54247. * @param value defines the webGL transform feedback object to delete
  54248. */
  54249. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  54250. /**
  54251. * Bind a webGL transform feedback object to the webgl context
  54252. * @param value defines the webGL transform feedback object to bind
  54253. */
  54254. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  54255. /**
  54256. * Begins a transform feedback operation
  54257. * @param usePoints defines if points or triangles must be used
  54258. */
  54259. beginTransformFeedback(usePoints: boolean): void;
  54260. /**
  54261. * Ends a transform feedback operation
  54262. */
  54263. endTransformFeedback(): void;
  54264. /**
  54265. * Specify the varyings to use with transform feedback
  54266. * @param program defines the associated webGL program
  54267. * @param value defines the list of strings representing the varying names
  54268. */
  54269. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  54270. /**
  54271. * Bind a webGL buffer for a transform feedback operation
  54272. * @param value defines the webGL buffer to bind
  54273. */
  54274. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  54275. }
  54276. }
  54277. }
  54278. declare module "babylonjs/Engines/Extensions/engine.views" {
  54279. import { Camera } from "babylonjs/Cameras/camera";
  54280. import { Nullable } from "babylonjs/types";
  54281. /**
  54282. * Class used to define an additional view for the engine
  54283. * @see https://doc.babylonjs.com/how_to/multi_canvases
  54284. */
  54285. export class EngineView {
  54286. /** Defines the canvas where to render the view */
  54287. target: HTMLCanvasElement;
  54288. /** Defines an optional camera used to render the view (will use active camera else) */
  54289. camera?: Camera;
  54290. }
  54291. module "babylonjs/Engines/engine" {
  54292. interface Engine {
  54293. /**
  54294. * Gets or sets the HTML element to use for attaching events
  54295. */
  54296. inputElement: Nullable<HTMLElement>;
  54297. /**
  54298. * Gets the current engine view
  54299. * @see https://doc.babylonjs.com/how_to/multi_canvases
  54300. */
  54301. activeView: Nullable<EngineView>;
  54302. /** Gets or sets the list of views */
  54303. views: EngineView[];
  54304. /**
  54305. * Register a new child canvas
  54306. * @param canvas defines the canvas to register
  54307. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  54308. * @returns the associated view
  54309. */
  54310. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  54311. /**
  54312. * Remove a registered child canvas
  54313. * @param canvas defines the canvas to remove
  54314. * @returns the current engine
  54315. */
  54316. unRegisterView(canvas: HTMLCanvasElement): Engine;
  54317. }
  54318. }
  54319. }
  54320. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  54321. import { Nullable } from "babylonjs/types";
  54322. module "babylonjs/Engines/engine" {
  54323. interface Engine {
  54324. /** @hidden */
  54325. _excludedCompressedTextures: string[];
  54326. /** @hidden */
  54327. _textureFormatInUse: string;
  54328. /**
  54329. * Gets the list of texture formats supported
  54330. */
  54331. readonly texturesSupported: Array<string>;
  54332. /**
  54333. * Gets the texture format in use
  54334. */
  54335. readonly textureFormatInUse: Nullable<string>;
  54336. /**
  54337. * Set the compressed texture extensions or file names to skip.
  54338. *
  54339. * @param skippedFiles defines the list of those texture files you want to skip
  54340. * Example: [".dds", ".env", "myfile.png"]
  54341. */
  54342. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  54343. /**
  54344. * Set the compressed texture format to use, based on the formats you have, and the formats
  54345. * supported by the hardware / browser.
  54346. *
  54347. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  54348. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  54349. * to API arguments needed to compressed textures. This puts the burden on the container
  54350. * generator to house the arcane code for determining these for current & future formats.
  54351. *
  54352. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  54353. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  54354. *
  54355. * Note: The result of this call is not taken into account when a texture is base64.
  54356. *
  54357. * @param formatsAvailable defines the list of those format families you have created
  54358. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  54359. *
  54360. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  54361. * @returns The extension selected.
  54362. */
  54363. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  54364. }
  54365. }
  54366. }
  54367. declare module "babylonjs/Engines/Extensions/index" {
  54368. export * from "babylonjs/Engines/Extensions/engine.alpha";
  54369. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  54370. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  54371. export * from "babylonjs/Engines/Extensions/engine.multiview";
  54372. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  54373. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  54374. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  54375. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  54376. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  54377. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  54378. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  54379. export * from "babylonjs/Engines/Extensions/engine.webVR";
  54380. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  54381. export * from "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  54382. export * from "babylonjs/Engines/Extensions/engine.views";
  54383. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  54384. import "babylonjs/Engines/Extensions/engine.textureSelector";
  54385. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  54386. }
  54387. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  54388. import { Nullable } from "babylonjs/types";
  54389. /**
  54390. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  54391. */
  54392. export interface CubeMapInfo {
  54393. /**
  54394. * The pixel array for the front face.
  54395. * This is stored in format, left to right, up to down format.
  54396. */
  54397. front: Nullable<ArrayBufferView>;
  54398. /**
  54399. * The pixel array for the back face.
  54400. * This is stored in format, left to right, up to down format.
  54401. */
  54402. back: Nullable<ArrayBufferView>;
  54403. /**
  54404. * The pixel array for the left face.
  54405. * This is stored in format, left to right, up to down format.
  54406. */
  54407. left: Nullable<ArrayBufferView>;
  54408. /**
  54409. * The pixel array for the right face.
  54410. * This is stored in format, left to right, up to down format.
  54411. */
  54412. right: Nullable<ArrayBufferView>;
  54413. /**
  54414. * The pixel array for the up face.
  54415. * This is stored in format, left to right, up to down format.
  54416. */
  54417. up: Nullable<ArrayBufferView>;
  54418. /**
  54419. * The pixel array for the down face.
  54420. * This is stored in format, left to right, up to down format.
  54421. */
  54422. down: Nullable<ArrayBufferView>;
  54423. /**
  54424. * The size of the cubemap stored.
  54425. *
  54426. * Each faces will be size * size pixels.
  54427. */
  54428. size: number;
  54429. /**
  54430. * The format of the texture.
  54431. *
  54432. * RGBA, RGB.
  54433. */
  54434. format: number;
  54435. /**
  54436. * The type of the texture data.
  54437. *
  54438. * UNSIGNED_INT, FLOAT.
  54439. */
  54440. type: number;
  54441. /**
  54442. * Specifies whether the texture is in gamma space.
  54443. */
  54444. gammaSpace: boolean;
  54445. }
  54446. /**
  54447. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  54448. */
  54449. export class PanoramaToCubeMapTools {
  54450. private static FACE_LEFT;
  54451. private static FACE_RIGHT;
  54452. private static FACE_FRONT;
  54453. private static FACE_BACK;
  54454. private static FACE_DOWN;
  54455. private static FACE_UP;
  54456. /**
  54457. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  54458. *
  54459. * @param float32Array The source data.
  54460. * @param inputWidth The width of the input panorama.
  54461. * @param inputHeight The height of the input panorama.
  54462. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  54463. * @return The cubemap data
  54464. */
  54465. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  54466. private static CreateCubemapTexture;
  54467. private static CalcProjectionSpherical;
  54468. }
  54469. }
  54470. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  54471. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54472. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54473. import { Nullable } from "babylonjs/types";
  54474. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  54475. /**
  54476. * Helper class dealing with the extraction of spherical polynomial dataArray
  54477. * from a cube map.
  54478. */
  54479. export class CubeMapToSphericalPolynomialTools {
  54480. private static FileFaces;
  54481. /**
  54482. * Converts a texture to the according Spherical Polynomial data.
  54483. * This extracts the first 3 orders only as they are the only one used in the lighting.
  54484. *
  54485. * @param texture The texture to extract the information from.
  54486. * @return The Spherical Polynomial data.
  54487. */
  54488. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  54489. /**
  54490. * Converts a cubemap to the according Spherical Polynomial data.
  54491. * This extracts the first 3 orders only as they are the only one used in the lighting.
  54492. *
  54493. * @param cubeInfo The Cube map to extract the information from.
  54494. * @return The Spherical Polynomial data.
  54495. */
  54496. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  54497. }
  54498. }
  54499. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  54500. import { Nullable } from "babylonjs/types";
  54501. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54502. module "babylonjs/Materials/Textures/baseTexture" {
  54503. interface BaseTexture {
  54504. /**
  54505. * Get the polynomial representation of the texture data.
  54506. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  54507. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  54508. */
  54509. sphericalPolynomial: Nullable<SphericalPolynomial>;
  54510. }
  54511. }
  54512. }
  54513. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  54514. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54515. /** @hidden */
  54516. export var rgbdEncodePixelShader: {
  54517. name: string;
  54518. shader: string;
  54519. };
  54520. }
  54521. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  54522. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54523. /** @hidden */
  54524. export var rgbdDecodePixelShader: {
  54525. name: string;
  54526. shader: string;
  54527. };
  54528. }
  54529. declare module "babylonjs/Misc/environmentTextureTools" {
  54530. import { Nullable } from "babylonjs/types";
  54531. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54532. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54533. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54534. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  54535. import "babylonjs/Engines/Extensions/engine.readTexture";
  54536. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  54537. import "babylonjs/Shaders/rgbdEncode.fragment";
  54538. import "babylonjs/Shaders/rgbdDecode.fragment";
  54539. /**
  54540. * Raw texture data and descriptor sufficient for WebGL texture upload
  54541. */
  54542. export interface EnvironmentTextureInfo {
  54543. /**
  54544. * Version of the environment map
  54545. */
  54546. version: number;
  54547. /**
  54548. * Width of image
  54549. */
  54550. width: number;
  54551. /**
  54552. * Irradiance information stored in the file.
  54553. */
  54554. irradiance: any;
  54555. /**
  54556. * Specular information stored in the file.
  54557. */
  54558. specular: any;
  54559. }
  54560. /**
  54561. * Defines One Image in the file. It requires only the position in the file
  54562. * as well as the length.
  54563. */
  54564. interface BufferImageData {
  54565. /**
  54566. * Length of the image data.
  54567. */
  54568. length: number;
  54569. /**
  54570. * Position of the data from the null terminator delimiting the end of the JSON.
  54571. */
  54572. position: number;
  54573. }
  54574. /**
  54575. * Defines the specular data enclosed in the file.
  54576. * This corresponds to the version 1 of the data.
  54577. */
  54578. export interface EnvironmentTextureSpecularInfoV1 {
  54579. /**
  54580. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  54581. */
  54582. specularDataPosition?: number;
  54583. /**
  54584. * This contains all the images data needed to reconstruct the cubemap.
  54585. */
  54586. mipmaps: Array<BufferImageData>;
  54587. /**
  54588. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  54589. */
  54590. lodGenerationScale: number;
  54591. }
  54592. /**
  54593. * Sets of helpers addressing the serialization and deserialization of environment texture
  54594. * stored in a BabylonJS env file.
  54595. * Those files are usually stored as .env files.
  54596. */
  54597. export class EnvironmentTextureTools {
  54598. /**
  54599. * Magic number identifying the env file.
  54600. */
  54601. private static _MagicBytes;
  54602. /**
  54603. * Gets the environment info from an env file.
  54604. * @param data The array buffer containing the .env bytes.
  54605. * @returns the environment file info (the json header) if successfully parsed.
  54606. */
  54607. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  54608. /**
  54609. * Creates an environment texture from a loaded cube texture.
  54610. * @param texture defines the cube texture to convert in env file
  54611. * @return a promise containing the environment data if succesfull.
  54612. */
  54613. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  54614. /**
  54615. * Creates a JSON representation of the spherical data.
  54616. * @param texture defines the texture containing the polynomials
  54617. * @return the JSON representation of the spherical info
  54618. */
  54619. private static _CreateEnvTextureIrradiance;
  54620. /**
  54621. * Creates the ArrayBufferViews used for initializing environment texture image data.
  54622. * @param data the image data
  54623. * @param info parameters that determine what views will be created for accessing the underlying buffer
  54624. * @return the views described by info providing access to the underlying buffer
  54625. */
  54626. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  54627. /**
  54628. * Uploads the texture info contained in the env file to the GPU.
  54629. * @param texture defines the internal texture to upload to
  54630. * @param data defines the data to load
  54631. * @param info defines the texture info retrieved through the GetEnvInfo method
  54632. * @returns a promise
  54633. */
  54634. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  54635. private static _OnImageReadyAsync;
  54636. /**
  54637. * Uploads the levels of image data to the GPU.
  54638. * @param texture defines the internal texture to upload to
  54639. * @param imageData defines the array buffer views of image data [mipmap][face]
  54640. * @returns a promise
  54641. */
  54642. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  54643. /**
  54644. * Uploads spherical polynomials information to the texture.
  54645. * @param texture defines the texture we are trying to upload the information to
  54646. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  54647. */
  54648. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  54649. /** @hidden */
  54650. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  54651. }
  54652. }
  54653. declare module "babylonjs/Engines/Processors/shaderCodeInliner" {
  54654. /**
  54655. * Class used to inline functions in shader code
  54656. */
  54657. export class ShaderCodeInliner {
  54658. private static readonly _RegexpFindFunctionNameAndType;
  54659. private _sourceCode;
  54660. private _functionDescr;
  54661. private _numMaxIterations;
  54662. /** Gets or sets the token used to mark the functions to inline */
  54663. inlineToken: string;
  54664. /** Gets or sets the debug mode */
  54665. debug: boolean;
  54666. /** Gets the code after the inlining process */
  54667. get code(): string;
  54668. /**
  54669. * Initializes the inliner
  54670. * @param sourceCode shader code source to inline
  54671. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  54672. */
  54673. constructor(sourceCode: string, numMaxIterations?: number);
  54674. /**
  54675. * Start the processing of the shader code
  54676. */
  54677. processCode(): void;
  54678. private _collectFunctions;
  54679. private _processInlining;
  54680. private _extractBetweenMarkers;
  54681. private _skipWhitespaces;
  54682. private _removeComments;
  54683. private _replaceFunctionCallsByCode;
  54684. private _findBackward;
  54685. private _escapeRegExp;
  54686. private _replaceNames;
  54687. }
  54688. }
  54689. declare module "babylonjs/Engines/nativeEngine" {
  54690. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  54691. import { Engine } from "babylonjs/Engines/engine";
  54692. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  54693. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54694. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54695. import { Effect } from "babylonjs/Materials/effect";
  54696. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  54697. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  54698. import { IColor4Like } from "babylonjs/Maths/math.like";
  54699. import { Scene } from "babylonjs/scene";
  54700. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  54701. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  54702. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  54703. /**
  54704. * Container for accessors for natively-stored mesh data buffers.
  54705. */
  54706. class NativeDataBuffer extends DataBuffer {
  54707. /**
  54708. * Accessor value used to identify/retrieve a natively-stored index buffer.
  54709. */
  54710. nativeIndexBuffer?: any;
  54711. /**
  54712. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  54713. */
  54714. nativeVertexBuffer?: any;
  54715. }
  54716. /** @hidden */
  54717. class NativeTexture extends InternalTexture {
  54718. getInternalTexture(): InternalTexture;
  54719. getViewCount(): number;
  54720. }
  54721. /** @hidden */
  54722. export class NativeEngine extends Engine {
  54723. private readonly _native;
  54724. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  54725. private readonly INVALID_HANDLE;
  54726. private _boundBuffersVertexArray;
  54727. getHardwareScalingLevel(): number;
  54728. constructor();
  54729. dispose(): void;
  54730. /**
  54731. * Can be used to override the current requestAnimationFrame requester.
  54732. * @hidden
  54733. */
  54734. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  54735. /**
  54736. * Override default engine behavior.
  54737. * @param color
  54738. * @param backBuffer
  54739. * @param depth
  54740. * @param stencil
  54741. */
  54742. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  54743. /**
  54744. * Gets host document
  54745. * @returns the host document object
  54746. */
  54747. getHostDocument(): Nullable<Document>;
  54748. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  54749. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  54750. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  54751. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  54752. [key: string]: VertexBuffer;
  54753. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  54754. bindBuffers(vertexBuffers: {
  54755. [key: string]: VertexBuffer;
  54756. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  54757. recordVertexArrayObject(vertexBuffers: {
  54758. [key: string]: VertexBuffer;
  54759. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  54760. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  54761. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  54762. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  54763. /**
  54764. * Draw a list of indexed primitives
  54765. * @param fillMode defines the primitive to use
  54766. * @param indexStart defines the starting index
  54767. * @param indexCount defines the number of index to draw
  54768. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54769. */
  54770. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  54771. /**
  54772. * Draw a list of unindexed primitives
  54773. * @param fillMode defines the primitive to use
  54774. * @param verticesStart defines the index of first vertex to draw
  54775. * @param verticesCount defines the count of vertices to draw
  54776. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54777. */
  54778. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  54779. createPipelineContext(): IPipelineContext;
  54780. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  54781. /** @hidden */
  54782. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  54783. /** @hidden */
  54784. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  54785. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  54786. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  54787. protected _setProgram(program: WebGLProgram): void;
  54788. _releaseEffect(effect: Effect): void;
  54789. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  54790. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  54791. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  54792. bindSamplers(effect: Effect): void;
  54793. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  54794. getRenderWidth(useScreen?: boolean): number;
  54795. getRenderHeight(useScreen?: boolean): number;
  54796. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  54797. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  54798. /**
  54799. * Set the z offset to apply to current rendering
  54800. * @param value defines the offset to apply
  54801. */
  54802. setZOffset(value: number): void;
  54803. /**
  54804. * Gets the current value of the zOffset
  54805. * @returns the current zOffset state
  54806. */
  54807. getZOffset(): number;
  54808. /**
  54809. * Enable or disable depth buffering
  54810. * @param enable defines the state to set
  54811. */
  54812. setDepthBuffer(enable: boolean): void;
  54813. /**
  54814. * Gets a boolean indicating if depth writing is enabled
  54815. * @returns the current depth writing state
  54816. */
  54817. getDepthWrite(): boolean;
  54818. /**
  54819. * Enable or disable depth writing
  54820. * @param enable defines the state to set
  54821. */
  54822. setDepthWrite(enable: boolean): void;
  54823. /**
  54824. * Enable or disable color writing
  54825. * @param enable defines the state to set
  54826. */
  54827. setColorWrite(enable: boolean): void;
  54828. /**
  54829. * Gets a boolean indicating if color writing is enabled
  54830. * @returns the current color writing state
  54831. */
  54832. getColorWrite(): boolean;
  54833. /**
  54834. * Sets alpha constants used by some alpha blending modes
  54835. * @param r defines the red component
  54836. * @param g defines the green component
  54837. * @param b defines the blue component
  54838. * @param a defines the alpha component
  54839. */
  54840. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  54841. /**
  54842. * Sets the current alpha mode
  54843. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  54844. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  54845. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  54846. */
  54847. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  54848. /**
  54849. * Gets the current alpha mode
  54850. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  54851. * @returns the current alpha mode
  54852. */
  54853. getAlphaMode(): number;
  54854. setInt(uniform: WebGLUniformLocation, int: number): void;
  54855. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  54856. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  54857. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  54858. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  54859. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  54860. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  54861. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  54862. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  54863. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  54864. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  54865. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  54866. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  54867. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  54868. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  54869. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  54870. setFloat(uniform: WebGLUniformLocation, value: number): void;
  54871. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  54872. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  54873. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  54874. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  54875. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  54876. wipeCaches(bruteForce?: boolean): void;
  54877. _createTexture(): WebGLTexture;
  54878. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  54879. /**
  54880. * Usually called from Texture.ts.
  54881. * Passed information to create a WebGLTexture
  54882. * @param url defines a value which contains one of the following:
  54883. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  54884. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  54885. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  54886. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  54887. * @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)
  54888. * @param scene needed for loading to the correct scene
  54889. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  54890. * @param onLoad optional callback to be called upon successful completion
  54891. * @param onError optional callback to be called upon failure
  54892. * @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
  54893. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  54894. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  54895. * @param forcedExtension defines the extension to use to pick the right loader
  54896. * @param mimeType defines an optional mime type
  54897. * @returns a InternalTexture for assignment back into BABYLON.Texture
  54898. */
  54899. 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;
  54900. /**
  54901. * Creates a cube texture
  54902. * @param rootUrl defines the url where the files to load is located
  54903. * @param scene defines the current scene
  54904. * @param files defines the list of files to load (1 per face)
  54905. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  54906. * @param onLoad defines an optional callback raised when the texture is loaded
  54907. * @param onError defines an optional callback raised if there is an issue to load the texture
  54908. * @param format defines the format of the data
  54909. * @param forcedExtension defines the extension to use to pick the right loader
  54910. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  54911. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  54912. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  54913. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  54914. * @returns the cube texture as an InternalTexture
  54915. */
  54916. 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;
  54917. private _getSamplingFilter;
  54918. private static _GetNativeTextureFormat;
  54919. createRenderTargetTexture(size: number | {
  54920. width: number;
  54921. height: number;
  54922. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  54923. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  54924. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  54925. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  54926. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  54927. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  54928. /**
  54929. * Updates a dynamic vertex buffer.
  54930. * @param vertexBuffer the vertex buffer to update
  54931. * @param data the data used to update the vertex buffer
  54932. * @param byteOffset the byte offset of the data (optional)
  54933. * @param byteLength the byte length of the data (optional)
  54934. */
  54935. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  54936. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  54937. private _updateAnisotropicLevel;
  54938. private _getAddressMode;
  54939. /** @hidden */
  54940. _bindTexture(channel: number, texture: InternalTexture): void;
  54941. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  54942. releaseEffects(): void;
  54943. /** @hidden */
  54944. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54945. /** @hidden */
  54946. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54947. /** @hidden */
  54948. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54949. /** @hidden */
  54950. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  54951. }
  54952. }
  54953. declare module "babylonjs/Engines/index" {
  54954. export * from "babylonjs/Engines/constants";
  54955. export * from "babylonjs/Engines/engineCapabilities";
  54956. export * from "babylonjs/Engines/instancingAttributeInfo";
  54957. export * from "babylonjs/Engines/thinEngine";
  54958. export * from "babylonjs/Engines/engine";
  54959. export * from "babylonjs/Engines/engineStore";
  54960. export * from "babylonjs/Engines/nullEngine";
  54961. export * from "babylonjs/Engines/Extensions/index";
  54962. export * from "babylonjs/Engines/IPipelineContext";
  54963. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  54964. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  54965. export * from "babylonjs/Engines/nativeEngine";
  54966. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  54967. export * from "babylonjs/Engines/performanceConfigurator";
  54968. }
  54969. declare module "babylonjs/Events/clipboardEvents" {
  54970. /**
  54971. * Gather the list of clipboard event types as constants.
  54972. */
  54973. export class ClipboardEventTypes {
  54974. /**
  54975. * The clipboard event is fired when a copy command is active (pressed).
  54976. */
  54977. static readonly COPY: number;
  54978. /**
  54979. * The clipboard event is fired when a cut command is active (pressed).
  54980. */
  54981. static readonly CUT: number;
  54982. /**
  54983. * The clipboard event is fired when a paste command is active (pressed).
  54984. */
  54985. static readonly PASTE: number;
  54986. }
  54987. /**
  54988. * This class is used to store clipboard related info for the onClipboardObservable event.
  54989. */
  54990. export class ClipboardInfo {
  54991. /**
  54992. * Defines the type of event (BABYLON.ClipboardEventTypes)
  54993. */
  54994. type: number;
  54995. /**
  54996. * Defines the related dom event
  54997. */
  54998. event: ClipboardEvent;
  54999. /**
  55000. *Creates an instance of ClipboardInfo.
  55001. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  55002. * @param event Defines the related dom event
  55003. */
  55004. constructor(
  55005. /**
  55006. * Defines the type of event (BABYLON.ClipboardEventTypes)
  55007. */
  55008. type: number,
  55009. /**
  55010. * Defines the related dom event
  55011. */
  55012. event: ClipboardEvent);
  55013. /**
  55014. * Get the clipboard event's type from the keycode.
  55015. * @param keyCode Defines the keyCode for the current keyboard event.
  55016. * @return {number}
  55017. */
  55018. static GetTypeFromCharacter(keyCode: number): number;
  55019. }
  55020. }
  55021. declare module "babylonjs/Events/index" {
  55022. export * from "babylonjs/Events/keyboardEvents";
  55023. export * from "babylonjs/Events/pointerEvents";
  55024. export * from "babylonjs/Events/clipboardEvents";
  55025. }
  55026. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  55027. import { Scene } from "babylonjs/scene";
  55028. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55029. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55030. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55031. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55032. /**
  55033. * Google Daydream controller
  55034. */
  55035. export class DaydreamController extends WebVRController {
  55036. /**
  55037. * Base Url for the controller model.
  55038. */
  55039. static MODEL_BASE_URL: string;
  55040. /**
  55041. * File name for the controller model.
  55042. */
  55043. static MODEL_FILENAME: string;
  55044. /**
  55045. * Gamepad Id prefix used to identify Daydream Controller.
  55046. */
  55047. static readonly GAMEPAD_ID_PREFIX: string;
  55048. /**
  55049. * Creates a new DaydreamController from a gamepad
  55050. * @param vrGamepad the gamepad that the controller should be created from
  55051. */
  55052. constructor(vrGamepad: any);
  55053. /**
  55054. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55055. * @param scene scene in which to add meshes
  55056. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55057. */
  55058. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55059. /**
  55060. * Called once for each button that changed state since the last frame
  55061. * @param buttonIdx Which button index changed
  55062. * @param state New state of the button
  55063. * @param changes Which properties on the state changed since last frame
  55064. */
  55065. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55066. }
  55067. }
  55068. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  55069. import { Scene } from "babylonjs/scene";
  55070. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55071. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55072. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55073. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55074. /**
  55075. * Gear VR Controller
  55076. */
  55077. export class GearVRController extends WebVRController {
  55078. /**
  55079. * Base Url for the controller model.
  55080. */
  55081. static MODEL_BASE_URL: string;
  55082. /**
  55083. * File name for the controller model.
  55084. */
  55085. static MODEL_FILENAME: string;
  55086. /**
  55087. * Gamepad Id prefix used to identify this controller.
  55088. */
  55089. static readonly GAMEPAD_ID_PREFIX: string;
  55090. private readonly _buttonIndexToObservableNameMap;
  55091. /**
  55092. * Creates a new GearVRController from a gamepad
  55093. * @param vrGamepad the gamepad that the controller should be created from
  55094. */
  55095. constructor(vrGamepad: any);
  55096. /**
  55097. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55098. * @param scene scene in which to add meshes
  55099. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55100. */
  55101. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55102. /**
  55103. * Called once for each button that changed state since the last frame
  55104. * @param buttonIdx Which button index changed
  55105. * @param state New state of the button
  55106. * @param changes Which properties on the state changed since last frame
  55107. */
  55108. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55109. }
  55110. }
  55111. declare module "babylonjs/Gamepads/Controllers/genericController" {
  55112. import { Scene } from "babylonjs/scene";
  55113. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55114. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55115. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55116. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55117. /**
  55118. * Generic Controller
  55119. */
  55120. export class GenericController extends WebVRController {
  55121. /**
  55122. * Base Url for the controller model.
  55123. */
  55124. static readonly MODEL_BASE_URL: string;
  55125. /**
  55126. * File name for the controller model.
  55127. */
  55128. static readonly MODEL_FILENAME: string;
  55129. /**
  55130. * Creates a new GenericController from a gamepad
  55131. * @param vrGamepad the gamepad that the controller should be created from
  55132. */
  55133. constructor(vrGamepad: any);
  55134. /**
  55135. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55136. * @param scene scene in which to add meshes
  55137. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55138. */
  55139. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55140. /**
  55141. * Called once for each button that changed state since the last frame
  55142. * @param buttonIdx Which button index changed
  55143. * @param state New state of the button
  55144. * @param changes Which properties on the state changed since last frame
  55145. */
  55146. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55147. }
  55148. }
  55149. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  55150. import { Observable } from "babylonjs/Misc/observable";
  55151. import { Scene } from "babylonjs/scene";
  55152. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55153. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55154. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55155. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55156. /**
  55157. * Oculus Touch Controller
  55158. */
  55159. export class OculusTouchController extends WebVRController {
  55160. /**
  55161. * Base Url for the controller model.
  55162. */
  55163. static MODEL_BASE_URL: string;
  55164. /**
  55165. * File name for the left controller model.
  55166. */
  55167. static MODEL_LEFT_FILENAME: string;
  55168. /**
  55169. * File name for the right controller model.
  55170. */
  55171. static MODEL_RIGHT_FILENAME: string;
  55172. /**
  55173. * Base Url for the Quest controller model.
  55174. */
  55175. static QUEST_MODEL_BASE_URL: string;
  55176. /**
  55177. * @hidden
  55178. * If the controllers are running on a device that needs the updated Quest controller models
  55179. */
  55180. static _IsQuest: boolean;
  55181. /**
  55182. * Fired when the secondary trigger on this controller is modified
  55183. */
  55184. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  55185. /**
  55186. * Fired when the thumb rest on this controller is modified
  55187. */
  55188. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  55189. /**
  55190. * Creates a new OculusTouchController from a gamepad
  55191. * @param vrGamepad the gamepad that the controller should be created from
  55192. */
  55193. constructor(vrGamepad: any);
  55194. /**
  55195. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55196. * @param scene scene in which to add meshes
  55197. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55198. */
  55199. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55200. /**
  55201. * Fired when the A button on this controller is modified
  55202. */
  55203. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55204. /**
  55205. * Fired when the B button on this controller is modified
  55206. */
  55207. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55208. /**
  55209. * Fired when the X button on this controller is modified
  55210. */
  55211. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55212. /**
  55213. * Fired when the Y button on this controller is modified
  55214. */
  55215. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55216. /**
  55217. * Called once for each button that changed state since the last frame
  55218. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  55219. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  55220. * 2) secondary trigger (same)
  55221. * 3) A (right) X (left), touch, pressed = value
  55222. * 4) B / Y
  55223. * 5) thumb rest
  55224. * @param buttonIdx Which button index changed
  55225. * @param state New state of the button
  55226. * @param changes Which properties on the state changed since last frame
  55227. */
  55228. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55229. }
  55230. }
  55231. declare module "babylonjs/Gamepads/Controllers/viveController" {
  55232. import { Scene } from "babylonjs/scene";
  55233. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55234. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55235. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55236. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55237. import { Observable } from "babylonjs/Misc/observable";
  55238. /**
  55239. * Vive Controller
  55240. */
  55241. export class ViveController extends WebVRController {
  55242. /**
  55243. * Base Url for the controller model.
  55244. */
  55245. static MODEL_BASE_URL: string;
  55246. /**
  55247. * File name for the controller model.
  55248. */
  55249. static MODEL_FILENAME: string;
  55250. /**
  55251. * Creates a new ViveController from a gamepad
  55252. * @param vrGamepad the gamepad that the controller should be created from
  55253. */
  55254. constructor(vrGamepad: any);
  55255. /**
  55256. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55257. * @param scene scene in which to add meshes
  55258. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55259. */
  55260. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55261. /**
  55262. * Fired when the left button on this controller is modified
  55263. */
  55264. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55265. /**
  55266. * Fired when the right button on this controller is modified
  55267. */
  55268. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55269. /**
  55270. * Fired when the menu button on this controller is modified
  55271. */
  55272. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55273. /**
  55274. * Called once for each button that changed state since the last frame
  55275. * Vive mapping:
  55276. * 0: touchpad
  55277. * 1: trigger
  55278. * 2: left AND right buttons
  55279. * 3: menu button
  55280. * @param buttonIdx Which button index changed
  55281. * @param state New state of the button
  55282. * @param changes Which properties on the state changed since last frame
  55283. */
  55284. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55285. }
  55286. }
  55287. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  55288. import { Observable } from "babylonjs/Misc/observable";
  55289. import { Scene } from "babylonjs/scene";
  55290. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55291. import { Ray } from "babylonjs/Culling/ray";
  55292. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55293. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55294. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55295. /**
  55296. * Defines the WindowsMotionController object that the state of the windows motion controller
  55297. */
  55298. export class WindowsMotionController extends WebVRController {
  55299. /**
  55300. * The base url used to load the left and right controller models
  55301. */
  55302. static MODEL_BASE_URL: string;
  55303. /**
  55304. * The name of the left controller model file
  55305. */
  55306. static MODEL_LEFT_FILENAME: string;
  55307. /**
  55308. * The name of the right controller model file
  55309. */
  55310. static MODEL_RIGHT_FILENAME: string;
  55311. /**
  55312. * The controller name prefix for this controller type
  55313. */
  55314. static readonly GAMEPAD_ID_PREFIX: string;
  55315. /**
  55316. * The controller id pattern for this controller type
  55317. */
  55318. private static readonly GAMEPAD_ID_PATTERN;
  55319. private _loadedMeshInfo;
  55320. protected readonly _mapping: {
  55321. buttons: string[];
  55322. buttonMeshNames: {
  55323. trigger: string;
  55324. menu: string;
  55325. grip: string;
  55326. thumbstick: string;
  55327. trackpad: string;
  55328. };
  55329. buttonObservableNames: {
  55330. trigger: string;
  55331. menu: string;
  55332. grip: string;
  55333. thumbstick: string;
  55334. trackpad: string;
  55335. };
  55336. axisMeshNames: string[];
  55337. pointingPoseMeshName: string;
  55338. };
  55339. /**
  55340. * Fired when the trackpad on this controller is clicked
  55341. */
  55342. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  55343. /**
  55344. * Fired when the trackpad on this controller is modified
  55345. */
  55346. onTrackpadValuesChangedObservable: Observable<StickValues>;
  55347. /**
  55348. * The current x and y values of this controller's trackpad
  55349. */
  55350. trackpad: StickValues;
  55351. /**
  55352. * Creates a new WindowsMotionController from a gamepad
  55353. * @param vrGamepad the gamepad that the controller should be created from
  55354. */
  55355. constructor(vrGamepad: any);
  55356. /**
  55357. * Fired when the trigger on this controller is modified
  55358. */
  55359. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55360. /**
  55361. * Fired when the menu button on this controller is modified
  55362. */
  55363. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55364. /**
  55365. * Fired when the grip button on this controller is modified
  55366. */
  55367. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55368. /**
  55369. * Fired when the thumbstick button on this controller is modified
  55370. */
  55371. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55372. /**
  55373. * Fired when the touchpad button on this controller is modified
  55374. */
  55375. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55376. /**
  55377. * Fired when the touchpad values on this controller are modified
  55378. */
  55379. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  55380. protected _updateTrackpad(): void;
  55381. /**
  55382. * Called once per frame by the engine.
  55383. */
  55384. update(): void;
  55385. /**
  55386. * Called once for each button that changed state since the last frame
  55387. * @param buttonIdx Which button index changed
  55388. * @param state New state of the button
  55389. * @param changes Which properties on the state changed since last frame
  55390. */
  55391. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55392. /**
  55393. * Moves the buttons on the controller mesh based on their current state
  55394. * @param buttonName the name of the button to move
  55395. * @param buttonValue the value of the button which determines the buttons new position
  55396. */
  55397. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  55398. /**
  55399. * Moves the axis on the controller mesh based on its current state
  55400. * @param axis the index of the axis
  55401. * @param axisValue the value of the axis which determines the meshes new position
  55402. * @hidden
  55403. */
  55404. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  55405. /**
  55406. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55407. * @param scene scene in which to add meshes
  55408. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55409. */
  55410. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  55411. /**
  55412. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  55413. * can be transformed by button presses and axes values, based on this._mapping.
  55414. *
  55415. * @param scene scene in which the meshes exist
  55416. * @param meshes list of meshes that make up the controller model to process
  55417. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  55418. */
  55419. private processModel;
  55420. private createMeshInfo;
  55421. /**
  55422. * Gets the ray of the controller in the direction the controller is pointing
  55423. * @param length the length the resulting ray should be
  55424. * @returns a ray in the direction the controller is pointing
  55425. */
  55426. getForwardRay(length?: number): Ray;
  55427. /**
  55428. * Disposes of the controller
  55429. */
  55430. dispose(): void;
  55431. }
  55432. /**
  55433. * This class represents a new windows motion controller in XR.
  55434. */
  55435. export class XRWindowsMotionController extends WindowsMotionController {
  55436. /**
  55437. * Changing the original WIndowsMotionController mapping to fir the new mapping
  55438. */
  55439. protected readonly _mapping: {
  55440. buttons: string[];
  55441. buttonMeshNames: {
  55442. trigger: string;
  55443. menu: string;
  55444. grip: string;
  55445. thumbstick: string;
  55446. trackpad: string;
  55447. };
  55448. buttonObservableNames: {
  55449. trigger: string;
  55450. menu: string;
  55451. grip: string;
  55452. thumbstick: string;
  55453. trackpad: string;
  55454. };
  55455. axisMeshNames: string[];
  55456. pointingPoseMeshName: string;
  55457. };
  55458. /**
  55459. * Construct a new XR-Based windows motion controller
  55460. *
  55461. * @param gamepadInfo the gamepad object from the browser
  55462. */
  55463. constructor(gamepadInfo: any);
  55464. /**
  55465. * holds the thumbstick values (X,Y)
  55466. */
  55467. thumbstickValues: StickValues;
  55468. /**
  55469. * Fired when the thumbstick on this controller is clicked
  55470. */
  55471. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  55472. /**
  55473. * Fired when the thumbstick on this controller is modified
  55474. */
  55475. onThumbstickValuesChangedObservable: Observable<StickValues>;
  55476. /**
  55477. * Fired when the touchpad button on this controller is modified
  55478. */
  55479. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  55480. /**
  55481. * Fired when the touchpad values on this controller are modified
  55482. */
  55483. onTrackpadValuesChangedObservable: Observable<StickValues>;
  55484. /**
  55485. * Fired when the thumbstick button on this controller is modified
  55486. * here to prevent breaking changes
  55487. */
  55488. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55489. /**
  55490. * updating the thumbstick(!) and not the trackpad.
  55491. * This is named this way due to the difference between WebVR and XR and to avoid
  55492. * changing the parent class.
  55493. */
  55494. protected _updateTrackpad(): void;
  55495. /**
  55496. * Disposes the class with joy
  55497. */
  55498. dispose(): void;
  55499. }
  55500. }
  55501. declare module "babylonjs/Gamepads/Controllers/index" {
  55502. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  55503. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  55504. export * from "babylonjs/Gamepads/Controllers/genericController";
  55505. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  55506. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55507. export * from "babylonjs/Gamepads/Controllers/viveController";
  55508. export * from "babylonjs/Gamepads/Controllers/webVRController";
  55509. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  55510. }
  55511. declare module "babylonjs/Gamepads/index" {
  55512. export * from "babylonjs/Gamepads/Controllers/index";
  55513. export * from "babylonjs/Gamepads/gamepad";
  55514. export * from "babylonjs/Gamepads/gamepadManager";
  55515. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  55516. export * from "babylonjs/Gamepads/xboxGamepad";
  55517. export * from "babylonjs/Gamepads/dualShockGamepad";
  55518. }
  55519. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  55520. import { Scene } from "babylonjs/scene";
  55521. import { Vector4 } from "babylonjs/Maths/math.vector";
  55522. import { Color4 } from "babylonjs/Maths/math.color";
  55523. import { Mesh } from "babylonjs/Meshes/mesh";
  55524. import { Nullable } from "babylonjs/types";
  55525. /**
  55526. * Class containing static functions to help procedurally build meshes
  55527. */
  55528. export class PolyhedronBuilder {
  55529. /**
  55530. * Creates a polyhedron mesh
  55531. * * 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
  55532. * * The parameter `size` (positive float, default 1) sets the polygon size
  55533. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  55534. * * 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`
  55535. * * 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
  55536. * * 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)`)
  55537. * * 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
  55538. * * 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
  55539. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55540. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55541. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55542. * @param name defines the name of the mesh
  55543. * @param options defines the options used to create the mesh
  55544. * @param scene defines the hosting scene
  55545. * @returns the polyhedron mesh
  55546. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  55547. */
  55548. static CreatePolyhedron(name: string, options: {
  55549. type?: number;
  55550. size?: number;
  55551. sizeX?: number;
  55552. sizeY?: number;
  55553. sizeZ?: number;
  55554. custom?: any;
  55555. faceUV?: Vector4[];
  55556. faceColors?: Color4[];
  55557. flat?: boolean;
  55558. updatable?: boolean;
  55559. sideOrientation?: number;
  55560. frontUVs?: Vector4;
  55561. backUVs?: Vector4;
  55562. }, scene?: Nullable<Scene>): Mesh;
  55563. }
  55564. }
  55565. declare module "babylonjs/Gizmos/scaleGizmo" {
  55566. import { Observable } from "babylonjs/Misc/observable";
  55567. import { Nullable } from "babylonjs/types";
  55568. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55569. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55570. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  55571. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55572. import { Node } from "babylonjs/node";
  55573. /**
  55574. * Gizmo that enables scaling a mesh along 3 axis
  55575. */
  55576. export class ScaleGizmo extends Gizmo {
  55577. /**
  55578. * Internal gizmo used for interactions on the x axis
  55579. */
  55580. xGizmo: AxisScaleGizmo;
  55581. /**
  55582. * Internal gizmo used for interactions on the y axis
  55583. */
  55584. yGizmo: AxisScaleGizmo;
  55585. /**
  55586. * Internal gizmo used for interactions on the z axis
  55587. */
  55588. zGizmo: AxisScaleGizmo;
  55589. /**
  55590. * Internal gizmo used to scale all axis equally
  55591. */
  55592. uniformScaleGizmo: AxisScaleGizmo;
  55593. private _meshAttached;
  55594. private _nodeAttached;
  55595. private _updateGizmoRotationToMatchAttachedMesh;
  55596. private _snapDistance;
  55597. private _scaleRatio;
  55598. private _uniformScalingMesh;
  55599. private _octahedron;
  55600. private _sensitivity;
  55601. /** Fires an event when any of it's sub gizmos are dragged */
  55602. onDragStartObservable: Observable<unknown>;
  55603. /** Fires an event when any of it's sub gizmos are released from dragging */
  55604. onDragEndObservable: Observable<unknown>;
  55605. get attachedMesh(): Nullable<AbstractMesh>;
  55606. set attachedMesh(mesh: Nullable<AbstractMesh>);
  55607. get attachedNode(): Nullable<Node>;
  55608. set attachedNode(node: Nullable<Node>);
  55609. /**
  55610. * Creates a ScaleGizmo
  55611. * @param gizmoLayer The utility layer the gizmo will be added to
  55612. * @param thickness display gizmo axis thickness
  55613. */
  55614. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  55615. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  55616. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  55617. /**
  55618. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55619. */
  55620. set snapDistance(value: number);
  55621. get snapDistance(): number;
  55622. /**
  55623. * Ratio for the scale of the gizmo (Default: 1)
  55624. */
  55625. set scaleRatio(value: number);
  55626. get scaleRatio(): number;
  55627. /**
  55628. * Sensitivity factor for dragging (Default: 1)
  55629. */
  55630. set sensitivity(value: number);
  55631. get sensitivity(): number;
  55632. /**
  55633. * Disposes of the gizmo
  55634. */
  55635. dispose(): void;
  55636. }
  55637. }
  55638. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  55639. import { Observable } from "babylonjs/Misc/observable";
  55640. import { Nullable } from "babylonjs/types";
  55641. import { Vector3 } from "babylonjs/Maths/math.vector";
  55642. import { Node } from "babylonjs/node";
  55643. import { Mesh } from "babylonjs/Meshes/mesh";
  55644. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  55645. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55646. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55647. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  55648. import { Color3 } from "babylonjs/Maths/math.color";
  55649. /**
  55650. * Single axis scale gizmo
  55651. */
  55652. export class AxisScaleGizmo extends Gizmo {
  55653. /**
  55654. * Drag behavior responsible for the gizmos dragging interactions
  55655. */
  55656. dragBehavior: PointerDragBehavior;
  55657. private _pointerObserver;
  55658. /**
  55659. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55660. */
  55661. snapDistance: number;
  55662. /**
  55663. * Event that fires each time the gizmo snaps to a new location.
  55664. * * snapDistance is the the change in distance
  55665. */
  55666. onSnapObservable: Observable<{
  55667. snapDistance: number;
  55668. }>;
  55669. /**
  55670. * If the scaling operation should be done on all axis (default: false)
  55671. */
  55672. uniformScaling: boolean;
  55673. /**
  55674. * Custom sensitivity value for the drag strength
  55675. */
  55676. sensitivity: number;
  55677. private _isEnabled;
  55678. private _parent;
  55679. private _arrow;
  55680. private _coloredMaterial;
  55681. private _hoverMaterial;
  55682. /**
  55683. * Creates an AxisScaleGizmo
  55684. * @param gizmoLayer The utility layer the gizmo will be added to
  55685. * @param dragAxis The axis which the gizmo will be able to scale on
  55686. * @param color The color of the gizmo
  55687. * @param thickness display gizmo axis thickness
  55688. */
  55689. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  55690. protected _attachedNodeChanged(value: Nullable<Node>): void;
  55691. /**
  55692. * If the gizmo is enabled
  55693. */
  55694. set isEnabled(value: boolean);
  55695. get isEnabled(): boolean;
  55696. /**
  55697. * Disposes of the gizmo
  55698. */
  55699. dispose(): void;
  55700. /**
  55701. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  55702. * @param mesh The mesh to replace the default mesh of the gizmo
  55703. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  55704. */
  55705. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  55706. }
  55707. }
  55708. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  55709. import { Observable } from "babylonjs/Misc/observable";
  55710. import { Nullable } from "babylonjs/types";
  55711. import { Vector3 } from "babylonjs/Maths/math.vector";
  55712. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55713. import { Mesh } from "babylonjs/Meshes/mesh";
  55714. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55715. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55716. import { Color3 } from "babylonjs/Maths/math.color";
  55717. import "babylonjs/Meshes/Builders/boxBuilder";
  55718. /**
  55719. * Bounding box gizmo
  55720. */
  55721. export class BoundingBoxGizmo extends Gizmo {
  55722. private _lineBoundingBox;
  55723. private _rotateSpheresParent;
  55724. private _scaleBoxesParent;
  55725. private _boundingDimensions;
  55726. private _renderObserver;
  55727. private _pointerObserver;
  55728. private _scaleDragSpeed;
  55729. private _tmpQuaternion;
  55730. private _tmpVector;
  55731. private _tmpRotationMatrix;
  55732. /**
  55733. * 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)
  55734. */
  55735. ignoreChildren: boolean;
  55736. /**
  55737. * 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)
  55738. */
  55739. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  55740. /**
  55741. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  55742. */
  55743. rotationSphereSize: number;
  55744. /**
  55745. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  55746. */
  55747. scaleBoxSize: number;
  55748. /**
  55749. * 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)
  55750. */
  55751. fixedDragMeshScreenSize: boolean;
  55752. /**
  55753. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  55754. */
  55755. fixedDragMeshScreenSizeDistanceFactor: number;
  55756. /**
  55757. * Fired when a rotation sphere or scale box is dragged
  55758. */
  55759. onDragStartObservable: Observable<{}>;
  55760. /**
  55761. * Fired when a scale box is dragged
  55762. */
  55763. onScaleBoxDragObservable: Observable<{}>;
  55764. /**
  55765. * Fired when a scale box drag is ended
  55766. */
  55767. onScaleBoxDragEndObservable: Observable<{}>;
  55768. /**
  55769. * Fired when a rotation sphere is dragged
  55770. */
  55771. onRotationSphereDragObservable: Observable<{}>;
  55772. /**
  55773. * Fired when a rotation sphere drag is ended
  55774. */
  55775. onRotationSphereDragEndObservable: Observable<{}>;
  55776. /**
  55777. * 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)
  55778. */
  55779. scalePivot: Nullable<Vector3>;
  55780. /**
  55781. * Mesh used as a pivot to rotate the attached node
  55782. */
  55783. private _anchorMesh;
  55784. private _existingMeshScale;
  55785. private _dragMesh;
  55786. private pointerDragBehavior;
  55787. private coloredMaterial;
  55788. private hoverColoredMaterial;
  55789. /**
  55790. * Sets the color of the bounding box gizmo
  55791. * @param color the color to set
  55792. */
  55793. setColor(color: Color3): void;
  55794. /**
  55795. * Creates an BoundingBoxGizmo
  55796. * @param gizmoLayer The utility layer the gizmo will be added to
  55797. * @param color The color of the gizmo
  55798. */
  55799. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  55800. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  55801. private _selectNode;
  55802. /**
  55803. * Updates the bounding box information for the Gizmo
  55804. */
  55805. updateBoundingBox(): void;
  55806. private _updateRotationSpheres;
  55807. private _updateScaleBoxes;
  55808. /**
  55809. * Enables rotation on the specified axis and disables rotation on the others
  55810. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  55811. */
  55812. setEnabledRotationAxis(axis: string): void;
  55813. /**
  55814. * Enables/disables scaling
  55815. * @param enable if scaling should be enabled
  55816. * @param homogeneousScaling defines if scaling should only be homogeneous
  55817. */
  55818. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  55819. private _updateDummy;
  55820. /**
  55821. * Enables a pointer drag behavior on the bounding box of the gizmo
  55822. */
  55823. enableDragBehavior(): void;
  55824. /**
  55825. * Disposes of the gizmo
  55826. */
  55827. dispose(): void;
  55828. /**
  55829. * 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)
  55830. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  55831. * @returns the bounding box mesh with the passed in mesh as a child
  55832. */
  55833. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  55834. /**
  55835. * CustomMeshes are not supported by this gizmo
  55836. * @param mesh The mesh to replace the default mesh of the gizmo
  55837. */
  55838. setCustomMesh(mesh: Mesh): void;
  55839. }
  55840. }
  55841. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  55842. import { Observable } from "babylonjs/Misc/observable";
  55843. import { Nullable } from "babylonjs/types";
  55844. import { Vector3 } from "babylonjs/Maths/math.vector";
  55845. import { Color3 } from "babylonjs/Maths/math.color";
  55846. import { Node } from "babylonjs/node";
  55847. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  55848. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55849. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55850. import "babylonjs/Meshes/Builders/linesBuilder";
  55851. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  55852. /**
  55853. * Single plane rotation gizmo
  55854. */
  55855. export class PlaneRotationGizmo extends Gizmo {
  55856. /**
  55857. * Drag behavior responsible for the gizmos dragging interactions
  55858. */
  55859. dragBehavior: PointerDragBehavior;
  55860. private _pointerObserver;
  55861. /**
  55862. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  55863. */
  55864. snapDistance: number;
  55865. /**
  55866. * Event that fires each time the gizmo snaps to a new location.
  55867. * * snapDistance is the the change in distance
  55868. */
  55869. onSnapObservable: Observable<{
  55870. snapDistance: number;
  55871. }>;
  55872. private _isEnabled;
  55873. private _parent;
  55874. /**
  55875. * Creates a PlaneRotationGizmo
  55876. * @param gizmoLayer The utility layer the gizmo will be added to
  55877. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  55878. * @param color The color of the gizmo
  55879. * @param tessellation Amount of tessellation to be used when creating rotation circles
  55880. * @param useEulerRotation Use and update Euler angle instead of quaternion
  55881. * @param thickness display gizmo axis thickness
  55882. */
  55883. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  55884. protected _attachedNodeChanged(value: Nullable<Node>): void;
  55885. /**
  55886. * If the gizmo is enabled
  55887. */
  55888. set isEnabled(value: boolean);
  55889. get isEnabled(): boolean;
  55890. /**
  55891. * Disposes of the gizmo
  55892. */
  55893. dispose(): void;
  55894. }
  55895. }
  55896. declare module "babylonjs/Gizmos/rotationGizmo" {
  55897. import { Observable } from "babylonjs/Misc/observable";
  55898. import { Nullable } from "babylonjs/types";
  55899. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55900. import { Mesh } from "babylonjs/Meshes/mesh";
  55901. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55902. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  55903. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55904. import { Node } from "babylonjs/node";
  55905. /**
  55906. * Gizmo that enables rotating a mesh along 3 axis
  55907. */
  55908. export class RotationGizmo extends Gizmo {
  55909. /**
  55910. * Internal gizmo used for interactions on the x axis
  55911. */
  55912. xGizmo: PlaneRotationGizmo;
  55913. /**
  55914. * Internal gizmo used for interactions on the y axis
  55915. */
  55916. yGizmo: PlaneRotationGizmo;
  55917. /**
  55918. * Internal gizmo used for interactions on the z axis
  55919. */
  55920. zGizmo: PlaneRotationGizmo;
  55921. /** Fires an event when any of it's sub gizmos are dragged */
  55922. onDragStartObservable: Observable<unknown>;
  55923. /** Fires an event when any of it's sub gizmos are released from dragging */
  55924. onDragEndObservable: Observable<unknown>;
  55925. private _meshAttached;
  55926. private _nodeAttached;
  55927. get attachedMesh(): Nullable<AbstractMesh>;
  55928. set attachedMesh(mesh: Nullable<AbstractMesh>);
  55929. get attachedNode(): Nullable<Node>;
  55930. set attachedNode(node: Nullable<Node>);
  55931. /**
  55932. * Creates a RotationGizmo
  55933. * @param gizmoLayer The utility layer the gizmo will be added to
  55934. * @param tessellation Amount of tessellation to be used when creating rotation circles
  55935. * @param useEulerRotation Use and update Euler angle instead of quaternion
  55936. * @param thickness display gizmo axis thickness
  55937. */
  55938. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  55939. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  55940. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  55941. /**
  55942. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55943. */
  55944. set snapDistance(value: number);
  55945. get snapDistance(): number;
  55946. /**
  55947. * Ratio for the scale of the gizmo (Default: 1)
  55948. */
  55949. set scaleRatio(value: number);
  55950. get scaleRatio(): number;
  55951. /**
  55952. * Disposes of the gizmo
  55953. */
  55954. dispose(): void;
  55955. /**
  55956. * CustomMeshes are not supported by this gizmo
  55957. * @param mesh The mesh to replace the default mesh of the gizmo
  55958. */
  55959. setCustomMesh(mesh: Mesh): void;
  55960. }
  55961. }
  55962. declare module "babylonjs/Gizmos/gizmoManager" {
  55963. import { Observable } from "babylonjs/Misc/observable";
  55964. import { Nullable } from "babylonjs/types";
  55965. import { Scene, IDisposable } from "babylonjs/scene";
  55966. import { Node } from "babylonjs/node";
  55967. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55968. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55969. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  55970. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  55971. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  55972. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  55973. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  55974. /**
  55975. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  55976. */
  55977. export class GizmoManager implements IDisposable {
  55978. private scene;
  55979. /**
  55980. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  55981. */
  55982. gizmos: {
  55983. positionGizmo: Nullable<PositionGizmo>;
  55984. rotationGizmo: Nullable<RotationGizmo>;
  55985. scaleGizmo: Nullable<ScaleGizmo>;
  55986. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  55987. };
  55988. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  55989. clearGizmoOnEmptyPointerEvent: boolean;
  55990. /** Fires an event when the manager is attached to a mesh */
  55991. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  55992. /** Fires an event when the manager is attached to a node */
  55993. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  55994. private _gizmosEnabled;
  55995. private _pointerObserver;
  55996. private _attachedMesh;
  55997. private _attachedNode;
  55998. private _boundingBoxColor;
  55999. private _defaultUtilityLayer;
  56000. private _defaultKeepDepthUtilityLayer;
  56001. private _thickness;
  56002. /**
  56003. * When bounding box gizmo is enabled, this can be used to track drag/end events
  56004. */
  56005. boundingBoxDragBehavior: SixDofDragBehavior;
  56006. /**
  56007. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  56008. */
  56009. attachableMeshes: Nullable<Array<AbstractMesh>>;
  56010. /**
  56011. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  56012. */
  56013. attachableNodes: Nullable<Array<Node>>;
  56014. /**
  56015. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  56016. */
  56017. usePointerToAttachGizmos: boolean;
  56018. /**
  56019. * Utility layer that the bounding box gizmo belongs to
  56020. */
  56021. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  56022. /**
  56023. * Utility layer that all gizmos besides bounding box belong to
  56024. */
  56025. get utilityLayer(): UtilityLayerRenderer;
  56026. /**
  56027. * Instatiates a gizmo manager
  56028. * @param scene the scene to overlay the gizmos on top of
  56029. * @param thickness display gizmo axis thickness
  56030. */
  56031. constructor(scene: Scene, thickness?: number);
  56032. /**
  56033. * Attaches a set of gizmos to the specified mesh
  56034. * @param mesh The mesh the gizmo's should be attached to
  56035. */
  56036. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  56037. /**
  56038. * Attaches a set of gizmos to the specified node
  56039. * @param node The node the gizmo's should be attached to
  56040. */
  56041. attachToNode(node: Nullable<Node>): void;
  56042. /**
  56043. * If the position gizmo is enabled
  56044. */
  56045. set positionGizmoEnabled(value: boolean);
  56046. get positionGizmoEnabled(): boolean;
  56047. /**
  56048. * If the rotation gizmo is enabled
  56049. */
  56050. set rotationGizmoEnabled(value: boolean);
  56051. get rotationGizmoEnabled(): boolean;
  56052. /**
  56053. * If the scale gizmo is enabled
  56054. */
  56055. set scaleGizmoEnabled(value: boolean);
  56056. get scaleGizmoEnabled(): boolean;
  56057. /**
  56058. * If the boundingBox gizmo is enabled
  56059. */
  56060. set boundingBoxGizmoEnabled(value: boolean);
  56061. get boundingBoxGizmoEnabled(): boolean;
  56062. /**
  56063. * Disposes of the gizmo manager
  56064. */
  56065. dispose(): void;
  56066. }
  56067. }
  56068. declare module "babylonjs/Lights/directionalLight" {
  56069. import { Camera } from "babylonjs/Cameras/camera";
  56070. import { Scene } from "babylonjs/scene";
  56071. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56072. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56073. import { Light } from "babylonjs/Lights/light";
  56074. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  56075. import { Effect } from "babylonjs/Materials/effect";
  56076. /**
  56077. * A directional light is defined by a direction (what a surprise!).
  56078. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  56079. * 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.
  56080. * Documentation: https://doc.babylonjs.com/babylon101/lights
  56081. */
  56082. export class DirectionalLight extends ShadowLight {
  56083. private _shadowFrustumSize;
  56084. /**
  56085. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  56086. */
  56087. get shadowFrustumSize(): number;
  56088. /**
  56089. * Specifies a fix frustum size for the shadow generation.
  56090. */
  56091. set shadowFrustumSize(value: number);
  56092. private _shadowOrthoScale;
  56093. /**
  56094. * Gets the shadow projection scale against the optimal computed one.
  56095. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  56096. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  56097. */
  56098. get shadowOrthoScale(): number;
  56099. /**
  56100. * Sets the shadow projection scale against the optimal computed one.
  56101. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  56102. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  56103. */
  56104. set shadowOrthoScale(value: number);
  56105. /**
  56106. * Automatically compute the projection matrix to best fit (including all the casters)
  56107. * on each frame.
  56108. */
  56109. autoUpdateExtends: boolean;
  56110. /**
  56111. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  56112. * on each frame. autoUpdateExtends must be set to true for this to work
  56113. */
  56114. autoCalcShadowZBounds: boolean;
  56115. private _orthoLeft;
  56116. private _orthoRight;
  56117. private _orthoTop;
  56118. private _orthoBottom;
  56119. /**
  56120. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  56121. * The directional light is emitted from everywhere in the given direction.
  56122. * It can cast shadows.
  56123. * Documentation : https://doc.babylonjs.com/babylon101/lights
  56124. * @param name The friendly name of the light
  56125. * @param direction The direction of the light
  56126. * @param scene The scene the light belongs to
  56127. */
  56128. constructor(name: string, direction: Vector3, scene: Scene);
  56129. /**
  56130. * Returns the string "DirectionalLight".
  56131. * @return The class name
  56132. */
  56133. getClassName(): string;
  56134. /**
  56135. * Returns the integer 1.
  56136. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  56137. */
  56138. getTypeID(): number;
  56139. /**
  56140. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  56141. * Returns the DirectionalLight Shadow projection matrix.
  56142. */
  56143. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56144. /**
  56145. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  56146. * Returns the DirectionalLight Shadow projection matrix.
  56147. */
  56148. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  56149. /**
  56150. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  56151. * Returns the DirectionalLight Shadow projection matrix.
  56152. */
  56153. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56154. protected _buildUniformLayout(): void;
  56155. /**
  56156. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  56157. * @param effect The effect to update
  56158. * @param lightIndex The index of the light in the effect to update
  56159. * @returns The directional light
  56160. */
  56161. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  56162. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  56163. /**
  56164. * Gets the minZ used for shadow according to both the scene and the light.
  56165. *
  56166. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  56167. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  56168. * @param activeCamera The camera we are returning the min for
  56169. * @returns the depth min z
  56170. */
  56171. getDepthMinZ(activeCamera: Camera): number;
  56172. /**
  56173. * Gets the maxZ used for shadow according to both the scene and the light.
  56174. *
  56175. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  56176. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  56177. * @param activeCamera The camera we are returning the max for
  56178. * @returns the depth max z
  56179. */
  56180. getDepthMaxZ(activeCamera: Camera): number;
  56181. /**
  56182. * Prepares the list of defines specific to the light type.
  56183. * @param defines the list of defines
  56184. * @param lightIndex defines the index of the light for the effect
  56185. */
  56186. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  56187. }
  56188. }
  56189. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  56190. import { Mesh } from "babylonjs/Meshes/mesh";
  56191. /**
  56192. * Class containing static functions to help procedurally build meshes
  56193. */
  56194. export class HemisphereBuilder {
  56195. /**
  56196. * Creates a hemisphere mesh
  56197. * @param name defines the name of the mesh
  56198. * @param options defines the options used to create the mesh
  56199. * @param scene defines the hosting scene
  56200. * @returns the hemisphere mesh
  56201. */
  56202. static CreateHemisphere(name: string, options: {
  56203. segments?: number;
  56204. diameter?: number;
  56205. sideOrientation?: number;
  56206. }, scene: any): Mesh;
  56207. }
  56208. }
  56209. declare module "babylonjs/Lights/spotLight" {
  56210. import { Nullable } from "babylonjs/types";
  56211. import { Scene } from "babylonjs/scene";
  56212. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56213. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56214. import { Effect } from "babylonjs/Materials/effect";
  56215. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56216. import { Light } from "babylonjs/Lights/light";
  56217. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  56218. /**
  56219. * A spot light is defined by a position, a direction, an angle, and an exponent.
  56220. * These values define a cone of light starting from the position, emitting toward the direction.
  56221. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  56222. * and the exponent defines the speed of the decay of the light with distance (reach).
  56223. * Documentation: https://doc.babylonjs.com/babylon101/lights
  56224. */
  56225. export class SpotLight extends ShadowLight {
  56226. private _angle;
  56227. private _innerAngle;
  56228. private _cosHalfAngle;
  56229. private _lightAngleScale;
  56230. private _lightAngleOffset;
  56231. /**
  56232. * Gets the cone angle of the spot light in Radians.
  56233. */
  56234. get angle(): number;
  56235. /**
  56236. * Sets the cone angle of the spot light in Radians.
  56237. */
  56238. set angle(value: number);
  56239. /**
  56240. * Only used in gltf falloff mode, this defines the angle where
  56241. * the directional falloff will start before cutting at angle which could be seen
  56242. * as outer angle.
  56243. */
  56244. get innerAngle(): number;
  56245. /**
  56246. * Only used in gltf falloff mode, this defines the angle where
  56247. * the directional falloff will start before cutting at angle which could be seen
  56248. * as outer angle.
  56249. */
  56250. set innerAngle(value: number);
  56251. private _shadowAngleScale;
  56252. /**
  56253. * Allows scaling the angle of the light for shadow generation only.
  56254. */
  56255. get shadowAngleScale(): number;
  56256. /**
  56257. * Allows scaling the angle of the light for shadow generation only.
  56258. */
  56259. set shadowAngleScale(value: number);
  56260. /**
  56261. * The light decay speed with the distance from the emission spot.
  56262. */
  56263. exponent: number;
  56264. private _projectionTextureMatrix;
  56265. /**
  56266. * Allows reading the projecton texture
  56267. */
  56268. get projectionTextureMatrix(): Matrix;
  56269. protected _projectionTextureLightNear: number;
  56270. /**
  56271. * Gets the near clip of the Spotlight for texture projection.
  56272. */
  56273. get projectionTextureLightNear(): number;
  56274. /**
  56275. * Sets the near clip of the Spotlight for texture projection.
  56276. */
  56277. set projectionTextureLightNear(value: number);
  56278. protected _projectionTextureLightFar: number;
  56279. /**
  56280. * Gets the far clip of the Spotlight for texture projection.
  56281. */
  56282. get projectionTextureLightFar(): number;
  56283. /**
  56284. * Sets the far clip of the Spotlight for texture projection.
  56285. */
  56286. set projectionTextureLightFar(value: number);
  56287. protected _projectionTextureUpDirection: Vector3;
  56288. /**
  56289. * Gets the Up vector of the Spotlight for texture projection.
  56290. */
  56291. get projectionTextureUpDirection(): Vector3;
  56292. /**
  56293. * Sets the Up vector of the Spotlight for texture projection.
  56294. */
  56295. set projectionTextureUpDirection(value: Vector3);
  56296. private _projectionTexture;
  56297. /**
  56298. * Gets the projection texture of the light.
  56299. */
  56300. get projectionTexture(): Nullable<BaseTexture>;
  56301. /**
  56302. * Sets the projection texture of the light.
  56303. */
  56304. set projectionTexture(value: Nullable<BaseTexture>);
  56305. private _projectionTextureViewLightDirty;
  56306. private _projectionTextureProjectionLightDirty;
  56307. private _projectionTextureDirty;
  56308. private _projectionTextureViewTargetVector;
  56309. private _projectionTextureViewLightMatrix;
  56310. private _projectionTextureProjectionLightMatrix;
  56311. private _projectionTextureScalingMatrix;
  56312. /**
  56313. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  56314. * It can cast shadows.
  56315. * Documentation : https://doc.babylonjs.com/babylon101/lights
  56316. * @param name The light friendly name
  56317. * @param position The position of the spot light in the scene
  56318. * @param direction The direction of the light in the scene
  56319. * @param angle The cone angle of the light in Radians
  56320. * @param exponent The light decay speed with the distance from the emission spot
  56321. * @param scene The scene the lights belongs to
  56322. */
  56323. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  56324. /**
  56325. * Returns the string "SpotLight".
  56326. * @returns the class name
  56327. */
  56328. getClassName(): string;
  56329. /**
  56330. * Returns the integer 2.
  56331. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  56332. */
  56333. getTypeID(): number;
  56334. /**
  56335. * Overrides the direction setter to recompute the projection texture view light Matrix.
  56336. */
  56337. protected _setDirection(value: Vector3): void;
  56338. /**
  56339. * Overrides the position setter to recompute the projection texture view light Matrix.
  56340. */
  56341. protected _setPosition(value: Vector3): void;
  56342. /**
  56343. * 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.
  56344. * Returns the SpotLight.
  56345. */
  56346. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56347. protected _computeProjectionTextureViewLightMatrix(): void;
  56348. protected _computeProjectionTextureProjectionLightMatrix(): void;
  56349. /**
  56350. * Main function for light texture projection matrix computing.
  56351. */
  56352. protected _computeProjectionTextureMatrix(): void;
  56353. protected _buildUniformLayout(): void;
  56354. private _computeAngleValues;
  56355. /**
  56356. * Sets the passed Effect "effect" with the Light textures.
  56357. * @param effect The effect to update
  56358. * @param lightIndex The index of the light in the effect to update
  56359. * @returns The light
  56360. */
  56361. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  56362. /**
  56363. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  56364. * @param effect The effect to update
  56365. * @param lightIndex The index of the light in the effect to update
  56366. * @returns The spot light
  56367. */
  56368. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  56369. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  56370. /**
  56371. * Disposes the light and the associated resources.
  56372. */
  56373. dispose(): void;
  56374. /**
  56375. * Prepares the list of defines specific to the light type.
  56376. * @param defines the list of defines
  56377. * @param lightIndex defines the index of the light for the effect
  56378. */
  56379. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  56380. }
  56381. }
  56382. declare module "babylonjs/Gizmos/lightGizmo" {
  56383. import { Nullable } from "babylonjs/types";
  56384. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56385. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56386. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  56387. import { Light } from "babylonjs/Lights/light";
  56388. /**
  56389. * Gizmo that enables viewing a light
  56390. */
  56391. export class LightGizmo extends Gizmo {
  56392. private _lightMesh;
  56393. private _material;
  56394. private _cachedPosition;
  56395. private _cachedForward;
  56396. private _attachedMeshParent;
  56397. /**
  56398. * Creates a LightGizmo
  56399. * @param gizmoLayer The utility layer the gizmo will be added to
  56400. */
  56401. constructor(gizmoLayer?: UtilityLayerRenderer);
  56402. private _light;
  56403. /**
  56404. * The light that the gizmo is attached to
  56405. */
  56406. set light(light: Nullable<Light>);
  56407. get light(): Nullable<Light>;
  56408. /**
  56409. * Gets the material used to render the light gizmo
  56410. */
  56411. get material(): StandardMaterial;
  56412. /**
  56413. * @hidden
  56414. * Updates the gizmo to match the attached mesh's position/rotation
  56415. */
  56416. protected _update(): void;
  56417. private static _Scale;
  56418. /**
  56419. * Creates the lines for a light mesh
  56420. */
  56421. private static _CreateLightLines;
  56422. /**
  56423. * Disposes of the light gizmo
  56424. */
  56425. dispose(): void;
  56426. private static _CreateHemisphericLightMesh;
  56427. private static _CreatePointLightMesh;
  56428. private static _CreateSpotLightMesh;
  56429. private static _CreateDirectionalLightMesh;
  56430. }
  56431. }
  56432. declare module "babylonjs/Gizmos/cameraGizmo" {
  56433. import { Nullable } from "babylonjs/types";
  56434. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56435. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56436. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  56437. import { Camera } from "babylonjs/Cameras/camera";
  56438. /**
  56439. * Gizmo that enables viewing a camera
  56440. */
  56441. export class CameraGizmo extends Gizmo {
  56442. private _cameraMesh;
  56443. private _cameraLinesMesh;
  56444. private _material;
  56445. /**
  56446. * Creates a CameraGizmo
  56447. * @param gizmoLayer The utility layer the gizmo will be added to
  56448. */
  56449. constructor(gizmoLayer?: UtilityLayerRenderer);
  56450. private _camera;
  56451. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  56452. get displayFrustum(): boolean;
  56453. set displayFrustum(value: boolean);
  56454. /**
  56455. * The camera that the gizmo is attached to
  56456. */
  56457. set camera(camera: Nullable<Camera>);
  56458. get camera(): Nullable<Camera>;
  56459. /**
  56460. * Gets the material used to render the camera gizmo
  56461. */
  56462. get material(): StandardMaterial;
  56463. /**
  56464. * @hidden
  56465. * Updates the gizmo to match the attached mesh's position/rotation
  56466. */
  56467. protected _update(): void;
  56468. private static _Scale;
  56469. private _invProjection;
  56470. /**
  56471. * Disposes of the camera gizmo
  56472. */
  56473. dispose(): void;
  56474. private static _CreateCameraMesh;
  56475. private static _CreateCameraFrustum;
  56476. }
  56477. }
  56478. declare module "babylonjs/Gizmos/index" {
  56479. export * from "babylonjs/Gizmos/axisDragGizmo";
  56480. export * from "babylonjs/Gizmos/axisScaleGizmo";
  56481. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  56482. export * from "babylonjs/Gizmos/gizmo";
  56483. export * from "babylonjs/Gizmos/gizmoManager";
  56484. export * from "babylonjs/Gizmos/planeRotationGizmo";
  56485. export * from "babylonjs/Gizmos/positionGizmo";
  56486. export * from "babylonjs/Gizmos/rotationGizmo";
  56487. export * from "babylonjs/Gizmos/scaleGizmo";
  56488. export * from "babylonjs/Gizmos/lightGizmo";
  56489. export * from "babylonjs/Gizmos/cameraGizmo";
  56490. export * from "babylonjs/Gizmos/planeDragGizmo";
  56491. }
  56492. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  56493. /** @hidden */
  56494. export var backgroundFragmentDeclaration: {
  56495. name: string;
  56496. shader: string;
  56497. };
  56498. }
  56499. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  56500. /** @hidden */
  56501. export var backgroundUboDeclaration: {
  56502. name: string;
  56503. shader: string;
  56504. };
  56505. }
  56506. declare module "babylonjs/Shaders/background.fragment" {
  56507. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  56508. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  56509. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  56510. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56511. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56512. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56513. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56514. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  56515. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  56516. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56517. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  56518. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  56519. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  56520. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  56521. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  56522. /** @hidden */
  56523. export var backgroundPixelShader: {
  56524. name: string;
  56525. shader: string;
  56526. };
  56527. }
  56528. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  56529. /** @hidden */
  56530. export var backgroundVertexDeclaration: {
  56531. name: string;
  56532. shader: string;
  56533. };
  56534. }
  56535. declare module "babylonjs/Shaders/background.vertex" {
  56536. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  56537. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  56538. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56539. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56540. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56541. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  56542. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  56543. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56544. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56545. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56546. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56547. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  56548. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  56549. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  56550. /** @hidden */
  56551. export var backgroundVertexShader: {
  56552. name: string;
  56553. shader: string;
  56554. };
  56555. }
  56556. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  56557. import { Nullable, int, float } from "babylonjs/types";
  56558. import { Scene } from "babylonjs/scene";
  56559. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56560. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56561. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56562. import { Mesh } from "babylonjs/Meshes/mesh";
  56563. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  56564. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  56565. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  56566. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56567. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  56568. import { Color3 } from "babylonjs/Maths/math.color";
  56569. import "babylonjs/Shaders/background.fragment";
  56570. import "babylonjs/Shaders/background.vertex";
  56571. /**
  56572. * Background material used to create an efficient environement around your scene.
  56573. */
  56574. export class BackgroundMaterial extends PushMaterial {
  56575. /**
  56576. * Standard reflectance value at parallel view angle.
  56577. */
  56578. static StandardReflectance0: number;
  56579. /**
  56580. * Standard reflectance value at grazing angle.
  56581. */
  56582. static StandardReflectance90: number;
  56583. protected _primaryColor: Color3;
  56584. /**
  56585. * Key light Color (multiply against the environement texture)
  56586. */
  56587. primaryColor: Color3;
  56588. protected __perceptualColor: Nullable<Color3>;
  56589. /**
  56590. * Experimental Internal Use Only.
  56591. *
  56592. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  56593. * This acts as a helper to set the primary color to a more "human friendly" value.
  56594. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  56595. * output color as close as possible from the chosen value.
  56596. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  56597. * part of lighting setup.)
  56598. */
  56599. get _perceptualColor(): Nullable<Color3>;
  56600. set _perceptualColor(value: Nullable<Color3>);
  56601. protected _primaryColorShadowLevel: float;
  56602. /**
  56603. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  56604. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  56605. */
  56606. get primaryColorShadowLevel(): float;
  56607. set primaryColorShadowLevel(value: float);
  56608. protected _primaryColorHighlightLevel: float;
  56609. /**
  56610. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  56611. * The primary color is used at the level chosen to define what the white area would look.
  56612. */
  56613. get primaryColorHighlightLevel(): float;
  56614. set primaryColorHighlightLevel(value: float);
  56615. protected _reflectionTexture: Nullable<BaseTexture>;
  56616. /**
  56617. * Reflection Texture used in the material.
  56618. * Should be author in a specific way for the best result (refer to the documentation).
  56619. */
  56620. reflectionTexture: Nullable<BaseTexture>;
  56621. protected _reflectionBlur: float;
  56622. /**
  56623. * Reflection Texture level of blur.
  56624. *
  56625. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  56626. * texture twice.
  56627. */
  56628. reflectionBlur: float;
  56629. protected _diffuseTexture: Nullable<BaseTexture>;
  56630. /**
  56631. * Diffuse Texture used in the material.
  56632. * Should be author in a specific way for the best result (refer to the documentation).
  56633. */
  56634. diffuseTexture: Nullable<BaseTexture>;
  56635. protected _shadowLights: Nullable<IShadowLight[]>;
  56636. /**
  56637. * Specify the list of lights casting shadow on the material.
  56638. * All scene shadow lights will be included if null.
  56639. */
  56640. shadowLights: Nullable<IShadowLight[]>;
  56641. protected _shadowLevel: float;
  56642. /**
  56643. * Helps adjusting the shadow to a softer level if required.
  56644. * 0 means black shadows and 1 means no shadows.
  56645. */
  56646. shadowLevel: float;
  56647. protected _sceneCenter: Vector3;
  56648. /**
  56649. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  56650. * It is usually zero but might be interesting to modify according to your setup.
  56651. */
  56652. sceneCenter: Vector3;
  56653. protected _opacityFresnel: boolean;
  56654. /**
  56655. * This helps specifying that the material is falling off to the sky box at grazing angle.
  56656. * This helps ensuring a nice transition when the camera goes under the ground.
  56657. */
  56658. opacityFresnel: boolean;
  56659. protected _reflectionFresnel: boolean;
  56660. /**
  56661. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  56662. * This helps adding a mirror texture on the ground.
  56663. */
  56664. reflectionFresnel: boolean;
  56665. protected _reflectionFalloffDistance: number;
  56666. /**
  56667. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  56668. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  56669. */
  56670. reflectionFalloffDistance: number;
  56671. protected _reflectionAmount: number;
  56672. /**
  56673. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  56674. */
  56675. reflectionAmount: number;
  56676. protected _reflectionReflectance0: number;
  56677. /**
  56678. * This specifies the weight of the reflection at grazing angle.
  56679. */
  56680. reflectionReflectance0: number;
  56681. protected _reflectionReflectance90: number;
  56682. /**
  56683. * This specifies the weight of the reflection at a perpendicular point of view.
  56684. */
  56685. reflectionReflectance90: number;
  56686. /**
  56687. * Sets the reflection reflectance fresnel values according to the default standard
  56688. * empirically know to work well :-)
  56689. */
  56690. set reflectionStandardFresnelWeight(value: number);
  56691. protected _useRGBColor: boolean;
  56692. /**
  56693. * Helps to directly use the maps channels instead of their level.
  56694. */
  56695. useRGBColor: boolean;
  56696. protected _enableNoise: boolean;
  56697. /**
  56698. * This helps reducing the banding effect that could occur on the background.
  56699. */
  56700. enableNoise: boolean;
  56701. /**
  56702. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  56703. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  56704. * Recommended to be keep at 1.0 except for special cases.
  56705. */
  56706. get fovMultiplier(): number;
  56707. set fovMultiplier(value: number);
  56708. private _fovMultiplier;
  56709. /**
  56710. * Enable the FOV adjustment feature controlled by fovMultiplier.
  56711. */
  56712. useEquirectangularFOV: boolean;
  56713. private _maxSimultaneousLights;
  56714. /**
  56715. * Number of Simultaneous lights allowed on the material.
  56716. */
  56717. maxSimultaneousLights: int;
  56718. private _shadowOnly;
  56719. /**
  56720. * Make the material only render shadows
  56721. */
  56722. shadowOnly: boolean;
  56723. /**
  56724. * Default configuration related to image processing available in the Background Material.
  56725. */
  56726. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  56727. /**
  56728. * Keep track of the image processing observer to allow dispose and replace.
  56729. */
  56730. private _imageProcessingObserver;
  56731. /**
  56732. * Attaches a new image processing configuration to the PBR Material.
  56733. * @param configuration (if null the scene configuration will be use)
  56734. */
  56735. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  56736. /**
  56737. * Gets the image processing configuration used either in this material.
  56738. */
  56739. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  56740. /**
  56741. * Sets the Default image processing configuration used either in the this material.
  56742. *
  56743. * If sets to null, the scene one is in use.
  56744. */
  56745. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  56746. /**
  56747. * Gets wether the color curves effect is enabled.
  56748. */
  56749. get cameraColorCurvesEnabled(): boolean;
  56750. /**
  56751. * Sets wether the color curves effect is enabled.
  56752. */
  56753. set cameraColorCurvesEnabled(value: boolean);
  56754. /**
  56755. * Gets wether the color grading effect is enabled.
  56756. */
  56757. get cameraColorGradingEnabled(): boolean;
  56758. /**
  56759. * Gets wether the color grading effect is enabled.
  56760. */
  56761. set cameraColorGradingEnabled(value: boolean);
  56762. /**
  56763. * Gets wether tonemapping is enabled or not.
  56764. */
  56765. get cameraToneMappingEnabled(): boolean;
  56766. /**
  56767. * Sets wether tonemapping is enabled or not
  56768. */
  56769. set cameraToneMappingEnabled(value: boolean);
  56770. /**
  56771. * The camera exposure used on this material.
  56772. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  56773. * This corresponds to a photographic exposure.
  56774. */
  56775. get cameraExposure(): float;
  56776. /**
  56777. * The camera exposure used on this material.
  56778. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  56779. * This corresponds to a photographic exposure.
  56780. */
  56781. set cameraExposure(value: float);
  56782. /**
  56783. * Gets The camera contrast used on this material.
  56784. */
  56785. get cameraContrast(): float;
  56786. /**
  56787. * Sets The camera contrast used on this material.
  56788. */
  56789. set cameraContrast(value: float);
  56790. /**
  56791. * Gets the Color Grading 2D Lookup Texture.
  56792. */
  56793. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  56794. /**
  56795. * Sets the Color Grading 2D Lookup Texture.
  56796. */
  56797. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  56798. /**
  56799. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  56800. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  56801. * 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;
  56802. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  56803. */
  56804. get cameraColorCurves(): Nullable<ColorCurves>;
  56805. /**
  56806. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  56807. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  56808. * 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;
  56809. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  56810. */
  56811. set cameraColorCurves(value: Nullable<ColorCurves>);
  56812. /**
  56813. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  56814. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  56815. */
  56816. switchToBGR: boolean;
  56817. private _renderTargets;
  56818. private _reflectionControls;
  56819. private _white;
  56820. private _primaryShadowColor;
  56821. private _primaryHighlightColor;
  56822. /**
  56823. * Instantiates a Background Material in the given scene
  56824. * @param name The friendly name of the material
  56825. * @param scene The scene to add the material to
  56826. */
  56827. constructor(name: string, scene: Scene);
  56828. /**
  56829. * Gets a boolean indicating that current material needs to register RTT
  56830. */
  56831. get hasRenderTargetTextures(): boolean;
  56832. /**
  56833. * The entire material has been created in order to prevent overdraw.
  56834. * @returns false
  56835. */
  56836. needAlphaTesting(): boolean;
  56837. /**
  56838. * The entire material has been created in order to prevent overdraw.
  56839. * @returns true if blending is enable
  56840. */
  56841. needAlphaBlending(): boolean;
  56842. /**
  56843. * Checks wether the material is ready to be rendered for a given mesh.
  56844. * @param mesh The mesh to render
  56845. * @param subMesh The submesh to check against
  56846. * @param useInstances Specify wether or not the material is used with instances
  56847. * @returns true if all the dependencies are ready (Textures, Effects...)
  56848. */
  56849. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  56850. /**
  56851. * Compute the primary color according to the chosen perceptual color.
  56852. */
  56853. private _computePrimaryColorFromPerceptualColor;
  56854. /**
  56855. * Compute the highlights and shadow colors according to their chosen levels.
  56856. */
  56857. private _computePrimaryColors;
  56858. /**
  56859. * Build the uniform buffer used in the material.
  56860. */
  56861. buildUniformLayout(): void;
  56862. /**
  56863. * Unbind the material.
  56864. */
  56865. unbind(): void;
  56866. /**
  56867. * Bind only the world matrix to the material.
  56868. * @param world The world matrix to bind.
  56869. */
  56870. bindOnlyWorldMatrix(world: Matrix): void;
  56871. /**
  56872. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  56873. * @param world The world matrix to bind.
  56874. * @param subMesh The submesh to bind for.
  56875. */
  56876. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  56877. /**
  56878. * Checks to see if a texture is used in the material.
  56879. * @param texture - Base texture to use.
  56880. * @returns - Boolean specifying if a texture is used in the material.
  56881. */
  56882. hasTexture(texture: BaseTexture): boolean;
  56883. /**
  56884. * Dispose the material.
  56885. * @param forceDisposeEffect Force disposal of the associated effect.
  56886. * @param forceDisposeTextures Force disposal of the associated textures.
  56887. */
  56888. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  56889. /**
  56890. * Clones the material.
  56891. * @param name The cloned name.
  56892. * @returns The cloned material.
  56893. */
  56894. clone(name: string): BackgroundMaterial;
  56895. /**
  56896. * Serializes the current material to its JSON representation.
  56897. * @returns The JSON representation.
  56898. */
  56899. serialize(): any;
  56900. /**
  56901. * Gets the class name of the material
  56902. * @returns "BackgroundMaterial"
  56903. */
  56904. getClassName(): string;
  56905. /**
  56906. * Parse a JSON input to create back a background material.
  56907. * @param source The JSON data to parse
  56908. * @param scene The scene to create the parsed material in
  56909. * @param rootUrl The root url of the assets the material depends upon
  56910. * @returns the instantiated BackgroundMaterial.
  56911. */
  56912. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  56913. }
  56914. }
  56915. declare module "babylonjs/Helpers/environmentHelper" {
  56916. import { Observable } from "babylonjs/Misc/observable";
  56917. import { Nullable } from "babylonjs/types";
  56918. import { Scene } from "babylonjs/scene";
  56919. import { Vector3 } from "babylonjs/Maths/math.vector";
  56920. import { Color3 } from "babylonjs/Maths/math.color";
  56921. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56922. import { Mesh } from "babylonjs/Meshes/mesh";
  56923. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56924. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  56925. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  56926. import "babylonjs/Meshes/Builders/planeBuilder";
  56927. import "babylonjs/Meshes/Builders/boxBuilder";
  56928. /**
  56929. * Represents the different options available during the creation of
  56930. * a Environment helper.
  56931. *
  56932. * This can control the default ground, skybox and image processing setup of your scene.
  56933. */
  56934. export interface IEnvironmentHelperOptions {
  56935. /**
  56936. * Specifies whether or not to create a ground.
  56937. * True by default.
  56938. */
  56939. createGround: boolean;
  56940. /**
  56941. * Specifies the ground size.
  56942. * 15 by default.
  56943. */
  56944. groundSize: number;
  56945. /**
  56946. * The texture used on the ground for the main color.
  56947. * Comes from the BabylonJS CDN by default.
  56948. *
  56949. * Remarks: Can be either a texture or a url.
  56950. */
  56951. groundTexture: string | BaseTexture;
  56952. /**
  56953. * The color mixed in the ground texture by default.
  56954. * BabylonJS clearColor by default.
  56955. */
  56956. groundColor: Color3;
  56957. /**
  56958. * Specifies the ground opacity.
  56959. * 1 by default.
  56960. */
  56961. groundOpacity: number;
  56962. /**
  56963. * Enables the ground to receive shadows.
  56964. * True by default.
  56965. */
  56966. enableGroundShadow: boolean;
  56967. /**
  56968. * Helps preventing the shadow to be fully black on the ground.
  56969. * 0.5 by default.
  56970. */
  56971. groundShadowLevel: number;
  56972. /**
  56973. * Creates a mirror texture attach to the ground.
  56974. * false by default.
  56975. */
  56976. enableGroundMirror: boolean;
  56977. /**
  56978. * Specifies the ground mirror size ratio.
  56979. * 0.3 by default as the default kernel is 64.
  56980. */
  56981. groundMirrorSizeRatio: number;
  56982. /**
  56983. * Specifies the ground mirror blur kernel size.
  56984. * 64 by default.
  56985. */
  56986. groundMirrorBlurKernel: number;
  56987. /**
  56988. * Specifies the ground mirror visibility amount.
  56989. * 1 by default
  56990. */
  56991. groundMirrorAmount: number;
  56992. /**
  56993. * Specifies the ground mirror reflectance weight.
  56994. * This uses the standard weight of the background material to setup the fresnel effect
  56995. * of the mirror.
  56996. * 1 by default.
  56997. */
  56998. groundMirrorFresnelWeight: number;
  56999. /**
  57000. * Specifies the ground mirror Falloff distance.
  57001. * This can helps reducing the size of the reflection.
  57002. * 0 by Default.
  57003. */
  57004. groundMirrorFallOffDistance: number;
  57005. /**
  57006. * Specifies the ground mirror texture type.
  57007. * Unsigned Int by Default.
  57008. */
  57009. groundMirrorTextureType: number;
  57010. /**
  57011. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  57012. * the shown objects.
  57013. */
  57014. groundYBias: number;
  57015. /**
  57016. * Specifies whether or not to create a skybox.
  57017. * True by default.
  57018. */
  57019. createSkybox: boolean;
  57020. /**
  57021. * Specifies the skybox size.
  57022. * 20 by default.
  57023. */
  57024. skyboxSize: number;
  57025. /**
  57026. * The texture used on the skybox for the main color.
  57027. * Comes from the BabylonJS CDN by default.
  57028. *
  57029. * Remarks: Can be either a texture or a url.
  57030. */
  57031. skyboxTexture: string | BaseTexture;
  57032. /**
  57033. * The color mixed in the skybox texture by default.
  57034. * BabylonJS clearColor by default.
  57035. */
  57036. skyboxColor: Color3;
  57037. /**
  57038. * The background rotation around the Y axis of the scene.
  57039. * This helps aligning the key lights of your scene with the background.
  57040. * 0 by default.
  57041. */
  57042. backgroundYRotation: number;
  57043. /**
  57044. * Compute automatically the size of the elements to best fit with the scene.
  57045. */
  57046. sizeAuto: boolean;
  57047. /**
  57048. * Default position of the rootMesh if autoSize is not true.
  57049. */
  57050. rootPosition: Vector3;
  57051. /**
  57052. * Sets up the image processing in the scene.
  57053. * true by default.
  57054. */
  57055. setupImageProcessing: boolean;
  57056. /**
  57057. * The texture used as your environment texture in the scene.
  57058. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  57059. *
  57060. * Remarks: Can be either a texture or a url.
  57061. */
  57062. environmentTexture: string | BaseTexture;
  57063. /**
  57064. * The value of the exposure to apply to the scene.
  57065. * 0.6 by default if setupImageProcessing is true.
  57066. */
  57067. cameraExposure: number;
  57068. /**
  57069. * The value of the contrast to apply to the scene.
  57070. * 1.6 by default if setupImageProcessing is true.
  57071. */
  57072. cameraContrast: number;
  57073. /**
  57074. * Specifies whether or not tonemapping should be enabled in the scene.
  57075. * true by default if setupImageProcessing is true.
  57076. */
  57077. toneMappingEnabled: boolean;
  57078. }
  57079. /**
  57080. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  57081. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  57082. * It also helps with the default setup of your imageProcessing configuration.
  57083. */
  57084. export class EnvironmentHelper {
  57085. /**
  57086. * Default ground texture URL.
  57087. */
  57088. private static _groundTextureCDNUrl;
  57089. /**
  57090. * Default skybox texture URL.
  57091. */
  57092. private static _skyboxTextureCDNUrl;
  57093. /**
  57094. * Default environment texture URL.
  57095. */
  57096. private static _environmentTextureCDNUrl;
  57097. /**
  57098. * Creates the default options for the helper.
  57099. */
  57100. private static _getDefaultOptions;
  57101. private _rootMesh;
  57102. /**
  57103. * Gets the root mesh created by the helper.
  57104. */
  57105. get rootMesh(): Mesh;
  57106. private _skybox;
  57107. /**
  57108. * Gets the skybox created by the helper.
  57109. */
  57110. get skybox(): Nullable<Mesh>;
  57111. private _skyboxTexture;
  57112. /**
  57113. * Gets the skybox texture created by the helper.
  57114. */
  57115. get skyboxTexture(): Nullable<BaseTexture>;
  57116. private _skyboxMaterial;
  57117. /**
  57118. * Gets the skybox material created by the helper.
  57119. */
  57120. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  57121. private _ground;
  57122. /**
  57123. * Gets the ground mesh created by the helper.
  57124. */
  57125. get ground(): Nullable<Mesh>;
  57126. private _groundTexture;
  57127. /**
  57128. * Gets the ground texture created by the helper.
  57129. */
  57130. get groundTexture(): Nullable<BaseTexture>;
  57131. private _groundMirror;
  57132. /**
  57133. * Gets the ground mirror created by the helper.
  57134. */
  57135. get groundMirror(): Nullable<MirrorTexture>;
  57136. /**
  57137. * Gets the ground mirror render list to helps pushing the meshes
  57138. * you wish in the ground reflection.
  57139. */
  57140. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  57141. private _groundMaterial;
  57142. /**
  57143. * Gets the ground material created by the helper.
  57144. */
  57145. get groundMaterial(): Nullable<BackgroundMaterial>;
  57146. /**
  57147. * Stores the creation options.
  57148. */
  57149. private readonly _scene;
  57150. private _options;
  57151. /**
  57152. * This observable will be notified with any error during the creation of the environment,
  57153. * mainly texture creation errors.
  57154. */
  57155. onErrorObservable: Observable<{
  57156. message?: string;
  57157. exception?: any;
  57158. }>;
  57159. /**
  57160. * constructor
  57161. * @param options Defines the options we want to customize the helper
  57162. * @param scene The scene to add the material to
  57163. */
  57164. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  57165. /**
  57166. * Updates the background according to the new options
  57167. * @param options
  57168. */
  57169. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  57170. /**
  57171. * Sets the primary color of all the available elements.
  57172. * @param color the main color to affect to the ground and the background
  57173. */
  57174. setMainColor(color: Color3): void;
  57175. /**
  57176. * Setup the image processing according to the specified options.
  57177. */
  57178. private _setupImageProcessing;
  57179. /**
  57180. * Setup the environment texture according to the specified options.
  57181. */
  57182. private _setupEnvironmentTexture;
  57183. /**
  57184. * Setup the background according to the specified options.
  57185. */
  57186. private _setupBackground;
  57187. /**
  57188. * Get the scene sizes according to the setup.
  57189. */
  57190. private _getSceneSize;
  57191. /**
  57192. * Setup the ground according to the specified options.
  57193. */
  57194. private _setupGround;
  57195. /**
  57196. * Setup the ground material according to the specified options.
  57197. */
  57198. private _setupGroundMaterial;
  57199. /**
  57200. * Setup the ground diffuse texture according to the specified options.
  57201. */
  57202. private _setupGroundDiffuseTexture;
  57203. /**
  57204. * Setup the ground mirror texture according to the specified options.
  57205. */
  57206. private _setupGroundMirrorTexture;
  57207. /**
  57208. * Setup the ground to receive the mirror texture.
  57209. */
  57210. private _setupMirrorInGroundMaterial;
  57211. /**
  57212. * Setup the skybox according to the specified options.
  57213. */
  57214. private _setupSkybox;
  57215. /**
  57216. * Setup the skybox material according to the specified options.
  57217. */
  57218. private _setupSkyboxMaterial;
  57219. /**
  57220. * Setup the skybox reflection texture according to the specified options.
  57221. */
  57222. private _setupSkyboxReflectionTexture;
  57223. private _errorHandler;
  57224. /**
  57225. * Dispose all the elements created by the Helper.
  57226. */
  57227. dispose(): void;
  57228. }
  57229. }
  57230. declare module "babylonjs/Helpers/photoDome" {
  57231. import { Observable } from "babylonjs/Misc/observable";
  57232. import { Nullable } from "babylonjs/types";
  57233. import { Scene } from "babylonjs/scene";
  57234. import { TransformNode } from "babylonjs/Meshes/transformNode";
  57235. import { Mesh } from "babylonjs/Meshes/mesh";
  57236. import { Texture } from "babylonjs/Materials/Textures/texture";
  57237. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  57238. import "babylonjs/Meshes/Builders/sphereBuilder";
  57239. /**
  57240. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  57241. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  57242. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  57243. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  57244. */
  57245. export class PhotoDome extends TransformNode {
  57246. /**
  57247. * Define the image as a Monoscopic panoramic 360 image.
  57248. */
  57249. static readonly MODE_MONOSCOPIC: number;
  57250. /**
  57251. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  57252. */
  57253. static readonly MODE_TOPBOTTOM: number;
  57254. /**
  57255. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  57256. */
  57257. static readonly MODE_SIDEBYSIDE: number;
  57258. private _useDirectMapping;
  57259. /**
  57260. * The texture being displayed on the sphere
  57261. */
  57262. protected _photoTexture: Texture;
  57263. /**
  57264. * Gets or sets the texture being displayed on the sphere
  57265. */
  57266. get photoTexture(): Texture;
  57267. set photoTexture(value: Texture);
  57268. /**
  57269. * Observable raised when an error occured while loading the 360 image
  57270. */
  57271. onLoadErrorObservable: Observable<string>;
  57272. /**
  57273. * The skybox material
  57274. */
  57275. protected _material: BackgroundMaterial;
  57276. /**
  57277. * The surface used for the skybox
  57278. */
  57279. protected _mesh: Mesh;
  57280. /**
  57281. * Gets the mesh used for the skybox.
  57282. */
  57283. get mesh(): Mesh;
  57284. /**
  57285. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  57286. * Also see the options.resolution property.
  57287. */
  57288. get fovMultiplier(): number;
  57289. set fovMultiplier(value: number);
  57290. private _imageMode;
  57291. /**
  57292. * Gets or set the current video mode for the video. It can be:
  57293. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  57294. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  57295. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  57296. */
  57297. get imageMode(): number;
  57298. set imageMode(value: number);
  57299. /**
  57300. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  57301. * @param name Element's name, child elements will append suffixes for their own names.
  57302. * @param urlsOfPhoto defines the url of the photo to display
  57303. * @param options defines an object containing optional or exposed sub element properties
  57304. * @param onError defines a callback called when an error occured while loading the texture
  57305. */
  57306. constructor(name: string, urlOfPhoto: string, options: {
  57307. resolution?: number;
  57308. size?: number;
  57309. useDirectMapping?: boolean;
  57310. faceForward?: boolean;
  57311. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  57312. private _onBeforeCameraRenderObserver;
  57313. private _changeImageMode;
  57314. /**
  57315. * Releases resources associated with this node.
  57316. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  57317. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  57318. */
  57319. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  57320. }
  57321. }
  57322. declare module "babylonjs/Misc/rgbdTextureTools" {
  57323. import "babylonjs/Shaders/rgbdDecode.fragment";
  57324. import "babylonjs/Engines/Extensions/engine.renderTarget";
  57325. import { Texture } from "babylonjs/Materials/Textures/texture";
  57326. /**
  57327. * Class used to host RGBD texture specific utilities
  57328. */
  57329. export class RGBDTextureTools {
  57330. /**
  57331. * Expand the RGBD Texture from RGBD to Half Float if possible.
  57332. * @param texture the texture to expand.
  57333. */
  57334. static ExpandRGBDTexture(texture: Texture): void;
  57335. }
  57336. }
  57337. declare module "babylonjs/Misc/brdfTextureTools" {
  57338. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57339. import { Scene } from "babylonjs/scene";
  57340. /**
  57341. * Class used to host texture specific utilities
  57342. */
  57343. export class BRDFTextureTools {
  57344. /**
  57345. * Prevents texture cache collision
  57346. */
  57347. private static _instanceNumber;
  57348. /**
  57349. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  57350. * @param scene defines the hosting scene
  57351. * @returns the environment BRDF texture
  57352. */
  57353. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  57354. private static _environmentBRDFBase64Texture;
  57355. }
  57356. }
  57357. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  57358. import { Nullable } from "babylonjs/types";
  57359. import { Color3 } from "babylonjs/Maths/math.color";
  57360. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57361. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  57362. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57363. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57364. import { Engine } from "babylonjs/Engines/engine";
  57365. import { Scene } from "babylonjs/scene";
  57366. /**
  57367. * @hidden
  57368. */
  57369. export interface IMaterialClearCoatDefines {
  57370. CLEARCOAT: boolean;
  57371. CLEARCOAT_DEFAULTIOR: boolean;
  57372. CLEARCOAT_TEXTURE: boolean;
  57373. CLEARCOAT_TEXTUREDIRECTUV: number;
  57374. CLEARCOAT_BUMP: boolean;
  57375. CLEARCOAT_BUMPDIRECTUV: number;
  57376. CLEARCOAT_TINT: boolean;
  57377. CLEARCOAT_TINT_TEXTURE: boolean;
  57378. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  57379. /** @hidden */
  57380. _areTexturesDirty: boolean;
  57381. }
  57382. /**
  57383. * Define the code related to the clear coat parameters of the pbr material.
  57384. */
  57385. export class PBRClearCoatConfiguration {
  57386. /**
  57387. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  57388. * The default fits with a polyurethane material.
  57389. */
  57390. private static readonly _DefaultIndexOfRefraction;
  57391. private _isEnabled;
  57392. /**
  57393. * Defines if the clear coat is enabled in the material.
  57394. */
  57395. isEnabled: boolean;
  57396. /**
  57397. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  57398. */
  57399. intensity: number;
  57400. /**
  57401. * Defines the clear coat layer roughness.
  57402. */
  57403. roughness: number;
  57404. private _indexOfRefraction;
  57405. /**
  57406. * Defines the index of refraction of the clear coat.
  57407. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  57408. * The default fits with a polyurethane material.
  57409. * Changing the default value is more performance intensive.
  57410. */
  57411. indexOfRefraction: number;
  57412. private _texture;
  57413. /**
  57414. * Stores the clear coat values in a texture.
  57415. */
  57416. texture: Nullable<BaseTexture>;
  57417. private _bumpTexture;
  57418. /**
  57419. * Define the clear coat specific bump texture.
  57420. */
  57421. bumpTexture: Nullable<BaseTexture>;
  57422. private _isTintEnabled;
  57423. /**
  57424. * Defines if the clear coat tint is enabled in the material.
  57425. */
  57426. isTintEnabled: boolean;
  57427. /**
  57428. * Defines the clear coat tint of the material.
  57429. * This is only use if tint is enabled
  57430. */
  57431. tintColor: Color3;
  57432. /**
  57433. * Defines the distance at which the tint color should be found in the
  57434. * clear coat media.
  57435. * This is only use if tint is enabled
  57436. */
  57437. tintColorAtDistance: number;
  57438. /**
  57439. * Defines the clear coat layer thickness.
  57440. * This is only use if tint is enabled
  57441. */
  57442. tintThickness: number;
  57443. private _tintTexture;
  57444. /**
  57445. * Stores the clear tint values in a texture.
  57446. * rgb is tint
  57447. * a is a thickness factor
  57448. */
  57449. tintTexture: Nullable<BaseTexture>;
  57450. /** @hidden */
  57451. private _internalMarkAllSubMeshesAsTexturesDirty;
  57452. /** @hidden */
  57453. _markAllSubMeshesAsTexturesDirty(): void;
  57454. /**
  57455. * Instantiate a new istance of clear coat configuration.
  57456. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  57457. */
  57458. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  57459. /**
  57460. * Gets wehter the submesh is ready to be used or not.
  57461. * @param defines the list of "defines" to update.
  57462. * @param scene defines the scene the material belongs to.
  57463. * @param engine defines the engine the material belongs to.
  57464. * @param disableBumpMap defines wether the material disables bump or not.
  57465. * @returns - boolean indicating that the submesh is ready or not.
  57466. */
  57467. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  57468. /**
  57469. * Checks to see if a texture is used in the material.
  57470. * @param defines the list of "defines" to update.
  57471. * @param scene defines the scene to the material belongs to.
  57472. */
  57473. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  57474. /**
  57475. * Binds the material data.
  57476. * @param uniformBuffer defines the Uniform buffer to fill in.
  57477. * @param scene defines the scene the material belongs to.
  57478. * @param engine defines the engine the material belongs to.
  57479. * @param disableBumpMap defines wether the material disables bump or not.
  57480. * @param isFrozen defines wether the material is frozen or not.
  57481. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  57482. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  57483. */
  57484. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  57485. /**
  57486. * Checks to see if a texture is used in the material.
  57487. * @param texture - Base texture to use.
  57488. * @returns - Boolean specifying if a texture is used in the material.
  57489. */
  57490. hasTexture(texture: BaseTexture): boolean;
  57491. /**
  57492. * Returns an array of the actively used textures.
  57493. * @param activeTextures Array of BaseTextures
  57494. */
  57495. getActiveTextures(activeTextures: BaseTexture[]): void;
  57496. /**
  57497. * Returns the animatable textures.
  57498. * @param animatables Array of animatable textures.
  57499. */
  57500. getAnimatables(animatables: IAnimatable[]): void;
  57501. /**
  57502. * Disposes the resources of the material.
  57503. * @param forceDisposeTextures - Forces the disposal of all textures.
  57504. */
  57505. dispose(forceDisposeTextures?: boolean): void;
  57506. /**
  57507. * Get the current class name of the texture useful for serialization or dynamic coding.
  57508. * @returns "PBRClearCoatConfiguration"
  57509. */
  57510. getClassName(): string;
  57511. /**
  57512. * Add fallbacks to the effect fallbacks list.
  57513. * @param defines defines the Base texture to use.
  57514. * @param fallbacks defines the current fallback list.
  57515. * @param currentRank defines the current fallback rank.
  57516. * @returns the new fallback rank.
  57517. */
  57518. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  57519. /**
  57520. * Add the required uniforms to the current list.
  57521. * @param uniforms defines the current uniform list.
  57522. */
  57523. static AddUniforms(uniforms: string[]): void;
  57524. /**
  57525. * Add the required samplers to the current list.
  57526. * @param samplers defines the current sampler list.
  57527. */
  57528. static AddSamplers(samplers: string[]): void;
  57529. /**
  57530. * Add the required uniforms to the current buffer.
  57531. * @param uniformBuffer defines the current uniform buffer.
  57532. */
  57533. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  57534. /**
  57535. * Makes a duplicate of the current configuration into another one.
  57536. * @param clearCoatConfiguration define the config where to copy the info
  57537. */
  57538. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  57539. /**
  57540. * Serializes this clear coat configuration.
  57541. * @returns - An object with the serialized config.
  57542. */
  57543. serialize(): any;
  57544. /**
  57545. * Parses a anisotropy Configuration from a serialized object.
  57546. * @param source - Serialized object.
  57547. * @param scene Defines the scene we are parsing for
  57548. * @param rootUrl Defines the rootUrl to load from
  57549. */
  57550. parse(source: any, scene: Scene, rootUrl: string): void;
  57551. }
  57552. }
  57553. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  57554. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  57555. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57556. import { Vector2 } from "babylonjs/Maths/math.vector";
  57557. import { Scene } from "babylonjs/scene";
  57558. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57559. import { Nullable } from "babylonjs/types";
  57560. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57561. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57562. /**
  57563. * @hidden
  57564. */
  57565. export interface IMaterialAnisotropicDefines {
  57566. ANISOTROPIC: boolean;
  57567. ANISOTROPIC_TEXTURE: boolean;
  57568. ANISOTROPIC_TEXTUREDIRECTUV: number;
  57569. MAINUV1: boolean;
  57570. _areTexturesDirty: boolean;
  57571. _needUVs: boolean;
  57572. }
  57573. /**
  57574. * Define the code related to the anisotropic parameters of the pbr material.
  57575. */
  57576. export class PBRAnisotropicConfiguration {
  57577. private _isEnabled;
  57578. /**
  57579. * Defines if the anisotropy is enabled in the material.
  57580. */
  57581. isEnabled: boolean;
  57582. /**
  57583. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  57584. */
  57585. intensity: number;
  57586. /**
  57587. * Defines if the effect is along the tangents, bitangents or in between.
  57588. * By default, the effect is "strectching" the highlights along the tangents.
  57589. */
  57590. direction: Vector2;
  57591. private _texture;
  57592. /**
  57593. * Stores the anisotropy values in a texture.
  57594. * rg is direction (like normal from -1 to 1)
  57595. * b is a intensity
  57596. */
  57597. texture: Nullable<BaseTexture>;
  57598. /** @hidden */
  57599. private _internalMarkAllSubMeshesAsTexturesDirty;
  57600. /** @hidden */
  57601. _markAllSubMeshesAsTexturesDirty(): void;
  57602. /**
  57603. * Instantiate a new istance of anisotropy configuration.
  57604. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  57605. */
  57606. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  57607. /**
  57608. * Specifies that the submesh is ready to be used.
  57609. * @param defines the list of "defines" to update.
  57610. * @param scene defines the scene the material belongs to.
  57611. * @returns - boolean indicating that the submesh is ready or not.
  57612. */
  57613. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  57614. /**
  57615. * Checks to see if a texture is used in the material.
  57616. * @param defines the list of "defines" to update.
  57617. * @param mesh the mesh we are preparing the defines for.
  57618. * @param scene defines the scene the material belongs to.
  57619. */
  57620. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  57621. /**
  57622. * Binds the material data.
  57623. * @param uniformBuffer defines the Uniform buffer to fill in.
  57624. * @param scene defines the scene the material belongs to.
  57625. * @param isFrozen defines wether the material is frozen or not.
  57626. */
  57627. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  57628. /**
  57629. * Checks to see if a texture is used in the material.
  57630. * @param texture - Base texture to use.
  57631. * @returns - Boolean specifying if a texture is used in the material.
  57632. */
  57633. hasTexture(texture: BaseTexture): boolean;
  57634. /**
  57635. * Returns an array of the actively used textures.
  57636. * @param activeTextures Array of BaseTextures
  57637. */
  57638. getActiveTextures(activeTextures: BaseTexture[]): void;
  57639. /**
  57640. * Returns the animatable textures.
  57641. * @param animatables Array of animatable textures.
  57642. */
  57643. getAnimatables(animatables: IAnimatable[]): void;
  57644. /**
  57645. * Disposes the resources of the material.
  57646. * @param forceDisposeTextures - Forces the disposal of all textures.
  57647. */
  57648. dispose(forceDisposeTextures?: boolean): void;
  57649. /**
  57650. * Get the current class name of the texture useful for serialization or dynamic coding.
  57651. * @returns "PBRAnisotropicConfiguration"
  57652. */
  57653. getClassName(): string;
  57654. /**
  57655. * Add fallbacks to the effect fallbacks list.
  57656. * @param defines defines the Base texture to use.
  57657. * @param fallbacks defines the current fallback list.
  57658. * @param currentRank defines the current fallback rank.
  57659. * @returns the new fallback rank.
  57660. */
  57661. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  57662. /**
  57663. * Add the required uniforms to the current list.
  57664. * @param uniforms defines the current uniform list.
  57665. */
  57666. static AddUniforms(uniforms: string[]): void;
  57667. /**
  57668. * Add the required uniforms to the current buffer.
  57669. * @param uniformBuffer defines the current uniform buffer.
  57670. */
  57671. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  57672. /**
  57673. * Add the required samplers to the current list.
  57674. * @param samplers defines the current sampler list.
  57675. */
  57676. static AddSamplers(samplers: string[]): void;
  57677. /**
  57678. * Makes a duplicate of the current configuration into another one.
  57679. * @param anisotropicConfiguration define the config where to copy the info
  57680. */
  57681. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  57682. /**
  57683. * Serializes this anisotropy configuration.
  57684. * @returns - An object with the serialized config.
  57685. */
  57686. serialize(): any;
  57687. /**
  57688. * Parses a anisotropy Configuration from a serialized object.
  57689. * @param source - Serialized object.
  57690. * @param scene Defines the scene we are parsing for
  57691. * @param rootUrl Defines the rootUrl to load from
  57692. */
  57693. parse(source: any, scene: Scene, rootUrl: string): void;
  57694. }
  57695. }
  57696. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  57697. import { Scene } from "babylonjs/scene";
  57698. /**
  57699. * @hidden
  57700. */
  57701. export interface IMaterialBRDFDefines {
  57702. BRDF_V_HEIGHT_CORRELATED: boolean;
  57703. MS_BRDF_ENERGY_CONSERVATION: boolean;
  57704. SPHERICAL_HARMONICS: boolean;
  57705. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  57706. /** @hidden */
  57707. _areMiscDirty: boolean;
  57708. }
  57709. /**
  57710. * Define the code related to the BRDF parameters of the pbr material.
  57711. */
  57712. export class PBRBRDFConfiguration {
  57713. /**
  57714. * Default value used for the energy conservation.
  57715. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  57716. */
  57717. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  57718. /**
  57719. * Default value used for the Smith Visibility Height Correlated mode.
  57720. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  57721. */
  57722. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  57723. /**
  57724. * Default value used for the IBL diffuse part.
  57725. * This can help switching back to the polynomials mode globally which is a tiny bit
  57726. * less GPU intensive at the drawback of a lower quality.
  57727. */
  57728. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  57729. /**
  57730. * Default value used for activating energy conservation for the specular workflow.
  57731. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  57732. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  57733. */
  57734. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  57735. private _useEnergyConservation;
  57736. /**
  57737. * Defines if the material uses energy conservation.
  57738. */
  57739. useEnergyConservation: boolean;
  57740. private _useSmithVisibilityHeightCorrelated;
  57741. /**
  57742. * LEGACY Mode set to false
  57743. * Defines if the material uses height smith correlated visibility term.
  57744. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  57745. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  57746. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  57747. * Not relying on height correlated will also disable energy conservation.
  57748. */
  57749. useSmithVisibilityHeightCorrelated: boolean;
  57750. private _useSphericalHarmonics;
  57751. /**
  57752. * LEGACY Mode set to false
  57753. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  57754. * diffuse part of the IBL.
  57755. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  57756. * to the ground truth.
  57757. */
  57758. useSphericalHarmonics: boolean;
  57759. private _useSpecularGlossinessInputEnergyConservation;
  57760. /**
  57761. * Defines if the material uses energy conservation, when the specular workflow is active.
  57762. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  57763. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  57764. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  57765. */
  57766. useSpecularGlossinessInputEnergyConservation: boolean;
  57767. /** @hidden */
  57768. private _internalMarkAllSubMeshesAsMiscDirty;
  57769. /** @hidden */
  57770. _markAllSubMeshesAsMiscDirty(): void;
  57771. /**
  57772. * Instantiate a new istance of clear coat configuration.
  57773. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  57774. */
  57775. constructor(markAllSubMeshesAsMiscDirty: () => void);
  57776. /**
  57777. * Checks to see if a texture is used in the material.
  57778. * @param defines the list of "defines" to update.
  57779. */
  57780. prepareDefines(defines: IMaterialBRDFDefines): void;
  57781. /**
  57782. * Get the current class name of the texture useful for serialization or dynamic coding.
  57783. * @returns "PBRClearCoatConfiguration"
  57784. */
  57785. getClassName(): string;
  57786. /**
  57787. * Makes a duplicate of the current configuration into another one.
  57788. * @param brdfConfiguration define the config where to copy the info
  57789. */
  57790. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  57791. /**
  57792. * Serializes this BRDF configuration.
  57793. * @returns - An object with the serialized config.
  57794. */
  57795. serialize(): any;
  57796. /**
  57797. * Parses a anisotropy Configuration from a serialized object.
  57798. * @param source - Serialized object.
  57799. * @param scene Defines the scene we are parsing for
  57800. * @param rootUrl Defines the rootUrl to load from
  57801. */
  57802. parse(source: any, scene: Scene, rootUrl: string): void;
  57803. }
  57804. }
  57805. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  57806. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  57807. import { Color3 } from "babylonjs/Maths/math.color";
  57808. import { Scene } from "babylonjs/scene";
  57809. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57810. import { Nullable } from "babylonjs/types";
  57811. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57812. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57813. /**
  57814. * @hidden
  57815. */
  57816. export interface IMaterialSheenDefines {
  57817. SHEEN: boolean;
  57818. SHEEN_TEXTURE: boolean;
  57819. SHEEN_TEXTUREDIRECTUV: number;
  57820. SHEEN_LINKWITHALBEDO: boolean;
  57821. SHEEN_ROUGHNESS: boolean;
  57822. SHEEN_ALBEDOSCALING: boolean;
  57823. /** @hidden */
  57824. _areTexturesDirty: boolean;
  57825. }
  57826. /**
  57827. * Define the code related to the Sheen parameters of the pbr material.
  57828. */
  57829. export class PBRSheenConfiguration {
  57830. private _isEnabled;
  57831. /**
  57832. * Defines if the material uses sheen.
  57833. */
  57834. isEnabled: boolean;
  57835. private _linkSheenWithAlbedo;
  57836. /**
  57837. * Defines if the sheen is linked to the sheen color.
  57838. */
  57839. linkSheenWithAlbedo: boolean;
  57840. /**
  57841. * Defines the sheen intensity.
  57842. */
  57843. intensity: number;
  57844. /**
  57845. * Defines the sheen color.
  57846. */
  57847. color: Color3;
  57848. private _texture;
  57849. /**
  57850. * Stores the sheen tint values in a texture.
  57851. * rgb is tint
  57852. * a is a intensity or roughness if roughness has been defined
  57853. */
  57854. texture: Nullable<BaseTexture>;
  57855. private _roughness;
  57856. /**
  57857. * Defines the sheen roughness.
  57858. * It is not taken into account if linkSheenWithAlbedo is true.
  57859. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  57860. */
  57861. roughness: Nullable<number>;
  57862. private _albedoScaling;
  57863. /**
  57864. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  57865. * It allows the strength of the sheen effect to not depend on the base color of the material,
  57866. * making it easier to setup and tweak the effect
  57867. */
  57868. albedoScaling: boolean;
  57869. /** @hidden */
  57870. private _internalMarkAllSubMeshesAsTexturesDirty;
  57871. /** @hidden */
  57872. _markAllSubMeshesAsTexturesDirty(): void;
  57873. /**
  57874. * Instantiate a new istance of clear coat configuration.
  57875. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  57876. */
  57877. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  57878. /**
  57879. * Specifies that the submesh is ready to be used.
  57880. * @param defines the list of "defines" to update.
  57881. * @param scene defines the scene the material belongs to.
  57882. * @returns - boolean indicating that the submesh is ready or not.
  57883. */
  57884. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  57885. /**
  57886. * Checks to see if a texture is used in the material.
  57887. * @param defines the list of "defines" to update.
  57888. * @param scene defines the scene the material belongs to.
  57889. */
  57890. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  57891. /**
  57892. * Binds the material data.
  57893. * @param uniformBuffer defines the Uniform buffer to fill in.
  57894. * @param scene defines the scene the material belongs to.
  57895. * @param isFrozen defines wether the material is frozen or not.
  57896. */
  57897. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  57898. /**
  57899. * Checks to see if a texture is used in the material.
  57900. * @param texture - Base texture to use.
  57901. * @returns - Boolean specifying if a texture is used in the material.
  57902. */
  57903. hasTexture(texture: BaseTexture): boolean;
  57904. /**
  57905. * Returns an array of the actively used textures.
  57906. * @param activeTextures Array of BaseTextures
  57907. */
  57908. getActiveTextures(activeTextures: BaseTexture[]): void;
  57909. /**
  57910. * Returns the animatable textures.
  57911. * @param animatables Array of animatable textures.
  57912. */
  57913. getAnimatables(animatables: IAnimatable[]): void;
  57914. /**
  57915. * Disposes the resources of the material.
  57916. * @param forceDisposeTextures - Forces the disposal of all textures.
  57917. */
  57918. dispose(forceDisposeTextures?: boolean): void;
  57919. /**
  57920. * Get the current class name of the texture useful for serialization or dynamic coding.
  57921. * @returns "PBRSheenConfiguration"
  57922. */
  57923. getClassName(): string;
  57924. /**
  57925. * Add fallbacks to the effect fallbacks list.
  57926. * @param defines defines the Base texture to use.
  57927. * @param fallbacks defines the current fallback list.
  57928. * @param currentRank defines the current fallback rank.
  57929. * @returns the new fallback rank.
  57930. */
  57931. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  57932. /**
  57933. * Add the required uniforms to the current list.
  57934. * @param uniforms defines the current uniform list.
  57935. */
  57936. static AddUniforms(uniforms: string[]): void;
  57937. /**
  57938. * Add the required uniforms to the current buffer.
  57939. * @param uniformBuffer defines the current uniform buffer.
  57940. */
  57941. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  57942. /**
  57943. * Add the required samplers to the current list.
  57944. * @param samplers defines the current sampler list.
  57945. */
  57946. static AddSamplers(samplers: string[]): void;
  57947. /**
  57948. * Makes a duplicate of the current configuration into another one.
  57949. * @param sheenConfiguration define the config where to copy the info
  57950. */
  57951. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  57952. /**
  57953. * Serializes this BRDF configuration.
  57954. * @returns - An object with the serialized config.
  57955. */
  57956. serialize(): any;
  57957. /**
  57958. * Parses a anisotropy Configuration from a serialized object.
  57959. * @param source - Serialized object.
  57960. * @param scene Defines the scene we are parsing for
  57961. * @param rootUrl Defines the rootUrl to load from
  57962. */
  57963. parse(source: any, scene: Scene, rootUrl: string): void;
  57964. }
  57965. }
  57966. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  57967. import { Nullable } from "babylonjs/types";
  57968. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57969. import { Color3 } from "babylonjs/Maths/math.color";
  57970. import { SmartArray } from "babylonjs/Misc/smartArray";
  57971. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57972. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57973. import { Effect } from "babylonjs/Materials/effect";
  57974. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  57975. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57976. import { Engine } from "babylonjs/Engines/engine";
  57977. import { Scene } from "babylonjs/scene";
  57978. /**
  57979. * @hidden
  57980. */
  57981. export interface IMaterialSubSurfaceDefines {
  57982. SUBSURFACE: boolean;
  57983. SS_REFRACTION: boolean;
  57984. SS_TRANSLUCENCY: boolean;
  57985. SS_SCATTERING: boolean;
  57986. SS_THICKNESSANDMASK_TEXTURE: boolean;
  57987. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  57988. SS_REFRACTIONMAP_3D: boolean;
  57989. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  57990. SS_LODINREFRACTIONALPHA: boolean;
  57991. SS_GAMMAREFRACTION: boolean;
  57992. SS_RGBDREFRACTION: boolean;
  57993. SS_LINEARSPECULARREFRACTION: boolean;
  57994. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  57995. SS_ALBEDOFORREFRACTIONTINT: boolean;
  57996. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  57997. /** @hidden */
  57998. _areTexturesDirty: boolean;
  57999. }
  58000. /**
  58001. * Define the code related to the sub surface parameters of the pbr material.
  58002. */
  58003. export class PBRSubSurfaceConfiguration {
  58004. private _isRefractionEnabled;
  58005. /**
  58006. * Defines if the refraction is enabled in the material.
  58007. */
  58008. isRefractionEnabled: boolean;
  58009. private _isTranslucencyEnabled;
  58010. /**
  58011. * Defines if the translucency is enabled in the material.
  58012. */
  58013. isTranslucencyEnabled: boolean;
  58014. private _isScatteringEnabled;
  58015. /**
  58016. * Defines if the sub surface scattering is enabled in the material.
  58017. */
  58018. isScatteringEnabled: boolean;
  58019. private _scatteringDiffusionProfileIndex;
  58020. /**
  58021. * Diffusion profile for subsurface scattering.
  58022. * Useful for better scattering in the skins or foliages.
  58023. */
  58024. get scatteringDiffusionProfile(): Nullable<Color3>;
  58025. set scatteringDiffusionProfile(c: Nullable<Color3>);
  58026. /**
  58027. * Defines the refraction intensity of the material.
  58028. * The refraction when enabled replaces the Diffuse part of the material.
  58029. * The intensity helps transitionning between diffuse and refraction.
  58030. */
  58031. refractionIntensity: number;
  58032. /**
  58033. * Defines the translucency intensity of the material.
  58034. * When translucency has been enabled, this defines how much of the "translucency"
  58035. * is addded to the diffuse part of the material.
  58036. */
  58037. translucencyIntensity: number;
  58038. /**
  58039. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  58040. */
  58041. useAlbedoToTintRefraction: boolean;
  58042. private _thicknessTexture;
  58043. /**
  58044. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  58045. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  58046. * 0 would mean minimumThickness
  58047. * 1 would mean maximumThickness
  58048. * The other channels might be use as a mask to vary the different effects intensity.
  58049. */
  58050. thicknessTexture: Nullable<BaseTexture>;
  58051. private _refractionTexture;
  58052. /**
  58053. * Defines the texture to use for refraction.
  58054. */
  58055. refractionTexture: Nullable<BaseTexture>;
  58056. private _indexOfRefraction;
  58057. /**
  58058. * Index of refraction of the material base layer.
  58059. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  58060. *
  58061. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  58062. *
  58063. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  58064. */
  58065. indexOfRefraction: number;
  58066. private _volumeIndexOfRefraction;
  58067. /**
  58068. * Index of refraction of the material's volume.
  58069. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  58070. *
  58071. * This ONLY impacts refraction. If not provided or given a non-valid value,
  58072. * the volume will use the same IOR as the surface.
  58073. */
  58074. get volumeIndexOfRefraction(): number;
  58075. set volumeIndexOfRefraction(value: number);
  58076. private _invertRefractionY;
  58077. /**
  58078. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  58079. */
  58080. invertRefractionY: boolean;
  58081. private _linkRefractionWithTransparency;
  58082. /**
  58083. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  58084. * Materials half opaque for instance using refraction could benefit from this control.
  58085. */
  58086. linkRefractionWithTransparency: boolean;
  58087. /**
  58088. * Defines the minimum thickness stored in the thickness map.
  58089. * If no thickness map is defined, this value will be used to simulate thickness.
  58090. */
  58091. minimumThickness: number;
  58092. /**
  58093. * Defines the maximum thickness stored in the thickness map.
  58094. */
  58095. maximumThickness: number;
  58096. /**
  58097. * Defines the volume tint of the material.
  58098. * This is used for both translucency and scattering.
  58099. */
  58100. tintColor: Color3;
  58101. /**
  58102. * Defines the distance at which the tint color should be found in the media.
  58103. * This is used for refraction only.
  58104. */
  58105. tintColorAtDistance: number;
  58106. /**
  58107. * Defines how far each channel transmit through the media.
  58108. * It is defined as a color to simplify it selection.
  58109. */
  58110. diffusionDistance: Color3;
  58111. private _useMaskFromThicknessTexture;
  58112. /**
  58113. * Stores the intensity of the different subsurface effects in the thickness texture.
  58114. * * the green channel is the translucency intensity.
  58115. * * the blue channel is the scattering intensity.
  58116. * * the alpha channel is the refraction intensity.
  58117. */
  58118. useMaskFromThicknessTexture: boolean;
  58119. private _scene;
  58120. /** @hidden */
  58121. private _internalMarkAllSubMeshesAsTexturesDirty;
  58122. private _internalMarkScenePrePassDirty;
  58123. /** @hidden */
  58124. _markAllSubMeshesAsTexturesDirty(): void;
  58125. /** @hidden */
  58126. _markScenePrePassDirty(): void;
  58127. /**
  58128. * Instantiate a new istance of sub surface configuration.
  58129. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  58130. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  58131. * @param scene The scene
  58132. */
  58133. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  58134. /**
  58135. * Gets wehter the submesh is ready to be used or not.
  58136. * @param defines the list of "defines" to update.
  58137. * @param scene defines the scene the material belongs to.
  58138. * @returns - boolean indicating that the submesh is ready or not.
  58139. */
  58140. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  58141. /**
  58142. * Checks to see if a texture is used in the material.
  58143. * @param defines the list of "defines" to update.
  58144. * @param scene defines the scene to the material belongs to.
  58145. */
  58146. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  58147. /**
  58148. * Binds the material data.
  58149. * @param uniformBuffer defines the Uniform buffer to fill in.
  58150. * @param scene defines the scene the material belongs to.
  58151. * @param engine defines the engine the material belongs to.
  58152. * @param isFrozen defines whether the material is frozen or not.
  58153. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  58154. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  58155. */
  58156. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  58157. /**
  58158. * Unbinds the material from the mesh.
  58159. * @param activeEffect defines the effect that should be unbound from.
  58160. * @returns true if unbound, otherwise false
  58161. */
  58162. unbind(activeEffect: Effect): boolean;
  58163. /**
  58164. * Returns the texture used for refraction or null if none is used.
  58165. * @param scene defines the scene the material belongs to.
  58166. * @returns - Refraction texture if present. If no refraction texture and refraction
  58167. * is linked with transparency, returns environment texture. Otherwise, returns null.
  58168. */
  58169. private _getRefractionTexture;
  58170. /**
  58171. * Returns true if alpha blending should be disabled.
  58172. */
  58173. get disableAlphaBlending(): boolean;
  58174. /**
  58175. * Fills the list of render target textures.
  58176. * @param renderTargets the list of render targets to update
  58177. */
  58178. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  58179. /**
  58180. * Checks to see if a texture is used in the material.
  58181. * @param texture - Base texture to use.
  58182. * @returns - Boolean specifying if a texture is used in the material.
  58183. */
  58184. hasTexture(texture: BaseTexture): boolean;
  58185. /**
  58186. * Gets a boolean indicating that current material needs to register RTT
  58187. * @returns true if this uses a render target otherwise false.
  58188. */
  58189. hasRenderTargetTextures(): boolean;
  58190. /**
  58191. * Returns an array of the actively used textures.
  58192. * @param activeTextures Array of BaseTextures
  58193. */
  58194. getActiveTextures(activeTextures: BaseTexture[]): void;
  58195. /**
  58196. * Returns the animatable textures.
  58197. * @param animatables Array of animatable textures.
  58198. */
  58199. getAnimatables(animatables: IAnimatable[]): void;
  58200. /**
  58201. * Disposes the resources of the material.
  58202. * @param forceDisposeTextures - Forces the disposal of all textures.
  58203. */
  58204. dispose(forceDisposeTextures?: boolean): void;
  58205. /**
  58206. * Get the current class name of the texture useful for serialization or dynamic coding.
  58207. * @returns "PBRSubSurfaceConfiguration"
  58208. */
  58209. getClassName(): string;
  58210. /**
  58211. * Add fallbacks to the effect fallbacks list.
  58212. * @param defines defines the Base texture to use.
  58213. * @param fallbacks defines the current fallback list.
  58214. * @param currentRank defines the current fallback rank.
  58215. * @returns the new fallback rank.
  58216. */
  58217. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  58218. /**
  58219. * Add the required uniforms to the current list.
  58220. * @param uniforms defines the current uniform list.
  58221. */
  58222. static AddUniforms(uniforms: string[]): void;
  58223. /**
  58224. * Add the required samplers to the current list.
  58225. * @param samplers defines the current sampler list.
  58226. */
  58227. static AddSamplers(samplers: string[]): void;
  58228. /**
  58229. * Add the required uniforms to the current buffer.
  58230. * @param uniformBuffer defines the current uniform buffer.
  58231. */
  58232. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  58233. /**
  58234. * Makes a duplicate of the current configuration into another one.
  58235. * @param configuration define the config where to copy the info
  58236. */
  58237. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  58238. /**
  58239. * Serializes this Sub Surface configuration.
  58240. * @returns - An object with the serialized config.
  58241. */
  58242. serialize(): any;
  58243. /**
  58244. * Parses a anisotropy Configuration from a serialized object.
  58245. * @param source - Serialized object.
  58246. * @param scene Defines the scene we are parsing for
  58247. * @param rootUrl Defines the rootUrl to load from
  58248. */
  58249. parse(source: any, scene: Scene, rootUrl: string): void;
  58250. }
  58251. }
  58252. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  58253. /** @hidden */
  58254. export var pbrFragmentDeclaration: {
  58255. name: string;
  58256. shader: string;
  58257. };
  58258. }
  58259. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  58260. /** @hidden */
  58261. export var pbrUboDeclaration: {
  58262. name: string;
  58263. shader: string;
  58264. };
  58265. }
  58266. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  58267. /** @hidden */
  58268. export var pbrFragmentExtraDeclaration: {
  58269. name: string;
  58270. shader: string;
  58271. };
  58272. }
  58273. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  58274. /** @hidden */
  58275. export var pbrFragmentSamplersDeclaration: {
  58276. name: string;
  58277. shader: string;
  58278. };
  58279. }
  58280. declare module "babylonjs/Shaders/ShadersInclude/importanceSampling" {
  58281. /** @hidden */
  58282. export var importanceSampling: {
  58283. name: string;
  58284. shader: string;
  58285. };
  58286. }
  58287. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  58288. /** @hidden */
  58289. export var pbrHelperFunctions: {
  58290. name: string;
  58291. shader: string;
  58292. };
  58293. }
  58294. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  58295. /** @hidden */
  58296. export var harmonicsFunctions: {
  58297. name: string;
  58298. shader: string;
  58299. };
  58300. }
  58301. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  58302. /** @hidden */
  58303. export var pbrDirectLightingSetupFunctions: {
  58304. name: string;
  58305. shader: string;
  58306. };
  58307. }
  58308. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  58309. /** @hidden */
  58310. export var pbrDirectLightingFalloffFunctions: {
  58311. name: string;
  58312. shader: string;
  58313. };
  58314. }
  58315. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  58316. /** @hidden */
  58317. export var pbrBRDFFunctions: {
  58318. name: string;
  58319. shader: string;
  58320. };
  58321. }
  58322. declare module "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions" {
  58323. /** @hidden */
  58324. export var hdrFilteringFunctions: {
  58325. name: string;
  58326. shader: string;
  58327. };
  58328. }
  58329. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  58330. /** @hidden */
  58331. export var pbrDirectLightingFunctions: {
  58332. name: string;
  58333. shader: string;
  58334. };
  58335. }
  58336. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  58337. /** @hidden */
  58338. export var pbrIBLFunctions: {
  58339. name: string;
  58340. shader: string;
  58341. };
  58342. }
  58343. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  58344. /** @hidden */
  58345. export var pbrBlockAlbedoOpacity: {
  58346. name: string;
  58347. shader: string;
  58348. };
  58349. }
  58350. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  58351. /** @hidden */
  58352. export var pbrBlockReflectivity: {
  58353. name: string;
  58354. shader: string;
  58355. };
  58356. }
  58357. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  58358. /** @hidden */
  58359. export var pbrBlockAmbientOcclusion: {
  58360. name: string;
  58361. shader: string;
  58362. };
  58363. }
  58364. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  58365. /** @hidden */
  58366. export var pbrBlockAlphaFresnel: {
  58367. name: string;
  58368. shader: string;
  58369. };
  58370. }
  58371. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  58372. /** @hidden */
  58373. export var pbrBlockAnisotropic: {
  58374. name: string;
  58375. shader: string;
  58376. };
  58377. }
  58378. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  58379. /** @hidden */
  58380. export var pbrBlockReflection: {
  58381. name: string;
  58382. shader: string;
  58383. };
  58384. }
  58385. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  58386. /** @hidden */
  58387. export var pbrBlockSheen: {
  58388. name: string;
  58389. shader: string;
  58390. };
  58391. }
  58392. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  58393. /** @hidden */
  58394. export var pbrBlockClearcoat: {
  58395. name: string;
  58396. shader: string;
  58397. };
  58398. }
  58399. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  58400. /** @hidden */
  58401. export var pbrBlockSubSurface: {
  58402. name: string;
  58403. shader: string;
  58404. };
  58405. }
  58406. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  58407. /** @hidden */
  58408. export var pbrBlockNormalGeometric: {
  58409. name: string;
  58410. shader: string;
  58411. };
  58412. }
  58413. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  58414. /** @hidden */
  58415. export var pbrBlockNormalFinal: {
  58416. name: string;
  58417. shader: string;
  58418. };
  58419. }
  58420. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit" {
  58421. /** @hidden */
  58422. export var pbrBlockLightmapInit: {
  58423. name: string;
  58424. shader: string;
  58425. };
  58426. }
  58427. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  58428. /** @hidden */
  58429. export var pbrBlockGeometryInfo: {
  58430. name: string;
  58431. shader: string;
  58432. };
  58433. }
  58434. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  58435. /** @hidden */
  58436. export var pbrBlockReflectance0: {
  58437. name: string;
  58438. shader: string;
  58439. };
  58440. }
  58441. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  58442. /** @hidden */
  58443. export var pbrBlockReflectance: {
  58444. name: string;
  58445. shader: string;
  58446. };
  58447. }
  58448. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  58449. /** @hidden */
  58450. export var pbrBlockDirectLighting: {
  58451. name: string;
  58452. shader: string;
  58453. };
  58454. }
  58455. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  58456. /** @hidden */
  58457. export var pbrBlockFinalLitComponents: {
  58458. name: string;
  58459. shader: string;
  58460. };
  58461. }
  58462. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  58463. /** @hidden */
  58464. export var pbrBlockFinalUnlitComponents: {
  58465. name: string;
  58466. shader: string;
  58467. };
  58468. }
  58469. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  58470. /** @hidden */
  58471. export var pbrBlockFinalColorComposition: {
  58472. name: string;
  58473. shader: string;
  58474. };
  58475. }
  58476. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  58477. /** @hidden */
  58478. export var pbrBlockImageProcessing: {
  58479. name: string;
  58480. shader: string;
  58481. };
  58482. }
  58483. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  58484. /** @hidden */
  58485. export var pbrDebug: {
  58486. name: string;
  58487. shader: string;
  58488. };
  58489. }
  58490. declare module "babylonjs/Shaders/pbr.fragment" {
  58491. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  58492. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  58493. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  58494. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  58495. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  58496. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  58497. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  58498. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  58499. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  58500. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  58501. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  58502. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58503. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  58504. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  58505. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  58506. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  58507. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  58508. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  58509. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  58510. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  58511. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  58512. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  58513. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  58514. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  58515. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  58516. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  58517. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  58518. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  58519. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  58520. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  58521. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  58522. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  58523. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  58524. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  58525. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  58526. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  58527. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  58528. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  58529. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  58530. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  58531. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  58532. import "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit";
  58533. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  58534. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  58535. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  58536. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  58537. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  58538. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  58539. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  58540. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  58541. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  58542. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  58543. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  58544. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  58545. /** @hidden */
  58546. export var pbrPixelShader: {
  58547. name: string;
  58548. shader: string;
  58549. };
  58550. }
  58551. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  58552. /** @hidden */
  58553. export var pbrVertexDeclaration: {
  58554. name: string;
  58555. shader: string;
  58556. };
  58557. }
  58558. declare module "babylonjs/Shaders/pbr.vertex" {
  58559. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  58560. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  58561. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58562. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  58563. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  58564. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  58565. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  58566. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  58567. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  58568. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  58569. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  58570. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  58571. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  58572. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  58573. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  58574. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  58575. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  58576. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  58577. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  58578. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  58579. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  58580. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  58581. /** @hidden */
  58582. export var pbrVertexShader: {
  58583. name: string;
  58584. shader: string;
  58585. };
  58586. }
  58587. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  58588. import { Nullable } from "babylonjs/types";
  58589. import { Scene } from "babylonjs/scene";
  58590. import { Matrix } from "babylonjs/Maths/math.vector";
  58591. import { SubMesh } from "babylonjs/Meshes/subMesh";
  58592. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58593. import { Mesh } from "babylonjs/Meshes/mesh";
  58594. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  58595. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  58596. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  58597. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  58598. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  58599. import { Color3 } from "babylonjs/Maths/math.color";
  58600. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  58601. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  58602. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  58603. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  58604. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58605. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  58606. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  58607. import "babylonjs/Shaders/pbr.fragment";
  58608. import "babylonjs/Shaders/pbr.vertex";
  58609. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  58610. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  58611. /**
  58612. * Manages the defines for the PBR Material.
  58613. * @hidden
  58614. */
  58615. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  58616. PBR: boolean;
  58617. NUM_SAMPLES: string;
  58618. REALTIME_FILTERING: boolean;
  58619. MAINUV1: boolean;
  58620. MAINUV2: boolean;
  58621. UV1: boolean;
  58622. UV2: boolean;
  58623. ALBEDO: boolean;
  58624. GAMMAALBEDO: boolean;
  58625. ALBEDODIRECTUV: number;
  58626. VERTEXCOLOR: boolean;
  58627. DETAIL: boolean;
  58628. DETAILDIRECTUV: number;
  58629. DETAIL_NORMALBLENDMETHOD: number;
  58630. AMBIENT: boolean;
  58631. AMBIENTDIRECTUV: number;
  58632. AMBIENTINGRAYSCALE: boolean;
  58633. OPACITY: boolean;
  58634. VERTEXALPHA: boolean;
  58635. OPACITYDIRECTUV: number;
  58636. OPACITYRGB: boolean;
  58637. ALPHATEST: boolean;
  58638. DEPTHPREPASS: boolean;
  58639. ALPHABLEND: boolean;
  58640. ALPHAFROMALBEDO: boolean;
  58641. ALPHATESTVALUE: string;
  58642. SPECULAROVERALPHA: boolean;
  58643. RADIANCEOVERALPHA: boolean;
  58644. ALPHAFRESNEL: boolean;
  58645. LINEARALPHAFRESNEL: boolean;
  58646. PREMULTIPLYALPHA: boolean;
  58647. EMISSIVE: boolean;
  58648. EMISSIVEDIRECTUV: number;
  58649. REFLECTIVITY: boolean;
  58650. REFLECTIVITYDIRECTUV: number;
  58651. SPECULARTERM: boolean;
  58652. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  58653. MICROSURFACEAUTOMATIC: boolean;
  58654. LODBASEDMICROSFURACE: boolean;
  58655. MICROSURFACEMAP: boolean;
  58656. MICROSURFACEMAPDIRECTUV: number;
  58657. METALLICWORKFLOW: boolean;
  58658. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  58659. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  58660. METALLNESSSTOREINMETALMAPBLUE: boolean;
  58661. AOSTOREINMETALMAPRED: boolean;
  58662. METALLIC_REFLECTANCE: boolean;
  58663. METALLIC_REFLECTANCEDIRECTUV: number;
  58664. ENVIRONMENTBRDF: boolean;
  58665. ENVIRONMENTBRDF_RGBD: boolean;
  58666. NORMAL: boolean;
  58667. TANGENT: boolean;
  58668. BUMP: boolean;
  58669. BUMPDIRECTUV: number;
  58670. OBJECTSPACE_NORMALMAP: boolean;
  58671. PARALLAX: boolean;
  58672. PARALLAXOCCLUSION: boolean;
  58673. NORMALXYSCALE: boolean;
  58674. LIGHTMAP: boolean;
  58675. LIGHTMAPDIRECTUV: number;
  58676. USELIGHTMAPASSHADOWMAP: boolean;
  58677. GAMMALIGHTMAP: boolean;
  58678. RGBDLIGHTMAP: boolean;
  58679. REFLECTION: boolean;
  58680. REFLECTIONMAP_3D: boolean;
  58681. REFLECTIONMAP_SPHERICAL: boolean;
  58682. REFLECTIONMAP_PLANAR: boolean;
  58683. REFLECTIONMAP_CUBIC: boolean;
  58684. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  58685. REFLECTIONMAP_PROJECTION: boolean;
  58686. REFLECTIONMAP_SKYBOX: boolean;
  58687. REFLECTIONMAP_EXPLICIT: boolean;
  58688. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  58689. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  58690. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  58691. INVERTCUBICMAP: boolean;
  58692. USESPHERICALFROMREFLECTIONMAP: boolean;
  58693. USEIRRADIANCEMAP: boolean;
  58694. SPHERICAL_HARMONICS: boolean;
  58695. USESPHERICALINVERTEX: boolean;
  58696. REFLECTIONMAP_OPPOSITEZ: boolean;
  58697. LODINREFLECTIONALPHA: boolean;
  58698. GAMMAREFLECTION: boolean;
  58699. RGBDREFLECTION: boolean;
  58700. LINEARSPECULARREFLECTION: boolean;
  58701. RADIANCEOCCLUSION: boolean;
  58702. HORIZONOCCLUSION: boolean;
  58703. INSTANCES: boolean;
  58704. THIN_INSTANCES: boolean;
  58705. PREPASS: boolean;
  58706. SCENE_MRT_COUNT: number;
  58707. NUM_BONE_INFLUENCERS: number;
  58708. BonesPerMesh: number;
  58709. BONETEXTURE: boolean;
  58710. NONUNIFORMSCALING: boolean;
  58711. MORPHTARGETS: boolean;
  58712. MORPHTARGETS_NORMAL: boolean;
  58713. MORPHTARGETS_TANGENT: boolean;
  58714. MORPHTARGETS_UV: boolean;
  58715. NUM_MORPH_INFLUENCERS: number;
  58716. IMAGEPROCESSING: boolean;
  58717. VIGNETTE: boolean;
  58718. VIGNETTEBLENDMODEMULTIPLY: boolean;
  58719. VIGNETTEBLENDMODEOPAQUE: boolean;
  58720. TONEMAPPING: boolean;
  58721. TONEMAPPING_ACES: boolean;
  58722. CONTRAST: boolean;
  58723. COLORCURVES: boolean;
  58724. COLORGRADING: boolean;
  58725. COLORGRADING3D: boolean;
  58726. SAMPLER3DGREENDEPTH: boolean;
  58727. SAMPLER3DBGRMAP: boolean;
  58728. IMAGEPROCESSINGPOSTPROCESS: boolean;
  58729. EXPOSURE: boolean;
  58730. MULTIVIEW: boolean;
  58731. USEPHYSICALLIGHTFALLOFF: boolean;
  58732. USEGLTFLIGHTFALLOFF: boolean;
  58733. TWOSIDEDLIGHTING: boolean;
  58734. SHADOWFLOAT: boolean;
  58735. CLIPPLANE: boolean;
  58736. CLIPPLANE2: boolean;
  58737. CLIPPLANE3: boolean;
  58738. CLIPPLANE4: boolean;
  58739. CLIPPLANE5: boolean;
  58740. CLIPPLANE6: boolean;
  58741. POINTSIZE: boolean;
  58742. FOG: boolean;
  58743. LOGARITHMICDEPTH: boolean;
  58744. FORCENORMALFORWARD: boolean;
  58745. SPECULARAA: boolean;
  58746. CLEARCOAT: boolean;
  58747. CLEARCOAT_DEFAULTIOR: boolean;
  58748. CLEARCOAT_TEXTURE: boolean;
  58749. CLEARCOAT_TEXTUREDIRECTUV: number;
  58750. CLEARCOAT_BUMP: boolean;
  58751. CLEARCOAT_BUMPDIRECTUV: number;
  58752. CLEARCOAT_TINT: boolean;
  58753. CLEARCOAT_TINT_TEXTURE: boolean;
  58754. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  58755. ANISOTROPIC: boolean;
  58756. ANISOTROPIC_TEXTURE: boolean;
  58757. ANISOTROPIC_TEXTUREDIRECTUV: number;
  58758. BRDF_V_HEIGHT_CORRELATED: boolean;
  58759. MS_BRDF_ENERGY_CONSERVATION: boolean;
  58760. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  58761. SHEEN: boolean;
  58762. SHEEN_TEXTURE: boolean;
  58763. SHEEN_TEXTUREDIRECTUV: number;
  58764. SHEEN_LINKWITHALBEDO: boolean;
  58765. SHEEN_ROUGHNESS: boolean;
  58766. SHEEN_ALBEDOSCALING: boolean;
  58767. SUBSURFACE: boolean;
  58768. SS_REFRACTION: boolean;
  58769. SS_TRANSLUCENCY: boolean;
  58770. SS_SCATTERING: boolean;
  58771. SS_THICKNESSANDMASK_TEXTURE: boolean;
  58772. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  58773. SS_REFRACTIONMAP_3D: boolean;
  58774. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  58775. SS_LODINREFRACTIONALPHA: boolean;
  58776. SS_GAMMAREFRACTION: boolean;
  58777. SS_RGBDREFRACTION: boolean;
  58778. SS_LINEARSPECULARREFRACTION: boolean;
  58779. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  58780. SS_ALBEDOFORREFRACTIONTINT: boolean;
  58781. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  58782. UNLIT: boolean;
  58783. DEBUGMODE: number;
  58784. /**
  58785. * Initializes the PBR Material defines.
  58786. */
  58787. constructor();
  58788. /**
  58789. * Resets the PBR Material defines.
  58790. */
  58791. reset(): void;
  58792. }
  58793. /**
  58794. * The Physically based material base class of BJS.
  58795. *
  58796. * This offers the main features of a standard PBR material.
  58797. * For more information, please refer to the documentation :
  58798. * https://doc.babylonjs.com/how_to/physically_based_rendering
  58799. */
  58800. export abstract class PBRBaseMaterial extends PushMaterial {
  58801. /**
  58802. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  58803. */
  58804. static readonly PBRMATERIAL_OPAQUE: number;
  58805. /**
  58806. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  58807. */
  58808. static readonly PBRMATERIAL_ALPHATEST: number;
  58809. /**
  58810. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  58811. */
  58812. static readonly PBRMATERIAL_ALPHABLEND: number;
  58813. /**
  58814. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  58815. * They are also discarded below the alpha cutoff threshold to improve performances.
  58816. */
  58817. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  58818. /**
  58819. * Defines the default value of how much AO map is occluding the analytical lights
  58820. * (point spot...).
  58821. */
  58822. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  58823. /**
  58824. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  58825. */
  58826. static readonly LIGHTFALLOFF_PHYSICAL: number;
  58827. /**
  58828. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  58829. * to enhance interoperability with other engines.
  58830. */
  58831. static readonly LIGHTFALLOFF_GLTF: number;
  58832. /**
  58833. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  58834. * to enhance interoperability with other materials.
  58835. */
  58836. static readonly LIGHTFALLOFF_STANDARD: number;
  58837. /**
  58838. * Intensity of the direct lights e.g. the four lights available in your scene.
  58839. * This impacts both the direct diffuse and specular highlights.
  58840. */
  58841. protected _directIntensity: number;
  58842. /**
  58843. * Intensity of the emissive part of the material.
  58844. * This helps controlling the emissive effect without modifying the emissive color.
  58845. */
  58846. protected _emissiveIntensity: number;
  58847. /**
  58848. * Intensity of the environment e.g. how much the environment will light the object
  58849. * either through harmonics for rough material or through the refelction for shiny ones.
  58850. */
  58851. protected _environmentIntensity: number;
  58852. /**
  58853. * This is a special control allowing the reduction of the specular highlights coming from the
  58854. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  58855. */
  58856. protected _specularIntensity: number;
  58857. /**
  58858. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  58859. */
  58860. private _lightingInfos;
  58861. /**
  58862. * Debug Control allowing disabling the bump map on this material.
  58863. */
  58864. protected _disableBumpMap: boolean;
  58865. /**
  58866. * AKA Diffuse Texture in standard nomenclature.
  58867. */
  58868. protected _albedoTexture: Nullable<BaseTexture>;
  58869. /**
  58870. * AKA Occlusion Texture in other nomenclature.
  58871. */
  58872. protected _ambientTexture: Nullable<BaseTexture>;
  58873. /**
  58874. * AKA Occlusion Texture Intensity in other nomenclature.
  58875. */
  58876. protected _ambientTextureStrength: number;
  58877. /**
  58878. * Defines how much the AO map is occluding the analytical lights (point spot...).
  58879. * 1 means it completely occludes it
  58880. * 0 mean it has no impact
  58881. */
  58882. protected _ambientTextureImpactOnAnalyticalLights: number;
  58883. /**
  58884. * Stores the alpha values in a texture.
  58885. */
  58886. protected _opacityTexture: Nullable<BaseTexture>;
  58887. /**
  58888. * Stores the reflection values in a texture.
  58889. */
  58890. protected _reflectionTexture: Nullable<BaseTexture>;
  58891. /**
  58892. * Stores the emissive values in a texture.
  58893. */
  58894. protected _emissiveTexture: Nullable<BaseTexture>;
  58895. /**
  58896. * AKA Specular texture in other nomenclature.
  58897. */
  58898. protected _reflectivityTexture: Nullable<BaseTexture>;
  58899. /**
  58900. * Used to switch from specular/glossiness to metallic/roughness workflow.
  58901. */
  58902. protected _metallicTexture: Nullable<BaseTexture>;
  58903. /**
  58904. * Specifies the metallic scalar of the metallic/roughness workflow.
  58905. * Can also be used to scale the metalness values of the metallic texture.
  58906. */
  58907. protected _metallic: Nullable<number>;
  58908. /**
  58909. * Specifies the roughness scalar of the metallic/roughness workflow.
  58910. * Can also be used to scale the roughness values of the metallic texture.
  58911. */
  58912. protected _roughness: Nullable<number>;
  58913. /**
  58914. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  58915. * By default the indexOfrefraction is used to compute F0;
  58916. *
  58917. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  58918. *
  58919. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  58920. * F90 = metallicReflectanceColor;
  58921. */
  58922. protected _metallicF0Factor: number;
  58923. /**
  58924. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  58925. * By default the F90 is always 1;
  58926. *
  58927. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  58928. *
  58929. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  58930. * F90 = metallicReflectanceColor;
  58931. */
  58932. protected _metallicReflectanceColor: Color3;
  58933. /**
  58934. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  58935. * This is multiply against the scalar values defined in the material.
  58936. */
  58937. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  58938. /**
  58939. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  58940. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  58941. */
  58942. protected _microSurfaceTexture: Nullable<BaseTexture>;
  58943. /**
  58944. * Stores surface normal data used to displace a mesh in a texture.
  58945. */
  58946. protected _bumpTexture: Nullable<BaseTexture>;
  58947. /**
  58948. * Stores the pre-calculated light information of a mesh in a texture.
  58949. */
  58950. protected _lightmapTexture: Nullable<BaseTexture>;
  58951. /**
  58952. * The color of a material in ambient lighting.
  58953. */
  58954. protected _ambientColor: Color3;
  58955. /**
  58956. * AKA Diffuse Color in other nomenclature.
  58957. */
  58958. protected _albedoColor: Color3;
  58959. /**
  58960. * AKA Specular Color in other nomenclature.
  58961. */
  58962. protected _reflectivityColor: Color3;
  58963. /**
  58964. * The color applied when light is reflected from a material.
  58965. */
  58966. protected _reflectionColor: Color3;
  58967. /**
  58968. * The color applied when light is emitted from a material.
  58969. */
  58970. protected _emissiveColor: Color3;
  58971. /**
  58972. * AKA Glossiness in other nomenclature.
  58973. */
  58974. protected _microSurface: number;
  58975. /**
  58976. * Specifies that the material will use the light map as a show map.
  58977. */
  58978. protected _useLightmapAsShadowmap: boolean;
  58979. /**
  58980. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  58981. * makes the reflect vector face the model (under horizon).
  58982. */
  58983. protected _useHorizonOcclusion: boolean;
  58984. /**
  58985. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  58986. * too much the area relying on ambient texture to define their ambient occlusion.
  58987. */
  58988. protected _useRadianceOcclusion: boolean;
  58989. /**
  58990. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  58991. */
  58992. protected _useAlphaFromAlbedoTexture: boolean;
  58993. /**
  58994. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  58995. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  58996. */
  58997. protected _useSpecularOverAlpha: boolean;
  58998. /**
  58999. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  59000. */
  59001. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  59002. /**
  59003. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  59004. */
  59005. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  59006. /**
  59007. * Specifies if the metallic texture contains the roughness information in its green channel.
  59008. */
  59009. protected _useRoughnessFromMetallicTextureGreen: boolean;
  59010. /**
  59011. * Specifies if the metallic texture contains the metallness information in its blue channel.
  59012. */
  59013. protected _useMetallnessFromMetallicTextureBlue: boolean;
  59014. /**
  59015. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  59016. */
  59017. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  59018. /**
  59019. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  59020. */
  59021. protected _useAmbientInGrayScale: boolean;
  59022. /**
  59023. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  59024. * The material will try to infer what glossiness each pixel should be.
  59025. */
  59026. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  59027. /**
  59028. * Defines the falloff type used in this material.
  59029. * It by default is Physical.
  59030. */
  59031. protected _lightFalloff: number;
  59032. /**
  59033. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  59034. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  59035. */
  59036. protected _useRadianceOverAlpha: boolean;
  59037. /**
  59038. * Allows using an object space normal map (instead of tangent space).
  59039. */
  59040. protected _useObjectSpaceNormalMap: boolean;
  59041. /**
  59042. * Allows using the bump map in parallax mode.
  59043. */
  59044. protected _useParallax: boolean;
  59045. /**
  59046. * Allows using the bump map in parallax occlusion mode.
  59047. */
  59048. protected _useParallaxOcclusion: boolean;
  59049. /**
  59050. * Controls the scale bias of the parallax mode.
  59051. */
  59052. protected _parallaxScaleBias: number;
  59053. /**
  59054. * If sets to true, disables all the lights affecting the material.
  59055. */
  59056. protected _disableLighting: boolean;
  59057. /**
  59058. * Number of Simultaneous lights allowed on the material.
  59059. */
  59060. protected _maxSimultaneousLights: number;
  59061. /**
  59062. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  59063. */
  59064. protected _invertNormalMapX: boolean;
  59065. /**
  59066. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  59067. */
  59068. protected _invertNormalMapY: boolean;
  59069. /**
  59070. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  59071. */
  59072. protected _twoSidedLighting: boolean;
  59073. /**
  59074. * Defines the alpha limits in alpha test mode.
  59075. */
  59076. protected _alphaCutOff: number;
  59077. /**
  59078. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  59079. */
  59080. protected _forceAlphaTest: boolean;
  59081. /**
  59082. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  59083. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  59084. */
  59085. protected _useAlphaFresnel: boolean;
  59086. /**
  59087. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  59088. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  59089. */
  59090. protected _useLinearAlphaFresnel: boolean;
  59091. /**
  59092. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  59093. * from cos thetav and roughness:
  59094. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  59095. */
  59096. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  59097. /**
  59098. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  59099. */
  59100. protected _forceIrradianceInFragment: boolean;
  59101. private _realTimeFiltering;
  59102. /**
  59103. * Enables realtime filtering on the texture.
  59104. */
  59105. get realTimeFiltering(): boolean;
  59106. set realTimeFiltering(b: boolean);
  59107. private _realTimeFilteringQuality;
  59108. /**
  59109. * Quality switch for realtime filtering
  59110. */
  59111. get realTimeFilteringQuality(): number;
  59112. set realTimeFilteringQuality(n: number);
  59113. /**
  59114. * Can this material render to several textures at once
  59115. */
  59116. get canRenderToMRT(): boolean;
  59117. /**
  59118. * Force normal to face away from face.
  59119. */
  59120. protected _forceNormalForward: boolean;
  59121. /**
  59122. * Enables specular anti aliasing in the PBR shader.
  59123. * It will both interacts on the Geometry for analytical and IBL lighting.
  59124. * It also prefilter the roughness map based on the bump values.
  59125. */
  59126. protected _enableSpecularAntiAliasing: boolean;
  59127. /**
  59128. * Default configuration related to image processing available in the PBR Material.
  59129. */
  59130. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  59131. /**
  59132. * Keep track of the image processing observer to allow dispose and replace.
  59133. */
  59134. private _imageProcessingObserver;
  59135. /**
  59136. * Attaches a new image processing configuration to the PBR Material.
  59137. * @param configuration
  59138. */
  59139. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  59140. /**
  59141. * Stores the available render targets.
  59142. */
  59143. private _renderTargets;
  59144. /**
  59145. * Sets the global ambient color for the material used in lighting calculations.
  59146. */
  59147. private _globalAmbientColor;
  59148. /**
  59149. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  59150. */
  59151. private _useLogarithmicDepth;
  59152. /**
  59153. * If set to true, no lighting calculations will be applied.
  59154. */
  59155. private _unlit;
  59156. private _debugMode;
  59157. /**
  59158. * @hidden
  59159. * This is reserved for the inspector.
  59160. * Defines the material debug mode.
  59161. * It helps seeing only some components of the material while troubleshooting.
  59162. */
  59163. debugMode: number;
  59164. /**
  59165. * @hidden
  59166. * This is reserved for the inspector.
  59167. * Specify from where on screen the debug mode should start.
  59168. * The value goes from -1 (full screen) to 1 (not visible)
  59169. * It helps with side by side comparison against the final render
  59170. * This defaults to -1
  59171. */
  59172. private debugLimit;
  59173. /**
  59174. * @hidden
  59175. * This is reserved for the inspector.
  59176. * As the default viewing range might not be enough (if the ambient is really small for instance)
  59177. * You can use the factor to better multiply the final value.
  59178. */
  59179. private debugFactor;
  59180. /**
  59181. * Defines the clear coat layer parameters for the material.
  59182. */
  59183. readonly clearCoat: PBRClearCoatConfiguration;
  59184. /**
  59185. * Defines the anisotropic parameters for the material.
  59186. */
  59187. readonly anisotropy: PBRAnisotropicConfiguration;
  59188. /**
  59189. * Defines the BRDF parameters for the material.
  59190. */
  59191. readonly brdf: PBRBRDFConfiguration;
  59192. /**
  59193. * Defines the Sheen parameters for the material.
  59194. */
  59195. readonly sheen: PBRSheenConfiguration;
  59196. /**
  59197. * Defines the SubSurface parameters for the material.
  59198. */
  59199. readonly subSurface: PBRSubSurfaceConfiguration;
  59200. /**
  59201. * Defines the detail map parameters for the material.
  59202. */
  59203. readonly detailMap: DetailMapConfiguration;
  59204. protected _rebuildInParallel: boolean;
  59205. /**
  59206. * Instantiates a new PBRMaterial instance.
  59207. *
  59208. * @param name The material name
  59209. * @param scene The scene the material will be use in.
  59210. */
  59211. constructor(name: string, scene: Scene);
  59212. /**
  59213. * Gets a boolean indicating that current material needs to register RTT
  59214. */
  59215. get hasRenderTargetTextures(): boolean;
  59216. /**
  59217. * Gets the name of the material class.
  59218. */
  59219. getClassName(): string;
  59220. /**
  59221. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  59222. */
  59223. get useLogarithmicDepth(): boolean;
  59224. /**
  59225. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  59226. */
  59227. set useLogarithmicDepth(value: boolean);
  59228. /**
  59229. * Returns true if alpha blending should be disabled.
  59230. */
  59231. protected get _disableAlphaBlending(): boolean;
  59232. /**
  59233. * Specifies whether or not this material should be rendered in alpha blend mode.
  59234. */
  59235. needAlphaBlending(): boolean;
  59236. /**
  59237. * Specifies whether or not this material should be rendered in alpha test mode.
  59238. */
  59239. needAlphaTesting(): boolean;
  59240. /**
  59241. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  59242. */
  59243. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  59244. /**
  59245. * Gets the texture used for the alpha test.
  59246. */
  59247. getAlphaTestTexture(): Nullable<BaseTexture>;
  59248. /**
  59249. * Specifies that the submesh is ready to be used.
  59250. * @param mesh - BJS mesh.
  59251. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  59252. * @param useInstances - Specifies that instances should be used.
  59253. * @returns - boolean indicating that the submesh is ready or not.
  59254. */
  59255. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  59256. /**
  59257. * Specifies if the material uses metallic roughness workflow.
  59258. * @returns boolean specifiying if the material uses metallic roughness workflow.
  59259. */
  59260. isMetallicWorkflow(): boolean;
  59261. private _prepareEffect;
  59262. private _prepareDefines;
  59263. /**
  59264. * Force shader compilation
  59265. */
  59266. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  59267. /**
  59268. * Initializes the uniform buffer layout for the shader.
  59269. */
  59270. buildUniformLayout(): void;
  59271. /**
  59272. * Unbinds the material from the mesh
  59273. */
  59274. unbind(): void;
  59275. /**
  59276. * Binds the submesh data.
  59277. * @param world - The world matrix.
  59278. * @param mesh - The BJS mesh.
  59279. * @param subMesh - A submesh of the BJS mesh.
  59280. */
  59281. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  59282. /**
  59283. * Returns the animatable textures.
  59284. * @returns - Array of animatable textures.
  59285. */
  59286. getAnimatables(): IAnimatable[];
  59287. /**
  59288. * Returns the texture used for reflections.
  59289. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  59290. */
  59291. private _getReflectionTexture;
  59292. /**
  59293. * Returns an array of the actively used textures.
  59294. * @returns - Array of BaseTextures
  59295. */
  59296. getActiveTextures(): BaseTexture[];
  59297. /**
  59298. * Checks to see if a texture is used in the material.
  59299. * @param texture - Base texture to use.
  59300. * @returns - Boolean specifying if a texture is used in the material.
  59301. */
  59302. hasTexture(texture: BaseTexture): boolean;
  59303. /**
  59304. * Sets the required values to the prepass renderer.
  59305. * @param prePassRenderer defines the prepass renderer to setup
  59306. */
  59307. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  59308. /**
  59309. * Disposes the resources of the material.
  59310. * @param forceDisposeEffect - Forces the disposal of effects.
  59311. * @param forceDisposeTextures - Forces the disposal of all textures.
  59312. */
  59313. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  59314. }
  59315. }
  59316. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  59317. import { Nullable } from "babylonjs/types";
  59318. import { Scene } from "babylonjs/scene";
  59319. import { Color3 } from "babylonjs/Maths/math.color";
  59320. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  59321. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  59322. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59323. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  59324. /**
  59325. * The Physically based material of BJS.
  59326. *
  59327. * This offers the main features of a standard PBR material.
  59328. * For more information, please refer to the documentation :
  59329. * https://doc.babylonjs.com/how_to/physically_based_rendering
  59330. */
  59331. export class PBRMaterial extends PBRBaseMaterial {
  59332. /**
  59333. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  59334. */
  59335. static readonly PBRMATERIAL_OPAQUE: number;
  59336. /**
  59337. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  59338. */
  59339. static readonly PBRMATERIAL_ALPHATEST: number;
  59340. /**
  59341. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59342. */
  59343. static readonly PBRMATERIAL_ALPHABLEND: number;
  59344. /**
  59345. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59346. * They are also discarded below the alpha cutoff threshold to improve performances.
  59347. */
  59348. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  59349. /**
  59350. * Defines the default value of how much AO map is occluding the analytical lights
  59351. * (point spot...).
  59352. */
  59353. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  59354. /**
  59355. * Intensity of the direct lights e.g. the four lights available in your scene.
  59356. * This impacts both the direct diffuse and specular highlights.
  59357. */
  59358. directIntensity: number;
  59359. /**
  59360. * Intensity of the emissive part of the material.
  59361. * This helps controlling the emissive effect without modifying the emissive color.
  59362. */
  59363. emissiveIntensity: number;
  59364. /**
  59365. * Intensity of the environment e.g. how much the environment will light the object
  59366. * either through harmonics for rough material or through the refelction for shiny ones.
  59367. */
  59368. environmentIntensity: number;
  59369. /**
  59370. * This is a special control allowing the reduction of the specular highlights coming from the
  59371. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  59372. */
  59373. specularIntensity: number;
  59374. /**
  59375. * Debug Control allowing disabling the bump map on this material.
  59376. */
  59377. disableBumpMap: boolean;
  59378. /**
  59379. * AKA Diffuse Texture in standard nomenclature.
  59380. */
  59381. albedoTexture: BaseTexture;
  59382. /**
  59383. * AKA Occlusion Texture in other nomenclature.
  59384. */
  59385. ambientTexture: BaseTexture;
  59386. /**
  59387. * AKA Occlusion Texture Intensity in other nomenclature.
  59388. */
  59389. ambientTextureStrength: number;
  59390. /**
  59391. * Defines how much the AO map is occluding the analytical lights (point spot...).
  59392. * 1 means it completely occludes it
  59393. * 0 mean it has no impact
  59394. */
  59395. ambientTextureImpactOnAnalyticalLights: number;
  59396. /**
  59397. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  59398. */
  59399. opacityTexture: BaseTexture;
  59400. /**
  59401. * Stores the reflection values in a texture.
  59402. */
  59403. reflectionTexture: Nullable<BaseTexture>;
  59404. /**
  59405. * Stores the emissive values in a texture.
  59406. */
  59407. emissiveTexture: BaseTexture;
  59408. /**
  59409. * AKA Specular texture in other nomenclature.
  59410. */
  59411. reflectivityTexture: BaseTexture;
  59412. /**
  59413. * Used to switch from specular/glossiness to metallic/roughness workflow.
  59414. */
  59415. metallicTexture: BaseTexture;
  59416. /**
  59417. * Specifies the metallic scalar of the metallic/roughness workflow.
  59418. * Can also be used to scale the metalness values of the metallic texture.
  59419. */
  59420. metallic: Nullable<number>;
  59421. /**
  59422. * Specifies the roughness scalar of the metallic/roughness workflow.
  59423. * Can also be used to scale the roughness values of the metallic texture.
  59424. */
  59425. roughness: Nullable<number>;
  59426. /**
  59427. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  59428. * By default the indexOfrefraction is used to compute F0;
  59429. *
  59430. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  59431. *
  59432. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  59433. * F90 = metallicReflectanceColor;
  59434. */
  59435. metallicF0Factor: number;
  59436. /**
  59437. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  59438. * By default the F90 is always 1;
  59439. *
  59440. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  59441. *
  59442. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  59443. * F90 = metallicReflectanceColor;
  59444. */
  59445. metallicReflectanceColor: Color3;
  59446. /**
  59447. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  59448. * This is multiply against the scalar values defined in the material.
  59449. */
  59450. metallicReflectanceTexture: Nullable<BaseTexture>;
  59451. /**
  59452. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  59453. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  59454. */
  59455. microSurfaceTexture: BaseTexture;
  59456. /**
  59457. * Stores surface normal data used to displace a mesh in a texture.
  59458. */
  59459. bumpTexture: BaseTexture;
  59460. /**
  59461. * Stores the pre-calculated light information of a mesh in a texture.
  59462. */
  59463. lightmapTexture: BaseTexture;
  59464. /**
  59465. * Stores the refracted light information in a texture.
  59466. */
  59467. get refractionTexture(): Nullable<BaseTexture>;
  59468. set refractionTexture(value: Nullable<BaseTexture>);
  59469. /**
  59470. * The color of a material in ambient lighting.
  59471. */
  59472. ambientColor: Color3;
  59473. /**
  59474. * AKA Diffuse Color in other nomenclature.
  59475. */
  59476. albedoColor: Color3;
  59477. /**
  59478. * AKA Specular Color in other nomenclature.
  59479. */
  59480. reflectivityColor: Color3;
  59481. /**
  59482. * The color reflected from the material.
  59483. */
  59484. reflectionColor: Color3;
  59485. /**
  59486. * The color emitted from the material.
  59487. */
  59488. emissiveColor: Color3;
  59489. /**
  59490. * AKA Glossiness in other nomenclature.
  59491. */
  59492. microSurface: number;
  59493. /**
  59494. * Index of refraction of the material base layer.
  59495. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  59496. *
  59497. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  59498. *
  59499. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  59500. */
  59501. get indexOfRefraction(): number;
  59502. set indexOfRefraction(value: number);
  59503. /**
  59504. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  59505. */
  59506. get invertRefractionY(): boolean;
  59507. set invertRefractionY(value: boolean);
  59508. /**
  59509. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  59510. * Materials half opaque for instance using refraction could benefit from this control.
  59511. */
  59512. get linkRefractionWithTransparency(): boolean;
  59513. set linkRefractionWithTransparency(value: boolean);
  59514. /**
  59515. * If true, the light map contains occlusion information instead of lighting info.
  59516. */
  59517. useLightmapAsShadowmap: boolean;
  59518. /**
  59519. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  59520. */
  59521. useAlphaFromAlbedoTexture: boolean;
  59522. /**
  59523. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  59524. */
  59525. forceAlphaTest: boolean;
  59526. /**
  59527. * Defines the alpha limits in alpha test mode.
  59528. */
  59529. alphaCutOff: number;
  59530. /**
  59531. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  59532. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  59533. */
  59534. useSpecularOverAlpha: boolean;
  59535. /**
  59536. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  59537. */
  59538. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  59539. /**
  59540. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  59541. */
  59542. useRoughnessFromMetallicTextureAlpha: boolean;
  59543. /**
  59544. * Specifies if the metallic texture contains the roughness information in its green channel.
  59545. */
  59546. useRoughnessFromMetallicTextureGreen: boolean;
  59547. /**
  59548. * Specifies if the metallic texture contains the metallness information in its blue channel.
  59549. */
  59550. useMetallnessFromMetallicTextureBlue: boolean;
  59551. /**
  59552. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  59553. */
  59554. useAmbientOcclusionFromMetallicTextureRed: boolean;
  59555. /**
  59556. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  59557. */
  59558. useAmbientInGrayScale: boolean;
  59559. /**
  59560. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  59561. * The material will try to infer what glossiness each pixel should be.
  59562. */
  59563. useAutoMicroSurfaceFromReflectivityMap: boolean;
  59564. /**
  59565. * BJS is using an harcoded light falloff based on a manually sets up range.
  59566. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  59567. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  59568. */
  59569. get usePhysicalLightFalloff(): boolean;
  59570. /**
  59571. * BJS is using an harcoded light falloff based on a manually sets up range.
  59572. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  59573. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  59574. */
  59575. set usePhysicalLightFalloff(value: boolean);
  59576. /**
  59577. * In order to support the falloff compatibility with gltf, a special mode has been added
  59578. * to reproduce the gltf light falloff.
  59579. */
  59580. get useGLTFLightFalloff(): boolean;
  59581. /**
  59582. * In order to support the falloff compatibility with gltf, a special mode has been added
  59583. * to reproduce the gltf light falloff.
  59584. */
  59585. set useGLTFLightFalloff(value: boolean);
  59586. /**
  59587. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  59588. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  59589. */
  59590. useRadianceOverAlpha: boolean;
  59591. /**
  59592. * Allows using an object space normal map (instead of tangent space).
  59593. */
  59594. useObjectSpaceNormalMap: boolean;
  59595. /**
  59596. * Allows using the bump map in parallax mode.
  59597. */
  59598. useParallax: boolean;
  59599. /**
  59600. * Allows using the bump map in parallax occlusion mode.
  59601. */
  59602. useParallaxOcclusion: boolean;
  59603. /**
  59604. * Controls the scale bias of the parallax mode.
  59605. */
  59606. parallaxScaleBias: number;
  59607. /**
  59608. * If sets to true, disables all the lights affecting the material.
  59609. */
  59610. disableLighting: boolean;
  59611. /**
  59612. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  59613. */
  59614. forceIrradianceInFragment: boolean;
  59615. /**
  59616. * Number of Simultaneous lights allowed on the material.
  59617. */
  59618. maxSimultaneousLights: number;
  59619. /**
  59620. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  59621. */
  59622. invertNormalMapX: boolean;
  59623. /**
  59624. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  59625. */
  59626. invertNormalMapY: boolean;
  59627. /**
  59628. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  59629. */
  59630. twoSidedLighting: boolean;
  59631. /**
  59632. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  59633. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  59634. */
  59635. useAlphaFresnel: boolean;
  59636. /**
  59637. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  59638. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  59639. */
  59640. useLinearAlphaFresnel: boolean;
  59641. /**
  59642. * Let user defines the brdf lookup texture used for IBL.
  59643. * A default 8bit version is embedded but you could point at :
  59644. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  59645. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  59646. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  59647. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  59648. */
  59649. environmentBRDFTexture: Nullable<BaseTexture>;
  59650. /**
  59651. * Force normal to face away from face.
  59652. */
  59653. forceNormalForward: boolean;
  59654. /**
  59655. * Enables specular anti aliasing in the PBR shader.
  59656. * It will both interacts on the Geometry for analytical and IBL lighting.
  59657. * It also prefilter the roughness map based on the bump values.
  59658. */
  59659. enableSpecularAntiAliasing: boolean;
  59660. /**
  59661. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  59662. * makes the reflect vector face the model (under horizon).
  59663. */
  59664. useHorizonOcclusion: boolean;
  59665. /**
  59666. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  59667. * too much the area relying on ambient texture to define their ambient occlusion.
  59668. */
  59669. useRadianceOcclusion: boolean;
  59670. /**
  59671. * If set to true, no lighting calculations will be applied.
  59672. */
  59673. unlit: boolean;
  59674. /**
  59675. * Gets the image processing configuration used either in this material.
  59676. */
  59677. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  59678. /**
  59679. * Sets the Default image processing configuration used either in the this material.
  59680. *
  59681. * If sets to null, the scene one is in use.
  59682. */
  59683. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  59684. /**
  59685. * Gets wether the color curves effect is enabled.
  59686. */
  59687. get cameraColorCurvesEnabled(): boolean;
  59688. /**
  59689. * Sets wether the color curves effect is enabled.
  59690. */
  59691. set cameraColorCurvesEnabled(value: boolean);
  59692. /**
  59693. * Gets wether the color grading effect is enabled.
  59694. */
  59695. get cameraColorGradingEnabled(): boolean;
  59696. /**
  59697. * Gets wether the color grading effect is enabled.
  59698. */
  59699. set cameraColorGradingEnabled(value: boolean);
  59700. /**
  59701. * Gets wether tonemapping is enabled or not.
  59702. */
  59703. get cameraToneMappingEnabled(): boolean;
  59704. /**
  59705. * Sets wether tonemapping is enabled or not
  59706. */
  59707. set cameraToneMappingEnabled(value: boolean);
  59708. /**
  59709. * The camera exposure used on this material.
  59710. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  59711. * This corresponds to a photographic exposure.
  59712. */
  59713. get cameraExposure(): number;
  59714. /**
  59715. * The camera exposure used on this material.
  59716. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  59717. * This corresponds to a photographic exposure.
  59718. */
  59719. set cameraExposure(value: number);
  59720. /**
  59721. * Gets The camera contrast used on this material.
  59722. */
  59723. get cameraContrast(): number;
  59724. /**
  59725. * Sets The camera contrast used on this material.
  59726. */
  59727. set cameraContrast(value: number);
  59728. /**
  59729. * Gets the Color Grading 2D Lookup Texture.
  59730. */
  59731. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  59732. /**
  59733. * Sets the Color Grading 2D Lookup Texture.
  59734. */
  59735. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  59736. /**
  59737. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  59738. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  59739. * 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;
  59740. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  59741. */
  59742. get cameraColorCurves(): Nullable<ColorCurves>;
  59743. /**
  59744. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  59745. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  59746. * 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;
  59747. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  59748. */
  59749. set cameraColorCurves(value: Nullable<ColorCurves>);
  59750. /**
  59751. * Instantiates a new PBRMaterial instance.
  59752. *
  59753. * @param name The material name
  59754. * @param scene The scene the material will be use in.
  59755. */
  59756. constructor(name: string, scene: Scene);
  59757. /**
  59758. * Returns the name of this material class.
  59759. */
  59760. getClassName(): string;
  59761. /**
  59762. * Makes a duplicate of the current material.
  59763. * @param name - name to use for the new material.
  59764. */
  59765. clone(name: string): PBRMaterial;
  59766. /**
  59767. * Serializes this PBR Material.
  59768. * @returns - An object with the serialized material.
  59769. */
  59770. serialize(): any;
  59771. /**
  59772. * Parses a PBR Material from a serialized object.
  59773. * @param source - Serialized object.
  59774. * @param scene - BJS scene instance.
  59775. * @param rootUrl - url for the scene object
  59776. * @returns - PBRMaterial
  59777. */
  59778. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  59779. }
  59780. }
  59781. declare module "babylonjs/Misc/dds" {
  59782. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  59783. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59784. import { Nullable } from "babylonjs/types";
  59785. import { Scene } from "babylonjs/scene";
  59786. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  59787. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59788. /**
  59789. * Direct draw surface info
  59790. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  59791. */
  59792. export interface DDSInfo {
  59793. /**
  59794. * Width of the texture
  59795. */
  59796. width: number;
  59797. /**
  59798. * Width of the texture
  59799. */
  59800. height: number;
  59801. /**
  59802. * Number of Mipmaps for the texture
  59803. * @see https://en.wikipedia.org/wiki/Mipmap
  59804. */
  59805. mipmapCount: number;
  59806. /**
  59807. * If the textures format is a known fourCC format
  59808. * @see https://www.fourcc.org/
  59809. */
  59810. isFourCC: boolean;
  59811. /**
  59812. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  59813. */
  59814. isRGB: boolean;
  59815. /**
  59816. * If the texture is a lumincance format
  59817. */
  59818. isLuminance: boolean;
  59819. /**
  59820. * If this is a cube texture
  59821. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  59822. */
  59823. isCube: boolean;
  59824. /**
  59825. * If the texture is a compressed format eg. FOURCC_DXT1
  59826. */
  59827. isCompressed: boolean;
  59828. /**
  59829. * The dxgiFormat of the texture
  59830. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  59831. */
  59832. dxgiFormat: number;
  59833. /**
  59834. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  59835. */
  59836. textureType: number;
  59837. /**
  59838. * Sphericle polynomial created for the dds texture
  59839. */
  59840. sphericalPolynomial?: SphericalPolynomial;
  59841. }
  59842. /**
  59843. * Class used to provide DDS decompression tools
  59844. */
  59845. export class DDSTools {
  59846. /**
  59847. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  59848. */
  59849. static StoreLODInAlphaChannel: boolean;
  59850. /**
  59851. * Gets DDS information from an array buffer
  59852. * @param data defines the array buffer view to read data from
  59853. * @returns the DDS information
  59854. */
  59855. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  59856. private static _FloatView;
  59857. private static _Int32View;
  59858. private static _ToHalfFloat;
  59859. private static _FromHalfFloat;
  59860. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  59861. private static _GetHalfFloatRGBAArrayBuffer;
  59862. private static _GetFloatRGBAArrayBuffer;
  59863. private static _GetFloatAsUIntRGBAArrayBuffer;
  59864. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  59865. private static _GetRGBAArrayBuffer;
  59866. private static _ExtractLongWordOrder;
  59867. private static _GetRGBArrayBuffer;
  59868. private static _GetLuminanceArrayBuffer;
  59869. /**
  59870. * Uploads DDS Levels to a Babylon Texture
  59871. * @hidden
  59872. */
  59873. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  59874. }
  59875. module "babylonjs/Engines/thinEngine" {
  59876. interface ThinEngine {
  59877. /**
  59878. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  59879. * @param rootUrl defines the url where the file to load is located
  59880. * @param scene defines the current scene
  59881. * @param lodScale defines scale to apply to the mip map selection
  59882. * @param lodOffset defines offset to apply to the mip map selection
  59883. * @param onLoad defines an optional callback raised when the texture is loaded
  59884. * @param onError defines an optional callback raised if there is an issue to load the texture
  59885. * @param format defines the format of the data
  59886. * @param forcedExtension defines the extension to use to pick the right loader
  59887. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  59888. * @returns the cube texture as an InternalTexture
  59889. */
  59890. 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;
  59891. }
  59892. }
  59893. }
  59894. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  59895. import { Nullable } from "babylonjs/types";
  59896. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59897. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  59898. /**
  59899. * Implementation of the DDS Texture Loader.
  59900. * @hidden
  59901. */
  59902. export class _DDSTextureLoader implements IInternalTextureLoader {
  59903. /**
  59904. * Defines wether the loader supports cascade loading the different faces.
  59905. */
  59906. readonly supportCascades: boolean;
  59907. /**
  59908. * This returns if the loader support the current file information.
  59909. * @param extension defines the file extension of the file being loaded
  59910. * @returns true if the loader can load the specified file
  59911. */
  59912. canLoad(extension: string): boolean;
  59913. /**
  59914. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59915. * @param data contains the texture data
  59916. * @param texture defines the BabylonJS internal texture
  59917. * @param createPolynomials will be true if polynomials have been requested
  59918. * @param onLoad defines the callback to trigger once the texture is ready
  59919. * @param onError defines the callback to trigger in case of error
  59920. */
  59921. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59922. /**
  59923. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59924. * @param data contains the texture data
  59925. * @param texture defines the BabylonJS internal texture
  59926. * @param callback defines the method to call once ready to upload
  59927. */
  59928. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59929. }
  59930. }
  59931. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  59932. import { Nullable } from "babylonjs/types";
  59933. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59934. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  59935. /**
  59936. * Implementation of the ENV Texture Loader.
  59937. * @hidden
  59938. */
  59939. export class _ENVTextureLoader implements IInternalTextureLoader {
  59940. /**
  59941. * Defines wether the loader supports cascade loading the different faces.
  59942. */
  59943. readonly supportCascades: boolean;
  59944. /**
  59945. * This returns if the loader support the current file information.
  59946. * @param extension defines the file extension of the file being loaded
  59947. * @returns true if the loader can load the specified file
  59948. */
  59949. canLoad(extension: string): boolean;
  59950. /**
  59951. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59952. * @param data contains the texture data
  59953. * @param texture defines the BabylonJS internal texture
  59954. * @param createPolynomials will be true if polynomials have been requested
  59955. * @param onLoad defines the callback to trigger once the texture is ready
  59956. * @param onError defines the callback to trigger in case of error
  59957. */
  59958. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59959. /**
  59960. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59961. * @param data contains the texture data
  59962. * @param texture defines the BabylonJS internal texture
  59963. * @param callback defines the method to call once ready to upload
  59964. */
  59965. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59966. }
  59967. }
  59968. declare module "babylonjs/Misc/khronosTextureContainer" {
  59969. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59970. /**
  59971. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  59972. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  59973. */
  59974. export class KhronosTextureContainer {
  59975. /** contents of the KTX container file */
  59976. data: ArrayBufferView;
  59977. private static HEADER_LEN;
  59978. private static COMPRESSED_2D;
  59979. private static COMPRESSED_3D;
  59980. private static TEX_2D;
  59981. private static TEX_3D;
  59982. /**
  59983. * Gets the openGL type
  59984. */
  59985. glType: number;
  59986. /**
  59987. * Gets the openGL type size
  59988. */
  59989. glTypeSize: number;
  59990. /**
  59991. * Gets the openGL format
  59992. */
  59993. glFormat: number;
  59994. /**
  59995. * Gets the openGL internal format
  59996. */
  59997. glInternalFormat: number;
  59998. /**
  59999. * Gets the base internal format
  60000. */
  60001. glBaseInternalFormat: number;
  60002. /**
  60003. * Gets image width in pixel
  60004. */
  60005. pixelWidth: number;
  60006. /**
  60007. * Gets image height in pixel
  60008. */
  60009. pixelHeight: number;
  60010. /**
  60011. * Gets image depth in pixels
  60012. */
  60013. pixelDepth: number;
  60014. /**
  60015. * Gets the number of array elements
  60016. */
  60017. numberOfArrayElements: number;
  60018. /**
  60019. * Gets the number of faces
  60020. */
  60021. numberOfFaces: number;
  60022. /**
  60023. * Gets the number of mipmap levels
  60024. */
  60025. numberOfMipmapLevels: number;
  60026. /**
  60027. * Gets the bytes of key value data
  60028. */
  60029. bytesOfKeyValueData: number;
  60030. /**
  60031. * Gets the load type
  60032. */
  60033. loadType: number;
  60034. /**
  60035. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  60036. */
  60037. isInvalid: boolean;
  60038. /**
  60039. * Creates a new KhronosTextureContainer
  60040. * @param data contents of the KTX container file
  60041. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  60042. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  60043. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  60044. */
  60045. constructor(
  60046. /** contents of the KTX container file */
  60047. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  60048. /**
  60049. * Uploads KTX content to a Babylon Texture.
  60050. * It is assumed that the texture has already been created & is currently bound
  60051. * @hidden
  60052. */
  60053. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  60054. private _upload2DCompressedLevels;
  60055. /**
  60056. * Checks if the given data starts with a KTX file identifier.
  60057. * @param data the data to check
  60058. * @returns true if the data is a KTX file or false otherwise
  60059. */
  60060. static IsValid(data: ArrayBufferView): boolean;
  60061. }
  60062. }
  60063. declare module "babylonjs/Misc/khronosTextureContainer2" {
  60064. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60065. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  60066. /**
  60067. * Class for loading KTX2 files
  60068. * !!! Experimental Extension Subject to Changes !!!
  60069. * @hidden
  60070. */
  60071. export class KhronosTextureContainer2 {
  60072. private static _ModulePromise;
  60073. private static _TranscodeFormat;
  60074. constructor(engine: ThinEngine);
  60075. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  60076. private _determineTranscodeFormat;
  60077. /**
  60078. * Checks if the given data starts with a KTX2 file identifier.
  60079. * @param data the data to check
  60080. * @returns true if the data is a KTX2 file or false otherwise
  60081. */
  60082. static IsValid(data: ArrayBufferView): boolean;
  60083. }
  60084. }
  60085. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  60086. import { Nullable } from "babylonjs/types";
  60087. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60088. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  60089. /**
  60090. * Implementation of the KTX Texture Loader.
  60091. * @hidden
  60092. */
  60093. export class _KTXTextureLoader implements IInternalTextureLoader {
  60094. /**
  60095. * Defines wether the loader supports cascade loading the different faces.
  60096. */
  60097. readonly supportCascades: boolean;
  60098. /**
  60099. * This returns if the loader support the current file information.
  60100. * @param extension defines the file extension of the file being loaded
  60101. * @param mimeType defines the optional mime type of the file being loaded
  60102. * @returns true if the loader can load the specified file
  60103. */
  60104. canLoad(extension: string, mimeType?: string): boolean;
  60105. /**
  60106. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60107. * @param data contains the texture data
  60108. * @param texture defines the BabylonJS internal texture
  60109. * @param createPolynomials will be true if polynomials have been requested
  60110. * @param onLoad defines the callback to trigger once the texture is ready
  60111. * @param onError defines the callback to trigger in case of error
  60112. */
  60113. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60114. /**
  60115. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60116. * @param data contains the texture data
  60117. * @param texture defines the BabylonJS internal texture
  60118. * @param callback defines the method to call once ready to upload
  60119. */
  60120. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  60121. }
  60122. }
  60123. declare module "babylonjs/Helpers/sceneHelpers" {
  60124. import { Nullable } from "babylonjs/types";
  60125. import { Mesh } from "babylonjs/Meshes/mesh";
  60126. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60127. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  60128. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  60129. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  60130. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  60131. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  60132. import "babylonjs/Meshes/Builders/boxBuilder";
  60133. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  60134. /** @hidden */
  60135. export var _forceSceneHelpersToBundle: boolean;
  60136. module "babylonjs/scene" {
  60137. interface Scene {
  60138. /**
  60139. * Creates a default light for the scene.
  60140. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  60141. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  60142. */
  60143. createDefaultLight(replace?: boolean): void;
  60144. /**
  60145. * Creates a default camera for the scene.
  60146. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  60147. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  60148. * @param replace has default false, when true replaces the active camera in the scene
  60149. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  60150. */
  60151. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  60152. /**
  60153. * Creates a default camera and a default light.
  60154. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  60155. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  60156. * @param replace has the default false, when true replaces the active camera/light in the scene
  60157. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  60158. */
  60159. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  60160. /**
  60161. * Creates a new sky box
  60162. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  60163. * @param environmentTexture defines the texture to use as environment texture
  60164. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  60165. * @param scale defines the overall scale of the skybox
  60166. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  60167. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  60168. * @returns a new mesh holding the sky box
  60169. */
  60170. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  60171. /**
  60172. * Creates a new environment
  60173. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  60174. * @param options defines the options you can use to configure the environment
  60175. * @returns the new EnvironmentHelper
  60176. */
  60177. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  60178. /**
  60179. * Creates a new VREXperienceHelper
  60180. * @see https://doc.babylonjs.com/how_to/webvr_helper
  60181. * @param webVROptions defines the options used to create the new VREXperienceHelper
  60182. * @returns a new VREXperienceHelper
  60183. */
  60184. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  60185. /**
  60186. * Creates a new WebXRDefaultExperience
  60187. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  60188. * @param options experience options
  60189. * @returns a promise for a new WebXRDefaultExperience
  60190. */
  60191. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  60192. }
  60193. }
  60194. }
  60195. declare module "babylonjs/Helpers/videoDome" {
  60196. import { Scene } from "babylonjs/scene";
  60197. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60198. import { Mesh } from "babylonjs/Meshes/mesh";
  60199. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  60200. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  60201. import "babylonjs/Meshes/Builders/sphereBuilder";
  60202. /**
  60203. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  60204. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  60205. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  60206. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  60207. */
  60208. export class VideoDome extends TransformNode {
  60209. /**
  60210. * Define the video source as a Monoscopic panoramic 360 video.
  60211. */
  60212. static readonly MODE_MONOSCOPIC: number;
  60213. /**
  60214. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  60215. */
  60216. static readonly MODE_TOPBOTTOM: number;
  60217. /**
  60218. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  60219. */
  60220. static readonly MODE_SIDEBYSIDE: number;
  60221. private _halfDome;
  60222. private _useDirectMapping;
  60223. /**
  60224. * The video texture being displayed on the sphere
  60225. */
  60226. protected _videoTexture: VideoTexture;
  60227. /**
  60228. * Gets the video texture being displayed on the sphere
  60229. */
  60230. get videoTexture(): VideoTexture;
  60231. /**
  60232. * The skybox material
  60233. */
  60234. protected _material: BackgroundMaterial;
  60235. /**
  60236. * The surface used for the video dome
  60237. */
  60238. protected _mesh: Mesh;
  60239. /**
  60240. * Gets the mesh used for the video dome.
  60241. */
  60242. get mesh(): Mesh;
  60243. /**
  60244. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  60245. */
  60246. private _halfDomeMask;
  60247. /**
  60248. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  60249. * Also see the options.resolution property.
  60250. */
  60251. get fovMultiplier(): number;
  60252. set fovMultiplier(value: number);
  60253. private _videoMode;
  60254. /**
  60255. * Gets or set the current video mode for the video. It can be:
  60256. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  60257. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  60258. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  60259. */
  60260. get videoMode(): number;
  60261. set videoMode(value: number);
  60262. /**
  60263. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  60264. *
  60265. */
  60266. get halfDome(): boolean;
  60267. /**
  60268. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  60269. */
  60270. set halfDome(enabled: boolean);
  60271. /**
  60272. * Oberserver used in Stereoscopic VR Mode.
  60273. */
  60274. private _onBeforeCameraRenderObserver;
  60275. /**
  60276. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  60277. * @param name Element's name, child elements will append suffixes for their own names.
  60278. * @param urlsOrVideo defines the url(s) or the video element to use
  60279. * @param options An object containing optional or exposed sub element properties
  60280. */
  60281. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  60282. resolution?: number;
  60283. clickToPlay?: boolean;
  60284. autoPlay?: boolean;
  60285. loop?: boolean;
  60286. size?: number;
  60287. poster?: string;
  60288. faceForward?: boolean;
  60289. useDirectMapping?: boolean;
  60290. halfDomeMode?: boolean;
  60291. }, scene: Scene);
  60292. private _changeVideoMode;
  60293. /**
  60294. * Releases resources associated with this node.
  60295. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  60296. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  60297. */
  60298. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  60299. }
  60300. }
  60301. declare module "babylonjs/Helpers/index" {
  60302. export * from "babylonjs/Helpers/environmentHelper";
  60303. export * from "babylonjs/Helpers/photoDome";
  60304. export * from "babylonjs/Helpers/sceneHelpers";
  60305. export * from "babylonjs/Helpers/videoDome";
  60306. }
  60307. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  60308. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  60309. import { IDisposable } from "babylonjs/scene";
  60310. import { Engine } from "babylonjs/Engines/engine";
  60311. /**
  60312. * This class can be used to get instrumentation data from a Babylon engine
  60313. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  60314. */
  60315. export class EngineInstrumentation implements IDisposable {
  60316. /**
  60317. * Define the instrumented engine.
  60318. */
  60319. engine: Engine;
  60320. private _captureGPUFrameTime;
  60321. private _gpuFrameTimeToken;
  60322. private _gpuFrameTime;
  60323. private _captureShaderCompilationTime;
  60324. private _shaderCompilationTime;
  60325. private _onBeginFrameObserver;
  60326. private _onEndFrameObserver;
  60327. private _onBeforeShaderCompilationObserver;
  60328. private _onAfterShaderCompilationObserver;
  60329. /**
  60330. * Gets the perf counter used for GPU frame time
  60331. */
  60332. get gpuFrameTimeCounter(): PerfCounter;
  60333. /**
  60334. * Gets the GPU frame time capture status
  60335. */
  60336. get captureGPUFrameTime(): boolean;
  60337. /**
  60338. * Enable or disable the GPU frame time capture
  60339. */
  60340. set captureGPUFrameTime(value: boolean);
  60341. /**
  60342. * Gets the perf counter used for shader compilation time
  60343. */
  60344. get shaderCompilationTimeCounter(): PerfCounter;
  60345. /**
  60346. * Gets the shader compilation time capture status
  60347. */
  60348. get captureShaderCompilationTime(): boolean;
  60349. /**
  60350. * Enable or disable the shader compilation time capture
  60351. */
  60352. set captureShaderCompilationTime(value: boolean);
  60353. /**
  60354. * Instantiates a new engine instrumentation.
  60355. * This class can be used to get instrumentation data from a Babylon engine
  60356. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  60357. * @param engine Defines the engine to instrument
  60358. */
  60359. constructor(
  60360. /**
  60361. * Define the instrumented engine.
  60362. */
  60363. engine: Engine);
  60364. /**
  60365. * Dispose and release associated resources.
  60366. */
  60367. dispose(): void;
  60368. }
  60369. }
  60370. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  60371. import { Scene, IDisposable } from "babylonjs/scene";
  60372. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  60373. /**
  60374. * This class can be used to get instrumentation data from a Babylon engine
  60375. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  60376. */
  60377. export class SceneInstrumentation implements IDisposable {
  60378. /**
  60379. * Defines the scene to instrument
  60380. */
  60381. scene: Scene;
  60382. private _captureActiveMeshesEvaluationTime;
  60383. private _activeMeshesEvaluationTime;
  60384. private _captureRenderTargetsRenderTime;
  60385. private _renderTargetsRenderTime;
  60386. private _captureFrameTime;
  60387. private _frameTime;
  60388. private _captureRenderTime;
  60389. private _renderTime;
  60390. private _captureInterFrameTime;
  60391. private _interFrameTime;
  60392. private _captureParticlesRenderTime;
  60393. private _particlesRenderTime;
  60394. private _captureSpritesRenderTime;
  60395. private _spritesRenderTime;
  60396. private _capturePhysicsTime;
  60397. private _physicsTime;
  60398. private _captureAnimationsTime;
  60399. private _animationsTime;
  60400. private _captureCameraRenderTime;
  60401. private _cameraRenderTime;
  60402. private _onBeforeActiveMeshesEvaluationObserver;
  60403. private _onAfterActiveMeshesEvaluationObserver;
  60404. private _onBeforeRenderTargetsRenderObserver;
  60405. private _onAfterRenderTargetsRenderObserver;
  60406. private _onAfterRenderObserver;
  60407. private _onBeforeDrawPhaseObserver;
  60408. private _onAfterDrawPhaseObserver;
  60409. private _onBeforeAnimationsObserver;
  60410. private _onBeforeParticlesRenderingObserver;
  60411. private _onAfterParticlesRenderingObserver;
  60412. private _onBeforeSpritesRenderingObserver;
  60413. private _onAfterSpritesRenderingObserver;
  60414. private _onBeforePhysicsObserver;
  60415. private _onAfterPhysicsObserver;
  60416. private _onAfterAnimationsObserver;
  60417. private _onBeforeCameraRenderObserver;
  60418. private _onAfterCameraRenderObserver;
  60419. /**
  60420. * Gets the perf counter used for active meshes evaluation time
  60421. */
  60422. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  60423. /**
  60424. * Gets the active meshes evaluation time capture status
  60425. */
  60426. get captureActiveMeshesEvaluationTime(): boolean;
  60427. /**
  60428. * Enable or disable the active meshes evaluation time capture
  60429. */
  60430. set captureActiveMeshesEvaluationTime(value: boolean);
  60431. /**
  60432. * Gets the perf counter used for render targets render time
  60433. */
  60434. get renderTargetsRenderTimeCounter(): PerfCounter;
  60435. /**
  60436. * Gets the render targets render time capture status
  60437. */
  60438. get captureRenderTargetsRenderTime(): boolean;
  60439. /**
  60440. * Enable or disable the render targets render time capture
  60441. */
  60442. set captureRenderTargetsRenderTime(value: boolean);
  60443. /**
  60444. * Gets the perf counter used for particles render time
  60445. */
  60446. get particlesRenderTimeCounter(): PerfCounter;
  60447. /**
  60448. * Gets the particles render time capture status
  60449. */
  60450. get captureParticlesRenderTime(): boolean;
  60451. /**
  60452. * Enable or disable the particles render time capture
  60453. */
  60454. set captureParticlesRenderTime(value: boolean);
  60455. /**
  60456. * Gets the perf counter used for sprites render time
  60457. */
  60458. get spritesRenderTimeCounter(): PerfCounter;
  60459. /**
  60460. * Gets the sprites render time capture status
  60461. */
  60462. get captureSpritesRenderTime(): boolean;
  60463. /**
  60464. * Enable or disable the sprites render time capture
  60465. */
  60466. set captureSpritesRenderTime(value: boolean);
  60467. /**
  60468. * Gets the perf counter used for physics time
  60469. */
  60470. get physicsTimeCounter(): PerfCounter;
  60471. /**
  60472. * Gets the physics time capture status
  60473. */
  60474. get capturePhysicsTime(): boolean;
  60475. /**
  60476. * Enable or disable the physics time capture
  60477. */
  60478. set capturePhysicsTime(value: boolean);
  60479. /**
  60480. * Gets the perf counter used for animations time
  60481. */
  60482. get animationsTimeCounter(): PerfCounter;
  60483. /**
  60484. * Gets the animations time capture status
  60485. */
  60486. get captureAnimationsTime(): boolean;
  60487. /**
  60488. * Enable or disable the animations time capture
  60489. */
  60490. set captureAnimationsTime(value: boolean);
  60491. /**
  60492. * Gets the perf counter used for frame time capture
  60493. */
  60494. get frameTimeCounter(): PerfCounter;
  60495. /**
  60496. * Gets the frame time capture status
  60497. */
  60498. get captureFrameTime(): boolean;
  60499. /**
  60500. * Enable or disable the frame time capture
  60501. */
  60502. set captureFrameTime(value: boolean);
  60503. /**
  60504. * Gets the perf counter used for inter-frames time capture
  60505. */
  60506. get interFrameTimeCounter(): PerfCounter;
  60507. /**
  60508. * Gets the inter-frames time capture status
  60509. */
  60510. get captureInterFrameTime(): boolean;
  60511. /**
  60512. * Enable or disable the inter-frames time capture
  60513. */
  60514. set captureInterFrameTime(value: boolean);
  60515. /**
  60516. * Gets the perf counter used for render time capture
  60517. */
  60518. get renderTimeCounter(): PerfCounter;
  60519. /**
  60520. * Gets the render time capture status
  60521. */
  60522. get captureRenderTime(): boolean;
  60523. /**
  60524. * Enable or disable the render time capture
  60525. */
  60526. set captureRenderTime(value: boolean);
  60527. /**
  60528. * Gets the perf counter used for camera render time capture
  60529. */
  60530. get cameraRenderTimeCounter(): PerfCounter;
  60531. /**
  60532. * Gets the camera render time capture status
  60533. */
  60534. get captureCameraRenderTime(): boolean;
  60535. /**
  60536. * Enable or disable the camera render time capture
  60537. */
  60538. set captureCameraRenderTime(value: boolean);
  60539. /**
  60540. * Gets the perf counter used for draw calls
  60541. */
  60542. get drawCallsCounter(): PerfCounter;
  60543. /**
  60544. * Instantiates a new scene instrumentation.
  60545. * This class can be used to get instrumentation data from a Babylon engine
  60546. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  60547. * @param scene Defines the scene to instrument
  60548. */
  60549. constructor(
  60550. /**
  60551. * Defines the scene to instrument
  60552. */
  60553. scene: Scene);
  60554. /**
  60555. * Dispose and release associated resources.
  60556. */
  60557. dispose(): void;
  60558. }
  60559. }
  60560. declare module "babylonjs/Instrumentation/index" {
  60561. export * from "babylonjs/Instrumentation/engineInstrumentation";
  60562. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  60563. export * from "babylonjs/Instrumentation/timeToken";
  60564. }
  60565. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  60566. /** @hidden */
  60567. export var glowMapGenerationPixelShader: {
  60568. name: string;
  60569. shader: string;
  60570. };
  60571. }
  60572. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  60573. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60574. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60575. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60576. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60577. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  60578. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60579. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60580. /** @hidden */
  60581. export var glowMapGenerationVertexShader: {
  60582. name: string;
  60583. shader: string;
  60584. };
  60585. }
  60586. declare module "babylonjs/Layers/effectLayer" {
  60587. import { Observable } from "babylonjs/Misc/observable";
  60588. import { Nullable } from "babylonjs/types";
  60589. import { Camera } from "babylonjs/Cameras/camera";
  60590. import { Scene } from "babylonjs/scene";
  60591. import { ISize } from "babylonjs/Maths/math.size";
  60592. import { Color4 } from "babylonjs/Maths/math.color";
  60593. import { Engine } from "babylonjs/Engines/engine";
  60594. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60595. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60596. import { Mesh } from "babylonjs/Meshes/mesh";
  60597. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60598. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60599. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60600. import { Effect } from "babylonjs/Materials/effect";
  60601. import { Material } from "babylonjs/Materials/material";
  60602. import "babylonjs/Shaders/glowMapGeneration.fragment";
  60603. import "babylonjs/Shaders/glowMapGeneration.vertex";
  60604. /**
  60605. * Effect layer options. This helps customizing the behaviour
  60606. * of the effect layer.
  60607. */
  60608. export interface IEffectLayerOptions {
  60609. /**
  60610. * Multiplication factor apply to the canvas size to compute the render target size
  60611. * used to generated the objects (the smaller the faster).
  60612. */
  60613. mainTextureRatio: number;
  60614. /**
  60615. * Enforces a fixed size texture to ensure effect stability across devices.
  60616. */
  60617. mainTextureFixedSize?: number;
  60618. /**
  60619. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  60620. */
  60621. alphaBlendingMode: number;
  60622. /**
  60623. * The camera attached to the layer.
  60624. */
  60625. camera: Nullable<Camera>;
  60626. /**
  60627. * The rendering group to draw the layer in.
  60628. */
  60629. renderingGroupId: number;
  60630. }
  60631. /**
  60632. * The effect layer Helps adding post process effect blended with the main pass.
  60633. *
  60634. * This can be for instance use to generate glow or higlight effects on the scene.
  60635. *
  60636. * The effect layer class can not be used directly and is intented to inherited from to be
  60637. * customized per effects.
  60638. */
  60639. export abstract class EffectLayer {
  60640. private _vertexBuffers;
  60641. private _indexBuffer;
  60642. private _cachedDefines;
  60643. private _effectLayerMapGenerationEffect;
  60644. private _effectLayerOptions;
  60645. private _mergeEffect;
  60646. protected _scene: Scene;
  60647. protected _engine: Engine;
  60648. protected _maxSize: number;
  60649. protected _mainTextureDesiredSize: ISize;
  60650. protected _mainTexture: RenderTargetTexture;
  60651. protected _shouldRender: boolean;
  60652. protected _postProcesses: PostProcess[];
  60653. protected _textures: BaseTexture[];
  60654. protected _emissiveTextureAndColor: {
  60655. texture: Nullable<BaseTexture>;
  60656. color: Color4;
  60657. };
  60658. /**
  60659. * The name of the layer
  60660. */
  60661. name: string;
  60662. /**
  60663. * The clear color of the texture used to generate the glow map.
  60664. */
  60665. neutralColor: Color4;
  60666. /**
  60667. * Specifies whether the highlight layer is enabled or not.
  60668. */
  60669. isEnabled: boolean;
  60670. /**
  60671. * Gets the camera attached to the layer.
  60672. */
  60673. get camera(): Nullable<Camera>;
  60674. /**
  60675. * Gets the rendering group id the layer should render in.
  60676. */
  60677. get renderingGroupId(): number;
  60678. set renderingGroupId(renderingGroupId: number);
  60679. /**
  60680. * An event triggered when the effect layer has been disposed.
  60681. */
  60682. onDisposeObservable: Observable<EffectLayer>;
  60683. /**
  60684. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  60685. */
  60686. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  60687. /**
  60688. * An event triggered when the generated texture is being merged in the scene.
  60689. */
  60690. onBeforeComposeObservable: Observable<EffectLayer>;
  60691. /**
  60692. * An event triggered when the mesh is rendered into the effect render target.
  60693. */
  60694. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  60695. /**
  60696. * An event triggered after the mesh has been rendered into the effect render target.
  60697. */
  60698. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  60699. /**
  60700. * An event triggered when the generated texture has been merged in the scene.
  60701. */
  60702. onAfterComposeObservable: Observable<EffectLayer>;
  60703. /**
  60704. * An event triggered when the efffect layer changes its size.
  60705. */
  60706. onSizeChangedObservable: Observable<EffectLayer>;
  60707. /** @hidden */
  60708. static _SceneComponentInitialization: (scene: Scene) => void;
  60709. /**
  60710. * Instantiates a new effect Layer and references it in the scene.
  60711. * @param name The name of the layer
  60712. * @param scene The scene to use the layer in
  60713. */
  60714. constructor(
  60715. /** The Friendly of the effect in the scene */
  60716. name: string, scene: Scene);
  60717. /**
  60718. * Get the effect name of the layer.
  60719. * @return The effect name
  60720. */
  60721. abstract getEffectName(): string;
  60722. /**
  60723. * Checks for the readiness of the element composing the layer.
  60724. * @param subMesh the mesh to check for
  60725. * @param useInstances specify whether or not to use instances to render the mesh
  60726. * @return true if ready otherwise, false
  60727. */
  60728. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60729. /**
  60730. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  60731. * @returns true if the effect requires stencil during the main canvas render pass.
  60732. */
  60733. abstract needStencil(): boolean;
  60734. /**
  60735. * Create the merge effect. This is the shader use to blit the information back
  60736. * to the main canvas at the end of the scene rendering.
  60737. * @returns The effect containing the shader used to merge the effect on the main canvas
  60738. */
  60739. protected abstract _createMergeEffect(): Effect;
  60740. /**
  60741. * Creates the render target textures and post processes used in the effect layer.
  60742. */
  60743. protected abstract _createTextureAndPostProcesses(): void;
  60744. /**
  60745. * Implementation specific of rendering the generating effect on the main canvas.
  60746. * @param effect The effect used to render through
  60747. */
  60748. protected abstract _internalRender(effect: Effect): void;
  60749. /**
  60750. * Sets the required values for both the emissive texture and and the main color.
  60751. */
  60752. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60753. /**
  60754. * Free any resources and references associated to a mesh.
  60755. * Internal use
  60756. * @param mesh The mesh to free.
  60757. */
  60758. abstract _disposeMesh(mesh: Mesh): void;
  60759. /**
  60760. * Serializes this layer (Glow or Highlight for example)
  60761. * @returns a serialized layer object
  60762. */
  60763. abstract serialize?(): any;
  60764. /**
  60765. * Initializes the effect layer with the required options.
  60766. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  60767. */
  60768. protected _init(options: Partial<IEffectLayerOptions>): void;
  60769. /**
  60770. * Generates the index buffer of the full screen quad blending to the main canvas.
  60771. */
  60772. private _generateIndexBuffer;
  60773. /**
  60774. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  60775. */
  60776. private _generateVertexBuffer;
  60777. /**
  60778. * Sets the main texture desired size which is the closest power of two
  60779. * of the engine canvas size.
  60780. */
  60781. private _setMainTextureSize;
  60782. /**
  60783. * Creates the main texture for the effect layer.
  60784. */
  60785. protected _createMainTexture(): void;
  60786. /**
  60787. * Adds specific effects defines.
  60788. * @param defines The defines to add specifics to.
  60789. */
  60790. protected _addCustomEffectDefines(defines: string[]): void;
  60791. /**
  60792. * Checks for the readiness of the element composing the layer.
  60793. * @param subMesh the mesh to check for
  60794. * @param useInstances specify whether or not to use instances to render the mesh
  60795. * @param emissiveTexture the associated emissive texture used to generate the glow
  60796. * @return true if ready otherwise, false
  60797. */
  60798. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  60799. /**
  60800. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  60801. */
  60802. render(): void;
  60803. /**
  60804. * Determine if a given mesh will be used in the current effect.
  60805. * @param mesh mesh to test
  60806. * @returns true if the mesh will be used
  60807. */
  60808. hasMesh(mesh: AbstractMesh): boolean;
  60809. /**
  60810. * Returns true if the layer contains information to display, otherwise false.
  60811. * @returns true if the glow layer should be rendered
  60812. */
  60813. shouldRender(): boolean;
  60814. /**
  60815. * Returns true if the mesh should render, otherwise false.
  60816. * @param mesh The mesh to render
  60817. * @returns true if it should render otherwise false
  60818. */
  60819. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  60820. /**
  60821. * Returns true if the mesh can be rendered, otherwise false.
  60822. * @param mesh The mesh to render
  60823. * @param material The material used on the mesh
  60824. * @returns true if it can be rendered otherwise false
  60825. */
  60826. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60827. /**
  60828. * Returns true if the mesh should render, otherwise false.
  60829. * @param mesh The mesh to render
  60830. * @returns true if it should render otherwise false
  60831. */
  60832. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  60833. /**
  60834. * Renders the submesh passed in parameter to the generation map.
  60835. */
  60836. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  60837. /**
  60838. * Defines whether the current material of the mesh should be use to render the effect.
  60839. * @param mesh defines the current mesh to render
  60840. */
  60841. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  60842. /**
  60843. * Rebuild the required buffers.
  60844. * @hidden Internal use only.
  60845. */
  60846. _rebuild(): void;
  60847. /**
  60848. * Dispose only the render target textures and post process.
  60849. */
  60850. private _disposeTextureAndPostProcesses;
  60851. /**
  60852. * Dispose the highlight layer and free resources.
  60853. */
  60854. dispose(): void;
  60855. /**
  60856. * Gets the class name of the effect layer
  60857. * @returns the string with the class name of the effect layer
  60858. */
  60859. getClassName(): string;
  60860. /**
  60861. * Creates an effect layer from parsed effect layer data
  60862. * @param parsedEffectLayer defines effect layer data
  60863. * @param scene defines the current scene
  60864. * @param rootUrl defines the root URL containing the effect layer information
  60865. * @returns a parsed effect Layer
  60866. */
  60867. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  60868. }
  60869. }
  60870. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  60871. import { Scene } from "babylonjs/scene";
  60872. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  60873. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  60874. import { AbstractScene } from "babylonjs/abstractScene";
  60875. module "babylonjs/abstractScene" {
  60876. interface AbstractScene {
  60877. /**
  60878. * The list of effect layers (highlights/glow) added to the scene
  60879. * @see https://doc.babylonjs.com/how_to/highlight_layer
  60880. * @see https://doc.babylonjs.com/how_to/glow_layer
  60881. */
  60882. effectLayers: Array<EffectLayer>;
  60883. /**
  60884. * Removes the given effect layer from this scene.
  60885. * @param toRemove defines the effect layer to remove
  60886. * @returns the index of the removed effect layer
  60887. */
  60888. removeEffectLayer(toRemove: EffectLayer): number;
  60889. /**
  60890. * Adds the given effect layer to this scene
  60891. * @param newEffectLayer defines the effect layer to add
  60892. */
  60893. addEffectLayer(newEffectLayer: EffectLayer): void;
  60894. }
  60895. }
  60896. /**
  60897. * Defines the layer scene component responsible to manage any effect layers
  60898. * in a given scene.
  60899. */
  60900. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  60901. /**
  60902. * The component name helpfull to identify the component in the list of scene components.
  60903. */
  60904. readonly name: string;
  60905. /**
  60906. * The scene the component belongs to.
  60907. */
  60908. scene: Scene;
  60909. private _engine;
  60910. private _renderEffects;
  60911. private _needStencil;
  60912. private _previousStencilState;
  60913. /**
  60914. * Creates a new instance of the component for the given scene
  60915. * @param scene Defines the scene to register the component in
  60916. */
  60917. constructor(scene: Scene);
  60918. /**
  60919. * Registers the component in a given scene
  60920. */
  60921. register(): void;
  60922. /**
  60923. * Rebuilds the elements related to this component in case of
  60924. * context lost for instance.
  60925. */
  60926. rebuild(): void;
  60927. /**
  60928. * Serializes the component data to the specified json object
  60929. * @param serializationObject The object to serialize to
  60930. */
  60931. serialize(serializationObject: any): void;
  60932. /**
  60933. * Adds all the elements from the container to the scene
  60934. * @param container the container holding the elements
  60935. */
  60936. addFromContainer(container: AbstractScene): void;
  60937. /**
  60938. * Removes all the elements in the container from the scene
  60939. * @param container contains the elements to remove
  60940. * @param dispose if the removed element should be disposed (default: false)
  60941. */
  60942. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60943. /**
  60944. * Disposes the component and the associated ressources.
  60945. */
  60946. dispose(): void;
  60947. private _isReadyForMesh;
  60948. private _renderMainTexture;
  60949. private _setStencil;
  60950. private _setStencilBack;
  60951. private _draw;
  60952. private _drawCamera;
  60953. private _drawRenderingGroup;
  60954. }
  60955. }
  60956. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  60957. /** @hidden */
  60958. export var glowMapMergePixelShader: {
  60959. name: string;
  60960. shader: string;
  60961. };
  60962. }
  60963. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  60964. /** @hidden */
  60965. export var glowMapMergeVertexShader: {
  60966. name: string;
  60967. shader: string;
  60968. };
  60969. }
  60970. declare module "babylonjs/Layers/glowLayer" {
  60971. import { Nullable } from "babylonjs/types";
  60972. import { Camera } from "babylonjs/Cameras/camera";
  60973. import { Scene } from "babylonjs/scene";
  60974. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60975. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60976. import { Mesh } from "babylonjs/Meshes/mesh";
  60977. import { Texture } from "babylonjs/Materials/Textures/texture";
  60978. import { Effect } from "babylonjs/Materials/effect";
  60979. import { Material } from "babylonjs/Materials/material";
  60980. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  60981. import { Color4 } from "babylonjs/Maths/math.color";
  60982. import "babylonjs/Shaders/glowMapMerge.fragment";
  60983. import "babylonjs/Shaders/glowMapMerge.vertex";
  60984. import "babylonjs/Layers/effectLayerSceneComponent";
  60985. module "babylonjs/abstractScene" {
  60986. interface AbstractScene {
  60987. /**
  60988. * Return a the first highlight layer of the scene with a given name.
  60989. * @param name The name of the highlight layer to look for.
  60990. * @return The highlight layer if found otherwise null.
  60991. */
  60992. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  60993. }
  60994. }
  60995. /**
  60996. * Glow layer options. This helps customizing the behaviour
  60997. * of the glow layer.
  60998. */
  60999. export interface IGlowLayerOptions {
  61000. /**
  61001. * Multiplication factor apply to the canvas size to compute the render target size
  61002. * used to generated the glowing objects (the smaller the faster).
  61003. */
  61004. mainTextureRatio: number;
  61005. /**
  61006. * Enforces a fixed size texture to ensure resize independant blur.
  61007. */
  61008. mainTextureFixedSize?: number;
  61009. /**
  61010. * How big is the kernel of the blur texture.
  61011. */
  61012. blurKernelSize: number;
  61013. /**
  61014. * The camera attached to the layer.
  61015. */
  61016. camera: Nullable<Camera>;
  61017. /**
  61018. * Enable MSAA by chosing the number of samples.
  61019. */
  61020. mainTextureSamples?: number;
  61021. /**
  61022. * The rendering group to draw the layer in.
  61023. */
  61024. renderingGroupId: number;
  61025. }
  61026. /**
  61027. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  61028. *
  61029. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  61030. *
  61031. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  61032. */
  61033. export class GlowLayer extends EffectLayer {
  61034. /**
  61035. * Effect Name of the layer.
  61036. */
  61037. static readonly EffectName: string;
  61038. /**
  61039. * The default blur kernel size used for the glow.
  61040. */
  61041. static DefaultBlurKernelSize: number;
  61042. /**
  61043. * The default texture size ratio used for the glow.
  61044. */
  61045. static DefaultTextureRatio: number;
  61046. /**
  61047. * Sets the kernel size of the blur.
  61048. */
  61049. set blurKernelSize(value: number);
  61050. /**
  61051. * Gets the kernel size of the blur.
  61052. */
  61053. get blurKernelSize(): number;
  61054. /**
  61055. * Sets the glow intensity.
  61056. */
  61057. set intensity(value: number);
  61058. /**
  61059. * Gets the glow intensity.
  61060. */
  61061. get intensity(): number;
  61062. private _options;
  61063. private _intensity;
  61064. private _horizontalBlurPostprocess1;
  61065. private _verticalBlurPostprocess1;
  61066. private _horizontalBlurPostprocess2;
  61067. private _verticalBlurPostprocess2;
  61068. private _blurTexture1;
  61069. private _blurTexture2;
  61070. private _postProcesses1;
  61071. private _postProcesses2;
  61072. private _includedOnlyMeshes;
  61073. private _excludedMeshes;
  61074. private _meshesUsingTheirOwnMaterials;
  61075. /**
  61076. * Callback used to let the user override the color selection on a per mesh basis
  61077. */
  61078. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  61079. /**
  61080. * Callback used to let the user override the texture selection on a per mesh basis
  61081. */
  61082. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  61083. /**
  61084. * Instantiates a new glow Layer and references it to the scene.
  61085. * @param name The name of the layer
  61086. * @param scene The scene to use the layer in
  61087. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  61088. */
  61089. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  61090. /**
  61091. * Get the effect name of the layer.
  61092. * @return The effect name
  61093. */
  61094. getEffectName(): string;
  61095. /**
  61096. * Create the merge effect. This is the shader use to blit the information back
  61097. * to the main canvas at the end of the scene rendering.
  61098. */
  61099. protected _createMergeEffect(): Effect;
  61100. /**
  61101. * Creates the render target textures and post processes used in the glow layer.
  61102. */
  61103. protected _createTextureAndPostProcesses(): void;
  61104. /**
  61105. * Checks for the readiness of the element composing the layer.
  61106. * @param subMesh the mesh to check for
  61107. * @param useInstances specify wether or not to use instances to render the mesh
  61108. * @param emissiveTexture the associated emissive texture used to generate the glow
  61109. * @return true if ready otherwise, false
  61110. */
  61111. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61112. /**
  61113. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  61114. */
  61115. needStencil(): boolean;
  61116. /**
  61117. * Returns true if the mesh can be rendered, otherwise false.
  61118. * @param mesh The mesh to render
  61119. * @param material The material used on the mesh
  61120. * @returns true if it can be rendered otherwise false
  61121. */
  61122. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  61123. /**
  61124. * Implementation specific of rendering the generating effect on the main canvas.
  61125. * @param effect The effect used to render through
  61126. */
  61127. protected _internalRender(effect: Effect): void;
  61128. /**
  61129. * Sets the required values for both the emissive texture and and the main color.
  61130. */
  61131. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  61132. /**
  61133. * Returns true if the mesh should render, otherwise false.
  61134. * @param mesh The mesh to render
  61135. * @returns true if it should render otherwise false
  61136. */
  61137. protected _shouldRenderMesh(mesh: Mesh): boolean;
  61138. /**
  61139. * Adds specific effects defines.
  61140. * @param defines The defines to add specifics to.
  61141. */
  61142. protected _addCustomEffectDefines(defines: string[]): void;
  61143. /**
  61144. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  61145. * @param mesh The mesh to exclude from the glow layer
  61146. */
  61147. addExcludedMesh(mesh: Mesh): void;
  61148. /**
  61149. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  61150. * @param mesh The mesh to remove
  61151. */
  61152. removeExcludedMesh(mesh: Mesh): void;
  61153. /**
  61154. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  61155. * @param mesh The mesh to include in the glow layer
  61156. */
  61157. addIncludedOnlyMesh(mesh: Mesh): void;
  61158. /**
  61159. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  61160. * @param mesh The mesh to remove
  61161. */
  61162. removeIncludedOnlyMesh(mesh: Mesh): void;
  61163. /**
  61164. * Determine if a given mesh will be used in the glow layer
  61165. * @param mesh The mesh to test
  61166. * @returns true if the mesh will be highlighted by the current glow layer
  61167. */
  61168. hasMesh(mesh: AbstractMesh): boolean;
  61169. /**
  61170. * Defines whether the current material of the mesh should be use to render the effect.
  61171. * @param mesh defines the current mesh to render
  61172. */
  61173. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  61174. /**
  61175. * Add a mesh to be rendered through its own material and not with emissive only.
  61176. * @param mesh The mesh for which we need to use its material
  61177. */
  61178. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  61179. /**
  61180. * Remove a mesh from being rendered through its own material and not with emissive only.
  61181. * @param mesh The mesh for which we need to not use its material
  61182. */
  61183. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  61184. /**
  61185. * Free any resources and references associated to a mesh.
  61186. * Internal use
  61187. * @param mesh The mesh to free.
  61188. * @hidden
  61189. */
  61190. _disposeMesh(mesh: Mesh): void;
  61191. /**
  61192. * Gets the class name of the effect layer
  61193. * @returns the string with the class name of the effect layer
  61194. */
  61195. getClassName(): string;
  61196. /**
  61197. * Serializes this glow layer
  61198. * @returns a serialized glow layer object
  61199. */
  61200. serialize(): any;
  61201. /**
  61202. * Creates a Glow Layer from parsed glow layer data
  61203. * @param parsedGlowLayer defines glow layer data
  61204. * @param scene defines the current scene
  61205. * @param rootUrl defines the root URL containing the glow layer information
  61206. * @returns a parsed Glow Layer
  61207. */
  61208. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  61209. }
  61210. }
  61211. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  61212. /** @hidden */
  61213. export var glowBlurPostProcessPixelShader: {
  61214. name: string;
  61215. shader: string;
  61216. };
  61217. }
  61218. declare module "babylonjs/Layers/highlightLayer" {
  61219. import { Observable } from "babylonjs/Misc/observable";
  61220. import { Nullable } from "babylonjs/types";
  61221. import { Camera } from "babylonjs/Cameras/camera";
  61222. import { Scene } from "babylonjs/scene";
  61223. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61224. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61225. import { Mesh } from "babylonjs/Meshes/mesh";
  61226. import { Effect } from "babylonjs/Materials/effect";
  61227. import { Material } from "babylonjs/Materials/material";
  61228. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  61229. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  61230. import "babylonjs/Shaders/glowMapMerge.fragment";
  61231. import "babylonjs/Shaders/glowMapMerge.vertex";
  61232. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  61233. module "babylonjs/abstractScene" {
  61234. interface AbstractScene {
  61235. /**
  61236. * Return a the first highlight layer of the scene with a given name.
  61237. * @param name The name of the highlight layer to look for.
  61238. * @return The highlight layer if found otherwise null.
  61239. */
  61240. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  61241. }
  61242. }
  61243. /**
  61244. * Highlight layer options. This helps customizing the behaviour
  61245. * of the highlight layer.
  61246. */
  61247. export interface IHighlightLayerOptions {
  61248. /**
  61249. * Multiplication factor apply to the canvas size to compute the render target size
  61250. * used to generated the glowing objects (the smaller the faster).
  61251. */
  61252. mainTextureRatio: number;
  61253. /**
  61254. * Enforces a fixed size texture to ensure resize independant blur.
  61255. */
  61256. mainTextureFixedSize?: number;
  61257. /**
  61258. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  61259. * of the picture to blur (the smaller the faster).
  61260. */
  61261. blurTextureSizeRatio: number;
  61262. /**
  61263. * How big in texel of the blur texture is the vertical blur.
  61264. */
  61265. blurVerticalSize: number;
  61266. /**
  61267. * How big in texel of the blur texture is the horizontal blur.
  61268. */
  61269. blurHorizontalSize: number;
  61270. /**
  61271. * Alpha blending mode used to apply the blur. Default is combine.
  61272. */
  61273. alphaBlendingMode: number;
  61274. /**
  61275. * The camera attached to the layer.
  61276. */
  61277. camera: Nullable<Camera>;
  61278. /**
  61279. * Should we display highlight as a solid stroke?
  61280. */
  61281. isStroke?: boolean;
  61282. /**
  61283. * The rendering group to draw the layer in.
  61284. */
  61285. renderingGroupId: number;
  61286. }
  61287. /**
  61288. * The highlight layer Helps adding a glow effect around a mesh.
  61289. *
  61290. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  61291. * glowy meshes to your scene.
  61292. *
  61293. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  61294. */
  61295. export class HighlightLayer extends EffectLayer {
  61296. name: string;
  61297. /**
  61298. * Effect Name of the highlight layer.
  61299. */
  61300. static readonly EffectName: string;
  61301. /**
  61302. * The neutral color used during the preparation of the glow effect.
  61303. * This is black by default as the blend operation is a blend operation.
  61304. */
  61305. static NeutralColor: Color4;
  61306. /**
  61307. * Stencil value used for glowing meshes.
  61308. */
  61309. static GlowingMeshStencilReference: number;
  61310. /**
  61311. * Stencil value used for the other meshes in the scene.
  61312. */
  61313. static NormalMeshStencilReference: number;
  61314. /**
  61315. * Specifies whether or not the inner glow is ACTIVE in the layer.
  61316. */
  61317. innerGlow: boolean;
  61318. /**
  61319. * Specifies whether or not the outer glow is ACTIVE in the layer.
  61320. */
  61321. outerGlow: boolean;
  61322. /**
  61323. * Specifies the horizontal size of the blur.
  61324. */
  61325. set blurHorizontalSize(value: number);
  61326. /**
  61327. * Specifies the vertical size of the blur.
  61328. */
  61329. set blurVerticalSize(value: number);
  61330. /**
  61331. * Gets the horizontal size of the blur.
  61332. */
  61333. get blurHorizontalSize(): number;
  61334. /**
  61335. * Gets the vertical size of the blur.
  61336. */
  61337. get blurVerticalSize(): number;
  61338. /**
  61339. * An event triggered when the highlight layer is being blurred.
  61340. */
  61341. onBeforeBlurObservable: Observable<HighlightLayer>;
  61342. /**
  61343. * An event triggered when the highlight layer has been blurred.
  61344. */
  61345. onAfterBlurObservable: Observable<HighlightLayer>;
  61346. private _instanceGlowingMeshStencilReference;
  61347. private _options;
  61348. private _downSamplePostprocess;
  61349. private _horizontalBlurPostprocess;
  61350. private _verticalBlurPostprocess;
  61351. private _blurTexture;
  61352. private _meshes;
  61353. private _excludedMeshes;
  61354. /**
  61355. * Instantiates a new highlight Layer and references it to the scene..
  61356. * @param name The name of the layer
  61357. * @param scene The scene to use the layer in
  61358. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  61359. */
  61360. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  61361. /**
  61362. * Get the effect name of the layer.
  61363. * @return The effect name
  61364. */
  61365. getEffectName(): string;
  61366. /**
  61367. * Create the merge effect. This is the shader use to blit the information back
  61368. * to the main canvas at the end of the scene rendering.
  61369. */
  61370. protected _createMergeEffect(): Effect;
  61371. /**
  61372. * Creates the render target textures and post processes used in the highlight layer.
  61373. */
  61374. protected _createTextureAndPostProcesses(): void;
  61375. /**
  61376. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  61377. */
  61378. needStencil(): boolean;
  61379. /**
  61380. * Checks for the readiness of the element composing the layer.
  61381. * @param subMesh the mesh to check for
  61382. * @param useInstances specify wether or not to use instances to render the mesh
  61383. * @param emissiveTexture the associated emissive texture used to generate the glow
  61384. * @return true if ready otherwise, false
  61385. */
  61386. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61387. /**
  61388. * Implementation specific of rendering the generating effect on the main canvas.
  61389. * @param effect The effect used to render through
  61390. */
  61391. protected _internalRender(effect: Effect): void;
  61392. /**
  61393. * Returns true if the layer contains information to display, otherwise false.
  61394. */
  61395. shouldRender(): boolean;
  61396. /**
  61397. * Returns true if the mesh should render, otherwise false.
  61398. * @param mesh The mesh to render
  61399. * @returns true if it should render otherwise false
  61400. */
  61401. protected _shouldRenderMesh(mesh: Mesh): boolean;
  61402. /**
  61403. * Returns true if the mesh can be rendered, otherwise false.
  61404. * @param mesh The mesh to render
  61405. * @param material The material used on the mesh
  61406. * @returns true if it can be rendered otherwise false
  61407. */
  61408. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  61409. /**
  61410. * Adds specific effects defines.
  61411. * @param defines The defines to add specifics to.
  61412. */
  61413. protected _addCustomEffectDefines(defines: string[]): void;
  61414. /**
  61415. * Sets the required values for both the emissive texture and and the main color.
  61416. */
  61417. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  61418. /**
  61419. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  61420. * @param mesh The mesh to exclude from the highlight layer
  61421. */
  61422. addExcludedMesh(mesh: Mesh): void;
  61423. /**
  61424. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  61425. * @param mesh The mesh to highlight
  61426. */
  61427. removeExcludedMesh(mesh: Mesh): void;
  61428. /**
  61429. * Determine if a given mesh will be highlighted by the current HighlightLayer
  61430. * @param mesh mesh to test
  61431. * @returns true if the mesh will be highlighted by the current HighlightLayer
  61432. */
  61433. hasMesh(mesh: AbstractMesh): boolean;
  61434. /**
  61435. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  61436. * @param mesh The mesh to highlight
  61437. * @param color The color of the highlight
  61438. * @param glowEmissiveOnly Extract the glow from the emissive texture
  61439. */
  61440. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  61441. /**
  61442. * Remove a mesh from the highlight layer in order to make it stop glowing.
  61443. * @param mesh The mesh to highlight
  61444. */
  61445. removeMesh(mesh: Mesh): void;
  61446. /**
  61447. * Remove all the meshes currently referenced in the highlight layer
  61448. */
  61449. removeAllMeshes(): void;
  61450. /**
  61451. * Force the stencil to the normal expected value for none glowing parts
  61452. */
  61453. private _defaultStencilReference;
  61454. /**
  61455. * Free any resources and references associated to a mesh.
  61456. * Internal use
  61457. * @param mesh The mesh to free.
  61458. * @hidden
  61459. */
  61460. _disposeMesh(mesh: Mesh): void;
  61461. /**
  61462. * Dispose the highlight layer and free resources.
  61463. */
  61464. dispose(): void;
  61465. /**
  61466. * Gets the class name of the effect layer
  61467. * @returns the string with the class name of the effect layer
  61468. */
  61469. getClassName(): string;
  61470. /**
  61471. * Serializes this Highlight layer
  61472. * @returns a serialized Highlight layer object
  61473. */
  61474. serialize(): any;
  61475. /**
  61476. * Creates a Highlight layer from parsed Highlight layer data
  61477. * @param parsedHightlightLayer defines the Highlight layer data
  61478. * @param scene defines the current scene
  61479. * @param rootUrl defines the root URL containing the Highlight layer information
  61480. * @returns a parsed Highlight layer
  61481. */
  61482. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  61483. }
  61484. }
  61485. declare module "babylonjs/Layers/layerSceneComponent" {
  61486. import { Scene } from "babylonjs/scene";
  61487. import { ISceneComponent } from "babylonjs/sceneComponent";
  61488. import { Layer } from "babylonjs/Layers/layer";
  61489. import { AbstractScene } from "babylonjs/abstractScene";
  61490. module "babylonjs/abstractScene" {
  61491. interface AbstractScene {
  61492. /**
  61493. * The list of layers (background and foreground) of the scene
  61494. */
  61495. layers: Array<Layer>;
  61496. }
  61497. }
  61498. /**
  61499. * Defines the layer scene component responsible to manage any layers
  61500. * in a given scene.
  61501. */
  61502. export class LayerSceneComponent implements ISceneComponent {
  61503. /**
  61504. * The component name helpfull to identify the component in the list of scene components.
  61505. */
  61506. readonly name: string;
  61507. /**
  61508. * The scene the component belongs to.
  61509. */
  61510. scene: Scene;
  61511. private _engine;
  61512. /**
  61513. * Creates a new instance of the component for the given scene
  61514. * @param scene Defines the scene to register the component in
  61515. */
  61516. constructor(scene: Scene);
  61517. /**
  61518. * Registers the component in a given scene
  61519. */
  61520. register(): void;
  61521. /**
  61522. * Rebuilds the elements related to this component in case of
  61523. * context lost for instance.
  61524. */
  61525. rebuild(): void;
  61526. /**
  61527. * Disposes the component and the associated ressources.
  61528. */
  61529. dispose(): void;
  61530. private _draw;
  61531. private _drawCameraPredicate;
  61532. private _drawCameraBackground;
  61533. private _drawCameraForeground;
  61534. private _drawRenderTargetPredicate;
  61535. private _drawRenderTargetBackground;
  61536. private _drawRenderTargetForeground;
  61537. /**
  61538. * Adds all the elements from the container to the scene
  61539. * @param container the container holding the elements
  61540. */
  61541. addFromContainer(container: AbstractScene): void;
  61542. /**
  61543. * Removes all the elements in the container from the scene
  61544. * @param container contains the elements to remove
  61545. * @param dispose if the removed element should be disposed (default: false)
  61546. */
  61547. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61548. }
  61549. }
  61550. declare module "babylonjs/Shaders/layer.fragment" {
  61551. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61552. /** @hidden */
  61553. export var layerPixelShader: {
  61554. name: string;
  61555. shader: string;
  61556. };
  61557. }
  61558. declare module "babylonjs/Shaders/layer.vertex" {
  61559. /** @hidden */
  61560. export var layerVertexShader: {
  61561. name: string;
  61562. shader: string;
  61563. };
  61564. }
  61565. declare module "babylonjs/Layers/layer" {
  61566. import { Observable } from "babylonjs/Misc/observable";
  61567. import { Nullable } from "babylonjs/types";
  61568. import { Scene } from "babylonjs/scene";
  61569. import { Vector2 } from "babylonjs/Maths/math.vector";
  61570. import { Color4 } from "babylonjs/Maths/math.color";
  61571. import { Texture } from "babylonjs/Materials/Textures/texture";
  61572. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61573. import "babylonjs/Shaders/layer.fragment";
  61574. import "babylonjs/Shaders/layer.vertex";
  61575. /**
  61576. * This represents a full screen 2d layer.
  61577. * This can be useful to display a picture in the background of your scene for instance.
  61578. * @see https://www.babylonjs-playground.com/#08A2BS#1
  61579. */
  61580. export class Layer {
  61581. /**
  61582. * Define the name of the layer.
  61583. */
  61584. name: string;
  61585. /**
  61586. * Define the texture the layer should display.
  61587. */
  61588. texture: Nullable<Texture>;
  61589. /**
  61590. * Is the layer in background or foreground.
  61591. */
  61592. isBackground: boolean;
  61593. /**
  61594. * Define the color of the layer (instead of texture).
  61595. */
  61596. color: Color4;
  61597. /**
  61598. * Define the scale of the layer in order to zoom in out of the texture.
  61599. */
  61600. scale: Vector2;
  61601. /**
  61602. * Define an offset for the layer in order to shift the texture.
  61603. */
  61604. offset: Vector2;
  61605. /**
  61606. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  61607. */
  61608. alphaBlendingMode: number;
  61609. /**
  61610. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  61611. * Alpha test will not mix with the background color in case of transparency.
  61612. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  61613. */
  61614. alphaTest: boolean;
  61615. /**
  61616. * Define a mask to restrict the layer to only some of the scene cameras.
  61617. */
  61618. layerMask: number;
  61619. /**
  61620. * Define the list of render target the layer is visible into.
  61621. */
  61622. renderTargetTextures: RenderTargetTexture[];
  61623. /**
  61624. * Define if the layer is only used in renderTarget or if it also
  61625. * renders in the main frame buffer of the canvas.
  61626. */
  61627. renderOnlyInRenderTargetTextures: boolean;
  61628. private _scene;
  61629. private _vertexBuffers;
  61630. private _indexBuffer;
  61631. private _effect;
  61632. private _previousDefines;
  61633. /**
  61634. * An event triggered when the layer is disposed.
  61635. */
  61636. onDisposeObservable: Observable<Layer>;
  61637. private _onDisposeObserver;
  61638. /**
  61639. * Back compatibility with callback before the onDisposeObservable existed.
  61640. * The set callback will be triggered when the layer has been disposed.
  61641. */
  61642. set onDispose(callback: () => void);
  61643. /**
  61644. * An event triggered before rendering the scene
  61645. */
  61646. onBeforeRenderObservable: Observable<Layer>;
  61647. private _onBeforeRenderObserver;
  61648. /**
  61649. * Back compatibility with callback before the onBeforeRenderObservable existed.
  61650. * The set callback will be triggered just before rendering the layer.
  61651. */
  61652. set onBeforeRender(callback: () => void);
  61653. /**
  61654. * An event triggered after rendering the scene
  61655. */
  61656. onAfterRenderObservable: Observable<Layer>;
  61657. private _onAfterRenderObserver;
  61658. /**
  61659. * Back compatibility with callback before the onAfterRenderObservable existed.
  61660. * The set callback will be triggered just after rendering the layer.
  61661. */
  61662. set onAfterRender(callback: () => void);
  61663. /**
  61664. * Instantiates a new layer.
  61665. * This represents a full screen 2d layer.
  61666. * This can be useful to display a picture in the background of your scene for instance.
  61667. * @see https://www.babylonjs-playground.com/#08A2BS#1
  61668. * @param name Define the name of the layer in the scene
  61669. * @param imgUrl Define the url of the texture to display in the layer
  61670. * @param scene Define the scene the layer belongs to
  61671. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  61672. * @param color Defines a color for the layer
  61673. */
  61674. constructor(
  61675. /**
  61676. * Define the name of the layer.
  61677. */
  61678. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  61679. private _createIndexBuffer;
  61680. /** @hidden */
  61681. _rebuild(): void;
  61682. /**
  61683. * Renders the layer in the scene.
  61684. */
  61685. render(): void;
  61686. /**
  61687. * Disposes and releases the associated ressources.
  61688. */
  61689. dispose(): void;
  61690. }
  61691. }
  61692. declare module "babylonjs/Layers/index" {
  61693. export * from "babylonjs/Layers/effectLayer";
  61694. export * from "babylonjs/Layers/effectLayerSceneComponent";
  61695. export * from "babylonjs/Layers/glowLayer";
  61696. export * from "babylonjs/Layers/highlightLayer";
  61697. export * from "babylonjs/Layers/layer";
  61698. export * from "babylonjs/Layers/layerSceneComponent";
  61699. }
  61700. declare module "babylonjs/Shaders/lensFlare.fragment" {
  61701. /** @hidden */
  61702. export var lensFlarePixelShader: {
  61703. name: string;
  61704. shader: string;
  61705. };
  61706. }
  61707. declare module "babylonjs/Shaders/lensFlare.vertex" {
  61708. /** @hidden */
  61709. export var lensFlareVertexShader: {
  61710. name: string;
  61711. shader: string;
  61712. };
  61713. }
  61714. declare module "babylonjs/LensFlares/lensFlareSystem" {
  61715. import { Scene } from "babylonjs/scene";
  61716. import { Vector3 } from "babylonjs/Maths/math.vector";
  61717. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61718. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  61719. import "babylonjs/Shaders/lensFlare.fragment";
  61720. import "babylonjs/Shaders/lensFlare.vertex";
  61721. import { Viewport } from "babylonjs/Maths/math.viewport";
  61722. /**
  61723. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  61724. * It is usually composed of several `lensFlare`.
  61725. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61726. */
  61727. export class LensFlareSystem {
  61728. /**
  61729. * Define the name of the lens flare system
  61730. */
  61731. name: string;
  61732. /**
  61733. * List of lens flares used in this system.
  61734. */
  61735. lensFlares: LensFlare[];
  61736. /**
  61737. * Define a limit from the border the lens flare can be visible.
  61738. */
  61739. borderLimit: number;
  61740. /**
  61741. * Define a viewport border we do not want to see the lens flare in.
  61742. */
  61743. viewportBorder: number;
  61744. /**
  61745. * Define a predicate which could limit the list of meshes able to occlude the effect.
  61746. */
  61747. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  61748. /**
  61749. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  61750. */
  61751. layerMask: number;
  61752. /**
  61753. * Define the id of the lens flare system in the scene.
  61754. * (equal to name by default)
  61755. */
  61756. id: string;
  61757. private _scene;
  61758. private _emitter;
  61759. private _vertexBuffers;
  61760. private _indexBuffer;
  61761. private _effect;
  61762. private _positionX;
  61763. private _positionY;
  61764. private _isEnabled;
  61765. /** @hidden */
  61766. static _SceneComponentInitialization: (scene: Scene) => void;
  61767. /**
  61768. * Instantiates a lens flare system.
  61769. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  61770. * It is usually composed of several `lensFlare`.
  61771. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61772. * @param name Define the name of the lens flare system in the scene
  61773. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  61774. * @param scene Define the scene the lens flare system belongs to
  61775. */
  61776. constructor(
  61777. /**
  61778. * Define the name of the lens flare system
  61779. */
  61780. name: string, emitter: any, scene: Scene);
  61781. /**
  61782. * Define if the lens flare system is enabled.
  61783. */
  61784. get isEnabled(): boolean;
  61785. set isEnabled(value: boolean);
  61786. /**
  61787. * Get the scene the effects belongs to.
  61788. * @returns the scene holding the lens flare system
  61789. */
  61790. getScene(): Scene;
  61791. /**
  61792. * Get the emitter of the lens flare system.
  61793. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  61794. * @returns the emitter of the lens flare system
  61795. */
  61796. getEmitter(): any;
  61797. /**
  61798. * Set the emitter of the lens flare system.
  61799. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  61800. * @param newEmitter Define the new emitter of the system
  61801. */
  61802. setEmitter(newEmitter: any): void;
  61803. /**
  61804. * Get the lens flare system emitter position.
  61805. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  61806. * @returns the position
  61807. */
  61808. getEmitterPosition(): Vector3;
  61809. /**
  61810. * @hidden
  61811. */
  61812. computeEffectivePosition(globalViewport: Viewport): boolean;
  61813. /** @hidden */
  61814. _isVisible(): boolean;
  61815. /**
  61816. * @hidden
  61817. */
  61818. render(): boolean;
  61819. /**
  61820. * Dispose and release the lens flare with its associated resources.
  61821. */
  61822. dispose(): void;
  61823. /**
  61824. * Parse a lens flare system from a JSON repressentation
  61825. * @param parsedLensFlareSystem Define the JSON to parse
  61826. * @param scene Define the scene the parsed system should be instantiated in
  61827. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  61828. * @returns the parsed system
  61829. */
  61830. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  61831. /**
  61832. * Serialize the current Lens Flare System into a JSON representation.
  61833. * @returns the serialized JSON
  61834. */
  61835. serialize(): any;
  61836. }
  61837. }
  61838. declare module "babylonjs/LensFlares/lensFlare" {
  61839. import { Nullable } from "babylonjs/types";
  61840. import { Color3 } from "babylonjs/Maths/math.color";
  61841. import { Texture } from "babylonjs/Materials/Textures/texture";
  61842. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  61843. /**
  61844. * This represents one of the lens effect in a `lensFlareSystem`.
  61845. * It controls one of the indiviual texture used in the effect.
  61846. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61847. */
  61848. export class LensFlare {
  61849. /**
  61850. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  61851. */
  61852. size: number;
  61853. /**
  61854. * 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.
  61855. */
  61856. position: number;
  61857. /**
  61858. * Define the lens color.
  61859. */
  61860. color: Color3;
  61861. /**
  61862. * Define the lens texture.
  61863. */
  61864. texture: Nullable<Texture>;
  61865. /**
  61866. * Define the alpha mode to render this particular lens.
  61867. */
  61868. alphaMode: number;
  61869. private _system;
  61870. /**
  61871. * Creates a new Lens Flare.
  61872. * This represents one of the lens effect in a `lensFlareSystem`.
  61873. * It controls one of the indiviual texture used in the effect.
  61874. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61875. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  61876. * @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.
  61877. * @param color Define the lens color
  61878. * @param imgUrl Define the lens texture url
  61879. * @param system Define the `lensFlareSystem` this flare is part of
  61880. * @returns The newly created Lens Flare
  61881. */
  61882. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  61883. /**
  61884. * Instantiates a new Lens Flare.
  61885. * This represents one of the lens effect in a `lensFlareSystem`.
  61886. * It controls one of the indiviual texture used in the effect.
  61887. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61888. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  61889. * @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.
  61890. * @param color Define the lens color
  61891. * @param imgUrl Define the lens texture url
  61892. * @param system Define the `lensFlareSystem` this flare is part of
  61893. */
  61894. constructor(
  61895. /**
  61896. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  61897. */
  61898. size: number,
  61899. /**
  61900. * 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.
  61901. */
  61902. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  61903. /**
  61904. * Dispose and release the lens flare with its associated resources.
  61905. */
  61906. dispose(): void;
  61907. }
  61908. }
  61909. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  61910. import { Nullable } from "babylonjs/types";
  61911. import { Scene } from "babylonjs/scene";
  61912. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  61913. import { AbstractScene } from "babylonjs/abstractScene";
  61914. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  61915. module "babylonjs/abstractScene" {
  61916. interface AbstractScene {
  61917. /**
  61918. * The list of lens flare system added to the scene
  61919. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61920. */
  61921. lensFlareSystems: Array<LensFlareSystem>;
  61922. /**
  61923. * Removes the given lens flare system from this scene.
  61924. * @param toRemove The lens flare system to remove
  61925. * @returns The index of the removed lens flare system
  61926. */
  61927. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  61928. /**
  61929. * Adds the given lens flare system to this scene
  61930. * @param newLensFlareSystem The lens flare system to add
  61931. */
  61932. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  61933. /**
  61934. * Gets a lens flare system using its name
  61935. * @param name defines the name to look for
  61936. * @returns the lens flare system or null if not found
  61937. */
  61938. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  61939. /**
  61940. * Gets a lens flare system using its id
  61941. * @param id defines the id to look for
  61942. * @returns the lens flare system or null if not found
  61943. */
  61944. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  61945. }
  61946. }
  61947. /**
  61948. * Defines the lens flare scene component responsible to manage any lens flares
  61949. * in a given scene.
  61950. */
  61951. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  61952. /**
  61953. * The component name helpfull to identify the component in the list of scene components.
  61954. */
  61955. readonly name: string;
  61956. /**
  61957. * The scene the component belongs to.
  61958. */
  61959. scene: Scene;
  61960. /**
  61961. * Creates a new instance of the component for the given scene
  61962. * @param scene Defines the scene to register the component in
  61963. */
  61964. constructor(scene: Scene);
  61965. /**
  61966. * Registers the component in a given scene
  61967. */
  61968. register(): void;
  61969. /**
  61970. * Rebuilds the elements related to this component in case of
  61971. * context lost for instance.
  61972. */
  61973. rebuild(): void;
  61974. /**
  61975. * Adds all the elements from the container to the scene
  61976. * @param container the container holding the elements
  61977. */
  61978. addFromContainer(container: AbstractScene): void;
  61979. /**
  61980. * Removes all the elements in the container from the scene
  61981. * @param container contains the elements to remove
  61982. * @param dispose if the removed element should be disposed (default: false)
  61983. */
  61984. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61985. /**
  61986. * Serializes the component data to the specified json object
  61987. * @param serializationObject The object to serialize to
  61988. */
  61989. serialize(serializationObject: any): void;
  61990. /**
  61991. * Disposes the component and the associated ressources.
  61992. */
  61993. dispose(): void;
  61994. private _draw;
  61995. }
  61996. }
  61997. declare module "babylonjs/LensFlares/index" {
  61998. export * from "babylonjs/LensFlares/lensFlare";
  61999. export * from "babylonjs/LensFlares/lensFlareSystem";
  62000. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  62001. }
  62002. declare module "babylonjs/Shaders/depth.fragment" {
  62003. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  62004. /** @hidden */
  62005. export var depthPixelShader: {
  62006. name: string;
  62007. shader: string;
  62008. };
  62009. }
  62010. declare module "babylonjs/Shaders/depth.vertex" {
  62011. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62012. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62013. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62014. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62015. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62016. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62017. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62018. /** @hidden */
  62019. export var depthVertexShader: {
  62020. name: string;
  62021. shader: string;
  62022. };
  62023. }
  62024. declare module "babylonjs/Rendering/depthRenderer" {
  62025. import { Nullable } from "babylonjs/types";
  62026. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62027. import { Scene } from "babylonjs/scene";
  62028. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62029. import { Camera } from "babylonjs/Cameras/camera";
  62030. import "babylonjs/Shaders/depth.fragment";
  62031. import "babylonjs/Shaders/depth.vertex";
  62032. /**
  62033. * This represents a depth renderer in Babylon.
  62034. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  62035. */
  62036. export class DepthRenderer {
  62037. private _scene;
  62038. private _depthMap;
  62039. private _effect;
  62040. private readonly _storeNonLinearDepth;
  62041. private readonly _clearColor;
  62042. /** Get if the depth renderer is using packed depth or not */
  62043. readonly isPacked: boolean;
  62044. private _cachedDefines;
  62045. private _camera;
  62046. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  62047. enabled: boolean;
  62048. /**
  62049. * Specifiess that the depth renderer will only be used within
  62050. * the camera it is created for.
  62051. * This can help forcing its rendering during the camera processing.
  62052. */
  62053. useOnlyInActiveCamera: boolean;
  62054. /** @hidden */
  62055. static _SceneComponentInitialization: (scene: Scene) => void;
  62056. /**
  62057. * Instantiates a depth renderer
  62058. * @param scene The scene the renderer belongs to
  62059. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  62060. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  62061. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  62062. */
  62063. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  62064. /**
  62065. * Creates the depth rendering effect and checks if the effect is ready.
  62066. * @param subMesh The submesh to be used to render the depth map of
  62067. * @param useInstances If multiple world instances should be used
  62068. * @returns if the depth renderer is ready to render the depth map
  62069. */
  62070. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62071. /**
  62072. * Gets the texture which the depth map will be written to.
  62073. * @returns The depth map texture
  62074. */
  62075. getDepthMap(): RenderTargetTexture;
  62076. /**
  62077. * Disposes of the depth renderer.
  62078. */
  62079. dispose(): void;
  62080. }
  62081. }
  62082. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  62083. /** @hidden */
  62084. export var minmaxReduxPixelShader: {
  62085. name: string;
  62086. shader: string;
  62087. };
  62088. }
  62089. declare module "babylonjs/Misc/minMaxReducer" {
  62090. import { Nullable } from "babylonjs/types";
  62091. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62092. import { Camera } from "babylonjs/Cameras/camera";
  62093. import { Observer } from "babylonjs/Misc/observable";
  62094. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62095. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  62096. import { Observable } from "babylonjs/Misc/observable";
  62097. import "babylonjs/Shaders/minmaxRedux.fragment";
  62098. /**
  62099. * This class computes a min/max reduction from a texture: it means it computes the minimum
  62100. * and maximum values from all values of the texture.
  62101. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  62102. * The source values are read from the red channel of the texture.
  62103. */
  62104. export class MinMaxReducer {
  62105. /**
  62106. * Observable triggered when the computation has been performed
  62107. */
  62108. onAfterReductionPerformed: Observable<{
  62109. min: number;
  62110. max: number;
  62111. }>;
  62112. protected _camera: Camera;
  62113. protected _sourceTexture: Nullable<RenderTargetTexture>;
  62114. protected _reductionSteps: Nullable<Array<PostProcess>>;
  62115. protected _postProcessManager: PostProcessManager;
  62116. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  62117. protected _forceFullscreenViewport: boolean;
  62118. /**
  62119. * Creates a min/max reducer
  62120. * @param camera The camera to use for the post processes
  62121. */
  62122. constructor(camera: Camera);
  62123. /**
  62124. * Gets the texture used to read the values from.
  62125. */
  62126. get sourceTexture(): Nullable<RenderTargetTexture>;
  62127. /**
  62128. * Sets the source texture to read the values from.
  62129. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  62130. * because in such textures '1' value must not be taken into account to compute the maximum
  62131. * as this value is used to clear the texture.
  62132. * Note that the computation is not activated by calling this function, you must call activate() for that!
  62133. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  62134. * @param depthRedux Indicates if the texture is a depth texture or not
  62135. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  62136. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  62137. */
  62138. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  62139. /**
  62140. * Defines the refresh rate of the computation.
  62141. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  62142. */
  62143. get refreshRate(): number;
  62144. set refreshRate(value: number);
  62145. protected _activated: boolean;
  62146. /**
  62147. * Gets the activation status of the reducer
  62148. */
  62149. get activated(): boolean;
  62150. /**
  62151. * Activates the reduction computation.
  62152. * When activated, the observers registered in onAfterReductionPerformed are
  62153. * called after the compuation is performed
  62154. */
  62155. activate(): void;
  62156. /**
  62157. * Deactivates the reduction computation.
  62158. */
  62159. deactivate(): void;
  62160. /**
  62161. * Disposes the min/max reducer
  62162. * @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.
  62163. */
  62164. dispose(disposeAll?: boolean): void;
  62165. }
  62166. }
  62167. declare module "babylonjs/Misc/depthReducer" {
  62168. import { Nullable } from "babylonjs/types";
  62169. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62170. import { Camera } from "babylonjs/Cameras/camera";
  62171. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  62172. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  62173. /**
  62174. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  62175. */
  62176. export class DepthReducer extends MinMaxReducer {
  62177. private _depthRenderer;
  62178. private _depthRendererId;
  62179. /**
  62180. * Gets the depth renderer used for the computation.
  62181. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  62182. */
  62183. get depthRenderer(): Nullable<DepthRenderer>;
  62184. /**
  62185. * Creates a depth reducer
  62186. * @param camera The camera used to render the depth texture
  62187. */
  62188. constructor(camera: Camera);
  62189. /**
  62190. * Sets the depth renderer to use to generate the depth map
  62191. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  62192. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  62193. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  62194. */
  62195. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  62196. /** @hidden */
  62197. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  62198. /**
  62199. * Activates the reduction computation.
  62200. * When activated, the observers registered in onAfterReductionPerformed are
  62201. * called after the compuation is performed
  62202. */
  62203. activate(): void;
  62204. /**
  62205. * Deactivates the reduction computation.
  62206. */
  62207. deactivate(): void;
  62208. /**
  62209. * Disposes the depth reducer
  62210. * @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.
  62211. */
  62212. dispose(disposeAll?: boolean): void;
  62213. }
  62214. }
  62215. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  62216. import { Nullable } from "babylonjs/types";
  62217. import { Scene } from "babylonjs/scene";
  62218. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  62219. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62220. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62221. import { Effect } from "babylonjs/Materials/effect";
  62222. import "babylonjs/Shaders/shadowMap.fragment";
  62223. import "babylonjs/Shaders/shadowMap.vertex";
  62224. import "babylonjs/Shaders/depthBoxBlur.fragment";
  62225. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  62226. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  62227. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  62228. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  62229. /**
  62230. * A CSM implementation allowing casting shadows on large scenes.
  62231. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  62232. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  62233. */
  62234. export class CascadedShadowGenerator extends ShadowGenerator {
  62235. private static readonly frustumCornersNDCSpace;
  62236. /**
  62237. * Name of the CSM class
  62238. */
  62239. static CLASSNAME: string;
  62240. /**
  62241. * Defines the default number of cascades used by the CSM.
  62242. */
  62243. static readonly DEFAULT_CASCADES_COUNT: number;
  62244. /**
  62245. * Defines the minimum number of cascades used by the CSM.
  62246. */
  62247. static readonly MIN_CASCADES_COUNT: number;
  62248. /**
  62249. * Defines the maximum number of cascades used by the CSM.
  62250. */
  62251. static readonly MAX_CASCADES_COUNT: number;
  62252. protected _validateFilter(filter: number): number;
  62253. /**
  62254. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  62255. */
  62256. penumbraDarkness: number;
  62257. private _numCascades;
  62258. /**
  62259. * Gets or set the number of cascades used by the CSM.
  62260. */
  62261. get numCascades(): number;
  62262. set numCascades(value: number);
  62263. /**
  62264. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  62265. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  62266. */
  62267. stabilizeCascades: boolean;
  62268. private _freezeShadowCastersBoundingInfo;
  62269. private _freezeShadowCastersBoundingInfoObservable;
  62270. /**
  62271. * Enables or disables the shadow casters bounding info computation.
  62272. * If your shadow casters don't move, you can disable this feature.
  62273. * If it is enabled, the bounding box computation is done every frame.
  62274. */
  62275. get freezeShadowCastersBoundingInfo(): boolean;
  62276. set freezeShadowCastersBoundingInfo(freeze: boolean);
  62277. private _scbiMin;
  62278. private _scbiMax;
  62279. protected _computeShadowCastersBoundingInfo(): void;
  62280. protected _shadowCastersBoundingInfo: BoundingInfo;
  62281. /**
  62282. * Gets or sets the shadow casters bounding info.
  62283. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  62284. * so that the system won't overwrite the bounds you provide
  62285. */
  62286. get shadowCastersBoundingInfo(): BoundingInfo;
  62287. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  62288. protected _breaksAreDirty: boolean;
  62289. protected _minDistance: number;
  62290. protected _maxDistance: number;
  62291. /**
  62292. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  62293. *
  62294. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  62295. * If you don't know these values, simply leave them to their defaults and don't call this function.
  62296. * @param min minimal distance for the breaks (default to 0.)
  62297. * @param max maximal distance for the breaks (default to 1.)
  62298. */
  62299. setMinMaxDistance(min: number, max: number): void;
  62300. /** Gets the minimal distance used in the cascade break computation */
  62301. get minDistance(): number;
  62302. /** Gets the maximal distance used in the cascade break computation */
  62303. get maxDistance(): number;
  62304. /**
  62305. * Gets the class name of that object
  62306. * @returns "CascadedShadowGenerator"
  62307. */
  62308. getClassName(): string;
  62309. private _cascadeMinExtents;
  62310. private _cascadeMaxExtents;
  62311. /**
  62312. * Gets a cascade minimum extents
  62313. * @param cascadeIndex index of the cascade
  62314. * @returns the minimum cascade extents
  62315. */
  62316. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  62317. /**
  62318. * Gets a cascade maximum extents
  62319. * @param cascadeIndex index of the cascade
  62320. * @returns the maximum cascade extents
  62321. */
  62322. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  62323. private _cascades;
  62324. private _currentLayer;
  62325. private _viewSpaceFrustumsZ;
  62326. private _viewMatrices;
  62327. private _projectionMatrices;
  62328. private _transformMatrices;
  62329. private _transformMatricesAsArray;
  62330. private _frustumLengths;
  62331. private _lightSizeUVCorrection;
  62332. private _depthCorrection;
  62333. private _frustumCornersWorldSpace;
  62334. private _frustumCenter;
  62335. private _shadowCameraPos;
  62336. private _shadowMaxZ;
  62337. /**
  62338. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  62339. * It defaults to camera.maxZ
  62340. */
  62341. get shadowMaxZ(): number;
  62342. /**
  62343. * Sets the shadow max z distance.
  62344. */
  62345. set shadowMaxZ(value: number);
  62346. protected _debug: boolean;
  62347. /**
  62348. * Gets or sets the debug flag.
  62349. * When enabled, the cascades are materialized by different colors on the screen.
  62350. */
  62351. get debug(): boolean;
  62352. set debug(dbg: boolean);
  62353. private _depthClamp;
  62354. /**
  62355. * Gets or sets the depth clamping value.
  62356. *
  62357. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  62358. * to account for the shadow casters far away.
  62359. *
  62360. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  62361. */
  62362. get depthClamp(): boolean;
  62363. set depthClamp(value: boolean);
  62364. private _cascadeBlendPercentage;
  62365. /**
  62366. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  62367. * It defaults to 0.1 (10% blending).
  62368. */
  62369. get cascadeBlendPercentage(): number;
  62370. set cascadeBlendPercentage(value: number);
  62371. private _lambda;
  62372. /**
  62373. * Gets or set the lambda parameter.
  62374. * This parameter is used to split the camera frustum and create the cascades.
  62375. * 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.
  62376. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  62377. */
  62378. get lambda(): number;
  62379. set lambda(value: number);
  62380. /**
  62381. * Gets the view matrix corresponding to a given cascade
  62382. * @param cascadeNum cascade to retrieve the view matrix from
  62383. * @returns the cascade view matrix
  62384. */
  62385. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  62386. /**
  62387. * Gets the projection matrix corresponding to a given cascade
  62388. * @param cascadeNum cascade to retrieve the projection matrix from
  62389. * @returns the cascade projection matrix
  62390. */
  62391. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  62392. /**
  62393. * Gets the transformation matrix corresponding to a given cascade
  62394. * @param cascadeNum cascade to retrieve the transformation matrix from
  62395. * @returns the cascade transformation matrix
  62396. */
  62397. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  62398. private _depthRenderer;
  62399. /**
  62400. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  62401. *
  62402. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  62403. *
  62404. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  62405. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  62406. * @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
  62407. */
  62408. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  62409. private _depthReducer;
  62410. private _autoCalcDepthBounds;
  62411. /**
  62412. * Gets or sets the autoCalcDepthBounds property.
  62413. *
  62414. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  62415. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  62416. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  62417. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  62418. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  62419. */
  62420. get autoCalcDepthBounds(): boolean;
  62421. set autoCalcDepthBounds(value: boolean);
  62422. /**
  62423. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  62424. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  62425. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  62426. * for setting the refresh rate on the renderer yourself!
  62427. */
  62428. get autoCalcDepthBoundsRefreshRate(): number;
  62429. set autoCalcDepthBoundsRefreshRate(value: number);
  62430. /**
  62431. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  62432. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  62433. * you change the camera near/far planes!
  62434. */
  62435. splitFrustum(): void;
  62436. private _splitFrustum;
  62437. private _computeMatrices;
  62438. private _computeFrustumInWorldSpace;
  62439. private _computeCascadeFrustum;
  62440. /**
  62441. * Support test.
  62442. */
  62443. static get IsSupported(): boolean;
  62444. /** @hidden */
  62445. static _SceneComponentInitialization: (scene: Scene) => void;
  62446. /**
  62447. * Creates a Cascaded Shadow Generator object.
  62448. * A ShadowGenerator is the required tool to use the shadows.
  62449. * Each directional light casting shadows needs to use its own ShadowGenerator.
  62450. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  62451. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  62452. * @param light The directional light object generating the shadows.
  62453. * @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.
  62454. */
  62455. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  62456. protected _initializeGenerator(): void;
  62457. protected _createTargetRenderTexture(): void;
  62458. protected _initializeShadowMap(): void;
  62459. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  62460. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  62461. /**
  62462. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  62463. * @param defines Defines of the material we want to update
  62464. * @param lightIndex Index of the light in the enabled light list of the material
  62465. */
  62466. prepareDefines(defines: any, lightIndex: number): void;
  62467. /**
  62468. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  62469. * defined in the generator but impacting the effect).
  62470. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  62471. * @param effect The effect we are binfing the information for
  62472. */
  62473. bindShadowLight(lightIndex: string, effect: Effect): void;
  62474. /**
  62475. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  62476. * (eq to view projection * shadow projection matrices)
  62477. * @returns The transform matrix used to create the shadow map
  62478. */
  62479. getTransformMatrix(): Matrix;
  62480. /**
  62481. * Disposes the ShadowGenerator.
  62482. * Returns nothing.
  62483. */
  62484. dispose(): void;
  62485. /**
  62486. * Serializes the shadow generator setup to a json object.
  62487. * @returns The serialized JSON object
  62488. */
  62489. serialize(): any;
  62490. /**
  62491. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  62492. * @param parsedShadowGenerator The JSON object to parse
  62493. * @param scene The scene to create the shadow map for
  62494. * @returns The parsed shadow generator
  62495. */
  62496. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  62497. }
  62498. }
  62499. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  62500. import { Scene } from "babylonjs/scene";
  62501. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  62502. import { AbstractScene } from "babylonjs/abstractScene";
  62503. /**
  62504. * Defines the shadow generator component responsible to manage any shadow generators
  62505. * in a given scene.
  62506. */
  62507. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  62508. /**
  62509. * The component name helpfull to identify the component in the list of scene components.
  62510. */
  62511. readonly name: string;
  62512. /**
  62513. * The scene the component belongs to.
  62514. */
  62515. scene: Scene;
  62516. /**
  62517. * Creates a new instance of the component for the given scene
  62518. * @param scene Defines the scene to register the component in
  62519. */
  62520. constructor(scene: Scene);
  62521. /**
  62522. * Registers the component in a given scene
  62523. */
  62524. register(): void;
  62525. /**
  62526. * Rebuilds the elements related to this component in case of
  62527. * context lost for instance.
  62528. */
  62529. rebuild(): void;
  62530. /**
  62531. * Serializes the component data to the specified json object
  62532. * @param serializationObject The object to serialize to
  62533. */
  62534. serialize(serializationObject: any): void;
  62535. /**
  62536. * Adds all the elements from the container to the scene
  62537. * @param container the container holding the elements
  62538. */
  62539. addFromContainer(container: AbstractScene): void;
  62540. /**
  62541. * Removes all the elements in the container from the scene
  62542. * @param container contains the elements to remove
  62543. * @param dispose if the removed element should be disposed (default: false)
  62544. */
  62545. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62546. /**
  62547. * Rebuilds the elements related to this component in case of
  62548. * context lost for instance.
  62549. */
  62550. dispose(): void;
  62551. private _gatherRenderTargets;
  62552. }
  62553. }
  62554. declare module "babylonjs/Lights/Shadows/index" {
  62555. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  62556. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  62557. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  62558. }
  62559. declare module "babylonjs/Lights/pointLight" {
  62560. import { Scene } from "babylonjs/scene";
  62561. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  62562. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62563. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  62564. import { Effect } from "babylonjs/Materials/effect";
  62565. /**
  62566. * A point light is a light defined by an unique point in world space.
  62567. * The light is emitted in every direction from this point.
  62568. * A good example of a point light is a standard light bulb.
  62569. * Documentation: https://doc.babylonjs.com/babylon101/lights
  62570. */
  62571. export class PointLight extends ShadowLight {
  62572. private _shadowAngle;
  62573. /**
  62574. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62575. * This specifies what angle the shadow will use to be created.
  62576. *
  62577. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  62578. */
  62579. get shadowAngle(): number;
  62580. /**
  62581. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62582. * This specifies what angle the shadow will use to be created.
  62583. *
  62584. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  62585. */
  62586. set shadowAngle(value: number);
  62587. /**
  62588. * Gets the direction if it has been set.
  62589. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62590. */
  62591. get direction(): Vector3;
  62592. /**
  62593. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62594. */
  62595. set direction(value: Vector3);
  62596. /**
  62597. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  62598. * A PointLight emits the light in every direction.
  62599. * It can cast shadows.
  62600. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  62601. * ```javascript
  62602. * var pointLight = new PointLight("pl", camera.position, scene);
  62603. * ```
  62604. * Documentation : https://doc.babylonjs.com/babylon101/lights
  62605. * @param name The light friendly name
  62606. * @param position The position of the point light in the scene
  62607. * @param scene The scene the lights belongs to
  62608. */
  62609. constructor(name: string, position: Vector3, scene: Scene);
  62610. /**
  62611. * Returns the string "PointLight"
  62612. * @returns the class name
  62613. */
  62614. getClassName(): string;
  62615. /**
  62616. * Returns the integer 0.
  62617. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  62618. */
  62619. getTypeID(): number;
  62620. /**
  62621. * Specifies wether or not the shadowmap should be a cube texture.
  62622. * @returns true if the shadowmap needs to be a cube texture.
  62623. */
  62624. needCube(): boolean;
  62625. /**
  62626. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  62627. * @param faceIndex The index of the face we are computed the direction to generate shadow
  62628. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  62629. */
  62630. getShadowDirection(faceIndex?: number): Vector3;
  62631. /**
  62632. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  62633. * - fov = PI / 2
  62634. * - aspect ratio : 1.0
  62635. * - z-near and far equal to the active camera minZ and maxZ.
  62636. * Returns the PointLight.
  62637. */
  62638. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  62639. protected _buildUniformLayout(): void;
  62640. /**
  62641. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  62642. * @param effect The effect to update
  62643. * @param lightIndex The index of the light in the effect to update
  62644. * @returns The point light
  62645. */
  62646. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  62647. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  62648. /**
  62649. * Prepares the list of defines specific to the light type.
  62650. * @param defines the list of defines
  62651. * @param lightIndex defines the index of the light for the effect
  62652. */
  62653. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  62654. }
  62655. }
  62656. declare module "babylonjs/Lights/index" {
  62657. export * from "babylonjs/Lights/light";
  62658. export * from "babylonjs/Lights/shadowLight";
  62659. export * from "babylonjs/Lights/Shadows/index";
  62660. export * from "babylonjs/Lights/directionalLight";
  62661. export * from "babylonjs/Lights/hemisphericLight";
  62662. export * from "babylonjs/Lights/pointLight";
  62663. export * from "babylonjs/Lights/spotLight";
  62664. }
  62665. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  62666. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  62667. /**
  62668. * Header information of HDR texture files.
  62669. */
  62670. export interface HDRInfo {
  62671. /**
  62672. * The height of the texture in pixels.
  62673. */
  62674. height: number;
  62675. /**
  62676. * The width of the texture in pixels.
  62677. */
  62678. width: number;
  62679. /**
  62680. * The index of the beginning of the data in the binary file.
  62681. */
  62682. dataPosition: number;
  62683. }
  62684. /**
  62685. * This groups tools to convert HDR texture to native colors array.
  62686. */
  62687. export class HDRTools {
  62688. private static Ldexp;
  62689. private static Rgbe2float;
  62690. private static readStringLine;
  62691. /**
  62692. * Reads header information from an RGBE texture stored in a native array.
  62693. * More information on this format are available here:
  62694. * https://en.wikipedia.org/wiki/RGBE_image_format
  62695. *
  62696. * @param uint8array The binary file stored in native array.
  62697. * @return The header information.
  62698. */
  62699. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  62700. /**
  62701. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  62702. * This RGBE texture needs to store the information as a panorama.
  62703. *
  62704. * More information on this format are available here:
  62705. * https://en.wikipedia.org/wiki/RGBE_image_format
  62706. *
  62707. * @param buffer The binary file stored in an array buffer.
  62708. * @param size The expected size of the extracted cubemap.
  62709. * @return The Cube Map information.
  62710. */
  62711. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  62712. /**
  62713. * Returns the pixels data extracted from an RGBE texture.
  62714. * This pixels will be stored left to right up to down in the R G B order in one array.
  62715. *
  62716. * More information on this format are available here:
  62717. * https://en.wikipedia.org/wiki/RGBE_image_format
  62718. *
  62719. * @param uint8array The binary file stored in an array buffer.
  62720. * @param hdrInfo The header information of the file.
  62721. * @return The pixels data in RGB right to left up to down order.
  62722. */
  62723. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  62724. private static RGBE_ReadPixels_RLE;
  62725. private static RGBE_ReadPixels_NOT_RLE;
  62726. }
  62727. }
  62728. declare module "babylonjs/Materials/effectRenderer" {
  62729. import { Nullable } from "babylonjs/types";
  62730. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  62731. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62732. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  62733. import { Viewport } from "babylonjs/Maths/math.viewport";
  62734. import { Observable } from "babylonjs/Misc/observable";
  62735. import { Effect } from "babylonjs/Materials/effect";
  62736. import "babylonjs/Shaders/postprocess.vertex";
  62737. /**
  62738. * Effect Render Options
  62739. */
  62740. export interface IEffectRendererOptions {
  62741. /**
  62742. * Defines the vertices positions.
  62743. */
  62744. positions?: number[];
  62745. /**
  62746. * Defines the indices.
  62747. */
  62748. indices?: number[];
  62749. }
  62750. /**
  62751. * Helper class to render one or more effects.
  62752. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  62753. */
  62754. export class EffectRenderer {
  62755. private engine;
  62756. private static _DefaultOptions;
  62757. private _vertexBuffers;
  62758. private _indexBuffer;
  62759. private _fullscreenViewport;
  62760. /**
  62761. * Creates an effect renderer
  62762. * @param engine the engine to use for rendering
  62763. * @param options defines the options of the effect renderer
  62764. */
  62765. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  62766. /**
  62767. * Sets the current viewport in normalized coordinates 0-1
  62768. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  62769. */
  62770. setViewport(viewport?: Viewport): void;
  62771. /**
  62772. * Binds the embedded attributes buffer to the effect.
  62773. * @param effect Defines the effect to bind the attributes for
  62774. */
  62775. bindBuffers(effect: Effect): void;
  62776. /**
  62777. * Sets the current effect wrapper to use during draw.
  62778. * The effect needs to be ready before calling this api.
  62779. * This also sets the default full screen position attribute.
  62780. * @param effectWrapper Defines the effect to draw with
  62781. */
  62782. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  62783. /**
  62784. * Restores engine states
  62785. */
  62786. restoreStates(): void;
  62787. /**
  62788. * Draws a full screen quad.
  62789. */
  62790. draw(): void;
  62791. private isRenderTargetTexture;
  62792. /**
  62793. * renders one or more effects to a specified texture
  62794. * @param effectWrapper the effect to renderer
  62795. * @param outputTexture texture to draw to, if null it will render to the screen.
  62796. */
  62797. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  62798. /**
  62799. * Disposes of the effect renderer
  62800. */
  62801. dispose(): void;
  62802. }
  62803. /**
  62804. * Options to create an EffectWrapper
  62805. */
  62806. interface EffectWrapperCreationOptions {
  62807. /**
  62808. * Engine to use to create the effect
  62809. */
  62810. engine: ThinEngine;
  62811. /**
  62812. * Fragment shader for the effect
  62813. */
  62814. fragmentShader: string;
  62815. /**
  62816. * Use the shader store instead of direct source code
  62817. */
  62818. useShaderStore?: boolean;
  62819. /**
  62820. * Vertex shader for the effect
  62821. */
  62822. vertexShader?: string;
  62823. /**
  62824. * Attributes to use in the shader
  62825. */
  62826. attributeNames?: Array<string>;
  62827. /**
  62828. * Uniforms to use in the shader
  62829. */
  62830. uniformNames?: Array<string>;
  62831. /**
  62832. * Texture sampler names to use in the shader
  62833. */
  62834. samplerNames?: Array<string>;
  62835. /**
  62836. * Defines to use in the shader
  62837. */
  62838. defines?: Array<string>;
  62839. /**
  62840. * Callback when effect is compiled
  62841. */
  62842. onCompiled?: Nullable<(effect: Effect) => void>;
  62843. /**
  62844. * The friendly name of the effect displayed in Spector.
  62845. */
  62846. name?: string;
  62847. }
  62848. /**
  62849. * Wraps an effect to be used for rendering
  62850. */
  62851. export class EffectWrapper {
  62852. /**
  62853. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  62854. */
  62855. onApplyObservable: Observable<{}>;
  62856. /**
  62857. * The underlying effect
  62858. */
  62859. effect: Effect;
  62860. /**
  62861. * Creates an effect to be renderer
  62862. * @param creationOptions options to create the effect
  62863. */
  62864. constructor(creationOptions: EffectWrapperCreationOptions);
  62865. /**
  62866. * Disposes of the effect wrapper
  62867. */
  62868. dispose(): void;
  62869. }
  62870. }
  62871. declare module "babylonjs/Shaders/hdrFiltering.vertex" {
  62872. /** @hidden */
  62873. export var hdrFilteringVertexShader: {
  62874. name: string;
  62875. shader: string;
  62876. };
  62877. }
  62878. declare module "babylonjs/Shaders/hdrFiltering.fragment" {
  62879. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62880. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  62881. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  62882. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  62883. /** @hidden */
  62884. export var hdrFilteringPixelShader: {
  62885. name: string;
  62886. shader: string;
  62887. };
  62888. }
  62889. declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
  62890. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62891. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  62892. import { Nullable } from "babylonjs/types";
  62893. import "babylonjs/Shaders/hdrFiltering.vertex";
  62894. import "babylonjs/Shaders/hdrFiltering.fragment";
  62895. /**
  62896. * Options for texture filtering
  62897. */
  62898. interface IHDRFilteringOptions {
  62899. /**
  62900. * Scales pixel intensity for the input HDR map.
  62901. */
  62902. hdrScale?: number;
  62903. /**
  62904. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  62905. */
  62906. quality?: number;
  62907. }
  62908. /**
  62909. * Filters HDR maps to get correct renderings of PBR reflections
  62910. */
  62911. export class HDRFiltering {
  62912. private _engine;
  62913. private _effectRenderer;
  62914. private _effectWrapper;
  62915. private _lodGenerationOffset;
  62916. private _lodGenerationScale;
  62917. /**
  62918. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  62919. * you care about baking speed.
  62920. */
  62921. quality: number;
  62922. /**
  62923. * Scales pixel intensity for the input HDR map.
  62924. */
  62925. hdrScale: number;
  62926. /**
  62927. * Instantiates HDR filter for reflection maps
  62928. *
  62929. * @param engine Thin engine
  62930. * @param options Options
  62931. */
  62932. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  62933. private _createRenderTarget;
  62934. private _prefilterInternal;
  62935. private _createEffect;
  62936. /**
  62937. * Get a value indicating if the filter is ready to be used
  62938. * @param texture Texture to filter
  62939. * @returns true if the filter is ready
  62940. */
  62941. isReady(texture: BaseTexture): boolean;
  62942. /**
  62943. * Prefilters a cube texture to have mipmap levels representing roughness values.
  62944. * Prefiltering will be invoked at the end of next rendering pass.
  62945. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  62946. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  62947. * @param texture Texture to filter
  62948. * @param onFinished Callback when filtering is done
  62949. * @return Promise called when prefiltering is done
  62950. */
  62951. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  62952. }
  62953. }
  62954. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  62955. import { Nullable } from "babylonjs/types";
  62956. import { Scene } from "babylonjs/scene";
  62957. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  62958. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62959. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  62960. import "babylonjs/Engines/Extensions/engine.rawTexture";
  62961. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  62962. /**
  62963. * This represents a texture coming from an HDR input.
  62964. *
  62965. * The only supported format is currently panorama picture stored in RGBE format.
  62966. * Example of such files can be found on HDRLib: http://hdrlib.com/
  62967. */
  62968. export class HDRCubeTexture extends BaseTexture {
  62969. private static _facesMapping;
  62970. private _generateHarmonics;
  62971. private _noMipmap;
  62972. private _prefilterOnLoad;
  62973. private _textureMatrix;
  62974. private _size;
  62975. private _onLoad;
  62976. private _onError;
  62977. /**
  62978. * The texture URL.
  62979. */
  62980. url: string;
  62981. /**
  62982. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  62983. */
  62984. coordinatesMode: number;
  62985. protected _isBlocking: boolean;
  62986. /**
  62987. * Sets wether or not the texture is blocking during loading.
  62988. */
  62989. set isBlocking(value: boolean);
  62990. /**
  62991. * Gets wether or not the texture is blocking during loading.
  62992. */
  62993. get isBlocking(): boolean;
  62994. protected _rotationY: number;
  62995. /**
  62996. * Sets texture matrix rotation angle around Y axis in radians.
  62997. */
  62998. set rotationY(value: number);
  62999. /**
  63000. * Gets texture matrix rotation angle around Y axis radians.
  63001. */
  63002. get rotationY(): number;
  63003. /**
  63004. * Gets or sets the center of the bounding box associated with the cube texture
  63005. * It must define where the camera used to render the texture was set
  63006. */
  63007. boundingBoxPosition: Vector3;
  63008. private _boundingBoxSize;
  63009. /**
  63010. * Gets or sets the size of the bounding box associated with the cube texture
  63011. * When defined, the cubemap will switch to local mode
  63012. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  63013. * @example https://www.babylonjs-playground.com/#RNASML
  63014. */
  63015. set boundingBoxSize(value: Vector3);
  63016. get boundingBoxSize(): Vector3;
  63017. /**
  63018. * Instantiates an HDRTexture from the following parameters.
  63019. *
  63020. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  63021. * @param sceneOrEngine The scene or engine the texture will be used in
  63022. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  63023. * @param noMipmap Forces to not generate the mipmap if true
  63024. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  63025. * @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)
  63026. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  63027. */
  63028. 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>);
  63029. /**
  63030. * Get the current class name of the texture useful for serialization or dynamic coding.
  63031. * @returns "HDRCubeTexture"
  63032. */
  63033. getClassName(): string;
  63034. /**
  63035. * Occurs when the file is raw .hdr file.
  63036. */
  63037. private loadTexture;
  63038. clone(): HDRCubeTexture;
  63039. delayLoad(): void;
  63040. /**
  63041. * Get the texture reflection matrix used to rotate/transform the reflection.
  63042. * @returns the reflection matrix
  63043. */
  63044. getReflectionTextureMatrix(): Matrix;
  63045. /**
  63046. * Set the texture reflection matrix used to rotate/transform the reflection.
  63047. * @param value Define the reflection matrix to set
  63048. */
  63049. setReflectionTextureMatrix(value: Matrix): void;
  63050. /**
  63051. * Parses a JSON representation of an HDR Texture in order to create the texture
  63052. * @param parsedTexture Define the JSON representation
  63053. * @param scene Define the scene the texture should be created in
  63054. * @param rootUrl Define the root url in case we need to load relative dependencies
  63055. * @returns the newly created texture after parsing
  63056. */
  63057. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  63058. serialize(): any;
  63059. }
  63060. }
  63061. declare module "babylonjs/Physics/physicsEngine" {
  63062. import { Nullable } from "babylonjs/types";
  63063. import { Vector3 } from "babylonjs/Maths/math.vector";
  63064. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  63065. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  63066. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  63067. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63068. /**
  63069. * Class used to control physics engine
  63070. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  63071. */
  63072. export class PhysicsEngine implements IPhysicsEngine {
  63073. private _physicsPlugin;
  63074. /**
  63075. * Global value used to control the smallest number supported by the simulation
  63076. */
  63077. static Epsilon: number;
  63078. private _impostors;
  63079. private _joints;
  63080. private _subTimeStep;
  63081. /**
  63082. * Gets the gravity vector used by the simulation
  63083. */
  63084. gravity: Vector3;
  63085. /**
  63086. * Factory used to create the default physics plugin.
  63087. * @returns The default physics plugin
  63088. */
  63089. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  63090. /**
  63091. * Creates a new Physics Engine
  63092. * @param gravity defines the gravity vector used by the simulation
  63093. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  63094. */
  63095. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  63096. /**
  63097. * Sets the gravity vector used by the simulation
  63098. * @param gravity defines the gravity vector to use
  63099. */
  63100. setGravity(gravity: Vector3): void;
  63101. /**
  63102. * Set the time step of the physics engine.
  63103. * Default is 1/60.
  63104. * To slow it down, enter 1/600 for example.
  63105. * To speed it up, 1/30
  63106. * @param newTimeStep defines the new timestep to apply to this world.
  63107. */
  63108. setTimeStep(newTimeStep?: number): void;
  63109. /**
  63110. * Get the time step of the physics engine.
  63111. * @returns the current time step
  63112. */
  63113. getTimeStep(): number;
  63114. /**
  63115. * Set the sub time step of the physics engine.
  63116. * Default is 0 meaning there is no sub steps
  63117. * To increase physics resolution precision, set a small value (like 1 ms)
  63118. * @param subTimeStep defines the new sub timestep used for physics resolution.
  63119. */
  63120. setSubTimeStep(subTimeStep?: number): void;
  63121. /**
  63122. * Get the sub time step of the physics engine.
  63123. * @returns the current sub time step
  63124. */
  63125. getSubTimeStep(): number;
  63126. /**
  63127. * Release all resources
  63128. */
  63129. dispose(): void;
  63130. /**
  63131. * Gets the name of the current physics plugin
  63132. * @returns the name of the plugin
  63133. */
  63134. getPhysicsPluginName(): string;
  63135. /**
  63136. * Adding a new impostor for the impostor tracking.
  63137. * This will be done by the impostor itself.
  63138. * @param impostor the impostor to add
  63139. */
  63140. addImpostor(impostor: PhysicsImpostor): void;
  63141. /**
  63142. * Remove an impostor from the engine.
  63143. * This impostor and its mesh will not longer be updated by the physics engine.
  63144. * @param impostor the impostor to remove
  63145. */
  63146. removeImpostor(impostor: PhysicsImpostor): void;
  63147. /**
  63148. * Add a joint to the physics engine
  63149. * @param mainImpostor defines the main impostor to which the joint is added.
  63150. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  63151. * @param joint defines the joint that will connect both impostors.
  63152. */
  63153. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  63154. /**
  63155. * Removes a joint from the simulation
  63156. * @param mainImpostor defines the impostor used with the joint
  63157. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  63158. * @param joint defines the joint to remove
  63159. */
  63160. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  63161. /**
  63162. * Called by the scene. No need to call it.
  63163. * @param delta defines the timespam between frames
  63164. */
  63165. _step(delta: number): void;
  63166. /**
  63167. * Gets the current plugin used to run the simulation
  63168. * @returns current plugin
  63169. */
  63170. getPhysicsPlugin(): IPhysicsEnginePlugin;
  63171. /**
  63172. * Gets the list of physic impostors
  63173. * @returns an array of PhysicsImpostor
  63174. */
  63175. getImpostors(): Array<PhysicsImpostor>;
  63176. /**
  63177. * Gets the impostor for a physics enabled object
  63178. * @param object defines the object impersonated by the impostor
  63179. * @returns the PhysicsImpostor or null if not found
  63180. */
  63181. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  63182. /**
  63183. * Gets the impostor for a physics body object
  63184. * @param body defines physics body used by the impostor
  63185. * @returns the PhysicsImpostor or null if not found
  63186. */
  63187. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  63188. /**
  63189. * Does a raycast in the physics world
  63190. * @param from when should the ray start?
  63191. * @param to when should the ray end?
  63192. * @returns PhysicsRaycastResult
  63193. */
  63194. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63195. }
  63196. }
  63197. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  63198. import { Nullable } from "babylonjs/types";
  63199. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  63200. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63201. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63202. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63203. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63204. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63205. /** @hidden */
  63206. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  63207. private _useDeltaForWorldStep;
  63208. world: any;
  63209. name: string;
  63210. private _physicsMaterials;
  63211. private _fixedTimeStep;
  63212. private _cannonRaycastResult;
  63213. private _raycastResult;
  63214. private _physicsBodysToRemoveAfterStep;
  63215. private _firstFrame;
  63216. BJSCANNON: any;
  63217. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  63218. setGravity(gravity: Vector3): void;
  63219. setTimeStep(timeStep: number): void;
  63220. getTimeStep(): number;
  63221. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63222. private _removeMarkedPhysicsBodiesFromWorld;
  63223. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63224. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63225. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63226. private _processChildMeshes;
  63227. removePhysicsBody(impostor: PhysicsImpostor): void;
  63228. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63229. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63230. private _addMaterial;
  63231. private _checkWithEpsilon;
  63232. private _createShape;
  63233. private _createHeightmap;
  63234. private _minus90X;
  63235. private _plus90X;
  63236. private _tmpPosition;
  63237. private _tmpDeltaPosition;
  63238. private _tmpUnityRotation;
  63239. private _updatePhysicsBodyTransformation;
  63240. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63241. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63242. isSupported(): boolean;
  63243. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63244. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63245. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63246. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63247. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63248. getBodyMass(impostor: PhysicsImpostor): number;
  63249. getBodyFriction(impostor: PhysicsImpostor): number;
  63250. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63251. getBodyRestitution(impostor: PhysicsImpostor): number;
  63252. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  63253. sleepBody(impostor: PhysicsImpostor): void;
  63254. wakeUpBody(impostor: PhysicsImpostor): void;
  63255. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  63256. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  63257. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  63258. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  63259. getRadius(impostor: PhysicsImpostor): number;
  63260. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  63261. dispose(): void;
  63262. private _extendNamespace;
  63263. /**
  63264. * Does a raycast in the physics world
  63265. * @param from when should the ray start?
  63266. * @param to when should the ray end?
  63267. * @returns PhysicsRaycastResult
  63268. */
  63269. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63270. }
  63271. }
  63272. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  63273. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63274. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63275. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63276. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63277. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  63278. import { Nullable } from "babylonjs/types";
  63279. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63280. /** @hidden */
  63281. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  63282. private _useDeltaForWorldStep;
  63283. world: any;
  63284. name: string;
  63285. BJSOIMO: any;
  63286. private _raycastResult;
  63287. private _fixedTimeStep;
  63288. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  63289. setGravity(gravity: Vector3): void;
  63290. setTimeStep(timeStep: number): void;
  63291. getTimeStep(): number;
  63292. private _tmpImpostorsArray;
  63293. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63294. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63295. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63296. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63297. private _tmpPositionVector;
  63298. removePhysicsBody(impostor: PhysicsImpostor): void;
  63299. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63300. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63301. isSupported(): boolean;
  63302. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63303. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63304. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63305. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63306. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63307. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63308. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63309. getBodyMass(impostor: PhysicsImpostor): number;
  63310. getBodyFriction(impostor: PhysicsImpostor): number;
  63311. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63312. getBodyRestitution(impostor: PhysicsImpostor): number;
  63313. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  63314. sleepBody(impostor: PhysicsImpostor): void;
  63315. wakeUpBody(impostor: PhysicsImpostor): void;
  63316. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  63317. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  63318. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  63319. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  63320. getRadius(impostor: PhysicsImpostor): number;
  63321. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  63322. dispose(): void;
  63323. /**
  63324. * Does a raycast in the physics world
  63325. * @param from when should the ray start?
  63326. * @param to when should the ray end?
  63327. * @returns PhysicsRaycastResult
  63328. */
  63329. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63330. }
  63331. }
  63332. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  63333. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  63334. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63335. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63336. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63337. import { Nullable } from "babylonjs/types";
  63338. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63339. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63340. /**
  63341. * AmmoJS Physics plugin
  63342. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  63343. * @see https://github.com/kripken/ammo.js/
  63344. */
  63345. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  63346. private _useDeltaForWorldStep;
  63347. /**
  63348. * Reference to the Ammo library
  63349. */
  63350. bjsAMMO: any;
  63351. /**
  63352. * Created ammoJS world which physics bodies are added to
  63353. */
  63354. world: any;
  63355. /**
  63356. * Name of the plugin
  63357. */
  63358. name: string;
  63359. private _timeStep;
  63360. private _fixedTimeStep;
  63361. private _maxSteps;
  63362. private _tmpQuaternion;
  63363. private _tmpAmmoTransform;
  63364. private _tmpAmmoQuaternion;
  63365. private _tmpAmmoConcreteContactResultCallback;
  63366. private _collisionConfiguration;
  63367. private _dispatcher;
  63368. private _overlappingPairCache;
  63369. private _solver;
  63370. private _softBodySolver;
  63371. private _tmpAmmoVectorA;
  63372. private _tmpAmmoVectorB;
  63373. private _tmpAmmoVectorC;
  63374. private _tmpAmmoVectorD;
  63375. private _tmpContactCallbackResult;
  63376. private _tmpAmmoVectorRCA;
  63377. private _tmpAmmoVectorRCB;
  63378. private _raycastResult;
  63379. private static readonly DISABLE_COLLISION_FLAG;
  63380. private static readonly KINEMATIC_FLAG;
  63381. private static readonly DISABLE_DEACTIVATION_FLAG;
  63382. /**
  63383. * Initializes the ammoJS plugin
  63384. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  63385. * @param ammoInjection can be used to inject your own ammo reference
  63386. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  63387. */
  63388. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  63389. /**
  63390. * Sets the gravity of the physics world (m/(s^2))
  63391. * @param gravity Gravity to set
  63392. */
  63393. setGravity(gravity: Vector3): void;
  63394. /**
  63395. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  63396. * @param timeStep timestep to use in seconds
  63397. */
  63398. setTimeStep(timeStep: number): void;
  63399. /**
  63400. * 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)
  63401. * @param fixedTimeStep fixedTimeStep to use in seconds
  63402. */
  63403. setFixedTimeStep(fixedTimeStep: number): void;
  63404. /**
  63405. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  63406. * @param maxSteps the maximum number of steps by the physics engine per frame
  63407. */
  63408. setMaxSteps(maxSteps: number): void;
  63409. /**
  63410. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  63411. * @returns the current timestep in seconds
  63412. */
  63413. getTimeStep(): number;
  63414. /**
  63415. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  63416. */
  63417. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  63418. private _isImpostorInContact;
  63419. private _isImpostorPairInContact;
  63420. private _stepSimulation;
  63421. /**
  63422. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  63423. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  63424. * After the step the babylon meshes are set to the position of the physics imposters
  63425. * @param delta amount of time to step forward
  63426. * @param impostors array of imposters to update before/after the step
  63427. */
  63428. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63429. /**
  63430. * Update babylon mesh to match physics world object
  63431. * @param impostor imposter to match
  63432. */
  63433. private _afterSoftStep;
  63434. /**
  63435. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  63436. * @param impostor imposter to match
  63437. */
  63438. private _ropeStep;
  63439. /**
  63440. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  63441. * @param impostor imposter to match
  63442. */
  63443. private _softbodyOrClothStep;
  63444. private _tmpMatrix;
  63445. /**
  63446. * Applies an impulse on the imposter
  63447. * @param impostor imposter to apply impulse to
  63448. * @param force amount of force to be applied to the imposter
  63449. * @param contactPoint the location to apply the impulse on the imposter
  63450. */
  63451. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63452. /**
  63453. * Applies a force on the imposter
  63454. * @param impostor imposter to apply force
  63455. * @param force amount of force to be applied to the imposter
  63456. * @param contactPoint the location to apply the force on the imposter
  63457. */
  63458. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63459. /**
  63460. * Creates a physics body using the plugin
  63461. * @param impostor the imposter to create the physics body on
  63462. */
  63463. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63464. /**
  63465. * Removes the physics body from the imposter and disposes of the body's memory
  63466. * @param impostor imposter to remove the physics body from
  63467. */
  63468. removePhysicsBody(impostor: PhysicsImpostor): void;
  63469. /**
  63470. * Generates a joint
  63471. * @param impostorJoint the imposter joint to create the joint with
  63472. */
  63473. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63474. /**
  63475. * Removes a joint
  63476. * @param impostorJoint the imposter joint to remove the joint from
  63477. */
  63478. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63479. private _addMeshVerts;
  63480. /**
  63481. * Initialise the soft body vertices to match its object's (mesh) vertices
  63482. * Softbody vertices (nodes) are in world space and to match this
  63483. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  63484. * @param impostor to create the softbody for
  63485. */
  63486. private _softVertexData;
  63487. /**
  63488. * Create an impostor's soft body
  63489. * @param impostor to create the softbody for
  63490. */
  63491. private _createSoftbody;
  63492. /**
  63493. * Create cloth for an impostor
  63494. * @param impostor to create the softbody for
  63495. */
  63496. private _createCloth;
  63497. /**
  63498. * Create rope for an impostor
  63499. * @param impostor to create the softbody for
  63500. */
  63501. private _createRope;
  63502. /**
  63503. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  63504. * @param impostor to create the custom physics shape for
  63505. */
  63506. private _createCustom;
  63507. private _addHullVerts;
  63508. private _createShape;
  63509. /**
  63510. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  63511. * @param impostor imposter containing the physics body and babylon object
  63512. */
  63513. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63514. /**
  63515. * Sets the babylon object's position/rotation from the physics body's position/rotation
  63516. * @param impostor imposter containing the physics body and babylon object
  63517. * @param newPosition new position
  63518. * @param newRotation new rotation
  63519. */
  63520. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63521. /**
  63522. * If this plugin is supported
  63523. * @returns true if its supported
  63524. */
  63525. isSupported(): boolean;
  63526. /**
  63527. * Sets the linear velocity of the physics body
  63528. * @param impostor imposter to set the velocity on
  63529. * @param velocity velocity to set
  63530. */
  63531. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63532. /**
  63533. * Sets the angular velocity of the physics body
  63534. * @param impostor imposter to set the velocity on
  63535. * @param velocity velocity to set
  63536. */
  63537. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63538. /**
  63539. * gets the linear velocity
  63540. * @param impostor imposter to get linear velocity from
  63541. * @returns linear velocity
  63542. */
  63543. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63544. /**
  63545. * gets the angular velocity
  63546. * @param impostor imposter to get angular velocity from
  63547. * @returns angular velocity
  63548. */
  63549. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63550. /**
  63551. * Sets the mass of physics body
  63552. * @param impostor imposter to set the mass on
  63553. * @param mass mass to set
  63554. */
  63555. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63556. /**
  63557. * Gets the mass of the physics body
  63558. * @param impostor imposter to get the mass from
  63559. * @returns mass
  63560. */
  63561. getBodyMass(impostor: PhysicsImpostor): number;
  63562. /**
  63563. * Gets friction of the impostor
  63564. * @param impostor impostor to get friction from
  63565. * @returns friction value
  63566. */
  63567. getBodyFriction(impostor: PhysicsImpostor): number;
  63568. /**
  63569. * Sets friction of the impostor
  63570. * @param impostor impostor to set friction on
  63571. * @param friction friction value
  63572. */
  63573. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63574. /**
  63575. * Gets restitution of the impostor
  63576. * @param impostor impostor to get restitution from
  63577. * @returns restitution value
  63578. */
  63579. getBodyRestitution(impostor: PhysicsImpostor): number;
  63580. /**
  63581. * Sets resitution of the impostor
  63582. * @param impostor impostor to set resitution on
  63583. * @param restitution resitution value
  63584. */
  63585. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  63586. /**
  63587. * Gets pressure inside the impostor
  63588. * @param impostor impostor to get pressure from
  63589. * @returns pressure value
  63590. */
  63591. getBodyPressure(impostor: PhysicsImpostor): number;
  63592. /**
  63593. * Sets pressure inside a soft body impostor
  63594. * Cloth and rope must remain 0 pressure
  63595. * @param impostor impostor to set pressure on
  63596. * @param pressure pressure value
  63597. */
  63598. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  63599. /**
  63600. * Gets stiffness of the impostor
  63601. * @param impostor impostor to get stiffness from
  63602. * @returns pressure value
  63603. */
  63604. getBodyStiffness(impostor: PhysicsImpostor): number;
  63605. /**
  63606. * Sets stiffness of the impostor
  63607. * @param impostor impostor to set stiffness on
  63608. * @param stiffness stiffness value from 0 to 1
  63609. */
  63610. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  63611. /**
  63612. * Gets velocityIterations of the impostor
  63613. * @param impostor impostor to get velocity iterations from
  63614. * @returns velocityIterations value
  63615. */
  63616. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  63617. /**
  63618. * Sets velocityIterations of the impostor
  63619. * @param impostor impostor to set velocity iterations on
  63620. * @param velocityIterations velocityIterations value
  63621. */
  63622. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  63623. /**
  63624. * Gets positionIterations of the impostor
  63625. * @param impostor impostor to get position iterations from
  63626. * @returns positionIterations value
  63627. */
  63628. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  63629. /**
  63630. * Sets positionIterations of the impostor
  63631. * @param impostor impostor to set position on
  63632. * @param positionIterations positionIterations value
  63633. */
  63634. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  63635. /**
  63636. * Append an anchor to a cloth object
  63637. * @param impostor is the cloth impostor to add anchor to
  63638. * @param otherImpostor is the rigid impostor to anchor to
  63639. * @param width ratio across width from 0 to 1
  63640. * @param height ratio up height from 0 to 1
  63641. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  63642. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  63643. */
  63644. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  63645. /**
  63646. * Append an hook to a rope object
  63647. * @param impostor is the rope impostor to add hook to
  63648. * @param otherImpostor is the rigid impostor to hook to
  63649. * @param length ratio along the rope from 0 to 1
  63650. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  63651. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  63652. */
  63653. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  63654. /**
  63655. * Sleeps the physics body and stops it from being active
  63656. * @param impostor impostor to sleep
  63657. */
  63658. sleepBody(impostor: PhysicsImpostor): void;
  63659. /**
  63660. * Activates the physics body
  63661. * @param impostor impostor to activate
  63662. */
  63663. wakeUpBody(impostor: PhysicsImpostor): void;
  63664. /**
  63665. * Updates the distance parameters of the joint
  63666. * @param joint joint to update
  63667. * @param maxDistance maximum distance of the joint
  63668. * @param minDistance minimum distance of the joint
  63669. */
  63670. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  63671. /**
  63672. * Sets a motor on the joint
  63673. * @param joint joint to set motor on
  63674. * @param speed speed of the motor
  63675. * @param maxForce maximum force of the motor
  63676. * @param motorIndex index of the motor
  63677. */
  63678. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  63679. /**
  63680. * Sets the motors limit
  63681. * @param joint joint to set limit on
  63682. * @param upperLimit upper limit
  63683. * @param lowerLimit lower limit
  63684. */
  63685. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  63686. /**
  63687. * Syncs the position and rotation of a mesh with the impostor
  63688. * @param mesh mesh to sync
  63689. * @param impostor impostor to update the mesh with
  63690. */
  63691. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  63692. /**
  63693. * Gets the radius of the impostor
  63694. * @param impostor impostor to get radius from
  63695. * @returns the radius
  63696. */
  63697. getRadius(impostor: PhysicsImpostor): number;
  63698. /**
  63699. * Gets the box size of the impostor
  63700. * @param impostor impostor to get box size from
  63701. * @param result the resulting box size
  63702. */
  63703. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  63704. /**
  63705. * Disposes of the impostor
  63706. */
  63707. dispose(): void;
  63708. /**
  63709. * Does a raycast in the physics world
  63710. * @param from when should the ray start?
  63711. * @param to when should the ray end?
  63712. * @returns PhysicsRaycastResult
  63713. */
  63714. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63715. }
  63716. }
  63717. declare module "babylonjs/Probes/reflectionProbe" {
  63718. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63719. import { Vector3 } from "babylonjs/Maths/math.vector";
  63720. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63721. import { Nullable } from "babylonjs/types";
  63722. import { Scene } from "babylonjs/scene";
  63723. module "babylonjs/abstractScene" {
  63724. interface AbstractScene {
  63725. /**
  63726. * The list of reflection probes added to the scene
  63727. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  63728. */
  63729. reflectionProbes: Array<ReflectionProbe>;
  63730. /**
  63731. * Removes the given reflection probe from this scene.
  63732. * @param toRemove The reflection probe to remove
  63733. * @returns The index of the removed reflection probe
  63734. */
  63735. removeReflectionProbe(toRemove: ReflectionProbe): number;
  63736. /**
  63737. * Adds the given reflection probe to this scene.
  63738. * @param newReflectionProbe The reflection probe to add
  63739. */
  63740. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  63741. }
  63742. }
  63743. /**
  63744. * Class used to generate realtime reflection / refraction cube textures
  63745. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  63746. */
  63747. export class ReflectionProbe {
  63748. /** defines the name of the probe */
  63749. name: string;
  63750. private _scene;
  63751. private _renderTargetTexture;
  63752. private _projectionMatrix;
  63753. private _viewMatrix;
  63754. private _target;
  63755. private _add;
  63756. private _attachedMesh;
  63757. private _invertYAxis;
  63758. /** Gets or sets probe position (center of the cube map) */
  63759. position: Vector3;
  63760. /**
  63761. * Creates a new reflection probe
  63762. * @param name defines the name of the probe
  63763. * @param size defines the texture resolution (for each face)
  63764. * @param scene defines the hosting scene
  63765. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  63766. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  63767. */
  63768. constructor(
  63769. /** defines the name of the probe */
  63770. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  63771. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  63772. get samples(): number;
  63773. set samples(value: number);
  63774. /** Gets or sets the refresh rate to use (on every frame by default) */
  63775. get refreshRate(): number;
  63776. set refreshRate(value: number);
  63777. /**
  63778. * Gets the hosting scene
  63779. * @returns a Scene
  63780. */
  63781. getScene(): Scene;
  63782. /** Gets the internal CubeTexture used to render to */
  63783. get cubeTexture(): RenderTargetTexture;
  63784. /** Gets the list of meshes to render */
  63785. get renderList(): Nullable<AbstractMesh[]>;
  63786. /**
  63787. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  63788. * @param mesh defines the mesh to attach to
  63789. */
  63790. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  63791. /**
  63792. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  63793. * @param renderingGroupId The rendering group id corresponding to its index
  63794. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  63795. */
  63796. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  63797. /**
  63798. * Clean all associated resources
  63799. */
  63800. dispose(): void;
  63801. /**
  63802. * Converts the reflection probe information to a readable string for debug purpose.
  63803. * @param fullDetails Supports for multiple levels of logging within scene loading
  63804. * @returns the human readable reflection probe info
  63805. */
  63806. toString(fullDetails?: boolean): string;
  63807. /**
  63808. * Get the class name of the relfection probe.
  63809. * @returns "ReflectionProbe"
  63810. */
  63811. getClassName(): string;
  63812. /**
  63813. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  63814. * @returns The JSON representation of the texture
  63815. */
  63816. serialize(): any;
  63817. /**
  63818. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  63819. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  63820. * @param scene Define the scene the parsed reflection probe should be instantiated in
  63821. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  63822. * @returns The parsed reflection probe if successful
  63823. */
  63824. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  63825. }
  63826. }
  63827. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  63828. /** @hidden */
  63829. export var _BabylonLoaderRegistered: boolean;
  63830. /**
  63831. * Helps setting up some configuration for the babylon file loader.
  63832. */
  63833. export class BabylonFileLoaderConfiguration {
  63834. /**
  63835. * The loader does not allow injecting custom physix engine into the plugins.
  63836. * Unfortunately in ES6, we need to manually inject them into the plugin.
  63837. * So you could set this variable to your engine import to make it work.
  63838. */
  63839. static LoaderInjectedPhysicsEngine: any;
  63840. }
  63841. }
  63842. declare module "babylonjs/Loading/Plugins/index" {
  63843. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  63844. }
  63845. declare module "babylonjs/Loading/index" {
  63846. export * from "babylonjs/Loading/loadingScreen";
  63847. export * from "babylonjs/Loading/Plugins/index";
  63848. export * from "babylonjs/Loading/sceneLoader";
  63849. export * from "babylonjs/Loading/sceneLoaderFlags";
  63850. }
  63851. declare module "babylonjs/Materials/Background/index" {
  63852. export * from "babylonjs/Materials/Background/backgroundMaterial";
  63853. }
  63854. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  63855. import { Scene } from "babylonjs/scene";
  63856. import { Color3 } from "babylonjs/Maths/math.color";
  63857. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  63858. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63859. /**
  63860. * The Physically based simple base material of BJS.
  63861. *
  63862. * This enables better naming and convention enforcements on top of the pbrMaterial.
  63863. * It is used as the base class for both the specGloss and metalRough conventions.
  63864. */
  63865. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  63866. /**
  63867. * Number of Simultaneous lights allowed on the material.
  63868. */
  63869. maxSimultaneousLights: number;
  63870. /**
  63871. * If sets to true, disables all the lights affecting the material.
  63872. */
  63873. disableLighting: boolean;
  63874. /**
  63875. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  63876. */
  63877. environmentTexture: BaseTexture;
  63878. /**
  63879. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  63880. */
  63881. invertNormalMapX: boolean;
  63882. /**
  63883. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  63884. */
  63885. invertNormalMapY: boolean;
  63886. /**
  63887. * Normal map used in the model.
  63888. */
  63889. normalTexture: BaseTexture;
  63890. /**
  63891. * Emissivie color used to self-illuminate the model.
  63892. */
  63893. emissiveColor: Color3;
  63894. /**
  63895. * Emissivie texture used to self-illuminate the model.
  63896. */
  63897. emissiveTexture: BaseTexture;
  63898. /**
  63899. * Occlusion Channel Strenght.
  63900. */
  63901. occlusionStrength: number;
  63902. /**
  63903. * Occlusion Texture of the material (adding extra occlusion effects).
  63904. */
  63905. occlusionTexture: BaseTexture;
  63906. /**
  63907. * Defines the alpha limits in alpha test mode.
  63908. */
  63909. alphaCutOff: number;
  63910. /**
  63911. * Gets the current double sided mode.
  63912. */
  63913. get doubleSided(): boolean;
  63914. /**
  63915. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  63916. */
  63917. set doubleSided(value: boolean);
  63918. /**
  63919. * Stores the pre-calculated light information of a mesh in a texture.
  63920. */
  63921. lightmapTexture: BaseTexture;
  63922. /**
  63923. * If true, the light map contains occlusion information instead of lighting info.
  63924. */
  63925. useLightmapAsShadowmap: boolean;
  63926. /**
  63927. * Instantiates a new PBRMaterial instance.
  63928. *
  63929. * @param name The material name
  63930. * @param scene The scene the material will be use in.
  63931. */
  63932. constructor(name: string, scene: Scene);
  63933. getClassName(): string;
  63934. }
  63935. }
  63936. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  63937. import { Scene } from "babylonjs/scene";
  63938. import { Color3 } from "babylonjs/Maths/math.color";
  63939. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63940. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  63941. /**
  63942. * The PBR material of BJS following the metal roughness convention.
  63943. *
  63944. * This fits to the PBR convention in the GLTF definition:
  63945. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  63946. */
  63947. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  63948. /**
  63949. * The base color has two different interpretations depending on the value of metalness.
  63950. * When the material is a metal, the base color is the specific measured reflectance value
  63951. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  63952. * of the material.
  63953. */
  63954. baseColor: Color3;
  63955. /**
  63956. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  63957. * well as opacity information in the alpha channel.
  63958. */
  63959. baseTexture: BaseTexture;
  63960. /**
  63961. * Specifies the metallic scalar value of the material.
  63962. * Can also be used to scale the metalness values of the metallic texture.
  63963. */
  63964. metallic: number;
  63965. /**
  63966. * Specifies the roughness scalar value of the material.
  63967. * Can also be used to scale the roughness values of the metallic texture.
  63968. */
  63969. roughness: number;
  63970. /**
  63971. * Texture containing both the metallic value in the B channel and the
  63972. * roughness value in the G channel to keep better precision.
  63973. */
  63974. metallicRoughnessTexture: BaseTexture;
  63975. /**
  63976. * Instantiates a new PBRMetalRoughnessMaterial instance.
  63977. *
  63978. * @param name The material name
  63979. * @param scene The scene the material will be use in.
  63980. */
  63981. constructor(name: string, scene: Scene);
  63982. /**
  63983. * Return the currrent class name of the material.
  63984. */
  63985. getClassName(): string;
  63986. /**
  63987. * Makes a duplicate of the current material.
  63988. * @param name - name to use for the new material.
  63989. */
  63990. clone(name: string): PBRMetallicRoughnessMaterial;
  63991. /**
  63992. * Serialize the material to a parsable JSON object.
  63993. */
  63994. serialize(): any;
  63995. /**
  63996. * Parses a JSON object correponding to the serialize function.
  63997. */
  63998. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  63999. }
  64000. }
  64001. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  64002. import { Scene } from "babylonjs/scene";
  64003. import { Color3 } from "babylonjs/Maths/math.color";
  64004. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64005. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  64006. /**
  64007. * The PBR material of BJS following the specular glossiness convention.
  64008. *
  64009. * This fits to the PBR convention in the GLTF definition:
  64010. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  64011. */
  64012. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  64013. /**
  64014. * Specifies the diffuse color of the material.
  64015. */
  64016. diffuseColor: Color3;
  64017. /**
  64018. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  64019. * channel.
  64020. */
  64021. diffuseTexture: BaseTexture;
  64022. /**
  64023. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  64024. */
  64025. specularColor: Color3;
  64026. /**
  64027. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  64028. */
  64029. glossiness: number;
  64030. /**
  64031. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  64032. */
  64033. specularGlossinessTexture: BaseTexture;
  64034. /**
  64035. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  64036. *
  64037. * @param name The material name
  64038. * @param scene The scene the material will be use in.
  64039. */
  64040. constructor(name: string, scene: Scene);
  64041. /**
  64042. * Return the currrent class name of the material.
  64043. */
  64044. getClassName(): string;
  64045. /**
  64046. * Makes a duplicate of the current material.
  64047. * @param name - name to use for the new material.
  64048. */
  64049. clone(name: string): PBRSpecularGlossinessMaterial;
  64050. /**
  64051. * Serialize the material to a parsable JSON object.
  64052. */
  64053. serialize(): any;
  64054. /**
  64055. * Parses a JSON object correponding to the serialize function.
  64056. */
  64057. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  64058. }
  64059. }
  64060. declare module "babylonjs/Materials/PBR/index" {
  64061. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  64062. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  64063. export * from "babylonjs/Materials/PBR/pbrMaterial";
  64064. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  64065. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  64066. }
  64067. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  64068. import { Nullable } from "babylonjs/types";
  64069. import { Scene } from "babylonjs/scene";
  64070. import { Matrix } from "babylonjs/Maths/math.vector";
  64071. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64072. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64073. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64074. /**
  64075. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  64076. * It can help converting any input color in a desired output one. This can then be used to create effects
  64077. * from sepia, black and white to sixties or futuristic rendering...
  64078. *
  64079. * The only supported format is currently 3dl.
  64080. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  64081. */
  64082. export class ColorGradingTexture extends BaseTexture {
  64083. /**
  64084. * The texture URL.
  64085. */
  64086. url: string;
  64087. /**
  64088. * Empty line regex stored for GC.
  64089. */
  64090. private static _noneEmptyLineRegex;
  64091. private _textureMatrix;
  64092. private _onLoad;
  64093. /**
  64094. * Instantiates a ColorGradingTexture from the following parameters.
  64095. *
  64096. * @param url The location of the color gradind data (currently only supporting 3dl)
  64097. * @param sceneOrEngine The scene or engine the texture will be used in
  64098. * @param onLoad defines a callback triggered when the texture has been loaded
  64099. */
  64100. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  64101. /**
  64102. * Fires the onload event from the constructor if requested.
  64103. */
  64104. private _triggerOnLoad;
  64105. /**
  64106. * Returns the texture matrix used in most of the material.
  64107. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  64108. */
  64109. getTextureMatrix(): Matrix;
  64110. /**
  64111. * Occurs when the file being loaded is a .3dl LUT file.
  64112. */
  64113. private load3dlTexture;
  64114. /**
  64115. * Starts the loading process of the texture.
  64116. */
  64117. private loadTexture;
  64118. /**
  64119. * Clones the color gradind texture.
  64120. */
  64121. clone(): ColorGradingTexture;
  64122. /**
  64123. * Called during delayed load for textures.
  64124. */
  64125. delayLoad(): void;
  64126. /**
  64127. * Parses a color grading texture serialized by Babylon.
  64128. * @param parsedTexture The texture information being parsedTexture
  64129. * @param scene The scene to load the texture in
  64130. * @param rootUrl The root url of the data assets to load
  64131. * @return A color gradind texture
  64132. */
  64133. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  64134. /**
  64135. * Serializes the LUT texture to json format.
  64136. */
  64137. serialize(): any;
  64138. }
  64139. }
  64140. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  64141. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64142. import { Scene } from "babylonjs/scene";
  64143. import { Nullable } from "babylonjs/types";
  64144. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64145. /**
  64146. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  64147. */
  64148. export class EquiRectangularCubeTexture extends BaseTexture {
  64149. /** The six faces of the cube. */
  64150. private static _FacesMapping;
  64151. private _noMipmap;
  64152. private _onLoad;
  64153. private _onError;
  64154. /** The size of the cubemap. */
  64155. private _size;
  64156. /** The buffer of the image. */
  64157. private _buffer;
  64158. /** The width of the input image. */
  64159. private _width;
  64160. /** The height of the input image. */
  64161. private _height;
  64162. /** The URL to the image. */
  64163. url: string;
  64164. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  64165. coordinatesMode: number;
  64166. /**
  64167. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  64168. * @param url The location of the image
  64169. * @param scene The scene the texture will be used in
  64170. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  64171. * @param noMipmap Forces to not generate the mipmap if true
  64172. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  64173. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  64174. * @param onLoad — defines a callback called when texture is loaded
  64175. * @param onError — defines a callback called if there is an error
  64176. */
  64177. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  64178. /**
  64179. * Load the image data, by putting the image on a canvas and extracting its buffer.
  64180. */
  64181. private loadImage;
  64182. /**
  64183. * Convert the image buffer into a cubemap and create a CubeTexture.
  64184. */
  64185. private loadTexture;
  64186. /**
  64187. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  64188. * @param buffer The ArrayBuffer that should be converted.
  64189. * @returns The buffer as Float32Array.
  64190. */
  64191. private getFloat32ArrayFromArrayBuffer;
  64192. /**
  64193. * Get the current class name of the texture useful for serialization or dynamic coding.
  64194. * @returns "EquiRectangularCubeTexture"
  64195. */
  64196. getClassName(): string;
  64197. /**
  64198. * Create a clone of the current EquiRectangularCubeTexture and return it.
  64199. * @returns A clone of the current EquiRectangularCubeTexture.
  64200. */
  64201. clone(): EquiRectangularCubeTexture;
  64202. }
  64203. }
  64204. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  64205. import { Nullable } from "babylonjs/types";
  64206. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64207. import { Matrix } from "babylonjs/Maths/math.vector";
  64208. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  64209. import "babylonjs/Engines/Extensions/engine.videoTexture";
  64210. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64211. import { Scene } from "babylonjs/scene";
  64212. /**
  64213. * Defines the options related to the creation of an HtmlElementTexture
  64214. */
  64215. export interface IHtmlElementTextureOptions {
  64216. /**
  64217. * Defines wether mip maps should be created or not.
  64218. */
  64219. generateMipMaps?: boolean;
  64220. /**
  64221. * Defines the sampling mode of the texture.
  64222. */
  64223. samplingMode?: number;
  64224. /**
  64225. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  64226. */
  64227. engine: Nullable<ThinEngine>;
  64228. /**
  64229. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  64230. */
  64231. scene: Nullable<Scene>;
  64232. }
  64233. /**
  64234. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  64235. * To be as efficient as possible depending on your constraints nothing aside the first upload
  64236. * is automatically managed.
  64237. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  64238. * in your application.
  64239. *
  64240. * As the update is not automatic, you need to call them manually.
  64241. */
  64242. export class HtmlElementTexture extends BaseTexture {
  64243. /**
  64244. * The texture URL.
  64245. */
  64246. element: HTMLVideoElement | HTMLCanvasElement;
  64247. private static readonly DefaultOptions;
  64248. private _textureMatrix;
  64249. private _isVideo;
  64250. private _generateMipMaps;
  64251. private _samplingMode;
  64252. /**
  64253. * Instantiates a HtmlElementTexture from the following parameters.
  64254. *
  64255. * @param name Defines the name of the texture
  64256. * @param element Defines the video or canvas the texture is filled with
  64257. * @param options Defines the other none mandatory texture creation options
  64258. */
  64259. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  64260. private _createInternalTexture;
  64261. /**
  64262. * Returns the texture matrix used in most of the material.
  64263. */
  64264. getTextureMatrix(): Matrix;
  64265. /**
  64266. * Updates the content of the texture.
  64267. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  64268. */
  64269. update(invertY?: Nullable<boolean>): void;
  64270. }
  64271. }
  64272. declare module "babylonjs/Misc/tga" {
  64273. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64274. /**
  64275. * Based on jsTGALoader - Javascript loader for TGA file
  64276. * By Vincent Thibault
  64277. * @see http://blog.robrowser.com/javascript-tga-loader.html
  64278. */
  64279. export class TGATools {
  64280. private static _TYPE_INDEXED;
  64281. private static _TYPE_RGB;
  64282. private static _TYPE_GREY;
  64283. private static _TYPE_RLE_INDEXED;
  64284. private static _TYPE_RLE_RGB;
  64285. private static _TYPE_RLE_GREY;
  64286. private static _ORIGIN_MASK;
  64287. private static _ORIGIN_SHIFT;
  64288. private static _ORIGIN_BL;
  64289. private static _ORIGIN_BR;
  64290. private static _ORIGIN_UL;
  64291. private static _ORIGIN_UR;
  64292. /**
  64293. * Gets the header of a TGA file
  64294. * @param data defines the TGA data
  64295. * @returns the header
  64296. */
  64297. static GetTGAHeader(data: Uint8Array): any;
  64298. /**
  64299. * Uploads TGA content to a Babylon Texture
  64300. * @hidden
  64301. */
  64302. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  64303. /** @hidden */
  64304. 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;
  64305. /** @hidden */
  64306. 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;
  64307. /** @hidden */
  64308. 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;
  64309. /** @hidden */
  64310. 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;
  64311. /** @hidden */
  64312. 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;
  64313. /** @hidden */
  64314. 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;
  64315. }
  64316. }
  64317. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  64318. import { Nullable } from "babylonjs/types";
  64319. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64320. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  64321. /**
  64322. * Implementation of the TGA Texture Loader.
  64323. * @hidden
  64324. */
  64325. export class _TGATextureLoader implements IInternalTextureLoader {
  64326. /**
  64327. * Defines wether the loader supports cascade loading the different faces.
  64328. */
  64329. readonly supportCascades: boolean;
  64330. /**
  64331. * This returns if the loader support the current file information.
  64332. * @param extension defines the file extension of the file being loaded
  64333. * @returns true if the loader can load the specified file
  64334. */
  64335. canLoad(extension: string): boolean;
  64336. /**
  64337. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  64338. * @param data contains the texture data
  64339. * @param texture defines the BabylonJS internal texture
  64340. * @param createPolynomials will be true if polynomials have been requested
  64341. * @param onLoad defines the callback to trigger once the texture is ready
  64342. * @param onError defines the callback to trigger in case of error
  64343. */
  64344. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  64345. /**
  64346. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  64347. * @param data contains the texture data
  64348. * @param texture defines the BabylonJS internal texture
  64349. * @param callback defines the method to call once ready to upload
  64350. */
  64351. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  64352. }
  64353. }
  64354. declare module "babylonjs/Misc/basis" {
  64355. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64356. /**
  64357. * Info about the .basis files
  64358. */
  64359. class BasisFileInfo {
  64360. /**
  64361. * If the file has alpha
  64362. */
  64363. hasAlpha: boolean;
  64364. /**
  64365. * Info about each image of the basis file
  64366. */
  64367. images: Array<{
  64368. levels: Array<{
  64369. width: number;
  64370. height: number;
  64371. transcodedPixels: ArrayBufferView;
  64372. }>;
  64373. }>;
  64374. }
  64375. /**
  64376. * Result of transcoding a basis file
  64377. */
  64378. class TranscodeResult {
  64379. /**
  64380. * Info about the .basis file
  64381. */
  64382. fileInfo: BasisFileInfo;
  64383. /**
  64384. * Format to use when loading the file
  64385. */
  64386. format: number;
  64387. }
  64388. /**
  64389. * Configuration options for the Basis transcoder
  64390. */
  64391. export class BasisTranscodeConfiguration {
  64392. /**
  64393. * Supported compression formats used to determine the supported output format of the transcoder
  64394. */
  64395. supportedCompressionFormats?: {
  64396. /**
  64397. * etc1 compression format
  64398. */
  64399. etc1?: boolean;
  64400. /**
  64401. * s3tc compression format
  64402. */
  64403. s3tc?: boolean;
  64404. /**
  64405. * pvrtc compression format
  64406. */
  64407. pvrtc?: boolean;
  64408. /**
  64409. * etc2 compression format
  64410. */
  64411. etc2?: boolean;
  64412. };
  64413. /**
  64414. * If mipmap levels should be loaded for transcoded images (Default: true)
  64415. */
  64416. loadMipmapLevels?: boolean;
  64417. /**
  64418. * Index of a single image to load (Default: all images)
  64419. */
  64420. loadSingleImage?: number;
  64421. }
  64422. /**
  64423. * Used to load .Basis files
  64424. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  64425. */
  64426. export class BasisTools {
  64427. private static _IgnoreSupportedFormats;
  64428. /**
  64429. * URL to use when loading the basis transcoder
  64430. */
  64431. static JSModuleURL: string;
  64432. /**
  64433. * URL to use when loading the wasm module for the transcoder
  64434. */
  64435. static WasmModuleURL: string;
  64436. /**
  64437. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  64438. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  64439. * @returns internal format corresponding to the Basis format
  64440. */
  64441. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  64442. private static _WorkerPromise;
  64443. private static _Worker;
  64444. private static _actionId;
  64445. private static _CreateWorkerAsync;
  64446. /**
  64447. * Transcodes a loaded image file to compressed pixel data
  64448. * @param data image data to transcode
  64449. * @param config configuration options for the transcoding
  64450. * @returns a promise resulting in the transcoded image
  64451. */
  64452. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  64453. /**
  64454. * Loads a texture from the transcode result
  64455. * @param texture texture load to
  64456. * @param transcodeResult the result of transcoding the basis file to load from
  64457. */
  64458. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  64459. }
  64460. }
  64461. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  64462. import { Nullable } from "babylonjs/types";
  64463. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64464. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  64465. /**
  64466. * Loader for .basis file format
  64467. */
  64468. export class _BasisTextureLoader implements IInternalTextureLoader {
  64469. /**
  64470. * Defines whether the loader supports cascade loading the different faces.
  64471. */
  64472. readonly supportCascades: boolean;
  64473. /**
  64474. * This returns if the loader support the current file information.
  64475. * @param extension defines the file extension of the file being loaded
  64476. * @returns true if the loader can load the specified file
  64477. */
  64478. canLoad(extension: string): boolean;
  64479. /**
  64480. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  64481. * @param data contains the texture data
  64482. * @param texture defines the BabylonJS internal texture
  64483. * @param createPolynomials will be true if polynomials have been requested
  64484. * @param onLoad defines the callback to trigger once the texture is ready
  64485. * @param onError defines the callback to trigger in case of error
  64486. */
  64487. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  64488. /**
  64489. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  64490. * @param data contains the texture data
  64491. * @param texture defines the BabylonJS internal texture
  64492. * @param callback defines the method to call once ready to upload
  64493. */
  64494. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  64495. }
  64496. }
  64497. declare module "babylonjs/Materials/Textures/Loaders/index" {
  64498. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  64499. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  64500. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  64501. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  64502. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  64503. }
  64504. declare module "babylonjs/Materials/Textures/Packer/frame" {
  64505. import { Vector2 } from "babylonjs/Maths/math.vector";
  64506. /**
  64507. * Defines the basic options interface of a TexturePacker Frame
  64508. */
  64509. export interface ITexturePackerFrame {
  64510. /**
  64511. * The frame ID
  64512. */
  64513. id: number;
  64514. /**
  64515. * The frames Scale
  64516. */
  64517. scale: Vector2;
  64518. /**
  64519. * The Frames offset
  64520. */
  64521. offset: Vector2;
  64522. }
  64523. /**
  64524. * This is a support class for frame Data on texture packer sets.
  64525. */
  64526. export class TexturePackerFrame implements ITexturePackerFrame {
  64527. /**
  64528. * The frame ID
  64529. */
  64530. id: number;
  64531. /**
  64532. * The frames Scale
  64533. */
  64534. scale: Vector2;
  64535. /**
  64536. * The Frames offset
  64537. */
  64538. offset: Vector2;
  64539. /**
  64540. * Initializes a texture package frame.
  64541. * @param id The numerical frame identifier
  64542. * @param scale Scalar Vector2 for UV frame
  64543. * @param offset Vector2 for the frame position in UV units.
  64544. * @returns TexturePackerFrame
  64545. */
  64546. constructor(id: number, scale: Vector2, offset: Vector2);
  64547. }
  64548. }
  64549. declare module "babylonjs/Materials/Textures/Packer/packer" {
  64550. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64551. import { Scene } from "babylonjs/scene";
  64552. import { Nullable } from "babylonjs/types";
  64553. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  64554. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  64555. /**
  64556. * Defines the basic options interface of a TexturePacker
  64557. */
  64558. export interface ITexturePackerOptions {
  64559. /**
  64560. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  64561. */
  64562. map?: string[];
  64563. /**
  64564. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  64565. */
  64566. uvsIn?: string;
  64567. /**
  64568. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  64569. */
  64570. uvsOut?: string;
  64571. /**
  64572. * number representing the layout style. Defaults to LAYOUT_STRIP
  64573. */
  64574. layout?: number;
  64575. /**
  64576. * number of columns if using custom column count layout(2). This defaults to 4.
  64577. */
  64578. colnum?: number;
  64579. /**
  64580. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  64581. */
  64582. updateInputMeshes?: boolean;
  64583. /**
  64584. * boolean flag to dispose all the source textures. Defaults to true.
  64585. */
  64586. disposeSources?: boolean;
  64587. /**
  64588. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  64589. */
  64590. fillBlanks?: boolean;
  64591. /**
  64592. * string value representing the context fill style color. Defaults to 'black'.
  64593. */
  64594. customFillColor?: string;
  64595. /**
  64596. * Width and Height Value of each Frame in the TexturePacker Sets
  64597. */
  64598. frameSize?: number;
  64599. /**
  64600. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  64601. */
  64602. paddingRatio?: number;
  64603. /**
  64604. * Number that declares the fill method for the padding gutter.
  64605. */
  64606. paddingMode?: number;
  64607. /**
  64608. * If in SUBUV_COLOR padding mode what color to use.
  64609. */
  64610. paddingColor?: Color3 | Color4;
  64611. }
  64612. /**
  64613. * Defines the basic interface of a TexturePacker JSON File
  64614. */
  64615. export interface ITexturePackerJSON {
  64616. /**
  64617. * The frame ID
  64618. */
  64619. name: string;
  64620. /**
  64621. * The base64 channel data
  64622. */
  64623. sets: any;
  64624. /**
  64625. * The options of the Packer
  64626. */
  64627. options: ITexturePackerOptions;
  64628. /**
  64629. * The frame data of the Packer
  64630. */
  64631. frames: Array<number>;
  64632. }
  64633. /**
  64634. * This is a support class that generates a series of packed texture sets.
  64635. * @see https://doc.babylonjs.com/babylon101/materials
  64636. */
  64637. export class TexturePacker {
  64638. /** Packer Layout Constant 0 */
  64639. static readonly LAYOUT_STRIP: number;
  64640. /** Packer Layout Constant 1 */
  64641. static readonly LAYOUT_POWER2: number;
  64642. /** Packer Layout Constant 2 */
  64643. static readonly LAYOUT_COLNUM: number;
  64644. /** Packer Layout Constant 0 */
  64645. static readonly SUBUV_WRAP: number;
  64646. /** Packer Layout Constant 1 */
  64647. static readonly SUBUV_EXTEND: number;
  64648. /** Packer Layout Constant 2 */
  64649. static readonly SUBUV_COLOR: number;
  64650. /** The Name of the Texture Package */
  64651. name: string;
  64652. /** The scene scope of the TexturePacker */
  64653. scene: Scene;
  64654. /** The Meshes to target */
  64655. meshes: AbstractMesh[];
  64656. /** Arguments passed with the Constructor */
  64657. options: ITexturePackerOptions;
  64658. /** The promise that is started upon initialization */
  64659. promise: Nullable<Promise<TexturePacker | string>>;
  64660. /** The Container object for the channel sets that are generated */
  64661. sets: object;
  64662. /** The Container array for the frames that are generated */
  64663. frames: TexturePackerFrame[];
  64664. /** The expected number of textures the system is parsing. */
  64665. private _expecting;
  64666. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  64667. private _paddingValue;
  64668. /**
  64669. * Initializes a texture package series from an array of meshes or a single mesh.
  64670. * @param name The name of the package
  64671. * @param meshes The target meshes to compose the package from
  64672. * @param options The arguments that texture packer should follow while building.
  64673. * @param scene The scene which the textures are scoped to.
  64674. * @returns TexturePacker
  64675. */
  64676. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  64677. /**
  64678. * Starts the package process
  64679. * @param resolve The promises resolution function
  64680. * @returns TexturePacker
  64681. */
  64682. private _createFrames;
  64683. /**
  64684. * Calculates the Size of the Channel Sets
  64685. * @returns Vector2
  64686. */
  64687. private _calculateSize;
  64688. /**
  64689. * Calculates the UV data for the frames.
  64690. * @param baseSize the base frameSize
  64691. * @param padding the base frame padding
  64692. * @param dtSize size of the Dynamic Texture for that channel
  64693. * @param dtUnits is 1/dtSize
  64694. * @param update flag to update the input meshes
  64695. */
  64696. private _calculateMeshUVFrames;
  64697. /**
  64698. * Calculates the frames Offset.
  64699. * @param index of the frame
  64700. * @returns Vector2
  64701. */
  64702. private _getFrameOffset;
  64703. /**
  64704. * Updates a Mesh to the frame data
  64705. * @param mesh that is the target
  64706. * @param frameID or the frame index
  64707. */
  64708. private _updateMeshUV;
  64709. /**
  64710. * Updates a Meshes materials to use the texture packer channels
  64711. * @param m is the mesh to target
  64712. * @param force all channels on the packer to be set.
  64713. */
  64714. private _updateTextureReferences;
  64715. /**
  64716. * Public method to set a Mesh to a frame
  64717. * @param m that is the target
  64718. * @param frameID or the frame index
  64719. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  64720. */
  64721. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  64722. /**
  64723. * Starts the async promise to compile the texture packer.
  64724. * @returns Promise<void>
  64725. */
  64726. processAsync(): Promise<void>;
  64727. /**
  64728. * Disposes all textures associated with this packer
  64729. */
  64730. dispose(): void;
  64731. /**
  64732. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  64733. * @param imageType is the image type to use.
  64734. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  64735. */
  64736. download(imageType?: string, quality?: number): void;
  64737. /**
  64738. * Public method to load a texturePacker JSON file.
  64739. * @param data of the JSON file in string format.
  64740. */
  64741. updateFromJSON(data: string): void;
  64742. }
  64743. }
  64744. declare module "babylonjs/Materials/Textures/Packer/index" {
  64745. export * from "babylonjs/Materials/Textures/Packer/packer";
  64746. export * from "babylonjs/Materials/Textures/Packer/frame";
  64747. }
  64748. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  64749. import { Scene } from "babylonjs/scene";
  64750. import { Texture } from "babylonjs/Materials/Textures/texture";
  64751. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  64752. /**
  64753. * 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.
  64754. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  64755. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  64756. */
  64757. export class CustomProceduralTexture extends ProceduralTexture {
  64758. private _animate;
  64759. private _time;
  64760. private _config;
  64761. private _texturePath;
  64762. /**
  64763. * Instantiates a new Custom Procedural Texture.
  64764. * 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.
  64765. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  64766. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  64767. * @param name Define the name of the texture
  64768. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  64769. * @param size Define the size of the texture to create
  64770. * @param scene Define the scene the texture belongs to
  64771. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  64772. * @param generateMipMaps Define if the texture should creates mip maps or not
  64773. */
  64774. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  64775. private _loadJson;
  64776. /**
  64777. * Is the texture ready to be used ? (rendered at least once)
  64778. * @returns true if ready, otherwise, false.
  64779. */
  64780. isReady(): boolean;
  64781. /**
  64782. * Render the texture to its associated render target.
  64783. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  64784. */
  64785. render(useCameraPostProcess?: boolean): void;
  64786. /**
  64787. * Update the list of dependant textures samplers in the shader.
  64788. */
  64789. updateTextures(): void;
  64790. /**
  64791. * Update the uniform values of the procedural texture in the shader.
  64792. */
  64793. updateShaderUniforms(): void;
  64794. /**
  64795. * Define if the texture animates or not.
  64796. */
  64797. get animate(): boolean;
  64798. set animate(value: boolean);
  64799. }
  64800. }
  64801. declare module "babylonjs/Shaders/noise.fragment" {
  64802. /** @hidden */
  64803. export var noisePixelShader: {
  64804. name: string;
  64805. shader: string;
  64806. };
  64807. }
  64808. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  64809. import { Nullable } from "babylonjs/types";
  64810. import { Scene } from "babylonjs/scene";
  64811. import { Texture } from "babylonjs/Materials/Textures/texture";
  64812. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  64813. import "babylonjs/Shaders/noise.fragment";
  64814. /**
  64815. * Class used to generate noise procedural textures
  64816. */
  64817. export class NoiseProceduralTexture extends ProceduralTexture {
  64818. private _time;
  64819. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  64820. brightness: number;
  64821. /** Defines the number of octaves to process */
  64822. octaves: number;
  64823. /** Defines the level of persistence (0.8 by default) */
  64824. persistence: number;
  64825. /** Gets or sets animation speed factor (default is 1) */
  64826. animationSpeedFactor: number;
  64827. /**
  64828. * Creates a new NoiseProceduralTexture
  64829. * @param name defines the name fo the texture
  64830. * @param size defines the size of the texture (default is 256)
  64831. * @param scene defines the hosting scene
  64832. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  64833. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  64834. */
  64835. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  64836. private _updateShaderUniforms;
  64837. protected _getDefines(): string;
  64838. /** Generate the current state of the procedural texture */
  64839. render(useCameraPostProcess?: boolean): void;
  64840. /**
  64841. * Serializes this noise procedural texture
  64842. * @returns a serialized noise procedural texture object
  64843. */
  64844. serialize(): any;
  64845. /**
  64846. * Clone the texture.
  64847. * @returns the cloned texture
  64848. */
  64849. clone(): NoiseProceduralTexture;
  64850. /**
  64851. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  64852. * @param parsedTexture defines parsed texture data
  64853. * @param scene defines the current scene
  64854. * @param rootUrl defines the root URL containing noise procedural texture information
  64855. * @returns a parsed NoiseProceduralTexture
  64856. */
  64857. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  64858. }
  64859. }
  64860. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  64861. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  64862. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  64863. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  64864. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  64865. }
  64866. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  64867. import { Nullable } from "babylonjs/types";
  64868. import { Scene } from "babylonjs/scene";
  64869. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  64870. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64871. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  64872. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64873. /**
  64874. * Raw cube texture where the raw buffers are passed in
  64875. */
  64876. export class RawCubeTexture extends CubeTexture {
  64877. /**
  64878. * Creates a cube texture where the raw buffers are passed in.
  64879. * @param scene defines the scene the texture is attached to
  64880. * @param data defines the array of data to use to create each face
  64881. * @param size defines the size of the textures
  64882. * @param format defines the format of the data
  64883. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  64884. * @param generateMipMaps defines if the engine should generate the mip levels
  64885. * @param invertY defines if data must be stored with Y axis inverted
  64886. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  64887. * @param compression defines the compression used (null by default)
  64888. */
  64889. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  64890. /**
  64891. * Updates the raw cube texture.
  64892. * @param data defines the data to store
  64893. * @param format defines the data format
  64894. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  64895. * @param invertY defines if data must be stored with Y axis inverted
  64896. * @param compression defines the compression used (null by default)
  64897. * @param level defines which level of the texture to update
  64898. */
  64899. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  64900. /**
  64901. * Updates a raw cube texture with RGBD encoded data.
  64902. * @param data defines the array of data [mipmap][face] to use to create each face
  64903. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  64904. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  64905. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  64906. * @returns a promsie that resolves when the operation is complete
  64907. */
  64908. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  64909. /**
  64910. * Clones the raw cube texture.
  64911. * @return a new cube texture
  64912. */
  64913. clone(): CubeTexture;
  64914. /** @hidden */
  64915. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  64916. }
  64917. }
  64918. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  64919. import { Scene } from "babylonjs/scene";
  64920. import { Texture } from "babylonjs/Materials/Textures/texture";
  64921. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64922. /**
  64923. * Class used to store 2D array textures containing user data
  64924. */
  64925. export class RawTexture2DArray extends Texture {
  64926. /** Gets or sets the texture format to use */
  64927. format: number;
  64928. /**
  64929. * Create a new RawTexture2DArray
  64930. * @param data defines the data of the texture
  64931. * @param width defines the width of the texture
  64932. * @param height defines the height of the texture
  64933. * @param depth defines the number of layers of the texture
  64934. * @param format defines the texture format to use
  64935. * @param scene defines the hosting scene
  64936. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  64937. * @param invertY defines if texture must be stored with Y axis inverted
  64938. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  64939. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  64940. */
  64941. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  64942. /** Gets or sets the texture format to use */
  64943. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  64944. /**
  64945. * Update the texture with new data
  64946. * @param data defines the data to store in the texture
  64947. */
  64948. update(data: ArrayBufferView): void;
  64949. }
  64950. }
  64951. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  64952. import { Scene } from "babylonjs/scene";
  64953. import { Texture } from "babylonjs/Materials/Textures/texture";
  64954. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64955. /**
  64956. * Class used to store 3D textures containing user data
  64957. */
  64958. export class RawTexture3D extends Texture {
  64959. /** Gets or sets the texture format to use */
  64960. format: number;
  64961. /**
  64962. * Create a new RawTexture3D
  64963. * @param data defines the data of the texture
  64964. * @param width defines the width of the texture
  64965. * @param height defines the height of the texture
  64966. * @param depth defines the depth of the texture
  64967. * @param format defines the texture format to use
  64968. * @param scene defines the hosting scene
  64969. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  64970. * @param invertY defines if texture must be stored with Y axis inverted
  64971. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  64972. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  64973. */
  64974. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  64975. /** Gets or sets the texture format to use */
  64976. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  64977. /**
  64978. * Update the texture with new data
  64979. * @param data defines the data to store in the texture
  64980. */
  64981. update(data: ArrayBufferView): void;
  64982. }
  64983. }
  64984. declare module "babylonjs/Materials/Textures/refractionTexture" {
  64985. import { Scene } from "babylonjs/scene";
  64986. import { Plane } from "babylonjs/Maths/math.plane";
  64987. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64988. /**
  64989. * Creates a refraction texture used by refraction channel of the standard material.
  64990. * It is like a mirror but to see through a material.
  64991. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  64992. */
  64993. export class RefractionTexture extends RenderTargetTexture {
  64994. /**
  64995. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  64996. * 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.
  64997. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  64998. */
  64999. refractionPlane: Plane;
  65000. /**
  65001. * Define how deep under the surface we should see.
  65002. */
  65003. depth: number;
  65004. /**
  65005. * Creates a refraction texture used by refraction channel of the standard material.
  65006. * It is like a mirror but to see through a material.
  65007. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  65008. * @param name Define the texture name
  65009. * @param size Define the size of the underlying texture
  65010. * @param scene Define the scene the refraction belongs to
  65011. * @param generateMipMaps Define if we need to generate mips level for the refraction
  65012. */
  65013. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  65014. /**
  65015. * Clone the refraction texture.
  65016. * @returns the cloned texture
  65017. */
  65018. clone(): RefractionTexture;
  65019. /**
  65020. * Serialize the texture to a JSON representation you could use in Parse later on
  65021. * @returns the serialized JSON representation
  65022. */
  65023. serialize(): any;
  65024. }
  65025. }
  65026. declare module "babylonjs/Materials/Textures/index" {
  65027. export * from "babylonjs/Materials/Textures/baseTexture";
  65028. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  65029. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  65030. export * from "babylonjs/Materials/Textures/cubeTexture";
  65031. export * from "babylonjs/Materials/Textures/dynamicTexture";
  65032. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  65033. export * from "babylonjs/Materials/Textures/Filtering/hdrFiltering";
  65034. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  65035. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  65036. export * from "babylonjs/Materials/Textures/internalTexture";
  65037. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  65038. export * from "babylonjs/Materials/Textures/Loaders/index";
  65039. export * from "babylonjs/Materials/Textures/mirrorTexture";
  65040. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  65041. export * from "babylonjs/Materials/Textures/Packer/index";
  65042. export * from "babylonjs/Materials/Textures/Procedurals/index";
  65043. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  65044. export * from "babylonjs/Materials/Textures/rawTexture";
  65045. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  65046. export * from "babylonjs/Materials/Textures/rawTexture3D";
  65047. export * from "babylonjs/Materials/Textures/refractionTexture";
  65048. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  65049. export * from "babylonjs/Materials/Textures/texture";
  65050. export * from "babylonjs/Materials/Textures/videoTexture";
  65051. }
  65052. declare module "babylonjs/Materials/Node/Enums/index" {
  65053. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  65054. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  65055. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  65056. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  65057. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  65058. }
  65059. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  65060. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65061. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65062. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65063. import { Mesh } from "babylonjs/Meshes/mesh";
  65064. import { Effect } from "babylonjs/Materials/effect";
  65065. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65066. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65067. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65068. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65069. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  65070. /**
  65071. * Block used to add support for vertex skinning (bones)
  65072. */
  65073. export class BonesBlock extends NodeMaterialBlock {
  65074. /**
  65075. * Creates a new BonesBlock
  65076. * @param name defines the block name
  65077. */
  65078. constructor(name: string);
  65079. /**
  65080. * Initialize the block and prepare the context for build
  65081. * @param state defines the state that will be used for the build
  65082. */
  65083. initialize(state: NodeMaterialBuildState): void;
  65084. /**
  65085. * Gets the current class name
  65086. * @returns the class name
  65087. */
  65088. getClassName(): string;
  65089. /**
  65090. * Gets the matrix indices input component
  65091. */
  65092. get matricesIndices(): NodeMaterialConnectionPoint;
  65093. /**
  65094. * Gets the matrix weights input component
  65095. */
  65096. get matricesWeights(): NodeMaterialConnectionPoint;
  65097. /**
  65098. * Gets the extra matrix indices input component
  65099. */
  65100. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  65101. /**
  65102. * Gets the extra matrix weights input component
  65103. */
  65104. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  65105. /**
  65106. * Gets the world input component
  65107. */
  65108. get world(): NodeMaterialConnectionPoint;
  65109. /**
  65110. * Gets the output component
  65111. */
  65112. get output(): NodeMaterialConnectionPoint;
  65113. autoConfigure(material: NodeMaterial): void;
  65114. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  65115. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65116. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65117. protected _buildBlock(state: NodeMaterialBuildState): this;
  65118. }
  65119. }
  65120. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  65121. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65122. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65123. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65124. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65125. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65126. import { SubMesh } from "babylonjs/Meshes/subMesh";
  65127. /**
  65128. * Block used to add support for instances
  65129. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  65130. */
  65131. export class InstancesBlock extends NodeMaterialBlock {
  65132. /**
  65133. * Creates a new InstancesBlock
  65134. * @param name defines the block name
  65135. */
  65136. constructor(name: string);
  65137. /**
  65138. * Gets the current class name
  65139. * @returns the class name
  65140. */
  65141. getClassName(): string;
  65142. /**
  65143. * Gets the first world row input component
  65144. */
  65145. get world0(): NodeMaterialConnectionPoint;
  65146. /**
  65147. * Gets the second world row input component
  65148. */
  65149. get world1(): NodeMaterialConnectionPoint;
  65150. /**
  65151. * Gets the third world row input component
  65152. */
  65153. get world2(): NodeMaterialConnectionPoint;
  65154. /**
  65155. * Gets the forth world row input component
  65156. */
  65157. get world3(): NodeMaterialConnectionPoint;
  65158. /**
  65159. * Gets the world input component
  65160. */
  65161. get world(): NodeMaterialConnectionPoint;
  65162. /**
  65163. * Gets the output component
  65164. */
  65165. get output(): NodeMaterialConnectionPoint;
  65166. /**
  65167. * Gets the isntanceID component
  65168. */
  65169. get instanceID(): NodeMaterialConnectionPoint;
  65170. autoConfigure(material: NodeMaterial): void;
  65171. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  65172. protected _buildBlock(state: NodeMaterialBuildState): this;
  65173. }
  65174. }
  65175. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  65176. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65177. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65178. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65179. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65180. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65181. import { Effect } from "babylonjs/Materials/effect";
  65182. import { Mesh } from "babylonjs/Meshes/mesh";
  65183. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65184. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65185. /**
  65186. * Block used to add morph targets support to vertex shader
  65187. */
  65188. export class MorphTargetsBlock extends NodeMaterialBlock {
  65189. private _repeatableContentAnchor;
  65190. /**
  65191. * Create a new MorphTargetsBlock
  65192. * @param name defines the block name
  65193. */
  65194. constructor(name: string);
  65195. /**
  65196. * Gets the current class name
  65197. * @returns the class name
  65198. */
  65199. getClassName(): string;
  65200. /**
  65201. * Gets the position input component
  65202. */
  65203. get position(): NodeMaterialConnectionPoint;
  65204. /**
  65205. * Gets the normal input component
  65206. */
  65207. get normal(): NodeMaterialConnectionPoint;
  65208. /**
  65209. * Gets the tangent input component
  65210. */
  65211. get tangent(): NodeMaterialConnectionPoint;
  65212. /**
  65213. * Gets the tangent input component
  65214. */
  65215. get uv(): NodeMaterialConnectionPoint;
  65216. /**
  65217. * Gets the position output component
  65218. */
  65219. get positionOutput(): NodeMaterialConnectionPoint;
  65220. /**
  65221. * Gets the normal output component
  65222. */
  65223. get normalOutput(): NodeMaterialConnectionPoint;
  65224. /**
  65225. * Gets the tangent output component
  65226. */
  65227. get tangentOutput(): NodeMaterialConnectionPoint;
  65228. /**
  65229. * Gets the tangent output component
  65230. */
  65231. get uvOutput(): NodeMaterialConnectionPoint;
  65232. initialize(state: NodeMaterialBuildState): void;
  65233. autoConfigure(material: NodeMaterial): void;
  65234. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65235. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65236. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  65237. protected _buildBlock(state: NodeMaterialBuildState): this;
  65238. }
  65239. }
  65240. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  65241. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65242. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65243. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65244. import { Nullable } from "babylonjs/types";
  65245. import { Scene } from "babylonjs/scene";
  65246. import { Effect } from "babylonjs/Materials/effect";
  65247. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65248. import { Mesh } from "babylonjs/Meshes/mesh";
  65249. import { Light } from "babylonjs/Lights/light";
  65250. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65251. /**
  65252. * Block used to get data information from a light
  65253. */
  65254. export class LightInformationBlock extends NodeMaterialBlock {
  65255. private _lightDataUniformName;
  65256. private _lightColorUniformName;
  65257. private _lightTypeDefineName;
  65258. /**
  65259. * Gets or sets the light associated with this block
  65260. */
  65261. light: Nullable<Light>;
  65262. /**
  65263. * Creates a new LightInformationBlock
  65264. * @param name defines the block name
  65265. */
  65266. constructor(name: string);
  65267. /**
  65268. * Gets the current class name
  65269. * @returns the class name
  65270. */
  65271. getClassName(): string;
  65272. /**
  65273. * Gets the world position input component
  65274. */
  65275. get worldPosition(): NodeMaterialConnectionPoint;
  65276. /**
  65277. * Gets the direction output component
  65278. */
  65279. get direction(): NodeMaterialConnectionPoint;
  65280. /**
  65281. * Gets the direction output component
  65282. */
  65283. get color(): NodeMaterialConnectionPoint;
  65284. /**
  65285. * Gets the direction output component
  65286. */
  65287. get intensity(): NodeMaterialConnectionPoint;
  65288. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65289. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65290. protected _buildBlock(state: NodeMaterialBuildState): this;
  65291. serialize(): any;
  65292. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65293. }
  65294. }
  65295. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  65296. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  65297. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  65298. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  65299. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  65300. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  65301. }
  65302. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  65303. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65304. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65305. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65306. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65307. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65308. import { Effect } from "babylonjs/Materials/effect";
  65309. import { Mesh } from "babylonjs/Meshes/mesh";
  65310. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65311. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  65312. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  65313. /**
  65314. * Block used to add image processing support to fragment shader
  65315. */
  65316. export class ImageProcessingBlock extends NodeMaterialBlock {
  65317. /**
  65318. * Create a new ImageProcessingBlock
  65319. * @param name defines the block name
  65320. */
  65321. constructor(name: string);
  65322. /**
  65323. * Gets the current class name
  65324. * @returns the class name
  65325. */
  65326. getClassName(): string;
  65327. /**
  65328. * Gets the color input component
  65329. */
  65330. get color(): NodeMaterialConnectionPoint;
  65331. /**
  65332. * Gets the output component
  65333. */
  65334. get output(): NodeMaterialConnectionPoint;
  65335. /**
  65336. * Initialize the block and prepare the context for build
  65337. * @param state defines the state that will be used for the build
  65338. */
  65339. initialize(state: NodeMaterialBuildState): void;
  65340. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  65341. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65342. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65343. protected _buildBlock(state: NodeMaterialBuildState): this;
  65344. }
  65345. }
  65346. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  65347. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65348. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65349. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65350. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65351. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65352. import { Effect } from "babylonjs/Materials/effect";
  65353. import { Mesh } from "babylonjs/Meshes/mesh";
  65354. import { Scene } from "babylonjs/scene";
  65355. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  65356. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  65357. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  65358. /**
  65359. * Block used to pertub normals based on a normal map
  65360. */
  65361. export class PerturbNormalBlock extends NodeMaterialBlock {
  65362. private _tangentSpaceParameterName;
  65363. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  65364. invertX: boolean;
  65365. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  65366. invertY: boolean;
  65367. /**
  65368. * Create a new PerturbNormalBlock
  65369. * @param name defines the block name
  65370. */
  65371. constructor(name: string);
  65372. /**
  65373. * Gets the current class name
  65374. * @returns the class name
  65375. */
  65376. getClassName(): string;
  65377. /**
  65378. * Gets the world position input component
  65379. */
  65380. get worldPosition(): NodeMaterialConnectionPoint;
  65381. /**
  65382. * Gets the world normal input component
  65383. */
  65384. get worldNormal(): NodeMaterialConnectionPoint;
  65385. /**
  65386. * Gets the world tangent input component
  65387. */
  65388. get worldTangent(): NodeMaterialConnectionPoint;
  65389. /**
  65390. * Gets the uv input component
  65391. */
  65392. get uv(): NodeMaterialConnectionPoint;
  65393. /**
  65394. * Gets the normal map color input component
  65395. */
  65396. get normalMapColor(): NodeMaterialConnectionPoint;
  65397. /**
  65398. * Gets the strength input component
  65399. */
  65400. get strength(): NodeMaterialConnectionPoint;
  65401. /**
  65402. * Gets the output component
  65403. */
  65404. get output(): NodeMaterialConnectionPoint;
  65405. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65406. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65407. autoConfigure(material: NodeMaterial): void;
  65408. protected _buildBlock(state: NodeMaterialBuildState): this;
  65409. protected _dumpPropertiesCode(): string;
  65410. serialize(): any;
  65411. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65412. }
  65413. }
  65414. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  65415. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65416. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65417. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65418. /**
  65419. * Block used to discard a pixel if a value is smaller than a cutoff
  65420. */
  65421. export class DiscardBlock extends NodeMaterialBlock {
  65422. /**
  65423. * Create a new DiscardBlock
  65424. * @param name defines the block name
  65425. */
  65426. constructor(name: string);
  65427. /**
  65428. * Gets the current class name
  65429. * @returns the class name
  65430. */
  65431. getClassName(): string;
  65432. /**
  65433. * Gets the color input component
  65434. */
  65435. get value(): NodeMaterialConnectionPoint;
  65436. /**
  65437. * Gets the cutoff input component
  65438. */
  65439. get cutoff(): NodeMaterialConnectionPoint;
  65440. protected _buildBlock(state: NodeMaterialBuildState): this;
  65441. }
  65442. }
  65443. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  65444. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65445. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65446. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65447. /**
  65448. * Block used to test if the fragment shader is front facing
  65449. */
  65450. export class FrontFacingBlock extends NodeMaterialBlock {
  65451. /**
  65452. * Creates a new FrontFacingBlock
  65453. * @param name defines the block name
  65454. */
  65455. constructor(name: string);
  65456. /**
  65457. * Gets the current class name
  65458. * @returns the class name
  65459. */
  65460. getClassName(): string;
  65461. /**
  65462. * Gets the output component
  65463. */
  65464. get output(): NodeMaterialConnectionPoint;
  65465. protected _buildBlock(state: NodeMaterialBuildState): this;
  65466. }
  65467. }
  65468. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  65469. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65470. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65471. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65472. /**
  65473. * Block used to get the derivative value on x and y of a given input
  65474. */
  65475. export class DerivativeBlock extends NodeMaterialBlock {
  65476. /**
  65477. * Create a new DerivativeBlock
  65478. * @param name defines the block name
  65479. */
  65480. constructor(name: string);
  65481. /**
  65482. * Gets the current class name
  65483. * @returns the class name
  65484. */
  65485. getClassName(): string;
  65486. /**
  65487. * Gets the input component
  65488. */
  65489. get input(): NodeMaterialConnectionPoint;
  65490. /**
  65491. * Gets the derivative output on x
  65492. */
  65493. get dx(): NodeMaterialConnectionPoint;
  65494. /**
  65495. * Gets the derivative output on y
  65496. */
  65497. get dy(): NodeMaterialConnectionPoint;
  65498. protected _buildBlock(state: NodeMaterialBuildState): this;
  65499. }
  65500. }
  65501. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock" {
  65502. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65503. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65504. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65505. /**
  65506. * Block used to make gl_FragCoord available
  65507. */
  65508. export class FragCoordBlock extends NodeMaterialBlock {
  65509. /**
  65510. * Creates a new FragCoordBlock
  65511. * @param name defines the block name
  65512. */
  65513. constructor(name: string);
  65514. /**
  65515. * Gets the current class name
  65516. * @returns the class name
  65517. */
  65518. getClassName(): string;
  65519. /**
  65520. * Gets the xy component
  65521. */
  65522. get xy(): NodeMaterialConnectionPoint;
  65523. /**
  65524. * Gets the xyz component
  65525. */
  65526. get xyz(): NodeMaterialConnectionPoint;
  65527. /**
  65528. * Gets the xyzw component
  65529. */
  65530. get xyzw(): NodeMaterialConnectionPoint;
  65531. /**
  65532. * Gets the x component
  65533. */
  65534. get x(): NodeMaterialConnectionPoint;
  65535. /**
  65536. * Gets the y component
  65537. */
  65538. get y(): NodeMaterialConnectionPoint;
  65539. /**
  65540. * Gets the z component
  65541. */
  65542. get z(): NodeMaterialConnectionPoint;
  65543. /**
  65544. * Gets the w component
  65545. */
  65546. get output(): NodeMaterialConnectionPoint;
  65547. protected writeOutputs(state: NodeMaterialBuildState): string;
  65548. protected _buildBlock(state: NodeMaterialBuildState): this;
  65549. }
  65550. }
  65551. declare module "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock" {
  65552. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65553. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65554. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65555. import { Effect } from "babylonjs/Materials/effect";
  65556. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65557. import { Mesh } from "babylonjs/Meshes/mesh";
  65558. /**
  65559. * Block used to get the screen sizes
  65560. */
  65561. export class ScreenSizeBlock extends NodeMaterialBlock {
  65562. private _varName;
  65563. private _scene;
  65564. /**
  65565. * Creates a new ScreenSizeBlock
  65566. * @param name defines the block name
  65567. */
  65568. constructor(name: string);
  65569. /**
  65570. * Gets the current class name
  65571. * @returns the class name
  65572. */
  65573. getClassName(): string;
  65574. /**
  65575. * Gets the xy component
  65576. */
  65577. get xy(): NodeMaterialConnectionPoint;
  65578. /**
  65579. * Gets the x component
  65580. */
  65581. get x(): NodeMaterialConnectionPoint;
  65582. /**
  65583. * Gets the y component
  65584. */
  65585. get y(): NodeMaterialConnectionPoint;
  65586. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65587. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  65588. protected _buildBlock(state: NodeMaterialBuildState): this;
  65589. }
  65590. }
  65591. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  65592. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  65593. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  65594. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  65595. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  65596. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  65597. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  65598. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock";
  65599. export * from "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock";
  65600. }
  65601. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  65602. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65603. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65604. import { Mesh } from "babylonjs/Meshes/mesh";
  65605. import { Effect } from "babylonjs/Materials/effect";
  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 "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  65610. /**
  65611. * Block used to add support for scene fog
  65612. */
  65613. export class FogBlock extends NodeMaterialBlock {
  65614. private _fogDistanceName;
  65615. private _fogParameters;
  65616. /**
  65617. * Create a new FogBlock
  65618. * @param name defines the block name
  65619. */
  65620. constructor(name: string);
  65621. /**
  65622. * Gets the current class name
  65623. * @returns the class name
  65624. */
  65625. getClassName(): string;
  65626. /**
  65627. * Gets the world position input component
  65628. */
  65629. get worldPosition(): NodeMaterialConnectionPoint;
  65630. /**
  65631. * Gets the view input component
  65632. */
  65633. get view(): NodeMaterialConnectionPoint;
  65634. /**
  65635. * Gets the color input component
  65636. */
  65637. get input(): NodeMaterialConnectionPoint;
  65638. /**
  65639. * Gets the fog color input component
  65640. */
  65641. get fogColor(): NodeMaterialConnectionPoint;
  65642. /**
  65643. * Gets the output component
  65644. */
  65645. get output(): NodeMaterialConnectionPoint;
  65646. autoConfigure(material: NodeMaterial): void;
  65647. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65648. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65649. protected _buildBlock(state: NodeMaterialBuildState): this;
  65650. }
  65651. }
  65652. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  65653. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65654. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65655. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65656. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65657. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65658. import { Effect } from "babylonjs/Materials/effect";
  65659. import { Mesh } from "babylonjs/Meshes/mesh";
  65660. import { Light } from "babylonjs/Lights/light";
  65661. import { Nullable } from "babylonjs/types";
  65662. import { Scene } from "babylonjs/scene";
  65663. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  65664. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  65665. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  65666. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65667. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  65668. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  65669. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  65670. /**
  65671. * Block used to add light in the fragment shader
  65672. */
  65673. export class LightBlock extends NodeMaterialBlock {
  65674. private _lightId;
  65675. /**
  65676. * Gets or sets the light associated with this block
  65677. */
  65678. light: Nullable<Light>;
  65679. /**
  65680. * Create a new LightBlock
  65681. * @param name defines the block name
  65682. */
  65683. constructor(name: string);
  65684. /**
  65685. * Gets the current class name
  65686. * @returns the class name
  65687. */
  65688. getClassName(): string;
  65689. /**
  65690. * Gets the world position input component
  65691. */
  65692. get worldPosition(): NodeMaterialConnectionPoint;
  65693. /**
  65694. * Gets the world normal input component
  65695. */
  65696. get worldNormal(): NodeMaterialConnectionPoint;
  65697. /**
  65698. * Gets the camera (or eye) position component
  65699. */
  65700. get cameraPosition(): NodeMaterialConnectionPoint;
  65701. /**
  65702. * Gets the glossiness component
  65703. */
  65704. get glossiness(): NodeMaterialConnectionPoint;
  65705. /**
  65706. * Gets the glossinness power component
  65707. */
  65708. get glossPower(): NodeMaterialConnectionPoint;
  65709. /**
  65710. * Gets the diffuse color component
  65711. */
  65712. get diffuseColor(): NodeMaterialConnectionPoint;
  65713. /**
  65714. * Gets the specular color component
  65715. */
  65716. get specularColor(): NodeMaterialConnectionPoint;
  65717. /**
  65718. * Gets the diffuse output component
  65719. */
  65720. get diffuseOutput(): NodeMaterialConnectionPoint;
  65721. /**
  65722. * Gets the specular output component
  65723. */
  65724. get specularOutput(): NodeMaterialConnectionPoint;
  65725. /**
  65726. * Gets the shadow output component
  65727. */
  65728. get shadow(): NodeMaterialConnectionPoint;
  65729. autoConfigure(material: NodeMaterial): void;
  65730. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65731. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  65732. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65733. private _injectVertexCode;
  65734. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65735. serialize(): any;
  65736. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65737. }
  65738. }
  65739. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  65740. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65741. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65742. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65743. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  65744. /**
  65745. * Block used to read a reflection texture from a sampler
  65746. */
  65747. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  65748. /**
  65749. * Create a new ReflectionTextureBlock
  65750. * @param name defines the block name
  65751. */
  65752. constructor(name: string);
  65753. /**
  65754. * Gets the current class name
  65755. * @returns the class name
  65756. */
  65757. getClassName(): string;
  65758. /**
  65759. * Gets the world position input component
  65760. */
  65761. get position(): NodeMaterialConnectionPoint;
  65762. /**
  65763. * Gets the world position input component
  65764. */
  65765. get worldPosition(): NodeMaterialConnectionPoint;
  65766. /**
  65767. * Gets the world normal input component
  65768. */
  65769. get worldNormal(): NodeMaterialConnectionPoint;
  65770. /**
  65771. * Gets the world input component
  65772. */
  65773. get world(): NodeMaterialConnectionPoint;
  65774. /**
  65775. * Gets the camera (or eye) position component
  65776. */
  65777. get cameraPosition(): NodeMaterialConnectionPoint;
  65778. /**
  65779. * Gets the view input component
  65780. */
  65781. get view(): NodeMaterialConnectionPoint;
  65782. /**
  65783. * Gets the rgb output component
  65784. */
  65785. get rgb(): NodeMaterialConnectionPoint;
  65786. /**
  65787. * Gets the rgba output component
  65788. */
  65789. get rgba(): NodeMaterialConnectionPoint;
  65790. /**
  65791. * Gets the r output component
  65792. */
  65793. get r(): NodeMaterialConnectionPoint;
  65794. /**
  65795. * Gets the g output component
  65796. */
  65797. get g(): NodeMaterialConnectionPoint;
  65798. /**
  65799. * Gets the b output component
  65800. */
  65801. get b(): NodeMaterialConnectionPoint;
  65802. /**
  65803. * Gets the a output component
  65804. */
  65805. get a(): NodeMaterialConnectionPoint;
  65806. autoConfigure(material: NodeMaterial): void;
  65807. protected _buildBlock(state: NodeMaterialBuildState): this;
  65808. }
  65809. }
  65810. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  65811. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  65812. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  65813. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  65814. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  65815. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  65816. }
  65817. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  65818. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  65819. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  65820. }
  65821. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  65822. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65823. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65824. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65825. /**
  65826. * Block used to add 2 vectors
  65827. */
  65828. export class AddBlock extends NodeMaterialBlock {
  65829. /**
  65830. * Creates a new AddBlock
  65831. * @param name defines the block name
  65832. */
  65833. constructor(name: string);
  65834. /**
  65835. * Gets the current class name
  65836. * @returns the class name
  65837. */
  65838. getClassName(): string;
  65839. /**
  65840. * Gets the left operand input component
  65841. */
  65842. get left(): NodeMaterialConnectionPoint;
  65843. /**
  65844. * Gets the right operand input component
  65845. */
  65846. get right(): NodeMaterialConnectionPoint;
  65847. /**
  65848. * Gets the output component
  65849. */
  65850. get output(): NodeMaterialConnectionPoint;
  65851. protected _buildBlock(state: NodeMaterialBuildState): this;
  65852. }
  65853. }
  65854. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  65855. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65856. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65857. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65858. /**
  65859. * Block used to scale a vector by a float
  65860. */
  65861. export class ScaleBlock extends NodeMaterialBlock {
  65862. /**
  65863. * Creates a new ScaleBlock
  65864. * @param name defines the block name
  65865. */
  65866. constructor(name: string);
  65867. /**
  65868. * Gets the current class name
  65869. * @returns the class name
  65870. */
  65871. getClassName(): string;
  65872. /**
  65873. * Gets the input component
  65874. */
  65875. get input(): NodeMaterialConnectionPoint;
  65876. /**
  65877. * Gets the factor input component
  65878. */
  65879. get factor(): NodeMaterialConnectionPoint;
  65880. /**
  65881. * Gets the output component
  65882. */
  65883. get output(): NodeMaterialConnectionPoint;
  65884. protected _buildBlock(state: NodeMaterialBuildState): this;
  65885. }
  65886. }
  65887. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  65888. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65889. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65890. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65891. import { Scene } from "babylonjs/scene";
  65892. /**
  65893. * Block used to clamp a float
  65894. */
  65895. export class ClampBlock extends NodeMaterialBlock {
  65896. /** Gets or sets the minimum range */
  65897. minimum: number;
  65898. /** Gets or sets the maximum range */
  65899. maximum: number;
  65900. /**
  65901. * Creates a new ClampBlock
  65902. * @param name defines the block name
  65903. */
  65904. constructor(name: string);
  65905. /**
  65906. * Gets the current class name
  65907. * @returns the class name
  65908. */
  65909. getClassName(): string;
  65910. /**
  65911. * Gets the value input component
  65912. */
  65913. get value(): NodeMaterialConnectionPoint;
  65914. /**
  65915. * Gets the output component
  65916. */
  65917. get output(): NodeMaterialConnectionPoint;
  65918. protected _buildBlock(state: NodeMaterialBuildState): this;
  65919. protected _dumpPropertiesCode(): string;
  65920. serialize(): any;
  65921. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65922. }
  65923. }
  65924. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  65925. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65926. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65927. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65928. /**
  65929. * Block used to apply a cross product between 2 vectors
  65930. */
  65931. export class CrossBlock extends NodeMaterialBlock {
  65932. /**
  65933. * Creates a new CrossBlock
  65934. * @param name defines the block name
  65935. */
  65936. constructor(name: string);
  65937. /**
  65938. * Gets the current class name
  65939. * @returns the class name
  65940. */
  65941. getClassName(): string;
  65942. /**
  65943. * Gets the left operand input component
  65944. */
  65945. get left(): NodeMaterialConnectionPoint;
  65946. /**
  65947. * Gets the right operand input component
  65948. */
  65949. get right(): NodeMaterialConnectionPoint;
  65950. /**
  65951. * Gets the output component
  65952. */
  65953. get output(): NodeMaterialConnectionPoint;
  65954. protected _buildBlock(state: NodeMaterialBuildState): this;
  65955. }
  65956. }
  65957. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  65958. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65959. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65960. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65961. /**
  65962. * Block used to apply a dot product between 2 vectors
  65963. */
  65964. export class DotBlock extends NodeMaterialBlock {
  65965. /**
  65966. * Creates a new DotBlock
  65967. * @param name defines the block name
  65968. */
  65969. constructor(name: string);
  65970. /**
  65971. * Gets the current class name
  65972. * @returns the class name
  65973. */
  65974. getClassName(): string;
  65975. /**
  65976. * Gets the left operand input component
  65977. */
  65978. get left(): NodeMaterialConnectionPoint;
  65979. /**
  65980. * Gets the right operand input component
  65981. */
  65982. get right(): NodeMaterialConnectionPoint;
  65983. /**
  65984. * Gets the output component
  65985. */
  65986. get output(): NodeMaterialConnectionPoint;
  65987. protected _buildBlock(state: NodeMaterialBuildState): this;
  65988. }
  65989. }
  65990. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  65991. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65992. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65993. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65994. /**
  65995. * Block used to normalize a vector
  65996. */
  65997. export class NormalizeBlock extends NodeMaterialBlock {
  65998. /**
  65999. * Creates a new NormalizeBlock
  66000. * @param name defines the block name
  66001. */
  66002. constructor(name: string);
  66003. /**
  66004. * Gets the current class name
  66005. * @returns the class name
  66006. */
  66007. getClassName(): string;
  66008. /**
  66009. * Gets the input component
  66010. */
  66011. get input(): NodeMaterialConnectionPoint;
  66012. /**
  66013. * Gets the output component
  66014. */
  66015. get output(): NodeMaterialConnectionPoint;
  66016. protected _buildBlock(state: NodeMaterialBuildState): this;
  66017. }
  66018. }
  66019. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  66020. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66021. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66022. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66023. import { Scene } from "babylonjs/scene";
  66024. /**
  66025. * Operations supported by the Trigonometry block
  66026. */
  66027. export enum TrigonometryBlockOperations {
  66028. /** Cos */
  66029. Cos = 0,
  66030. /** Sin */
  66031. Sin = 1,
  66032. /** Abs */
  66033. Abs = 2,
  66034. /** Exp */
  66035. Exp = 3,
  66036. /** Exp2 */
  66037. Exp2 = 4,
  66038. /** Round */
  66039. Round = 5,
  66040. /** Floor */
  66041. Floor = 6,
  66042. /** Ceiling */
  66043. Ceiling = 7,
  66044. /** Square root */
  66045. Sqrt = 8,
  66046. /** Log */
  66047. Log = 9,
  66048. /** Tangent */
  66049. Tan = 10,
  66050. /** Arc tangent */
  66051. ArcTan = 11,
  66052. /** Arc cosinus */
  66053. ArcCos = 12,
  66054. /** Arc sinus */
  66055. ArcSin = 13,
  66056. /** Fraction */
  66057. Fract = 14,
  66058. /** Sign */
  66059. Sign = 15,
  66060. /** To radians (from degrees) */
  66061. Radians = 16,
  66062. /** To degrees (from radians) */
  66063. Degrees = 17
  66064. }
  66065. /**
  66066. * Block used to apply trigonometry operation to floats
  66067. */
  66068. export class TrigonometryBlock extends NodeMaterialBlock {
  66069. /**
  66070. * Gets or sets the operation applied by the block
  66071. */
  66072. operation: TrigonometryBlockOperations;
  66073. /**
  66074. * Creates a new TrigonometryBlock
  66075. * @param name defines the block name
  66076. */
  66077. constructor(name: string);
  66078. /**
  66079. * Gets the current class name
  66080. * @returns the class name
  66081. */
  66082. getClassName(): string;
  66083. /**
  66084. * Gets the input component
  66085. */
  66086. get input(): NodeMaterialConnectionPoint;
  66087. /**
  66088. * Gets the output component
  66089. */
  66090. get output(): NodeMaterialConnectionPoint;
  66091. protected _buildBlock(state: NodeMaterialBuildState): this;
  66092. serialize(): any;
  66093. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66094. protected _dumpPropertiesCode(): string;
  66095. }
  66096. }
  66097. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  66098. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66099. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66100. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66101. /**
  66102. * Block used to create a Color3/4 out of individual inputs (one for each component)
  66103. */
  66104. export class ColorMergerBlock extends NodeMaterialBlock {
  66105. /**
  66106. * Create a new ColorMergerBlock
  66107. * @param name defines the block name
  66108. */
  66109. constructor(name: string);
  66110. /**
  66111. * Gets the current class name
  66112. * @returns the class name
  66113. */
  66114. getClassName(): string;
  66115. /**
  66116. * Gets the rgb component (input)
  66117. */
  66118. get rgbIn(): NodeMaterialConnectionPoint;
  66119. /**
  66120. * Gets the r component (input)
  66121. */
  66122. get r(): NodeMaterialConnectionPoint;
  66123. /**
  66124. * Gets the g component (input)
  66125. */
  66126. get g(): NodeMaterialConnectionPoint;
  66127. /**
  66128. * Gets the b component (input)
  66129. */
  66130. get b(): NodeMaterialConnectionPoint;
  66131. /**
  66132. * Gets the a component (input)
  66133. */
  66134. get a(): NodeMaterialConnectionPoint;
  66135. /**
  66136. * Gets the rgba component (output)
  66137. */
  66138. get rgba(): NodeMaterialConnectionPoint;
  66139. /**
  66140. * Gets the rgb component (output)
  66141. */
  66142. get rgbOut(): NodeMaterialConnectionPoint;
  66143. /**
  66144. * Gets the rgb component (output)
  66145. * @deprecated Please use rgbOut instead.
  66146. */
  66147. get rgb(): NodeMaterialConnectionPoint;
  66148. protected _buildBlock(state: NodeMaterialBuildState): this;
  66149. }
  66150. }
  66151. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  66152. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66153. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66154. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66155. /**
  66156. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  66157. */
  66158. export class VectorSplitterBlock extends NodeMaterialBlock {
  66159. /**
  66160. * Create a new VectorSplitterBlock
  66161. * @param name defines the block name
  66162. */
  66163. constructor(name: string);
  66164. /**
  66165. * Gets the current class name
  66166. * @returns the class name
  66167. */
  66168. getClassName(): string;
  66169. /**
  66170. * Gets the xyzw component (input)
  66171. */
  66172. get xyzw(): NodeMaterialConnectionPoint;
  66173. /**
  66174. * Gets the xyz component (input)
  66175. */
  66176. get xyzIn(): NodeMaterialConnectionPoint;
  66177. /**
  66178. * Gets the xy component (input)
  66179. */
  66180. get xyIn(): NodeMaterialConnectionPoint;
  66181. /**
  66182. * Gets the xyz component (output)
  66183. */
  66184. get xyzOut(): NodeMaterialConnectionPoint;
  66185. /**
  66186. * Gets the xy component (output)
  66187. */
  66188. get xyOut(): NodeMaterialConnectionPoint;
  66189. /**
  66190. * Gets the x component (output)
  66191. */
  66192. get x(): NodeMaterialConnectionPoint;
  66193. /**
  66194. * Gets the y component (output)
  66195. */
  66196. get y(): NodeMaterialConnectionPoint;
  66197. /**
  66198. * Gets the z component (output)
  66199. */
  66200. get z(): NodeMaterialConnectionPoint;
  66201. /**
  66202. * Gets the w component (output)
  66203. */
  66204. get w(): NodeMaterialConnectionPoint;
  66205. protected _inputRename(name: string): string;
  66206. protected _outputRename(name: string): string;
  66207. protected _buildBlock(state: NodeMaterialBuildState): this;
  66208. }
  66209. }
  66210. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  66211. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66212. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66213. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66214. /**
  66215. * Block used to lerp between 2 values
  66216. */
  66217. export class LerpBlock extends NodeMaterialBlock {
  66218. /**
  66219. * Creates a new LerpBlock
  66220. * @param name defines the block name
  66221. */
  66222. constructor(name: string);
  66223. /**
  66224. * Gets the current class name
  66225. * @returns the class name
  66226. */
  66227. getClassName(): string;
  66228. /**
  66229. * Gets the left operand input component
  66230. */
  66231. get left(): NodeMaterialConnectionPoint;
  66232. /**
  66233. * Gets the right operand input component
  66234. */
  66235. get right(): NodeMaterialConnectionPoint;
  66236. /**
  66237. * Gets the gradient operand input component
  66238. */
  66239. get gradient(): NodeMaterialConnectionPoint;
  66240. /**
  66241. * Gets the output component
  66242. */
  66243. get output(): NodeMaterialConnectionPoint;
  66244. protected _buildBlock(state: NodeMaterialBuildState): this;
  66245. }
  66246. }
  66247. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  66248. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66249. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66250. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66251. /**
  66252. * Block used to divide 2 vectors
  66253. */
  66254. export class DivideBlock extends NodeMaterialBlock {
  66255. /**
  66256. * Creates a new DivideBlock
  66257. * @param name defines the block name
  66258. */
  66259. constructor(name: string);
  66260. /**
  66261. * Gets the current class name
  66262. * @returns the class name
  66263. */
  66264. getClassName(): string;
  66265. /**
  66266. * Gets the left operand input component
  66267. */
  66268. get left(): NodeMaterialConnectionPoint;
  66269. /**
  66270. * Gets the right operand input component
  66271. */
  66272. get right(): NodeMaterialConnectionPoint;
  66273. /**
  66274. * Gets the output component
  66275. */
  66276. get output(): NodeMaterialConnectionPoint;
  66277. protected _buildBlock(state: NodeMaterialBuildState): this;
  66278. }
  66279. }
  66280. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  66281. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66282. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66283. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66284. /**
  66285. * Block used to subtract 2 vectors
  66286. */
  66287. export class SubtractBlock extends NodeMaterialBlock {
  66288. /**
  66289. * Creates a new SubtractBlock
  66290. * @param name defines the block name
  66291. */
  66292. constructor(name: string);
  66293. /**
  66294. * Gets the current class name
  66295. * @returns the class name
  66296. */
  66297. getClassName(): string;
  66298. /**
  66299. * Gets the left operand input component
  66300. */
  66301. get left(): NodeMaterialConnectionPoint;
  66302. /**
  66303. * Gets the right operand input component
  66304. */
  66305. get right(): NodeMaterialConnectionPoint;
  66306. /**
  66307. * Gets the output component
  66308. */
  66309. get output(): NodeMaterialConnectionPoint;
  66310. protected _buildBlock(state: NodeMaterialBuildState): this;
  66311. }
  66312. }
  66313. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  66314. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66315. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66316. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66317. /**
  66318. * Block used to step a value
  66319. */
  66320. export class StepBlock extends NodeMaterialBlock {
  66321. /**
  66322. * Creates a new StepBlock
  66323. * @param name defines the block name
  66324. */
  66325. constructor(name: string);
  66326. /**
  66327. * Gets the current class name
  66328. * @returns the class name
  66329. */
  66330. getClassName(): string;
  66331. /**
  66332. * Gets the value operand input component
  66333. */
  66334. get value(): NodeMaterialConnectionPoint;
  66335. /**
  66336. * Gets the edge operand input component
  66337. */
  66338. get edge(): NodeMaterialConnectionPoint;
  66339. /**
  66340. * Gets the output component
  66341. */
  66342. get output(): NodeMaterialConnectionPoint;
  66343. protected _buildBlock(state: NodeMaterialBuildState): this;
  66344. }
  66345. }
  66346. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  66347. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66348. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66349. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66350. /**
  66351. * Block used to get the opposite (1 - x) of a value
  66352. */
  66353. export class OneMinusBlock extends NodeMaterialBlock {
  66354. /**
  66355. * Creates a new OneMinusBlock
  66356. * @param name defines the block name
  66357. */
  66358. constructor(name: string);
  66359. /**
  66360. * Gets the current class name
  66361. * @returns the class name
  66362. */
  66363. getClassName(): string;
  66364. /**
  66365. * Gets the input component
  66366. */
  66367. get input(): NodeMaterialConnectionPoint;
  66368. /**
  66369. * Gets the output component
  66370. */
  66371. get output(): NodeMaterialConnectionPoint;
  66372. protected _buildBlock(state: NodeMaterialBuildState): this;
  66373. }
  66374. }
  66375. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  66376. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66377. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66378. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66379. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66380. /**
  66381. * Block used to get the view direction
  66382. */
  66383. export class ViewDirectionBlock extends NodeMaterialBlock {
  66384. /**
  66385. * Creates a new ViewDirectionBlock
  66386. * @param name defines the block name
  66387. */
  66388. constructor(name: string);
  66389. /**
  66390. * Gets the current class name
  66391. * @returns the class name
  66392. */
  66393. getClassName(): string;
  66394. /**
  66395. * Gets the world position component
  66396. */
  66397. get worldPosition(): NodeMaterialConnectionPoint;
  66398. /**
  66399. * Gets the camera position component
  66400. */
  66401. get cameraPosition(): NodeMaterialConnectionPoint;
  66402. /**
  66403. * Gets the output component
  66404. */
  66405. get output(): NodeMaterialConnectionPoint;
  66406. autoConfigure(material: NodeMaterial): void;
  66407. protected _buildBlock(state: NodeMaterialBuildState): this;
  66408. }
  66409. }
  66410. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  66411. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66412. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66413. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66414. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66415. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  66416. /**
  66417. * Block used to compute fresnel value
  66418. */
  66419. export class FresnelBlock extends NodeMaterialBlock {
  66420. /**
  66421. * Create a new FresnelBlock
  66422. * @param name defines the block name
  66423. */
  66424. constructor(name: string);
  66425. /**
  66426. * Gets the current class name
  66427. * @returns the class name
  66428. */
  66429. getClassName(): string;
  66430. /**
  66431. * Gets the world normal input component
  66432. */
  66433. get worldNormal(): NodeMaterialConnectionPoint;
  66434. /**
  66435. * Gets the view direction input component
  66436. */
  66437. get viewDirection(): NodeMaterialConnectionPoint;
  66438. /**
  66439. * Gets the bias input component
  66440. */
  66441. get bias(): NodeMaterialConnectionPoint;
  66442. /**
  66443. * Gets the camera (or eye) position component
  66444. */
  66445. get power(): NodeMaterialConnectionPoint;
  66446. /**
  66447. * Gets the fresnel output component
  66448. */
  66449. get fresnel(): NodeMaterialConnectionPoint;
  66450. autoConfigure(material: NodeMaterial): void;
  66451. protected _buildBlock(state: NodeMaterialBuildState): this;
  66452. }
  66453. }
  66454. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  66455. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66456. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66457. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66458. /**
  66459. * Block used to get the max of 2 values
  66460. */
  66461. export class MaxBlock extends NodeMaterialBlock {
  66462. /**
  66463. * Creates a new MaxBlock
  66464. * @param name defines the block name
  66465. */
  66466. constructor(name: string);
  66467. /**
  66468. * Gets the current class name
  66469. * @returns the class name
  66470. */
  66471. getClassName(): string;
  66472. /**
  66473. * Gets the left operand input component
  66474. */
  66475. get left(): NodeMaterialConnectionPoint;
  66476. /**
  66477. * Gets the right operand input component
  66478. */
  66479. get right(): NodeMaterialConnectionPoint;
  66480. /**
  66481. * Gets the output component
  66482. */
  66483. get output(): NodeMaterialConnectionPoint;
  66484. protected _buildBlock(state: NodeMaterialBuildState): this;
  66485. }
  66486. }
  66487. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  66488. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66489. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66490. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66491. /**
  66492. * Block used to get the min of 2 values
  66493. */
  66494. export class MinBlock extends NodeMaterialBlock {
  66495. /**
  66496. * Creates a new MinBlock
  66497. * @param name defines the block name
  66498. */
  66499. constructor(name: string);
  66500. /**
  66501. * Gets the current class name
  66502. * @returns the class name
  66503. */
  66504. getClassName(): string;
  66505. /**
  66506. * Gets the left operand input component
  66507. */
  66508. get left(): NodeMaterialConnectionPoint;
  66509. /**
  66510. * Gets the right operand input component
  66511. */
  66512. get right(): NodeMaterialConnectionPoint;
  66513. /**
  66514. * Gets the output component
  66515. */
  66516. get output(): NodeMaterialConnectionPoint;
  66517. protected _buildBlock(state: NodeMaterialBuildState): this;
  66518. }
  66519. }
  66520. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  66521. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66522. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66523. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66524. /**
  66525. * Block used to get the distance between 2 values
  66526. */
  66527. export class DistanceBlock extends NodeMaterialBlock {
  66528. /**
  66529. * Creates a new DistanceBlock
  66530. * @param name defines the block name
  66531. */
  66532. constructor(name: string);
  66533. /**
  66534. * Gets the current class name
  66535. * @returns the class name
  66536. */
  66537. getClassName(): string;
  66538. /**
  66539. * Gets the left operand input component
  66540. */
  66541. get left(): NodeMaterialConnectionPoint;
  66542. /**
  66543. * Gets the right operand input component
  66544. */
  66545. get right(): NodeMaterialConnectionPoint;
  66546. /**
  66547. * Gets the output component
  66548. */
  66549. get output(): NodeMaterialConnectionPoint;
  66550. protected _buildBlock(state: NodeMaterialBuildState): this;
  66551. }
  66552. }
  66553. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  66554. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66555. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66556. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66557. /**
  66558. * Block used to get the length of a vector
  66559. */
  66560. export class LengthBlock extends NodeMaterialBlock {
  66561. /**
  66562. * Creates a new LengthBlock
  66563. * @param name defines the block name
  66564. */
  66565. constructor(name: string);
  66566. /**
  66567. * Gets the current class name
  66568. * @returns the class name
  66569. */
  66570. getClassName(): string;
  66571. /**
  66572. * Gets the value input component
  66573. */
  66574. get value(): NodeMaterialConnectionPoint;
  66575. /**
  66576. * Gets the output component
  66577. */
  66578. get output(): NodeMaterialConnectionPoint;
  66579. protected _buildBlock(state: NodeMaterialBuildState): this;
  66580. }
  66581. }
  66582. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  66583. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66584. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66585. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66586. /**
  66587. * Block used to get negative version of a value (i.e. x * -1)
  66588. */
  66589. export class NegateBlock extends NodeMaterialBlock {
  66590. /**
  66591. * Creates a new NegateBlock
  66592. * @param name defines the block name
  66593. */
  66594. constructor(name: string);
  66595. /**
  66596. * Gets the current class name
  66597. * @returns the class name
  66598. */
  66599. getClassName(): string;
  66600. /**
  66601. * Gets the value input component
  66602. */
  66603. get value(): NodeMaterialConnectionPoint;
  66604. /**
  66605. * Gets the output component
  66606. */
  66607. get output(): NodeMaterialConnectionPoint;
  66608. protected _buildBlock(state: NodeMaterialBuildState): this;
  66609. }
  66610. }
  66611. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  66612. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66613. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66614. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66615. /**
  66616. * Block used to get the value of the first parameter raised to the power of the second
  66617. */
  66618. export class PowBlock extends NodeMaterialBlock {
  66619. /**
  66620. * Creates a new PowBlock
  66621. * @param name defines the block name
  66622. */
  66623. constructor(name: string);
  66624. /**
  66625. * Gets the current class name
  66626. * @returns the class name
  66627. */
  66628. getClassName(): string;
  66629. /**
  66630. * Gets the value operand input component
  66631. */
  66632. get value(): NodeMaterialConnectionPoint;
  66633. /**
  66634. * Gets the power operand input component
  66635. */
  66636. get power(): NodeMaterialConnectionPoint;
  66637. /**
  66638. * Gets the output component
  66639. */
  66640. get output(): NodeMaterialConnectionPoint;
  66641. protected _buildBlock(state: NodeMaterialBuildState): this;
  66642. }
  66643. }
  66644. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  66645. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66646. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66647. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66648. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66649. /**
  66650. * Block used to get a random number
  66651. */
  66652. export class RandomNumberBlock extends NodeMaterialBlock {
  66653. /**
  66654. * Creates a new RandomNumberBlock
  66655. * @param name defines the block name
  66656. */
  66657. constructor(name: string);
  66658. /**
  66659. * Gets the current class name
  66660. * @returns the class name
  66661. */
  66662. getClassName(): string;
  66663. /**
  66664. * Gets the seed input component
  66665. */
  66666. get seed(): NodeMaterialConnectionPoint;
  66667. /**
  66668. * Gets the output component
  66669. */
  66670. get output(): NodeMaterialConnectionPoint;
  66671. protected _buildBlock(state: NodeMaterialBuildState): this;
  66672. }
  66673. }
  66674. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  66675. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66676. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66677. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66678. /**
  66679. * Block used to compute arc tangent of 2 values
  66680. */
  66681. export class ArcTan2Block extends NodeMaterialBlock {
  66682. /**
  66683. * Creates a new ArcTan2Block
  66684. * @param name defines the block name
  66685. */
  66686. constructor(name: string);
  66687. /**
  66688. * Gets the current class name
  66689. * @returns the class name
  66690. */
  66691. getClassName(): string;
  66692. /**
  66693. * Gets the x operand input component
  66694. */
  66695. get x(): NodeMaterialConnectionPoint;
  66696. /**
  66697. * Gets the y operand input component
  66698. */
  66699. get y(): NodeMaterialConnectionPoint;
  66700. /**
  66701. * Gets the output component
  66702. */
  66703. get output(): NodeMaterialConnectionPoint;
  66704. protected _buildBlock(state: NodeMaterialBuildState): this;
  66705. }
  66706. }
  66707. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  66708. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66709. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66710. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66711. /**
  66712. * Block used to smooth step a value
  66713. */
  66714. export class SmoothStepBlock extends NodeMaterialBlock {
  66715. /**
  66716. * Creates a new SmoothStepBlock
  66717. * @param name defines the block name
  66718. */
  66719. constructor(name: string);
  66720. /**
  66721. * Gets the current class name
  66722. * @returns the class name
  66723. */
  66724. getClassName(): string;
  66725. /**
  66726. * Gets the value operand input component
  66727. */
  66728. get value(): NodeMaterialConnectionPoint;
  66729. /**
  66730. * Gets the first edge operand input component
  66731. */
  66732. get edge0(): NodeMaterialConnectionPoint;
  66733. /**
  66734. * Gets the second edge operand input component
  66735. */
  66736. get edge1(): NodeMaterialConnectionPoint;
  66737. /**
  66738. * Gets the output component
  66739. */
  66740. get output(): NodeMaterialConnectionPoint;
  66741. protected _buildBlock(state: NodeMaterialBuildState): this;
  66742. }
  66743. }
  66744. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  66745. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66746. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66747. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66748. /**
  66749. * Block used to get the reciprocal (1 / x) of a value
  66750. */
  66751. export class ReciprocalBlock extends NodeMaterialBlock {
  66752. /**
  66753. * Creates a new ReciprocalBlock
  66754. * @param name defines the block name
  66755. */
  66756. constructor(name: string);
  66757. /**
  66758. * Gets the current class name
  66759. * @returns the class name
  66760. */
  66761. getClassName(): string;
  66762. /**
  66763. * Gets the input component
  66764. */
  66765. get input(): NodeMaterialConnectionPoint;
  66766. /**
  66767. * Gets the output component
  66768. */
  66769. get output(): NodeMaterialConnectionPoint;
  66770. protected _buildBlock(state: NodeMaterialBuildState): this;
  66771. }
  66772. }
  66773. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  66774. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66775. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66776. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66777. /**
  66778. * Block used to replace a color by another one
  66779. */
  66780. export class ReplaceColorBlock extends NodeMaterialBlock {
  66781. /**
  66782. * Creates a new ReplaceColorBlock
  66783. * @param name defines the block name
  66784. */
  66785. constructor(name: string);
  66786. /**
  66787. * Gets the current class name
  66788. * @returns the class name
  66789. */
  66790. getClassName(): string;
  66791. /**
  66792. * Gets the value input component
  66793. */
  66794. get value(): NodeMaterialConnectionPoint;
  66795. /**
  66796. * Gets the reference input component
  66797. */
  66798. get reference(): NodeMaterialConnectionPoint;
  66799. /**
  66800. * Gets the distance input component
  66801. */
  66802. get distance(): NodeMaterialConnectionPoint;
  66803. /**
  66804. * Gets the replacement input component
  66805. */
  66806. get replacement(): NodeMaterialConnectionPoint;
  66807. /**
  66808. * Gets the output component
  66809. */
  66810. get output(): NodeMaterialConnectionPoint;
  66811. protected _buildBlock(state: NodeMaterialBuildState): this;
  66812. }
  66813. }
  66814. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  66815. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66816. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66817. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66818. /**
  66819. * Block used to posterize a value
  66820. * @see https://en.wikipedia.org/wiki/Posterization
  66821. */
  66822. export class PosterizeBlock extends NodeMaterialBlock {
  66823. /**
  66824. * Creates a new PosterizeBlock
  66825. * @param name defines the block name
  66826. */
  66827. constructor(name: string);
  66828. /**
  66829. * Gets the current class name
  66830. * @returns the class name
  66831. */
  66832. getClassName(): string;
  66833. /**
  66834. * Gets the value input component
  66835. */
  66836. get value(): NodeMaterialConnectionPoint;
  66837. /**
  66838. * Gets the steps input component
  66839. */
  66840. get steps(): NodeMaterialConnectionPoint;
  66841. /**
  66842. * Gets the output component
  66843. */
  66844. get output(): NodeMaterialConnectionPoint;
  66845. protected _buildBlock(state: NodeMaterialBuildState): this;
  66846. }
  66847. }
  66848. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  66849. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66850. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66851. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66852. import { Scene } from "babylonjs/scene";
  66853. /**
  66854. * Operations supported by the Wave block
  66855. */
  66856. export enum WaveBlockKind {
  66857. /** SawTooth */
  66858. SawTooth = 0,
  66859. /** Square */
  66860. Square = 1,
  66861. /** Triangle */
  66862. Triangle = 2
  66863. }
  66864. /**
  66865. * Block used to apply wave operation to floats
  66866. */
  66867. export class WaveBlock extends NodeMaterialBlock {
  66868. /**
  66869. * Gets or sets the kibnd of wave to be applied by the block
  66870. */
  66871. kind: WaveBlockKind;
  66872. /**
  66873. * Creates a new WaveBlock
  66874. * @param name defines the block name
  66875. */
  66876. constructor(name: string);
  66877. /**
  66878. * Gets the current class name
  66879. * @returns the class name
  66880. */
  66881. getClassName(): string;
  66882. /**
  66883. * Gets the input component
  66884. */
  66885. get input(): NodeMaterialConnectionPoint;
  66886. /**
  66887. * Gets the output component
  66888. */
  66889. get output(): NodeMaterialConnectionPoint;
  66890. protected _buildBlock(state: NodeMaterialBuildState): this;
  66891. serialize(): any;
  66892. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66893. }
  66894. }
  66895. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  66896. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66897. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66898. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66899. import { Color3 } from "babylonjs/Maths/math.color";
  66900. import { Scene } from "babylonjs/scene";
  66901. /**
  66902. * Class used to store a color step for the GradientBlock
  66903. */
  66904. export class GradientBlockColorStep {
  66905. /**
  66906. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  66907. */
  66908. step: number;
  66909. /**
  66910. * Gets or sets the color associated with this step
  66911. */
  66912. color: Color3;
  66913. /**
  66914. * Creates a new GradientBlockColorStep
  66915. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  66916. * @param color defines the color associated with this step
  66917. */
  66918. constructor(
  66919. /**
  66920. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  66921. */
  66922. step: number,
  66923. /**
  66924. * Gets or sets the color associated with this step
  66925. */
  66926. color: Color3);
  66927. }
  66928. /**
  66929. * Block used to return a color from a gradient based on an input value between 0 and 1
  66930. */
  66931. export class GradientBlock extends NodeMaterialBlock {
  66932. /**
  66933. * Gets or sets the list of color steps
  66934. */
  66935. colorSteps: GradientBlockColorStep[];
  66936. /**
  66937. * Creates a new GradientBlock
  66938. * @param name defines the block name
  66939. */
  66940. constructor(name: string);
  66941. /**
  66942. * Gets the current class name
  66943. * @returns the class name
  66944. */
  66945. getClassName(): string;
  66946. /**
  66947. * Gets the gradient input component
  66948. */
  66949. get gradient(): NodeMaterialConnectionPoint;
  66950. /**
  66951. * Gets the output component
  66952. */
  66953. get output(): NodeMaterialConnectionPoint;
  66954. private _writeColorConstant;
  66955. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66956. serialize(): any;
  66957. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66958. protected _dumpPropertiesCode(): string;
  66959. }
  66960. }
  66961. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  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 normalize lerp between 2 values
  66967. */
  66968. export class NLerpBlock extends NodeMaterialBlock {
  66969. /**
  66970. * Creates a new NLerpBlock
  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 left operand input component
  66981. */
  66982. get left(): NodeMaterialConnectionPoint;
  66983. /**
  66984. * Gets the right operand input component
  66985. */
  66986. get right(): NodeMaterialConnectionPoint;
  66987. /**
  66988. * Gets the gradient operand input component
  66989. */
  66990. get gradient(): NodeMaterialConnectionPoint;
  66991. /**
  66992. * Gets the output component
  66993. */
  66994. get output(): NodeMaterialConnectionPoint;
  66995. protected _buildBlock(state: NodeMaterialBuildState): this;
  66996. }
  66997. }
  66998. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  66999. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67000. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67001. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67002. import { Scene } from "babylonjs/scene";
  67003. /**
  67004. * block used to Generate a Worley Noise 3D Noise Pattern
  67005. */
  67006. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  67007. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  67008. manhattanDistance: boolean;
  67009. /**
  67010. * Creates a new WorleyNoise3DBlock
  67011. * @param name defines the block name
  67012. */
  67013. constructor(name: string);
  67014. /**
  67015. * Gets the current class name
  67016. * @returns the class name
  67017. */
  67018. getClassName(): string;
  67019. /**
  67020. * Gets the seed input component
  67021. */
  67022. get seed(): NodeMaterialConnectionPoint;
  67023. /**
  67024. * Gets the jitter input component
  67025. */
  67026. get jitter(): NodeMaterialConnectionPoint;
  67027. /**
  67028. * Gets the output component
  67029. */
  67030. get output(): NodeMaterialConnectionPoint;
  67031. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67032. /**
  67033. * Exposes the properties to the UI?
  67034. */
  67035. protected _dumpPropertiesCode(): string;
  67036. /**
  67037. * Exposes the properties to the Seralize?
  67038. */
  67039. serialize(): any;
  67040. /**
  67041. * Exposes the properties to the deseralize?
  67042. */
  67043. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67044. }
  67045. }
  67046. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  67047. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67048. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67049. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67050. /**
  67051. * block used to Generate a Simplex Perlin 3d Noise Pattern
  67052. */
  67053. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  67054. /**
  67055. * Creates a new SimplexPerlin3DBlock
  67056. * @param name defines the block name
  67057. */
  67058. constructor(name: string);
  67059. /**
  67060. * Gets the current class name
  67061. * @returns the class name
  67062. */
  67063. getClassName(): string;
  67064. /**
  67065. * Gets the seed operand input component
  67066. */
  67067. get seed(): NodeMaterialConnectionPoint;
  67068. /**
  67069. * Gets the output component
  67070. */
  67071. get output(): NodeMaterialConnectionPoint;
  67072. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67073. }
  67074. }
  67075. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  67076. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67077. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67078. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67079. /**
  67080. * Block used to blend normals
  67081. */
  67082. export class NormalBlendBlock extends NodeMaterialBlock {
  67083. /**
  67084. * Creates a new NormalBlendBlock
  67085. * @param name defines the block name
  67086. */
  67087. constructor(name: string);
  67088. /**
  67089. * Gets the current class name
  67090. * @returns the class name
  67091. */
  67092. getClassName(): string;
  67093. /**
  67094. * Gets the first input component
  67095. */
  67096. get normalMap0(): NodeMaterialConnectionPoint;
  67097. /**
  67098. * Gets the second input component
  67099. */
  67100. get normalMap1(): NodeMaterialConnectionPoint;
  67101. /**
  67102. * Gets the output component
  67103. */
  67104. get output(): NodeMaterialConnectionPoint;
  67105. protected _buildBlock(state: NodeMaterialBuildState): this;
  67106. }
  67107. }
  67108. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  67109. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67110. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67111. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67112. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  67113. /**
  67114. * Block used to rotate a 2d vector by a given angle
  67115. */
  67116. export class Rotate2dBlock extends NodeMaterialBlock {
  67117. /**
  67118. * Creates a new Rotate2dBlock
  67119. * @param name defines the block name
  67120. */
  67121. constructor(name: string);
  67122. /**
  67123. * Gets the current class name
  67124. * @returns the class name
  67125. */
  67126. getClassName(): string;
  67127. /**
  67128. * Gets the input vector
  67129. */
  67130. get input(): NodeMaterialConnectionPoint;
  67131. /**
  67132. * Gets the input angle
  67133. */
  67134. get angle(): NodeMaterialConnectionPoint;
  67135. /**
  67136. * Gets the output component
  67137. */
  67138. get output(): NodeMaterialConnectionPoint;
  67139. autoConfigure(material: NodeMaterial): void;
  67140. protected _buildBlock(state: NodeMaterialBuildState): this;
  67141. }
  67142. }
  67143. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  67144. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67145. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67146. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67147. /**
  67148. * Block used to get the reflected vector from a direction and a normal
  67149. */
  67150. export class ReflectBlock extends NodeMaterialBlock {
  67151. /**
  67152. * Creates a new ReflectBlock
  67153. * @param name defines the block name
  67154. */
  67155. constructor(name: string);
  67156. /**
  67157. * Gets the current class name
  67158. * @returns the class name
  67159. */
  67160. getClassName(): string;
  67161. /**
  67162. * Gets the incident component
  67163. */
  67164. get incident(): NodeMaterialConnectionPoint;
  67165. /**
  67166. * Gets the normal component
  67167. */
  67168. get normal(): NodeMaterialConnectionPoint;
  67169. /**
  67170. * Gets the output component
  67171. */
  67172. get output(): NodeMaterialConnectionPoint;
  67173. protected _buildBlock(state: NodeMaterialBuildState): this;
  67174. }
  67175. }
  67176. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  67177. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67178. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67179. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67180. /**
  67181. * Block used to get the refracted vector from a direction and a normal
  67182. */
  67183. export class RefractBlock extends NodeMaterialBlock {
  67184. /**
  67185. * Creates a new RefractBlock
  67186. * @param name defines the block name
  67187. */
  67188. constructor(name: string);
  67189. /**
  67190. * Gets the current class name
  67191. * @returns the class name
  67192. */
  67193. getClassName(): string;
  67194. /**
  67195. * Gets the incident component
  67196. */
  67197. get incident(): NodeMaterialConnectionPoint;
  67198. /**
  67199. * Gets the normal component
  67200. */
  67201. get normal(): NodeMaterialConnectionPoint;
  67202. /**
  67203. * Gets the index of refraction component
  67204. */
  67205. get ior(): NodeMaterialConnectionPoint;
  67206. /**
  67207. * Gets the output component
  67208. */
  67209. get output(): NodeMaterialConnectionPoint;
  67210. protected _buildBlock(state: NodeMaterialBuildState): this;
  67211. }
  67212. }
  67213. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  67214. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67215. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67216. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67217. /**
  67218. * Block used to desaturate a color
  67219. */
  67220. export class DesaturateBlock extends NodeMaterialBlock {
  67221. /**
  67222. * Creates a new DesaturateBlock
  67223. * @param name defines the block name
  67224. */
  67225. constructor(name: string);
  67226. /**
  67227. * Gets the current class name
  67228. * @returns the class name
  67229. */
  67230. getClassName(): string;
  67231. /**
  67232. * Gets the color operand input component
  67233. */
  67234. get color(): NodeMaterialConnectionPoint;
  67235. /**
  67236. * Gets the level operand input component
  67237. */
  67238. get level(): NodeMaterialConnectionPoint;
  67239. /**
  67240. * Gets the output component
  67241. */
  67242. get output(): NodeMaterialConnectionPoint;
  67243. protected _buildBlock(state: NodeMaterialBuildState): this;
  67244. }
  67245. }
  67246. declare module "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock" {
  67247. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67248. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67249. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67250. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67251. import { Nullable } from "babylonjs/types";
  67252. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67253. import { Scene } from "babylonjs/scene";
  67254. /**
  67255. * Block used to implement the ambient occlusion module of the PBR material
  67256. */
  67257. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  67258. /**
  67259. * Create a new AmbientOcclusionBlock
  67260. * @param name defines the block name
  67261. */
  67262. constructor(name: string);
  67263. /**
  67264. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  67265. */
  67266. useAmbientInGrayScale: boolean;
  67267. /**
  67268. * Initialize the block and prepare the context for build
  67269. * @param state defines the state that will be used for the build
  67270. */
  67271. initialize(state: NodeMaterialBuildState): void;
  67272. /**
  67273. * Gets the current class name
  67274. * @returns the class name
  67275. */
  67276. getClassName(): string;
  67277. /**
  67278. * Gets the texture input component
  67279. */
  67280. get texture(): NodeMaterialConnectionPoint;
  67281. /**
  67282. * Gets the texture intensity component
  67283. */
  67284. get intensity(): NodeMaterialConnectionPoint;
  67285. /**
  67286. * Gets the direct light intensity input component
  67287. */
  67288. get directLightIntensity(): NodeMaterialConnectionPoint;
  67289. /**
  67290. * Gets the ambient occlusion object output component
  67291. */
  67292. get ambientOcclusion(): NodeMaterialConnectionPoint;
  67293. /**
  67294. * Gets the main code of the block (fragment side)
  67295. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  67296. * @returns the shader code
  67297. */
  67298. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  67299. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67300. protected _buildBlock(state: NodeMaterialBuildState): this;
  67301. protected _dumpPropertiesCode(): string;
  67302. serialize(): any;
  67303. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67304. }
  67305. }
  67306. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  67307. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67308. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67309. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67310. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  67311. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67312. import { Nullable } from "babylonjs/types";
  67313. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  67314. import { Mesh } from "babylonjs/Meshes/mesh";
  67315. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67316. import { Effect } from "babylonjs/Materials/effect";
  67317. import { Scene } from "babylonjs/scene";
  67318. /**
  67319. * Block used to implement the reflection module of the PBR material
  67320. */
  67321. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  67322. /** @hidden */
  67323. _defineLODReflectionAlpha: string;
  67324. /** @hidden */
  67325. _defineLinearSpecularReflection: string;
  67326. private _vEnvironmentIrradianceName;
  67327. /** @hidden */
  67328. _vReflectionMicrosurfaceInfosName: string;
  67329. /** @hidden */
  67330. _vReflectionInfosName: string;
  67331. /** @hidden */
  67332. _vReflectionFilteringInfoName: string;
  67333. private _scene;
  67334. /**
  67335. * The three properties below are set by the main PBR block prior to calling methods of this class.
  67336. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  67337. * It's less burden on the user side in the editor part.
  67338. */
  67339. /** @hidden */
  67340. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  67341. /** @hidden */
  67342. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  67343. /** @hidden */
  67344. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  67345. /**
  67346. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  67347. * diffuse part of the IBL.
  67348. */
  67349. useSphericalHarmonics: boolean;
  67350. /**
  67351. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  67352. */
  67353. forceIrradianceInFragment: boolean;
  67354. /**
  67355. * Create a new ReflectionBlock
  67356. * @param name defines the block name
  67357. */
  67358. constructor(name: string);
  67359. /**
  67360. * Gets the current class name
  67361. * @returns the class name
  67362. */
  67363. getClassName(): string;
  67364. /**
  67365. * Gets the position input component
  67366. */
  67367. get position(): NodeMaterialConnectionPoint;
  67368. /**
  67369. * Gets the world position input component
  67370. */
  67371. get worldPosition(): NodeMaterialConnectionPoint;
  67372. /**
  67373. * Gets the world normal input component
  67374. */
  67375. get worldNormal(): NodeMaterialConnectionPoint;
  67376. /**
  67377. * Gets the world input component
  67378. */
  67379. get world(): NodeMaterialConnectionPoint;
  67380. /**
  67381. * Gets the camera (or eye) position component
  67382. */
  67383. get cameraPosition(): NodeMaterialConnectionPoint;
  67384. /**
  67385. * Gets the view input component
  67386. */
  67387. get view(): NodeMaterialConnectionPoint;
  67388. /**
  67389. * Gets the color input component
  67390. */
  67391. get color(): NodeMaterialConnectionPoint;
  67392. /**
  67393. * Gets the reflection object output component
  67394. */
  67395. get reflection(): NodeMaterialConnectionPoint;
  67396. /**
  67397. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  67398. */
  67399. get hasTexture(): boolean;
  67400. /**
  67401. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  67402. */
  67403. get reflectionColor(): string;
  67404. protected _getTexture(): Nullable<BaseTexture>;
  67405. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67406. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  67407. /**
  67408. * Gets the code to inject in the vertex shader
  67409. * @param state current state of the node material building
  67410. * @returns the shader code
  67411. */
  67412. handleVertexSide(state: NodeMaterialBuildState): string;
  67413. /**
  67414. * Gets the main code of the block (fragment side)
  67415. * @param state current state of the node material building
  67416. * @param normalVarName name of the existing variable corresponding to the normal
  67417. * @returns the shader code
  67418. */
  67419. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  67420. protected _buildBlock(state: NodeMaterialBuildState): this;
  67421. protected _dumpPropertiesCode(): string;
  67422. serialize(): any;
  67423. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67424. }
  67425. }
  67426. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  67427. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67428. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67429. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67430. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67431. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67432. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67433. import { Scene } from "babylonjs/scene";
  67434. import { Nullable } from "babylonjs/types";
  67435. /**
  67436. * Block used to implement the sheen module of the PBR material
  67437. */
  67438. export class SheenBlock extends NodeMaterialBlock {
  67439. /**
  67440. * Create a new SheenBlock
  67441. * @param name defines the block name
  67442. */
  67443. constructor(name: string);
  67444. /**
  67445. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  67446. * It allows the strength of the sheen effect to not depend on the base color of the material,
  67447. * making it easier to setup and tweak the effect
  67448. */
  67449. albedoScaling: boolean;
  67450. /**
  67451. * Defines if the sheen is linked to the sheen color.
  67452. */
  67453. linkSheenWithAlbedo: boolean;
  67454. /**
  67455. * Initialize the block and prepare the context for build
  67456. * @param state defines the state that will be used for the build
  67457. */
  67458. initialize(state: NodeMaterialBuildState): void;
  67459. /**
  67460. * Gets the current class name
  67461. * @returns the class name
  67462. */
  67463. getClassName(): string;
  67464. /**
  67465. * Gets the intensity input component
  67466. */
  67467. get intensity(): NodeMaterialConnectionPoint;
  67468. /**
  67469. * Gets the color input component
  67470. */
  67471. get color(): NodeMaterialConnectionPoint;
  67472. /**
  67473. * Gets the roughness input component
  67474. */
  67475. get roughness(): NodeMaterialConnectionPoint;
  67476. /**
  67477. * Gets the sheen object output component
  67478. */
  67479. get sheen(): NodeMaterialConnectionPoint;
  67480. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67481. /**
  67482. * Gets the main code of the block (fragment side)
  67483. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  67484. * @returns the shader code
  67485. */
  67486. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  67487. protected _buildBlock(state: NodeMaterialBuildState): this;
  67488. protected _dumpPropertiesCode(): string;
  67489. serialize(): any;
  67490. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67491. }
  67492. }
  67493. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock" {
  67494. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67495. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67496. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67497. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67498. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67499. import { Scene } from "babylonjs/scene";
  67500. import { Nullable } from "babylonjs/types";
  67501. import { Mesh } from "babylonjs/Meshes/mesh";
  67502. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67503. import { Effect } from "babylonjs/Materials/effect";
  67504. /**
  67505. * Block used to implement the reflectivity module of the PBR material
  67506. */
  67507. export class ReflectivityBlock extends NodeMaterialBlock {
  67508. private _metallicReflectanceColor;
  67509. private _metallicF0Factor;
  67510. /** @hidden */
  67511. _vMetallicReflectanceFactorsName: string;
  67512. /**
  67513. * The property below is set by the main PBR block prior to calling methods of this class.
  67514. */
  67515. /** @hidden */
  67516. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  67517. /**
  67518. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  67519. */
  67520. useAmbientOcclusionFromMetallicTextureRed: boolean;
  67521. /**
  67522. * Specifies if the metallic texture contains the metallness information in its blue channel.
  67523. */
  67524. useMetallnessFromMetallicTextureBlue: boolean;
  67525. /**
  67526. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  67527. */
  67528. useRoughnessFromMetallicTextureAlpha: boolean;
  67529. /**
  67530. * Specifies if the metallic texture contains the roughness information in its green channel.
  67531. */
  67532. useRoughnessFromMetallicTextureGreen: boolean;
  67533. /**
  67534. * Create a new ReflectivityBlock
  67535. * @param name defines the block name
  67536. */
  67537. constructor(name: string);
  67538. /**
  67539. * Initialize the block and prepare the context for build
  67540. * @param state defines the state that will be used for the build
  67541. */
  67542. initialize(state: NodeMaterialBuildState): void;
  67543. /**
  67544. * Gets the current class name
  67545. * @returns the class name
  67546. */
  67547. getClassName(): string;
  67548. /**
  67549. * Gets the metallic input component
  67550. */
  67551. get metallic(): NodeMaterialConnectionPoint;
  67552. /**
  67553. * Gets the roughness input component
  67554. */
  67555. get roughness(): NodeMaterialConnectionPoint;
  67556. /**
  67557. * Gets the texture input component
  67558. */
  67559. get texture(): NodeMaterialConnectionPoint;
  67560. /**
  67561. * Gets the reflectivity object output component
  67562. */
  67563. get reflectivity(): NodeMaterialConnectionPoint;
  67564. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  67565. /**
  67566. * Gets the main code of the block (fragment side)
  67567. * @param state current state of the node material building
  67568. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  67569. * @returns the shader code
  67570. */
  67571. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  67572. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67573. protected _buildBlock(state: NodeMaterialBuildState): this;
  67574. protected _dumpPropertiesCode(): string;
  67575. serialize(): any;
  67576. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67577. }
  67578. }
  67579. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  67580. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67581. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67582. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67583. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67584. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67585. /**
  67586. * Block used to implement the anisotropy module of the PBR material
  67587. */
  67588. export class AnisotropyBlock extends NodeMaterialBlock {
  67589. /**
  67590. * The two properties below are set by the main PBR block prior to calling methods of this class.
  67591. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  67592. * It's less burden on the user side in the editor part.
  67593. */
  67594. /** @hidden */
  67595. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  67596. /** @hidden */
  67597. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  67598. /**
  67599. * Create a new AnisotropyBlock
  67600. * @param name defines the block name
  67601. */
  67602. constructor(name: string);
  67603. /**
  67604. * Initialize the block and prepare the context for build
  67605. * @param state defines the state that will be used for the build
  67606. */
  67607. initialize(state: NodeMaterialBuildState): void;
  67608. /**
  67609. * Gets the current class name
  67610. * @returns the class name
  67611. */
  67612. getClassName(): string;
  67613. /**
  67614. * Gets the intensity input component
  67615. */
  67616. get intensity(): NodeMaterialConnectionPoint;
  67617. /**
  67618. * Gets the direction input component
  67619. */
  67620. get direction(): NodeMaterialConnectionPoint;
  67621. /**
  67622. * Gets the texture input component
  67623. */
  67624. get texture(): NodeMaterialConnectionPoint;
  67625. /**
  67626. * Gets the uv input component
  67627. */
  67628. get uv(): NodeMaterialConnectionPoint;
  67629. /**
  67630. * Gets the worldTangent input component
  67631. */
  67632. get worldTangent(): NodeMaterialConnectionPoint;
  67633. /**
  67634. * Gets the anisotropy object output component
  67635. */
  67636. get anisotropy(): NodeMaterialConnectionPoint;
  67637. private _generateTBNSpace;
  67638. /**
  67639. * Gets the main code of the block (fragment side)
  67640. * @param state current state of the node material building
  67641. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  67642. * @returns the shader code
  67643. */
  67644. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  67645. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67646. protected _buildBlock(state: NodeMaterialBuildState): this;
  67647. }
  67648. }
  67649. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  67650. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67651. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67652. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67653. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67654. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67655. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67656. import { Nullable } from "babylonjs/types";
  67657. import { Mesh } from "babylonjs/Meshes/mesh";
  67658. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67659. import { Effect } from "babylonjs/Materials/effect";
  67660. /**
  67661. * Block used to implement the clear coat module of the PBR material
  67662. */
  67663. export class ClearCoatBlock extends NodeMaterialBlock {
  67664. private _scene;
  67665. /**
  67666. * Create a new ClearCoatBlock
  67667. * @param name defines the block name
  67668. */
  67669. constructor(name: string);
  67670. /**
  67671. * Initialize the block and prepare the context for build
  67672. * @param state defines the state that will be used for the build
  67673. */
  67674. initialize(state: NodeMaterialBuildState): void;
  67675. /**
  67676. * Gets the current class name
  67677. * @returns the class name
  67678. */
  67679. getClassName(): string;
  67680. /**
  67681. * Gets the intensity input component
  67682. */
  67683. get intensity(): NodeMaterialConnectionPoint;
  67684. /**
  67685. * Gets the roughness input component
  67686. */
  67687. get roughness(): NodeMaterialConnectionPoint;
  67688. /**
  67689. * Gets the ior input component
  67690. */
  67691. get ior(): NodeMaterialConnectionPoint;
  67692. /**
  67693. * Gets the texture input component
  67694. */
  67695. get texture(): NodeMaterialConnectionPoint;
  67696. /**
  67697. * Gets the bump texture input component
  67698. */
  67699. get bumpTexture(): NodeMaterialConnectionPoint;
  67700. /**
  67701. * Gets the uv input component
  67702. */
  67703. get uv(): NodeMaterialConnectionPoint;
  67704. /**
  67705. * Gets the tint color input component
  67706. */
  67707. get tintColor(): NodeMaterialConnectionPoint;
  67708. /**
  67709. * Gets the tint "at distance" input component
  67710. */
  67711. get tintAtDistance(): NodeMaterialConnectionPoint;
  67712. /**
  67713. * Gets the tint thickness input component
  67714. */
  67715. get tintThickness(): NodeMaterialConnectionPoint;
  67716. /**
  67717. * Gets the world tangent input component
  67718. */
  67719. get worldTangent(): NodeMaterialConnectionPoint;
  67720. /**
  67721. * Gets the clear coat object output component
  67722. */
  67723. get clearcoat(): NodeMaterialConnectionPoint;
  67724. autoConfigure(material: NodeMaterial): void;
  67725. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67726. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  67727. private _generateTBNSpace;
  67728. /**
  67729. * Gets the main code of the block (fragment side)
  67730. * @param state current state of the node material building
  67731. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  67732. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  67733. * @param worldPosVarName name of the variable holding the world position
  67734. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  67735. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  67736. * @param worldNormalVarName name of the variable holding the world normal
  67737. * @returns the shader code
  67738. */
  67739. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  67740. protected _buildBlock(state: NodeMaterialBuildState): this;
  67741. }
  67742. }
  67743. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  67744. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67745. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67746. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67747. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67748. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67749. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67750. import { Nullable } from "babylonjs/types";
  67751. /**
  67752. * Block used to implement the sub surface module of the PBR material
  67753. */
  67754. export class SubSurfaceBlock extends NodeMaterialBlock {
  67755. /**
  67756. * Create a new SubSurfaceBlock
  67757. * @param name defines the block name
  67758. */
  67759. constructor(name: string);
  67760. /**
  67761. * Stores the intensity of the different subsurface effects in the thickness texture.
  67762. * * the green channel is the translucency intensity.
  67763. * * the blue channel is the scattering intensity.
  67764. * * the alpha channel is the refraction intensity.
  67765. */
  67766. useMaskFromThicknessTexture: boolean;
  67767. /**
  67768. * Initialize the block and prepare the context for build
  67769. * @param state defines the state that will be used for the build
  67770. */
  67771. initialize(state: NodeMaterialBuildState): void;
  67772. /**
  67773. * Gets the current class name
  67774. * @returns the class name
  67775. */
  67776. getClassName(): string;
  67777. /**
  67778. * Gets the min thickness input component
  67779. */
  67780. get minThickness(): NodeMaterialConnectionPoint;
  67781. /**
  67782. * Gets the max thickness input component
  67783. */
  67784. get maxThickness(): NodeMaterialConnectionPoint;
  67785. /**
  67786. * Gets the thickness texture component
  67787. */
  67788. get thicknessTexture(): NodeMaterialConnectionPoint;
  67789. /**
  67790. * Gets the tint color input component
  67791. */
  67792. get tintColor(): NodeMaterialConnectionPoint;
  67793. /**
  67794. * Gets the translucency intensity input component
  67795. */
  67796. get translucencyIntensity(): NodeMaterialConnectionPoint;
  67797. /**
  67798. * Gets the translucency diffusion distance input component
  67799. */
  67800. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  67801. /**
  67802. * Gets the refraction object parameters
  67803. */
  67804. get refraction(): NodeMaterialConnectionPoint;
  67805. /**
  67806. * Gets the sub surface object output component
  67807. */
  67808. get subsurface(): NodeMaterialConnectionPoint;
  67809. autoConfigure(material: NodeMaterial): void;
  67810. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67811. /**
  67812. * Gets the main code of the block (fragment side)
  67813. * @param state current state of the node material building
  67814. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  67815. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  67816. * @param worldPosVarName name of the variable holding the world position
  67817. * @returns the shader code
  67818. */
  67819. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  67820. protected _buildBlock(state: NodeMaterialBuildState): this;
  67821. }
  67822. }
  67823. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  67824. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67825. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67826. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67827. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67828. import { Light } from "babylonjs/Lights/light";
  67829. import { Nullable } from "babylonjs/types";
  67830. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67831. import { Effect } from "babylonjs/Materials/effect";
  67832. import { Mesh } from "babylonjs/Meshes/mesh";
  67833. import { Scene } from "babylonjs/scene";
  67834. /**
  67835. * Block used to implement the PBR metallic/roughness model
  67836. */
  67837. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  67838. /**
  67839. * Gets or sets the light associated with this block
  67840. */
  67841. light: Nullable<Light>;
  67842. private _lightId;
  67843. private _scene;
  67844. private _environmentBRDFTexture;
  67845. private _environmentBrdfSamplerName;
  67846. private _vNormalWName;
  67847. private _invertNormalName;
  67848. /**
  67849. * Create a new ReflectionBlock
  67850. * @param name defines the block name
  67851. */
  67852. constructor(name: string);
  67853. /**
  67854. * Intensity of the direct lights e.g. the four lights available in your scene.
  67855. * This impacts both the direct diffuse and specular highlights.
  67856. */
  67857. directIntensity: number;
  67858. /**
  67859. * Intensity of the environment e.g. how much the environment will light the object
  67860. * either through harmonics for rough material or through the refelction for shiny ones.
  67861. */
  67862. environmentIntensity: number;
  67863. /**
  67864. * This is a special control allowing the reduction of the specular highlights coming from the
  67865. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  67866. */
  67867. specularIntensity: number;
  67868. /**
  67869. * Defines the falloff type used in this material.
  67870. * It by default is Physical.
  67871. */
  67872. lightFalloff: number;
  67873. /**
  67874. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  67875. */
  67876. useAlphaFromAlbedoTexture: boolean;
  67877. /**
  67878. * Specifies that alpha test should be used
  67879. */
  67880. useAlphaTest: boolean;
  67881. /**
  67882. * Defines the alpha limits in alpha test mode.
  67883. */
  67884. alphaTestCutoff: number;
  67885. /**
  67886. * Specifies that alpha blending should be used
  67887. */
  67888. useAlphaBlending: boolean;
  67889. /**
  67890. * Defines if the alpha value should be determined via the rgb values.
  67891. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  67892. */
  67893. opacityRGB: boolean;
  67894. /**
  67895. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  67896. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  67897. */
  67898. useRadianceOverAlpha: boolean;
  67899. /**
  67900. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  67901. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  67902. */
  67903. useSpecularOverAlpha: boolean;
  67904. /**
  67905. * Enables specular anti aliasing in the PBR shader.
  67906. * It will both interacts on the Geometry for analytical and IBL lighting.
  67907. * It also prefilter the roughness map based on the bump values.
  67908. */
  67909. enableSpecularAntiAliasing: boolean;
  67910. /**
  67911. * Enables realtime filtering on the texture.
  67912. */
  67913. realTimeFiltering: boolean;
  67914. /**
  67915. * Quality switch for realtime filtering
  67916. */
  67917. realTimeFilteringQuality: number;
  67918. /**
  67919. * Defines if the material uses energy conservation.
  67920. */
  67921. useEnergyConservation: boolean;
  67922. /**
  67923. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  67924. * too much the area relying on ambient texture to define their ambient occlusion.
  67925. */
  67926. useRadianceOcclusion: boolean;
  67927. /**
  67928. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  67929. * makes the reflect vector face the model (under horizon).
  67930. */
  67931. useHorizonOcclusion: boolean;
  67932. /**
  67933. * If set to true, no lighting calculations will be applied.
  67934. */
  67935. unlit: boolean;
  67936. /**
  67937. * Force normal to face away from face.
  67938. */
  67939. forceNormalForward: boolean;
  67940. /**
  67941. * Defines the material debug mode.
  67942. * It helps seeing only some components of the material while troubleshooting.
  67943. */
  67944. debugMode: number;
  67945. /**
  67946. * Specify from where on screen the debug mode should start.
  67947. * The value goes from -1 (full screen) to 1 (not visible)
  67948. * It helps with side by side comparison against the final render
  67949. * This defaults to 0
  67950. */
  67951. debugLimit: number;
  67952. /**
  67953. * As the default viewing range might not be enough (if the ambient is really small for instance)
  67954. * You can use the factor to better multiply the final value.
  67955. */
  67956. debugFactor: number;
  67957. /**
  67958. * Initialize the block and prepare the context for build
  67959. * @param state defines the state that will be used for the build
  67960. */
  67961. initialize(state: NodeMaterialBuildState): void;
  67962. /**
  67963. * Gets the current class name
  67964. * @returns the class name
  67965. */
  67966. getClassName(): string;
  67967. /**
  67968. * Gets the world position input component
  67969. */
  67970. get worldPosition(): NodeMaterialConnectionPoint;
  67971. /**
  67972. * Gets the world normal input component
  67973. */
  67974. get worldNormal(): NodeMaterialConnectionPoint;
  67975. /**
  67976. * Gets the perturbed normal input component
  67977. */
  67978. get perturbedNormal(): NodeMaterialConnectionPoint;
  67979. /**
  67980. * Gets the camera position input component
  67981. */
  67982. get cameraPosition(): NodeMaterialConnectionPoint;
  67983. /**
  67984. * Gets the base color input component
  67985. */
  67986. get baseColor(): NodeMaterialConnectionPoint;
  67987. /**
  67988. * Gets the opacity texture input component
  67989. */
  67990. get opacityTexture(): NodeMaterialConnectionPoint;
  67991. /**
  67992. * Gets the ambient color input component
  67993. */
  67994. get ambientColor(): NodeMaterialConnectionPoint;
  67995. /**
  67996. * Gets the reflectivity object parameters
  67997. */
  67998. get reflectivity(): NodeMaterialConnectionPoint;
  67999. /**
  68000. * Gets the ambient occlusion object parameters
  68001. */
  68002. get ambientOcclusion(): NodeMaterialConnectionPoint;
  68003. /**
  68004. * Gets the reflection object parameters
  68005. */
  68006. get reflection(): NodeMaterialConnectionPoint;
  68007. /**
  68008. * Gets the sheen object parameters
  68009. */
  68010. get sheen(): NodeMaterialConnectionPoint;
  68011. /**
  68012. * Gets the clear coat object parameters
  68013. */
  68014. get clearcoat(): NodeMaterialConnectionPoint;
  68015. /**
  68016. * Gets the sub surface object parameters
  68017. */
  68018. get subsurface(): NodeMaterialConnectionPoint;
  68019. /**
  68020. * Gets the anisotropy object parameters
  68021. */
  68022. get anisotropy(): NodeMaterialConnectionPoint;
  68023. /**
  68024. * Gets the ambient output component
  68025. */
  68026. get ambient(): NodeMaterialConnectionPoint;
  68027. /**
  68028. * Gets the diffuse output component
  68029. */
  68030. get diffuse(): NodeMaterialConnectionPoint;
  68031. /**
  68032. * Gets the specular output component
  68033. */
  68034. get specular(): NodeMaterialConnectionPoint;
  68035. /**
  68036. * Gets the sheen output component
  68037. */
  68038. get sheenDir(): NodeMaterialConnectionPoint;
  68039. /**
  68040. * Gets the clear coat output component
  68041. */
  68042. get clearcoatDir(): NodeMaterialConnectionPoint;
  68043. /**
  68044. * Gets the indirect diffuse output component
  68045. */
  68046. get diffuseIndirect(): NodeMaterialConnectionPoint;
  68047. /**
  68048. * Gets the indirect specular output component
  68049. */
  68050. get specularIndirect(): NodeMaterialConnectionPoint;
  68051. /**
  68052. * Gets the indirect sheen output component
  68053. */
  68054. get sheenIndirect(): NodeMaterialConnectionPoint;
  68055. /**
  68056. * Gets the indirect clear coat output component
  68057. */
  68058. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  68059. /**
  68060. * Gets the refraction output component
  68061. */
  68062. get refraction(): NodeMaterialConnectionPoint;
  68063. /**
  68064. * Gets the global lighting output component
  68065. */
  68066. get lighting(): NodeMaterialConnectionPoint;
  68067. /**
  68068. * Gets the shadow output component
  68069. */
  68070. get shadow(): NodeMaterialConnectionPoint;
  68071. /**
  68072. * Gets the alpha output component
  68073. */
  68074. get alpha(): NodeMaterialConnectionPoint;
  68075. autoConfigure(material: NodeMaterial): void;
  68076. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68077. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  68078. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  68079. private _injectVertexCode;
  68080. /**
  68081. * Gets the code corresponding to the albedo/opacity module
  68082. * @returns the shader code
  68083. */
  68084. getAlbedoOpacityCode(): string;
  68085. protected _buildBlock(state: NodeMaterialBuildState): this;
  68086. protected _dumpPropertiesCode(): string;
  68087. serialize(): any;
  68088. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68089. }
  68090. }
  68091. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  68092. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  68093. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  68094. export * from "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock";
  68095. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock";
  68096. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  68097. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68098. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  68099. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  68100. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  68101. }
  68102. declare module "babylonjs/Materials/Node/Blocks/Particle/index" {
  68103. export * from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  68104. export * from "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock";
  68105. export * from "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock";
  68106. }
  68107. declare module "babylonjs/Materials/Node/Blocks/modBlock" {
  68108. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68109. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68110. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68111. /**
  68112. * Block used to compute value of one parameter modulo another
  68113. */
  68114. export class ModBlock extends NodeMaterialBlock {
  68115. /**
  68116. * Creates a new ModBlock
  68117. * @param name defines the block name
  68118. */
  68119. constructor(name: string);
  68120. /**
  68121. * Gets the current class name
  68122. * @returns the class name
  68123. */
  68124. getClassName(): string;
  68125. /**
  68126. * Gets the left operand input component
  68127. */
  68128. get left(): NodeMaterialConnectionPoint;
  68129. /**
  68130. * Gets the right operand input component
  68131. */
  68132. get right(): NodeMaterialConnectionPoint;
  68133. /**
  68134. * Gets the output component
  68135. */
  68136. get output(): NodeMaterialConnectionPoint;
  68137. protected _buildBlock(state: NodeMaterialBuildState): this;
  68138. }
  68139. }
  68140. declare module "babylonjs/Materials/Node/Blocks/index" {
  68141. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  68142. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  68143. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  68144. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  68145. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  68146. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  68147. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  68148. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  68149. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  68150. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  68151. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  68152. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  68153. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  68154. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  68155. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  68156. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  68157. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  68158. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  68159. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  68160. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  68161. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  68162. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  68163. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  68164. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  68165. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  68166. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  68167. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  68168. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  68169. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  68170. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  68171. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  68172. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  68173. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  68174. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  68175. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  68176. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  68177. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  68178. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  68179. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  68180. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  68181. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  68182. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  68183. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  68184. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  68185. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  68186. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  68187. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  68188. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  68189. export * from "babylonjs/Materials/Node/Blocks/Particle/index";
  68190. export * from "babylonjs/Materials/Node/Blocks/modBlock";
  68191. }
  68192. declare module "babylonjs/Materials/Node/Optimizers/index" {
  68193. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  68194. }
  68195. declare module "babylonjs/Materials/Node/index" {
  68196. export * from "babylonjs/Materials/Node/Enums/index";
  68197. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68198. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  68199. export * from "babylonjs/Materials/Node/nodeMaterial";
  68200. export * from "babylonjs/Materials/Node/Blocks/index";
  68201. export * from "babylonjs/Materials/Node/Optimizers/index";
  68202. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  68203. }
  68204. declare module "babylonjs/Materials/index" {
  68205. export * from "babylonjs/Materials/Background/index";
  68206. export * from "babylonjs/Materials/colorCurves";
  68207. export * from "babylonjs/Materials/iEffectFallbacks";
  68208. export * from "babylonjs/Materials/effectFallbacks";
  68209. export * from "babylonjs/Materials/effect";
  68210. export * from "babylonjs/Materials/fresnelParameters";
  68211. export * from "babylonjs/Materials/imageProcessingConfiguration";
  68212. export * from "babylonjs/Materials/material";
  68213. export * from "babylonjs/Materials/materialDefines";
  68214. export * from "babylonjs/Materials/thinMaterialHelper";
  68215. export * from "babylonjs/Materials/materialHelper";
  68216. export * from "babylonjs/Materials/multiMaterial";
  68217. export * from "babylonjs/Materials/PBR/index";
  68218. export * from "babylonjs/Materials/pushMaterial";
  68219. export * from "babylonjs/Materials/shaderMaterial";
  68220. export * from "babylonjs/Materials/standardMaterial";
  68221. export * from "babylonjs/Materials/Textures/index";
  68222. export * from "babylonjs/Materials/uniformBuffer";
  68223. export * from "babylonjs/Materials/materialFlags";
  68224. export * from "babylonjs/Materials/Node/index";
  68225. export * from "babylonjs/Materials/effectRenderer";
  68226. export * from "babylonjs/Materials/shadowDepthWrapper";
  68227. }
  68228. declare module "babylonjs/Maths/index" {
  68229. export * from "babylonjs/Maths/math.scalar";
  68230. export * from "babylonjs/Maths/math";
  68231. export * from "babylonjs/Maths/sphericalPolynomial";
  68232. }
  68233. declare module "babylonjs/Misc/workerPool" {
  68234. import { IDisposable } from "babylonjs/scene";
  68235. /**
  68236. * Helper class to push actions to a pool of workers.
  68237. */
  68238. export class WorkerPool implements IDisposable {
  68239. private _workerInfos;
  68240. private _pendingActions;
  68241. /**
  68242. * Constructor
  68243. * @param workers Array of workers to use for actions
  68244. */
  68245. constructor(workers: Array<Worker>);
  68246. /**
  68247. * Terminates all workers and clears any pending actions.
  68248. */
  68249. dispose(): void;
  68250. /**
  68251. * Pushes an action to the worker pool. If all the workers are active, the action will be
  68252. * pended until a worker has completed its action.
  68253. * @param action The action to perform. Call onComplete when the action is complete.
  68254. */
  68255. push(action: (worker: Worker, onComplete: () => void) => void): void;
  68256. private _execute;
  68257. }
  68258. }
  68259. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  68260. import { IDisposable } from "babylonjs/scene";
  68261. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  68262. /**
  68263. * Configuration for Draco compression
  68264. */
  68265. export interface IDracoCompressionConfiguration {
  68266. /**
  68267. * Configuration for the decoder.
  68268. */
  68269. decoder: {
  68270. /**
  68271. * The url to the WebAssembly module.
  68272. */
  68273. wasmUrl?: string;
  68274. /**
  68275. * The url to the WebAssembly binary.
  68276. */
  68277. wasmBinaryUrl?: string;
  68278. /**
  68279. * The url to the fallback JavaScript module.
  68280. */
  68281. fallbackUrl?: string;
  68282. };
  68283. }
  68284. /**
  68285. * Draco compression (https://google.github.io/draco/)
  68286. *
  68287. * This class wraps the Draco module.
  68288. *
  68289. * **Encoder**
  68290. *
  68291. * The encoder is not currently implemented.
  68292. *
  68293. * **Decoder**
  68294. *
  68295. * 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.
  68296. *
  68297. * To update the configuration, use the following code:
  68298. * ```javascript
  68299. * DracoCompression.Configuration = {
  68300. * decoder: {
  68301. * wasmUrl: "<url to the WebAssembly library>",
  68302. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  68303. * fallbackUrl: "<url to the fallback JavaScript library>",
  68304. * }
  68305. * };
  68306. * ```
  68307. *
  68308. * 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.
  68309. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  68310. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  68311. *
  68312. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  68313. * ```javascript
  68314. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  68315. * ```
  68316. *
  68317. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  68318. */
  68319. export class DracoCompression implements IDisposable {
  68320. private _workerPoolPromise?;
  68321. private _decoderModulePromise?;
  68322. /**
  68323. * The configuration. Defaults to the following urls:
  68324. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  68325. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  68326. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  68327. */
  68328. static Configuration: IDracoCompressionConfiguration;
  68329. /**
  68330. * Returns true if the decoder configuration is available.
  68331. */
  68332. static get DecoderAvailable(): boolean;
  68333. /**
  68334. * Default number of workers to create when creating the draco compression object.
  68335. */
  68336. static DefaultNumWorkers: number;
  68337. private static GetDefaultNumWorkers;
  68338. private static _Default;
  68339. /**
  68340. * Default instance for the draco compression object.
  68341. */
  68342. static get Default(): DracoCompression;
  68343. /**
  68344. * Constructor
  68345. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  68346. */
  68347. constructor(numWorkers?: number);
  68348. /**
  68349. * Stop all async operations and release resources.
  68350. */
  68351. dispose(): void;
  68352. /**
  68353. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  68354. * @returns a promise that resolves when ready
  68355. */
  68356. whenReadyAsync(): Promise<void>;
  68357. /**
  68358. * Decode Draco compressed mesh data to vertex data.
  68359. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  68360. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  68361. * @returns A promise that resolves with the decoded vertex data
  68362. */
  68363. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  68364. [kind: string]: number;
  68365. }): Promise<VertexData>;
  68366. }
  68367. }
  68368. declare module "babylonjs/Meshes/Compression/index" {
  68369. export * from "babylonjs/Meshes/Compression/dracoCompression";
  68370. }
  68371. declare module "babylonjs/Meshes/csg" {
  68372. import { Nullable } from "babylonjs/types";
  68373. import { Scene } from "babylonjs/scene";
  68374. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  68375. import { Mesh } from "babylonjs/Meshes/mesh";
  68376. import { Material } from "babylonjs/Materials/material";
  68377. /**
  68378. * Class for building Constructive Solid Geometry
  68379. */
  68380. export class CSG {
  68381. private polygons;
  68382. /**
  68383. * The world matrix
  68384. */
  68385. matrix: Matrix;
  68386. /**
  68387. * Stores the position
  68388. */
  68389. position: Vector3;
  68390. /**
  68391. * Stores the rotation
  68392. */
  68393. rotation: Vector3;
  68394. /**
  68395. * Stores the rotation quaternion
  68396. */
  68397. rotationQuaternion: Nullable<Quaternion>;
  68398. /**
  68399. * Stores the scaling vector
  68400. */
  68401. scaling: Vector3;
  68402. /**
  68403. * Convert the Mesh to CSG
  68404. * @param mesh The Mesh to convert to CSG
  68405. * @returns A new CSG from the Mesh
  68406. */
  68407. static FromMesh(mesh: Mesh): CSG;
  68408. /**
  68409. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  68410. * @param polygons Polygons used to construct a CSG solid
  68411. */
  68412. private static FromPolygons;
  68413. /**
  68414. * Clones, or makes a deep copy, of the CSG
  68415. * @returns A new CSG
  68416. */
  68417. clone(): CSG;
  68418. /**
  68419. * Unions this CSG with another CSG
  68420. * @param csg The CSG to union against this CSG
  68421. * @returns The unioned CSG
  68422. */
  68423. union(csg: CSG): CSG;
  68424. /**
  68425. * Unions this CSG with another CSG in place
  68426. * @param csg The CSG to union against this CSG
  68427. */
  68428. unionInPlace(csg: CSG): void;
  68429. /**
  68430. * Subtracts this CSG with another CSG
  68431. * @param csg The CSG to subtract against this CSG
  68432. * @returns A new CSG
  68433. */
  68434. subtract(csg: CSG): CSG;
  68435. /**
  68436. * Subtracts this CSG with another CSG in place
  68437. * @param csg The CSG to subtact against this CSG
  68438. */
  68439. subtractInPlace(csg: CSG): void;
  68440. /**
  68441. * Intersect this CSG with another CSG
  68442. * @param csg The CSG to intersect against this CSG
  68443. * @returns A new CSG
  68444. */
  68445. intersect(csg: CSG): CSG;
  68446. /**
  68447. * Intersects this CSG with another CSG in place
  68448. * @param csg The CSG to intersect against this CSG
  68449. */
  68450. intersectInPlace(csg: CSG): void;
  68451. /**
  68452. * Return a new CSG solid with solid and empty space switched. This solid is
  68453. * not modified.
  68454. * @returns A new CSG solid with solid and empty space switched
  68455. */
  68456. inverse(): CSG;
  68457. /**
  68458. * Inverses the CSG in place
  68459. */
  68460. inverseInPlace(): void;
  68461. /**
  68462. * This is used to keep meshes transformations so they can be restored
  68463. * when we build back a Babylon Mesh
  68464. * NB : All CSG operations are performed in world coordinates
  68465. * @param csg The CSG to copy the transform attributes from
  68466. * @returns This CSG
  68467. */
  68468. copyTransformAttributes(csg: CSG): CSG;
  68469. /**
  68470. * Build Raw mesh from CSG
  68471. * Coordinates here are in world space
  68472. * @param name The name of the mesh geometry
  68473. * @param scene The Scene
  68474. * @param keepSubMeshes Specifies if the submeshes should be kept
  68475. * @returns A new Mesh
  68476. */
  68477. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  68478. /**
  68479. * Build Mesh from CSG taking material and transforms into account
  68480. * @param name The name of the Mesh
  68481. * @param material The material of the Mesh
  68482. * @param scene The Scene
  68483. * @param keepSubMeshes Specifies if submeshes should be kept
  68484. * @returns The new Mesh
  68485. */
  68486. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  68487. }
  68488. }
  68489. declare module "babylonjs/Meshes/trailMesh" {
  68490. import { Mesh } from "babylonjs/Meshes/mesh";
  68491. import { Scene } from "babylonjs/scene";
  68492. import { TransformNode } from "babylonjs/Meshes/transformNode";
  68493. /**
  68494. * Class used to create a trail following a mesh
  68495. */
  68496. export class TrailMesh extends Mesh {
  68497. private _generator;
  68498. private _autoStart;
  68499. private _running;
  68500. private _diameter;
  68501. private _length;
  68502. private _sectionPolygonPointsCount;
  68503. private _sectionVectors;
  68504. private _sectionNormalVectors;
  68505. private _beforeRenderObserver;
  68506. /**
  68507. * @constructor
  68508. * @param name The value used by scene.getMeshByName() to do a lookup.
  68509. * @param generator The mesh or transform node to generate a trail.
  68510. * @param scene The scene to add this mesh to.
  68511. * @param diameter Diameter of trailing mesh. Default is 1.
  68512. * @param length Length of trailing mesh. Default is 60.
  68513. * @param autoStart Automatically start trailing mesh. Default true.
  68514. */
  68515. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  68516. /**
  68517. * "TrailMesh"
  68518. * @returns "TrailMesh"
  68519. */
  68520. getClassName(): string;
  68521. private _createMesh;
  68522. /**
  68523. * Start trailing mesh.
  68524. */
  68525. start(): void;
  68526. /**
  68527. * Stop trailing mesh.
  68528. */
  68529. stop(): void;
  68530. /**
  68531. * Update trailing mesh geometry.
  68532. */
  68533. update(): void;
  68534. /**
  68535. * Returns a new TrailMesh object.
  68536. * @param name is a string, the name given to the new mesh
  68537. * @param newGenerator use new generator object for cloned trail mesh
  68538. * @returns a new mesh
  68539. */
  68540. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  68541. /**
  68542. * Serializes this trail mesh
  68543. * @param serializationObject object to write serialization to
  68544. */
  68545. serialize(serializationObject: any): void;
  68546. /**
  68547. * Parses a serialized trail mesh
  68548. * @param parsedMesh the serialized mesh
  68549. * @param scene the scene to create the trail mesh in
  68550. * @returns the created trail mesh
  68551. */
  68552. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  68553. }
  68554. }
  68555. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  68556. import { Nullable } from "babylonjs/types";
  68557. import { Scene } from "babylonjs/scene";
  68558. import { Vector4 } from "babylonjs/Maths/math.vector";
  68559. import { Color4 } from "babylonjs/Maths/math.color";
  68560. import { Mesh } from "babylonjs/Meshes/mesh";
  68561. /**
  68562. * Class containing static functions to help procedurally build meshes
  68563. */
  68564. export class TiledBoxBuilder {
  68565. /**
  68566. * Creates a box mesh
  68567. * 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)
  68568. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  68569. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68570. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68571. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68572. * @param name defines the name of the mesh
  68573. * @param options defines the options used to create the mesh
  68574. * @param scene defines the hosting scene
  68575. * @returns the box mesh
  68576. */
  68577. static CreateTiledBox(name: string, options: {
  68578. pattern?: number;
  68579. width?: number;
  68580. height?: number;
  68581. depth?: number;
  68582. tileSize?: number;
  68583. tileWidth?: number;
  68584. tileHeight?: number;
  68585. alignHorizontal?: number;
  68586. alignVertical?: number;
  68587. faceUV?: Vector4[];
  68588. faceColors?: Color4[];
  68589. sideOrientation?: number;
  68590. updatable?: boolean;
  68591. }, scene?: Nullable<Scene>): Mesh;
  68592. }
  68593. }
  68594. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  68595. import { Vector4 } from "babylonjs/Maths/math.vector";
  68596. import { Mesh } from "babylonjs/Meshes/mesh";
  68597. /**
  68598. * Class containing static functions to help procedurally build meshes
  68599. */
  68600. export class TorusKnotBuilder {
  68601. /**
  68602. * Creates a torus knot mesh
  68603. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  68604. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  68605. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  68606. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  68607. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68608. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68609. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68610. * @param name defines the name of the mesh
  68611. * @param options defines the options used to create the mesh
  68612. * @param scene defines the hosting scene
  68613. * @returns the torus knot mesh
  68614. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  68615. */
  68616. static CreateTorusKnot(name: string, options: {
  68617. radius?: number;
  68618. tube?: number;
  68619. radialSegments?: number;
  68620. tubularSegments?: number;
  68621. p?: number;
  68622. q?: number;
  68623. updatable?: boolean;
  68624. sideOrientation?: number;
  68625. frontUVs?: Vector4;
  68626. backUVs?: Vector4;
  68627. }, scene: any): Mesh;
  68628. }
  68629. }
  68630. declare module "babylonjs/Meshes/polygonMesh" {
  68631. import { Scene } from "babylonjs/scene";
  68632. import { Vector2 } from "babylonjs/Maths/math.vector";
  68633. import { Mesh } from "babylonjs/Meshes/mesh";
  68634. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  68635. import { Path2 } from "babylonjs/Maths/math.path";
  68636. /**
  68637. * Polygon
  68638. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  68639. */
  68640. export class Polygon {
  68641. /**
  68642. * Creates a rectangle
  68643. * @param xmin bottom X coord
  68644. * @param ymin bottom Y coord
  68645. * @param xmax top X coord
  68646. * @param ymax top Y coord
  68647. * @returns points that make the resulting rectation
  68648. */
  68649. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  68650. /**
  68651. * Creates a circle
  68652. * @param radius radius of circle
  68653. * @param cx scale in x
  68654. * @param cy scale in y
  68655. * @param numberOfSides number of sides that make up the circle
  68656. * @returns points that make the resulting circle
  68657. */
  68658. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  68659. /**
  68660. * Creates a polygon from input string
  68661. * @param input Input polygon data
  68662. * @returns the parsed points
  68663. */
  68664. static Parse(input: string): Vector2[];
  68665. /**
  68666. * Starts building a polygon from x and y coordinates
  68667. * @param x x coordinate
  68668. * @param y y coordinate
  68669. * @returns the started path2
  68670. */
  68671. static StartingAt(x: number, y: number): Path2;
  68672. }
  68673. /**
  68674. * Builds a polygon
  68675. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  68676. */
  68677. export class PolygonMeshBuilder {
  68678. private _points;
  68679. private _outlinepoints;
  68680. private _holes;
  68681. private _name;
  68682. private _scene;
  68683. private _epoints;
  68684. private _eholes;
  68685. private _addToepoint;
  68686. /**
  68687. * Babylon reference to the earcut plugin.
  68688. */
  68689. bjsEarcut: any;
  68690. /**
  68691. * Creates a PolygonMeshBuilder
  68692. * @param name name of the builder
  68693. * @param contours Path of the polygon
  68694. * @param scene scene to add to when creating the mesh
  68695. * @param earcutInjection can be used to inject your own earcut reference
  68696. */
  68697. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  68698. /**
  68699. * Adds a whole within the polygon
  68700. * @param hole Array of points defining the hole
  68701. * @returns this
  68702. */
  68703. addHole(hole: Vector2[]): PolygonMeshBuilder;
  68704. /**
  68705. * Creates the polygon
  68706. * @param updatable If the mesh should be updatable
  68707. * @param depth The depth of the mesh created
  68708. * @returns the created mesh
  68709. */
  68710. build(updatable?: boolean, depth?: number): Mesh;
  68711. /**
  68712. * Creates the polygon
  68713. * @param depth The depth of the mesh created
  68714. * @returns the created VertexData
  68715. */
  68716. buildVertexData(depth?: number): VertexData;
  68717. /**
  68718. * Adds a side to the polygon
  68719. * @param positions points that make the polygon
  68720. * @param normals normals of the polygon
  68721. * @param uvs uvs of the polygon
  68722. * @param indices indices of the polygon
  68723. * @param bounds bounds of the polygon
  68724. * @param points points of the polygon
  68725. * @param depth depth of the polygon
  68726. * @param flip flip of the polygon
  68727. */
  68728. private addSide;
  68729. }
  68730. }
  68731. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  68732. import { Scene } from "babylonjs/scene";
  68733. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  68734. import { Color4 } from "babylonjs/Maths/math.color";
  68735. import { Mesh } from "babylonjs/Meshes/mesh";
  68736. import { Nullable } from "babylonjs/types";
  68737. /**
  68738. * Class containing static functions to help procedurally build meshes
  68739. */
  68740. export class PolygonBuilder {
  68741. /**
  68742. * Creates a polygon mesh
  68743. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  68744. * * 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
  68745. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  68746. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68747. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  68748. * * Remember you can only change the shape positions, not their number when updating a polygon
  68749. * @param name defines the name of the mesh
  68750. * @param options defines the options used to create the mesh
  68751. * @param scene defines the hosting scene
  68752. * @param earcutInjection can be used to inject your own earcut reference
  68753. * @returns the polygon mesh
  68754. */
  68755. static CreatePolygon(name: string, options: {
  68756. shape: Vector3[];
  68757. holes?: Vector3[][];
  68758. depth?: number;
  68759. faceUV?: Vector4[];
  68760. faceColors?: Color4[];
  68761. updatable?: boolean;
  68762. sideOrientation?: number;
  68763. frontUVs?: Vector4;
  68764. backUVs?: Vector4;
  68765. wrap?: boolean;
  68766. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  68767. /**
  68768. * Creates an extruded polygon mesh, with depth in the Y direction.
  68769. * * 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)
  68770. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  68771. * @param name defines the name of the mesh
  68772. * @param options defines the options used to create the mesh
  68773. * @param scene defines the hosting scene
  68774. * @param earcutInjection can be used to inject your own earcut reference
  68775. * @returns the polygon mesh
  68776. */
  68777. static ExtrudePolygon(name: string, options: {
  68778. shape: Vector3[];
  68779. holes?: Vector3[][];
  68780. depth?: number;
  68781. faceUV?: Vector4[];
  68782. faceColors?: Color4[];
  68783. updatable?: boolean;
  68784. sideOrientation?: number;
  68785. frontUVs?: Vector4;
  68786. backUVs?: Vector4;
  68787. wrap?: boolean;
  68788. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  68789. }
  68790. }
  68791. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  68792. import { Scene } from "babylonjs/scene";
  68793. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  68794. import { Mesh } from "babylonjs/Meshes/mesh";
  68795. import { Nullable } from "babylonjs/types";
  68796. /**
  68797. * Class containing static functions to help procedurally build meshes
  68798. */
  68799. export class LatheBuilder {
  68800. /**
  68801. * Creates lathe mesh.
  68802. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  68803. * * 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
  68804. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  68805. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  68806. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  68807. * * 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
  68808. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  68809. * * 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
  68810. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68811. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68812. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68813. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68814. * @param name defines the name of the mesh
  68815. * @param options defines the options used to create the mesh
  68816. * @param scene defines the hosting scene
  68817. * @returns the lathe mesh
  68818. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  68819. */
  68820. static CreateLathe(name: string, options: {
  68821. shape: Vector3[];
  68822. radius?: number;
  68823. tessellation?: number;
  68824. clip?: number;
  68825. arc?: number;
  68826. closed?: boolean;
  68827. updatable?: boolean;
  68828. sideOrientation?: number;
  68829. frontUVs?: Vector4;
  68830. backUVs?: Vector4;
  68831. cap?: number;
  68832. invertUV?: boolean;
  68833. }, scene?: Nullable<Scene>): Mesh;
  68834. }
  68835. }
  68836. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  68837. import { Nullable } from "babylonjs/types";
  68838. import { Scene } from "babylonjs/scene";
  68839. import { Vector4 } from "babylonjs/Maths/math.vector";
  68840. import { Mesh } from "babylonjs/Meshes/mesh";
  68841. /**
  68842. * Class containing static functions to help procedurally build meshes
  68843. */
  68844. export class TiledPlaneBuilder {
  68845. /**
  68846. * Creates a tiled plane mesh
  68847. * * The parameter `pattern` will, depending on value, do nothing or
  68848. * * * flip (reflect about central vertical) alternate tiles across and up
  68849. * * * flip every tile on alternate rows
  68850. * * * rotate (180 degs) alternate tiles across and up
  68851. * * * rotate every tile on alternate rows
  68852. * * * flip and rotate alternate tiles across and up
  68853. * * * flip and rotate every tile on alternate rows
  68854. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  68855. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  68856. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68857. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  68858. * * 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)
  68859. * * 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)
  68860. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  68861. * @param name defines the name of the mesh
  68862. * @param options defines the options used to create the mesh
  68863. * @param scene defines the hosting scene
  68864. * @returns the box mesh
  68865. */
  68866. static CreateTiledPlane(name: string, options: {
  68867. pattern?: number;
  68868. tileSize?: number;
  68869. tileWidth?: number;
  68870. tileHeight?: number;
  68871. size?: number;
  68872. width?: number;
  68873. height?: number;
  68874. alignHorizontal?: number;
  68875. alignVertical?: number;
  68876. sideOrientation?: number;
  68877. frontUVs?: Vector4;
  68878. backUVs?: Vector4;
  68879. updatable?: boolean;
  68880. }, scene?: Nullable<Scene>): Mesh;
  68881. }
  68882. }
  68883. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  68884. import { Nullable } from "babylonjs/types";
  68885. import { Scene } from "babylonjs/scene";
  68886. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  68887. import { Mesh } from "babylonjs/Meshes/mesh";
  68888. /**
  68889. * Class containing static functions to help procedurally build meshes
  68890. */
  68891. export class TubeBuilder {
  68892. /**
  68893. * Creates a tube mesh.
  68894. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  68895. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  68896. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  68897. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  68898. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  68899. * * 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)
  68900. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  68901. * * 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
  68902. * * 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
  68903. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68904. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68905. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68906. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68907. * @param name defines the name of the mesh
  68908. * @param options defines the options used to create the mesh
  68909. * @param scene defines the hosting scene
  68910. * @returns the tube mesh
  68911. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68912. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  68913. */
  68914. static CreateTube(name: string, options: {
  68915. path: Vector3[];
  68916. radius?: number;
  68917. tessellation?: number;
  68918. radiusFunction?: {
  68919. (i: number, distance: number): number;
  68920. };
  68921. cap?: number;
  68922. arc?: number;
  68923. updatable?: boolean;
  68924. sideOrientation?: number;
  68925. frontUVs?: Vector4;
  68926. backUVs?: Vector4;
  68927. instance?: Mesh;
  68928. invertUV?: boolean;
  68929. }, scene?: Nullable<Scene>): Mesh;
  68930. }
  68931. }
  68932. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  68933. import { Scene } from "babylonjs/scene";
  68934. import { Vector4 } from "babylonjs/Maths/math.vector";
  68935. import { Mesh } from "babylonjs/Meshes/mesh";
  68936. import { Nullable } from "babylonjs/types";
  68937. /**
  68938. * Class containing static functions to help procedurally build meshes
  68939. */
  68940. export class IcoSphereBuilder {
  68941. /**
  68942. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  68943. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  68944. * * 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`)
  68945. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  68946. * * 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
  68947. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68948. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68949. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68950. * @param name defines the name of the mesh
  68951. * @param options defines the options used to create the mesh
  68952. * @param scene defines the hosting scene
  68953. * @returns the icosahedron mesh
  68954. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  68955. */
  68956. static CreateIcoSphere(name: string, options: {
  68957. radius?: number;
  68958. radiusX?: number;
  68959. radiusY?: number;
  68960. radiusZ?: number;
  68961. flat?: boolean;
  68962. subdivisions?: number;
  68963. sideOrientation?: number;
  68964. frontUVs?: Vector4;
  68965. backUVs?: Vector4;
  68966. updatable?: boolean;
  68967. }, scene?: Nullable<Scene>): Mesh;
  68968. }
  68969. }
  68970. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  68971. import { Vector3 } from "babylonjs/Maths/math.vector";
  68972. import { Mesh } from "babylonjs/Meshes/mesh";
  68973. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68974. /**
  68975. * Class containing static functions to help procedurally build meshes
  68976. */
  68977. export class DecalBuilder {
  68978. /**
  68979. * Creates a decal mesh.
  68980. * 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
  68981. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  68982. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  68983. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  68984. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  68985. * @param name defines the name of the mesh
  68986. * @param sourceMesh defines the mesh where the decal must be applied
  68987. * @param options defines the options used to create the mesh
  68988. * @param scene defines the hosting scene
  68989. * @returns the decal mesh
  68990. * @see https://doc.babylonjs.com/how_to/decals
  68991. */
  68992. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  68993. position?: Vector3;
  68994. normal?: Vector3;
  68995. size?: Vector3;
  68996. angle?: number;
  68997. }): Mesh;
  68998. }
  68999. }
  69000. declare module "babylonjs/Meshes/meshBuilder" {
  69001. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  69002. import { Nullable } from "babylonjs/types";
  69003. import { Scene } from "babylonjs/scene";
  69004. import { Mesh } from "babylonjs/Meshes/mesh";
  69005. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  69006. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  69007. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69008. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  69009. import { Plane } from "babylonjs/Maths/math.plane";
  69010. /**
  69011. * Class containing static functions to help procedurally build meshes
  69012. */
  69013. export class MeshBuilder {
  69014. /**
  69015. * Creates a box mesh
  69016. * * The parameter `size` sets the size (float) of each box side (default 1)
  69017. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  69018. * * 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)
  69019. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69020. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69021. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69022. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69023. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  69024. * @param name defines the name of the mesh
  69025. * @param options defines the options used to create the mesh
  69026. * @param scene defines the hosting scene
  69027. * @returns the box mesh
  69028. */
  69029. static CreateBox(name: string, options: {
  69030. size?: number;
  69031. width?: number;
  69032. height?: number;
  69033. depth?: number;
  69034. faceUV?: Vector4[];
  69035. faceColors?: Color4[];
  69036. sideOrientation?: number;
  69037. frontUVs?: Vector4;
  69038. backUVs?: Vector4;
  69039. wrap?: boolean;
  69040. topBaseAt?: number;
  69041. bottomBaseAt?: number;
  69042. updatable?: boolean;
  69043. }, scene?: Nullable<Scene>): Mesh;
  69044. /**
  69045. * Creates a tiled box mesh
  69046. * * faceTiles sets the pattern, tile size and number of tiles for a face
  69047. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69048. * @param name defines the name of the mesh
  69049. * @param options defines the options used to create the mesh
  69050. * @param scene defines the hosting scene
  69051. * @returns the tiled box mesh
  69052. */
  69053. static CreateTiledBox(name: string, options: {
  69054. pattern?: number;
  69055. size?: number;
  69056. width?: number;
  69057. height?: number;
  69058. depth: number;
  69059. tileSize?: number;
  69060. tileWidth?: number;
  69061. tileHeight?: number;
  69062. faceUV?: Vector4[];
  69063. faceColors?: Color4[];
  69064. alignHorizontal?: number;
  69065. alignVertical?: number;
  69066. sideOrientation?: number;
  69067. updatable?: boolean;
  69068. }, scene?: Nullable<Scene>): Mesh;
  69069. /**
  69070. * Creates a sphere mesh
  69071. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  69072. * * 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`)
  69073. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  69074. * * 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
  69075. * * 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)
  69076. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69077. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69078. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69079. * @param name defines the name of the mesh
  69080. * @param options defines the options used to create the mesh
  69081. * @param scene defines the hosting scene
  69082. * @returns the sphere mesh
  69083. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  69084. */
  69085. static CreateSphere(name: string, options: {
  69086. segments?: number;
  69087. diameter?: number;
  69088. diameterX?: number;
  69089. diameterY?: number;
  69090. diameterZ?: number;
  69091. arc?: number;
  69092. slice?: number;
  69093. sideOrientation?: number;
  69094. frontUVs?: Vector4;
  69095. backUVs?: Vector4;
  69096. updatable?: boolean;
  69097. }, scene?: Nullable<Scene>): Mesh;
  69098. /**
  69099. * Creates a plane polygonal mesh. By default, this is a disc
  69100. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  69101. * * 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
  69102. * * 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
  69103. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69104. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69105. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69106. * @param name defines the name of the mesh
  69107. * @param options defines the options used to create the mesh
  69108. * @param scene defines the hosting scene
  69109. * @returns the plane polygonal mesh
  69110. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  69111. */
  69112. static CreateDisc(name: string, options: {
  69113. radius?: number;
  69114. tessellation?: number;
  69115. arc?: number;
  69116. updatable?: boolean;
  69117. sideOrientation?: number;
  69118. frontUVs?: Vector4;
  69119. backUVs?: Vector4;
  69120. }, scene?: Nullable<Scene>): Mesh;
  69121. /**
  69122. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  69123. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  69124. * * 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`)
  69125. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  69126. * * 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
  69127. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69128. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69129. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69130. * @param name defines the name of the mesh
  69131. * @param options defines the options used to create the mesh
  69132. * @param scene defines the hosting scene
  69133. * @returns the icosahedron mesh
  69134. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  69135. */
  69136. static CreateIcoSphere(name: string, options: {
  69137. radius?: number;
  69138. radiusX?: number;
  69139. radiusY?: number;
  69140. radiusZ?: number;
  69141. flat?: boolean;
  69142. subdivisions?: number;
  69143. sideOrientation?: number;
  69144. frontUVs?: Vector4;
  69145. backUVs?: Vector4;
  69146. updatable?: boolean;
  69147. }, scene?: Nullable<Scene>): Mesh;
  69148. /**
  69149. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69150. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  69151. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  69152. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  69153. * * 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
  69154. * * 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
  69155. * * 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
  69156. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69157. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69158. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69159. * * 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
  69160. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  69161. * * 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
  69162. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  69163. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69164. * @param name defines the name of the mesh
  69165. * @param options defines the options used to create the mesh
  69166. * @param scene defines the hosting scene
  69167. * @returns the ribbon mesh
  69168. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  69169. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69170. */
  69171. static CreateRibbon(name: string, options: {
  69172. pathArray: Vector3[][];
  69173. closeArray?: boolean;
  69174. closePath?: boolean;
  69175. offset?: number;
  69176. updatable?: boolean;
  69177. sideOrientation?: number;
  69178. frontUVs?: Vector4;
  69179. backUVs?: Vector4;
  69180. instance?: Mesh;
  69181. invertUV?: boolean;
  69182. uvs?: Vector2[];
  69183. colors?: Color4[];
  69184. }, scene?: Nullable<Scene>): Mesh;
  69185. /**
  69186. * Creates a cylinder or a cone mesh
  69187. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  69188. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  69189. * * 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.
  69190. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  69191. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  69192. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  69193. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  69194. * * 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).
  69195. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  69196. * * 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).
  69197. * * 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
  69198. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  69199. * * 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
  69200. * * 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.
  69201. * * If `enclose` is false, a ring surface is one element.
  69202. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  69203. * * 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
  69204. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69205. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69206. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69207. * @param name defines the name of the mesh
  69208. * @param options defines the options used to create the mesh
  69209. * @param scene defines the hosting scene
  69210. * @returns the cylinder mesh
  69211. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  69212. */
  69213. static CreateCylinder(name: string, options: {
  69214. height?: number;
  69215. diameterTop?: number;
  69216. diameterBottom?: number;
  69217. diameter?: number;
  69218. tessellation?: number;
  69219. subdivisions?: number;
  69220. arc?: number;
  69221. faceColors?: Color4[];
  69222. faceUV?: Vector4[];
  69223. updatable?: boolean;
  69224. hasRings?: boolean;
  69225. enclose?: boolean;
  69226. cap?: number;
  69227. sideOrientation?: number;
  69228. frontUVs?: Vector4;
  69229. backUVs?: Vector4;
  69230. }, scene?: Nullable<Scene>): Mesh;
  69231. /**
  69232. * Creates a torus mesh
  69233. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  69234. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  69235. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  69236. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69237. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69238. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69239. * @param name defines the name of the mesh
  69240. * @param options defines the options used to create the mesh
  69241. * @param scene defines the hosting scene
  69242. * @returns the torus mesh
  69243. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  69244. */
  69245. static CreateTorus(name: string, options: {
  69246. diameter?: number;
  69247. thickness?: number;
  69248. tessellation?: number;
  69249. updatable?: boolean;
  69250. sideOrientation?: number;
  69251. frontUVs?: Vector4;
  69252. backUVs?: Vector4;
  69253. }, scene?: Nullable<Scene>): Mesh;
  69254. /**
  69255. * Creates a torus knot mesh
  69256. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  69257. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  69258. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  69259. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  69260. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69261. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69262. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69263. * @param name defines the name of the mesh
  69264. * @param options defines the options used to create the mesh
  69265. * @param scene defines the hosting scene
  69266. * @returns the torus knot mesh
  69267. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  69268. */
  69269. static CreateTorusKnot(name: string, options: {
  69270. radius?: number;
  69271. tube?: number;
  69272. radialSegments?: number;
  69273. tubularSegments?: number;
  69274. p?: number;
  69275. q?: number;
  69276. updatable?: boolean;
  69277. sideOrientation?: number;
  69278. frontUVs?: Vector4;
  69279. backUVs?: Vector4;
  69280. }, scene?: Nullable<Scene>): Mesh;
  69281. /**
  69282. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  69283. * * 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
  69284. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  69285. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  69286. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  69287. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  69288. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  69289. * * 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
  69290. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  69291. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69292. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  69293. * @param name defines the name of the new line system
  69294. * @param options defines the options used to create the line system
  69295. * @param scene defines the hosting scene
  69296. * @returns a new line system mesh
  69297. */
  69298. static CreateLineSystem(name: string, options: {
  69299. lines: Vector3[][];
  69300. updatable?: boolean;
  69301. instance?: Nullable<LinesMesh>;
  69302. colors?: Nullable<Color4[][]>;
  69303. useVertexAlpha?: boolean;
  69304. }, scene: Nullable<Scene>): LinesMesh;
  69305. /**
  69306. * Creates a line mesh
  69307. * 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
  69308. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  69309. * * The parameter `points` is an array successive Vector3
  69310. * * 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
  69311. * * The optional parameter `colors` is an array of successive Color4, one per line point
  69312. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  69313. * * When updating an instance, remember that only point positions can change, not the number of points
  69314. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69315. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  69316. * @param name defines the name of the new line system
  69317. * @param options defines the options used to create the line system
  69318. * @param scene defines the hosting scene
  69319. * @returns a new line mesh
  69320. */
  69321. static CreateLines(name: string, options: {
  69322. points: Vector3[];
  69323. updatable?: boolean;
  69324. instance?: Nullable<LinesMesh>;
  69325. colors?: Color4[];
  69326. useVertexAlpha?: boolean;
  69327. }, scene?: Nullable<Scene>): LinesMesh;
  69328. /**
  69329. * Creates a dashed line mesh
  69330. * * 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
  69331. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  69332. * * The parameter `points` is an array successive Vector3
  69333. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  69334. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  69335. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  69336. * * 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
  69337. * * When updating an instance, remember that only point positions can change, not the number of points
  69338. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69339. * @param name defines the name of the mesh
  69340. * @param options defines the options used to create the mesh
  69341. * @param scene defines the hosting scene
  69342. * @returns the dashed line mesh
  69343. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  69344. */
  69345. static CreateDashedLines(name: string, options: {
  69346. points: Vector3[];
  69347. dashSize?: number;
  69348. gapSize?: number;
  69349. dashNb?: number;
  69350. updatable?: boolean;
  69351. instance?: LinesMesh;
  69352. }, scene?: Nullable<Scene>): LinesMesh;
  69353. /**
  69354. * 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.
  69355. * * 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.
  69356. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  69357. * * 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.
  69358. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  69359. * * 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
  69360. * * 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
  69361. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  69362. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69363. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69364. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  69365. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69366. * @param name defines the name of the mesh
  69367. * @param options defines the options used to create the mesh
  69368. * @param scene defines the hosting scene
  69369. * @returns the extruded shape mesh
  69370. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69371. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  69372. */
  69373. static ExtrudeShape(name: string, options: {
  69374. shape: Vector3[];
  69375. path: Vector3[];
  69376. scale?: number;
  69377. rotation?: number;
  69378. cap?: number;
  69379. updatable?: boolean;
  69380. sideOrientation?: number;
  69381. frontUVs?: Vector4;
  69382. backUVs?: Vector4;
  69383. instance?: Mesh;
  69384. invertUV?: boolean;
  69385. }, scene?: Nullable<Scene>): Mesh;
  69386. /**
  69387. * Creates an custom extruded shape mesh.
  69388. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  69389. * * 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.
  69390. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  69391. * * 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
  69392. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  69393. * * 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
  69394. * * It must returns a float value that will be the scale value applied to the shape on each path point
  69395. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  69396. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  69397. * * 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
  69398. * * 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
  69399. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  69400. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69401. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69402. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69403. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69404. * @param name defines the name of the mesh
  69405. * @param options defines the options used to create the mesh
  69406. * @param scene defines the hosting scene
  69407. * @returns the custom extruded shape mesh
  69408. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  69409. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69410. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  69411. */
  69412. static ExtrudeShapeCustom(name: string, options: {
  69413. shape: Vector3[];
  69414. path: Vector3[];
  69415. scaleFunction?: any;
  69416. rotationFunction?: any;
  69417. ribbonCloseArray?: boolean;
  69418. ribbonClosePath?: boolean;
  69419. cap?: number;
  69420. updatable?: boolean;
  69421. sideOrientation?: number;
  69422. frontUVs?: Vector4;
  69423. backUVs?: Vector4;
  69424. instance?: Mesh;
  69425. invertUV?: boolean;
  69426. }, scene?: Nullable<Scene>): Mesh;
  69427. /**
  69428. * Creates lathe mesh.
  69429. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  69430. * * 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
  69431. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  69432. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  69433. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  69434. * * 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
  69435. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  69436. * * 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
  69437. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69438. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69439. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69440. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69441. * @param name defines the name of the mesh
  69442. * @param options defines the options used to create the mesh
  69443. * @param scene defines the hosting scene
  69444. * @returns the lathe mesh
  69445. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  69446. */
  69447. static CreateLathe(name: string, options: {
  69448. shape: Vector3[];
  69449. radius?: number;
  69450. tessellation?: number;
  69451. clip?: number;
  69452. arc?: number;
  69453. closed?: boolean;
  69454. updatable?: boolean;
  69455. sideOrientation?: number;
  69456. frontUVs?: Vector4;
  69457. backUVs?: Vector4;
  69458. cap?: number;
  69459. invertUV?: boolean;
  69460. }, scene?: Nullable<Scene>): Mesh;
  69461. /**
  69462. * Creates a tiled plane mesh
  69463. * * You can set a limited pattern arrangement with the tiles
  69464. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69465. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69466. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69467. * @param name defines the name of the mesh
  69468. * @param options defines the options used to create the mesh
  69469. * @param scene defines the hosting scene
  69470. * @returns the plane mesh
  69471. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  69472. */
  69473. static CreateTiledPlane(name: string, options: {
  69474. pattern?: number;
  69475. tileSize?: number;
  69476. tileWidth?: number;
  69477. tileHeight?: number;
  69478. size?: number;
  69479. width?: number;
  69480. height?: number;
  69481. alignHorizontal?: number;
  69482. alignVertical?: number;
  69483. sideOrientation?: number;
  69484. frontUVs?: Vector4;
  69485. backUVs?: Vector4;
  69486. updatable?: boolean;
  69487. }, scene?: Nullable<Scene>): Mesh;
  69488. /**
  69489. * Creates a plane mesh
  69490. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  69491. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  69492. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  69493. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69494. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  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 plane mesh
  69500. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  69501. */
  69502. static CreatePlane(name: string, options: {
  69503. size?: number;
  69504. width?: number;
  69505. height?: number;
  69506. sideOrientation?: number;
  69507. frontUVs?: Vector4;
  69508. backUVs?: Vector4;
  69509. updatable?: boolean;
  69510. sourcePlane?: Plane;
  69511. }, scene?: Nullable<Scene>): Mesh;
  69512. /**
  69513. * Creates a ground mesh
  69514. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  69515. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  69516. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69517. * @param name defines the name of the mesh
  69518. * @param options defines the options used to create the mesh
  69519. * @param scene defines the hosting scene
  69520. * @returns the ground mesh
  69521. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  69522. */
  69523. static CreateGround(name: string, options: {
  69524. width?: number;
  69525. height?: number;
  69526. subdivisions?: number;
  69527. subdivisionsX?: number;
  69528. subdivisionsY?: number;
  69529. updatable?: boolean;
  69530. }, scene?: Nullable<Scene>): Mesh;
  69531. /**
  69532. * Creates a tiled ground mesh
  69533. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  69534. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  69535. * * 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
  69536. * * 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
  69537. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69538. * @param name defines the name of the mesh
  69539. * @param options defines the options used to create the mesh
  69540. * @param scene defines the hosting scene
  69541. * @returns the tiled ground mesh
  69542. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  69543. */
  69544. static CreateTiledGround(name: string, options: {
  69545. xmin: number;
  69546. zmin: number;
  69547. xmax: number;
  69548. zmax: number;
  69549. subdivisions?: {
  69550. w: number;
  69551. h: number;
  69552. };
  69553. precision?: {
  69554. w: number;
  69555. h: number;
  69556. };
  69557. updatable?: boolean;
  69558. }, scene?: Nullable<Scene>): Mesh;
  69559. /**
  69560. * Creates a ground mesh from a height map
  69561. * * The parameter `url` sets the URL of the height map image resource.
  69562. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  69563. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  69564. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  69565. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  69566. * * 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.
  69567. * * 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).
  69568. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  69569. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69570. * @param name defines the name of the mesh
  69571. * @param url defines the url to the height map
  69572. * @param options defines the options used to create the mesh
  69573. * @param scene defines the hosting scene
  69574. * @returns the ground mesh
  69575. * @see https://doc.babylonjs.com/babylon101/height_map
  69576. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  69577. */
  69578. static CreateGroundFromHeightMap(name: string, url: string, options: {
  69579. width?: number;
  69580. height?: number;
  69581. subdivisions?: number;
  69582. minHeight?: number;
  69583. maxHeight?: number;
  69584. colorFilter?: Color3;
  69585. alphaFilter?: number;
  69586. updatable?: boolean;
  69587. onReady?: (mesh: GroundMesh) => void;
  69588. }, scene?: Nullable<Scene>): GroundMesh;
  69589. /**
  69590. * Creates a polygon mesh
  69591. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  69592. * * 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
  69593. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  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. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  69596. * * Remember you can only change the shape positions, not their number when updating a polygon
  69597. * @param name defines the name of the mesh
  69598. * @param options defines the options used to create the mesh
  69599. * @param scene defines the hosting scene
  69600. * @param earcutInjection can be used to inject your own earcut reference
  69601. * @returns the polygon mesh
  69602. */
  69603. static CreatePolygon(name: string, options: {
  69604. shape: Vector3[];
  69605. holes?: Vector3[][];
  69606. depth?: number;
  69607. faceUV?: Vector4[];
  69608. faceColors?: Color4[];
  69609. updatable?: boolean;
  69610. sideOrientation?: number;
  69611. frontUVs?: Vector4;
  69612. backUVs?: Vector4;
  69613. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69614. /**
  69615. * Creates an extruded polygon mesh, with depth in the Y direction.
  69616. * * 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)
  69617. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69618. * @param name defines the name of the mesh
  69619. * @param options defines the options used to create the mesh
  69620. * @param scene defines the hosting scene
  69621. * @param earcutInjection can be used to inject your own earcut reference
  69622. * @returns the polygon mesh
  69623. */
  69624. static ExtrudePolygon(name: string, options: {
  69625. shape: Vector3[];
  69626. holes?: Vector3[][];
  69627. depth?: number;
  69628. faceUV?: Vector4[];
  69629. faceColors?: Color4[];
  69630. updatable?: boolean;
  69631. sideOrientation?: number;
  69632. frontUVs?: Vector4;
  69633. backUVs?: Vector4;
  69634. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69635. /**
  69636. * Creates a tube mesh.
  69637. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69638. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  69639. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  69640. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  69641. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  69642. * * 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)
  69643. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  69644. * * 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
  69645. * * 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
  69646. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69647. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69648. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69649. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69650. * @param name defines the name of the mesh
  69651. * @param options defines the options used to create the mesh
  69652. * @param scene defines the hosting scene
  69653. * @returns the tube mesh
  69654. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69655. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  69656. */
  69657. static CreateTube(name: string, options: {
  69658. path: Vector3[];
  69659. radius?: number;
  69660. tessellation?: number;
  69661. radiusFunction?: {
  69662. (i: number, distance: number): number;
  69663. };
  69664. cap?: number;
  69665. arc?: number;
  69666. updatable?: boolean;
  69667. sideOrientation?: number;
  69668. frontUVs?: Vector4;
  69669. backUVs?: Vector4;
  69670. instance?: Mesh;
  69671. invertUV?: boolean;
  69672. }, scene?: Nullable<Scene>): Mesh;
  69673. /**
  69674. * Creates a polyhedron mesh
  69675. * * 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
  69676. * * The parameter `size` (positive float, default 1) sets the polygon size
  69677. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  69678. * * 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`
  69679. * * 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
  69680. * * 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)`)
  69681. * * 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
  69682. * * 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
  69683. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69684. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69685. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69686. * @param name defines the name of the mesh
  69687. * @param options defines the options used to create the mesh
  69688. * @param scene defines the hosting scene
  69689. * @returns the polyhedron mesh
  69690. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  69691. */
  69692. static CreatePolyhedron(name: string, options: {
  69693. type?: number;
  69694. size?: number;
  69695. sizeX?: number;
  69696. sizeY?: number;
  69697. sizeZ?: number;
  69698. custom?: any;
  69699. faceUV?: Vector4[];
  69700. faceColors?: Color4[];
  69701. flat?: boolean;
  69702. updatable?: boolean;
  69703. sideOrientation?: number;
  69704. frontUVs?: Vector4;
  69705. backUVs?: Vector4;
  69706. }, scene?: Nullable<Scene>): Mesh;
  69707. /**
  69708. * Creates a decal mesh.
  69709. * 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
  69710. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  69711. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  69712. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  69713. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  69714. * @param name defines the name of the mesh
  69715. * @param sourceMesh defines the mesh where the decal must be applied
  69716. * @param options defines the options used to create the mesh
  69717. * @param scene defines the hosting scene
  69718. * @returns the decal mesh
  69719. * @see https://doc.babylonjs.com/how_to/decals
  69720. */
  69721. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  69722. position?: Vector3;
  69723. normal?: Vector3;
  69724. size?: Vector3;
  69725. angle?: number;
  69726. }): Mesh;
  69727. }
  69728. }
  69729. declare module "babylonjs/Meshes/meshSimplification" {
  69730. import { Mesh } from "babylonjs/Meshes/mesh";
  69731. /**
  69732. * A simplifier interface for future simplification implementations
  69733. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69734. */
  69735. export interface ISimplifier {
  69736. /**
  69737. * Simplification of a given mesh according to the given settings.
  69738. * Since this requires computation, it is assumed that the function runs async.
  69739. * @param settings The settings of the simplification, including quality and distance
  69740. * @param successCallback A callback that will be called after the mesh was simplified.
  69741. * @param errorCallback in case of an error, this callback will be called. optional.
  69742. */
  69743. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  69744. }
  69745. /**
  69746. * Expected simplification settings.
  69747. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  69748. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69749. */
  69750. export interface ISimplificationSettings {
  69751. /**
  69752. * Gets or sets the expected quality
  69753. */
  69754. quality: number;
  69755. /**
  69756. * Gets or sets the distance when this optimized version should be used
  69757. */
  69758. distance: number;
  69759. /**
  69760. * Gets an already optimized mesh
  69761. */
  69762. optimizeMesh?: boolean;
  69763. }
  69764. /**
  69765. * Class used to specify simplification options
  69766. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69767. */
  69768. export class SimplificationSettings implements ISimplificationSettings {
  69769. /** expected quality */
  69770. quality: number;
  69771. /** distance when this optimized version should be used */
  69772. distance: number;
  69773. /** already optimized mesh */
  69774. optimizeMesh?: boolean | undefined;
  69775. /**
  69776. * Creates a SimplificationSettings
  69777. * @param quality expected quality
  69778. * @param distance distance when this optimized version should be used
  69779. * @param optimizeMesh already optimized mesh
  69780. */
  69781. constructor(
  69782. /** expected quality */
  69783. quality: number,
  69784. /** distance when this optimized version should be used */
  69785. distance: number,
  69786. /** already optimized mesh */
  69787. optimizeMesh?: boolean | undefined);
  69788. }
  69789. /**
  69790. * Interface used to define a simplification task
  69791. */
  69792. export interface ISimplificationTask {
  69793. /**
  69794. * Array of settings
  69795. */
  69796. settings: Array<ISimplificationSettings>;
  69797. /**
  69798. * Simplification type
  69799. */
  69800. simplificationType: SimplificationType;
  69801. /**
  69802. * Mesh to simplify
  69803. */
  69804. mesh: Mesh;
  69805. /**
  69806. * Callback called on success
  69807. */
  69808. successCallback?: () => void;
  69809. /**
  69810. * Defines if parallel processing can be used
  69811. */
  69812. parallelProcessing: boolean;
  69813. }
  69814. /**
  69815. * Queue used to order the simplification tasks
  69816. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69817. */
  69818. export class SimplificationQueue {
  69819. private _simplificationArray;
  69820. /**
  69821. * Gets a boolean indicating that the process is still running
  69822. */
  69823. running: boolean;
  69824. /**
  69825. * Creates a new queue
  69826. */
  69827. constructor();
  69828. /**
  69829. * Adds a new simplification task
  69830. * @param task defines a task to add
  69831. */
  69832. addTask(task: ISimplificationTask): void;
  69833. /**
  69834. * Execute next task
  69835. */
  69836. executeNext(): void;
  69837. /**
  69838. * Execute a simplification task
  69839. * @param task defines the task to run
  69840. */
  69841. runSimplification(task: ISimplificationTask): void;
  69842. private getSimplifier;
  69843. }
  69844. /**
  69845. * The implemented types of simplification
  69846. * At the moment only Quadratic Error Decimation is implemented
  69847. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69848. */
  69849. export enum SimplificationType {
  69850. /** Quadratic error decimation */
  69851. QUADRATIC = 0
  69852. }
  69853. /**
  69854. * An implementation of the Quadratic Error simplification algorithm.
  69855. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  69856. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  69857. * @author RaananW
  69858. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69859. */
  69860. export class QuadraticErrorSimplification implements ISimplifier {
  69861. private _mesh;
  69862. private triangles;
  69863. private vertices;
  69864. private references;
  69865. private _reconstructedMesh;
  69866. /** Gets or sets the number pf sync interations */
  69867. syncIterations: number;
  69868. /** Gets or sets the aggressiveness of the simplifier */
  69869. aggressiveness: number;
  69870. /** Gets or sets the number of allowed iterations for decimation */
  69871. decimationIterations: number;
  69872. /** Gets or sets the espilon to use for bounding box computation */
  69873. boundingBoxEpsilon: number;
  69874. /**
  69875. * Creates a new QuadraticErrorSimplification
  69876. * @param _mesh defines the target mesh
  69877. */
  69878. constructor(_mesh: Mesh);
  69879. /**
  69880. * Simplification of a given mesh according to the given settings.
  69881. * Since this requires computation, it is assumed that the function runs async.
  69882. * @param settings The settings of the simplification, including quality and distance
  69883. * @param successCallback A callback that will be called after the mesh was simplified.
  69884. */
  69885. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  69886. private runDecimation;
  69887. private initWithMesh;
  69888. private init;
  69889. private reconstructMesh;
  69890. private initDecimatedMesh;
  69891. private isFlipped;
  69892. private updateTriangles;
  69893. private identifyBorder;
  69894. private updateMesh;
  69895. private vertexError;
  69896. private calculateError;
  69897. }
  69898. }
  69899. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  69900. import { Scene } from "babylonjs/scene";
  69901. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  69902. import { ISceneComponent } from "babylonjs/sceneComponent";
  69903. module "babylonjs/scene" {
  69904. interface Scene {
  69905. /** @hidden (Backing field) */
  69906. _simplificationQueue: SimplificationQueue;
  69907. /**
  69908. * Gets or sets the simplification queue attached to the scene
  69909. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69910. */
  69911. simplificationQueue: SimplificationQueue;
  69912. }
  69913. }
  69914. module "babylonjs/Meshes/mesh" {
  69915. interface Mesh {
  69916. /**
  69917. * Simplify the mesh according to the given array of settings.
  69918. * Function will return immediately and will simplify async
  69919. * @param settings a collection of simplification settings
  69920. * @param parallelProcessing should all levels calculate parallel or one after the other
  69921. * @param simplificationType the type of simplification to run
  69922. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  69923. * @returns the current mesh
  69924. */
  69925. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  69926. }
  69927. }
  69928. /**
  69929. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  69930. * created in a scene
  69931. */
  69932. export class SimplicationQueueSceneComponent implements ISceneComponent {
  69933. /**
  69934. * The component name helpfull to identify the component in the list of scene components.
  69935. */
  69936. readonly name: string;
  69937. /**
  69938. * The scene the component belongs to.
  69939. */
  69940. scene: Scene;
  69941. /**
  69942. * Creates a new instance of the component for the given scene
  69943. * @param scene Defines the scene to register the component in
  69944. */
  69945. constructor(scene: Scene);
  69946. /**
  69947. * Registers the component in a given scene
  69948. */
  69949. register(): void;
  69950. /**
  69951. * Rebuilds the elements related to this component in case of
  69952. * context lost for instance.
  69953. */
  69954. rebuild(): void;
  69955. /**
  69956. * Disposes the component and the associated ressources
  69957. */
  69958. dispose(): void;
  69959. private _beforeCameraUpdate;
  69960. }
  69961. }
  69962. declare module "babylonjs/Meshes/Builders/index" {
  69963. export * from "babylonjs/Meshes/Builders/boxBuilder";
  69964. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  69965. export * from "babylonjs/Meshes/Builders/discBuilder";
  69966. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  69967. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  69968. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  69969. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  69970. export * from "babylonjs/Meshes/Builders/torusBuilder";
  69971. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  69972. export * from "babylonjs/Meshes/Builders/linesBuilder";
  69973. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  69974. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  69975. export * from "babylonjs/Meshes/Builders/latheBuilder";
  69976. export * from "babylonjs/Meshes/Builders/planeBuilder";
  69977. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  69978. export * from "babylonjs/Meshes/Builders/groundBuilder";
  69979. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  69980. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  69981. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  69982. export * from "babylonjs/Meshes/Builders/decalBuilder";
  69983. }
  69984. declare module "babylonjs/Meshes/thinInstanceMesh" {
  69985. import { Nullable, DeepImmutableObject } from "babylonjs/types";
  69986. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  69987. import { Matrix } from "babylonjs/Maths/math.vector";
  69988. module "babylonjs/Meshes/mesh" {
  69989. interface Mesh {
  69990. /**
  69991. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  69992. */
  69993. thinInstanceEnablePicking: boolean;
  69994. /**
  69995. * Creates a new thin instance
  69996. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  69997. * @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
  69998. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  69999. */
  70000. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  70001. /**
  70002. * Adds the transformation (matrix) of the current mesh as a thin instance
  70003. * @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
  70004. * @returns the thin instance index number
  70005. */
  70006. thinInstanceAddSelf(refresh: boolean): number;
  70007. /**
  70008. * Registers a custom attribute to be used with thin instances
  70009. * @param kind name of the attribute
  70010. * @param stride size in floats of the attribute
  70011. */
  70012. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  70013. /**
  70014. * Sets the matrix of a thin instance
  70015. * @param index index of the thin instance
  70016. * @param matrix matrix to set
  70017. * @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
  70018. */
  70019. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  70020. /**
  70021. * Sets the value of a custom attribute for a thin instance
  70022. * @param kind name of the attribute
  70023. * @param index index of the thin instance
  70024. * @param value value to set
  70025. * @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
  70026. */
  70027. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  70028. /**
  70029. * 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.
  70030. */
  70031. thinInstanceCount: number;
  70032. /**
  70033. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  70034. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  70035. * @param buffer buffer to set
  70036. * @param stride size in floats of each value of the buffer
  70037. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  70038. */
  70039. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  70040. /**
  70041. * Gets the list of world matrices
  70042. * @return an array containing all the world matrices from the thin instances
  70043. */
  70044. thinInstanceGetWorldMatrices(): Matrix[];
  70045. /**
  70046. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  70047. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  70048. */
  70049. thinInstanceBufferUpdated(kind: string): void;
  70050. /**
  70051. * Refreshes the bounding info, taking into account all the thin instances defined
  70052. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  70053. */
  70054. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  70055. /** @hidden */
  70056. _thinInstanceInitializeUserStorage(): void;
  70057. /** @hidden */
  70058. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  70059. /** @hidden */
  70060. _userThinInstanceBuffersStorage: {
  70061. data: {
  70062. [key: string]: Float32Array;
  70063. };
  70064. sizes: {
  70065. [key: string]: number;
  70066. };
  70067. vertexBuffers: {
  70068. [key: string]: Nullable<VertexBuffer>;
  70069. };
  70070. strides: {
  70071. [key: string]: number;
  70072. };
  70073. };
  70074. }
  70075. }
  70076. }
  70077. declare module "babylonjs/Meshes/index" {
  70078. export * from "babylonjs/Meshes/abstractMesh";
  70079. export * from "babylonjs/Meshes/buffer";
  70080. export * from "babylonjs/Meshes/Compression/index";
  70081. export * from "babylonjs/Meshes/csg";
  70082. export * from "babylonjs/Meshes/geometry";
  70083. export * from "babylonjs/Meshes/groundMesh";
  70084. export * from "babylonjs/Meshes/trailMesh";
  70085. export * from "babylonjs/Meshes/instancedMesh";
  70086. export * from "babylonjs/Meshes/linesMesh";
  70087. export * from "babylonjs/Meshes/mesh";
  70088. export * from "babylonjs/Meshes/mesh.vertexData";
  70089. export * from "babylonjs/Meshes/meshBuilder";
  70090. export * from "babylonjs/Meshes/meshSimplification";
  70091. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  70092. export * from "babylonjs/Meshes/polygonMesh";
  70093. export * from "babylonjs/Meshes/subMesh";
  70094. export * from "babylonjs/Meshes/meshLODLevel";
  70095. export * from "babylonjs/Meshes/transformNode";
  70096. export * from "babylonjs/Meshes/Builders/index";
  70097. export * from "babylonjs/Meshes/dataBuffer";
  70098. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  70099. import "babylonjs/Meshes/thinInstanceMesh";
  70100. export * from "babylonjs/Meshes/thinInstanceMesh";
  70101. }
  70102. declare module "babylonjs/Morph/index" {
  70103. export * from "babylonjs/Morph/morphTarget";
  70104. export * from "babylonjs/Morph/morphTargetManager";
  70105. }
  70106. declare module "babylonjs/Navigation/INavigationEngine" {
  70107. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70108. import { Vector3 } from "babylonjs/Maths/math";
  70109. import { Mesh } from "babylonjs/Meshes/mesh";
  70110. import { Scene } from "babylonjs/scene";
  70111. /**
  70112. * Navigation plugin interface to add navigation constrained by a navigation mesh
  70113. */
  70114. export interface INavigationEnginePlugin {
  70115. /**
  70116. * plugin name
  70117. */
  70118. name: string;
  70119. /**
  70120. * Creates a navigation mesh
  70121. * @param meshes array of all the geometry used to compute the navigatio mesh
  70122. * @param parameters bunch of parameters used to filter geometry
  70123. */
  70124. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  70125. /**
  70126. * Create a navigation mesh debug mesh
  70127. * @param scene is where the mesh will be added
  70128. * @returns debug display mesh
  70129. */
  70130. createDebugNavMesh(scene: Scene): Mesh;
  70131. /**
  70132. * Get a navigation mesh constrained position, closest to the parameter position
  70133. * @param position world position
  70134. * @returns the closest point to position constrained by the navigation mesh
  70135. */
  70136. getClosestPoint(position: Vector3): Vector3;
  70137. /**
  70138. * Get a navigation mesh constrained position, closest to the parameter position
  70139. * @param position world position
  70140. * @param result output the closest point to position constrained by the navigation mesh
  70141. */
  70142. getClosestPointToRef(position: Vector3, result: Vector3): void;
  70143. /**
  70144. * Get a navigation mesh constrained position, within a particular radius
  70145. * @param position world position
  70146. * @param maxRadius the maximum distance to the constrained world position
  70147. * @returns the closest point to position constrained by the navigation mesh
  70148. */
  70149. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  70150. /**
  70151. * Get a navigation mesh constrained position, within a particular radius
  70152. * @param position world position
  70153. * @param maxRadius the maximum distance to the constrained world position
  70154. * @param result output the closest point to position constrained by the navigation mesh
  70155. */
  70156. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  70157. /**
  70158. * Compute the final position from a segment made of destination-position
  70159. * @param position world position
  70160. * @param destination world position
  70161. * @returns the resulting point along the navmesh
  70162. */
  70163. moveAlong(position: Vector3, destination: Vector3): Vector3;
  70164. /**
  70165. * Compute the final position from a segment made of destination-position
  70166. * @param position world position
  70167. * @param destination world position
  70168. * @param result output the resulting point along the navmesh
  70169. */
  70170. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  70171. /**
  70172. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  70173. * @param start world position
  70174. * @param end world position
  70175. * @returns array containing world position composing the path
  70176. */
  70177. computePath(start: Vector3, end: Vector3): Vector3[];
  70178. /**
  70179. * If this plugin is supported
  70180. * @returns true if plugin is supported
  70181. */
  70182. isSupported(): boolean;
  70183. /**
  70184. * Create a new Crowd so you can add agents
  70185. * @param maxAgents the maximum agent count in the crowd
  70186. * @param maxAgentRadius the maximum radius an agent can have
  70187. * @param scene to attach the crowd to
  70188. * @returns the crowd you can add agents to
  70189. */
  70190. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  70191. /**
  70192. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70193. * The queries will try to find a solution within those bounds
  70194. * default is (1,1,1)
  70195. * @param extent x,y,z value that define the extent around the queries point of reference
  70196. */
  70197. setDefaultQueryExtent(extent: Vector3): void;
  70198. /**
  70199. * Get the Bounding box extent specified by setDefaultQueryExtent
  70200. * @returns the box extent values
  70201. */
  70202. getDefaultQueryExtent(): Vector3;
  70203. /**
  70204. * build the navmesh from a previously saved state using getNavmeshData
  70205. * @param data the Uint8Array returned by getNavmeshData
  70206. */
  70207. buildFromNavmeshData(data: Uint8Array): void;
  70208. /**
  70209. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  70210. * @returns data the Uint8Array that can be saved and reused
  70211. */
  70212. getNavmeshData(): Uint8Array;
  70213. /**
  70214. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70215. * @param result output the box extent values
  70216. */
  70217. getDefaultQueryExtentToRef(result: Vector3): void;
  70218. /**
  70219. * Release all resources
  70220. */
  70221. dispose(): void;
  70222. }
  70223. /**
  70224. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  70225. */
  70226. export interface ICrowd {
  70227. /**
  70228. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  70229. * You can attach anything to that node. The node position is updated in the scene update tick.
  70230. * @param pos world position that will be constrained by the navigation mesh
  70231. * @param parameters agent parameters
  70232. * @param transform hooked to the agent that will be update by the scene
  70233. * @returns agent index
  70234. */
  70235. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  70236. /**
  70237. * Returns the agent position in world space
  70238. * @param index agent index returned by addAgent
  70239. * @returns world space position
  70240. */
  70241. getAgentPosition(index: number): Vector3;
  70242. /**
  70243. * Gets the agent position result in world space
  70244. * @param index agent index returned by addAgent
  70245. * @param result output world space position
  70246. */
  70247. getAgentPositionToRef(index: number, result: Vector3): void;
  70248. /**
  70249. * Gets the agent velocity in world space
  70250. * @param index agent index returned by addAgent
  70251. * @returns world space velocity
  70252. */
  70253. getAgentVelocity(index: number): Vector3;
  70254. /**
  70255. * Gets the agent velocity result in world space
  70256. * @param index agent index returned by addAgent
  70257. * @param result output world space velocity
  70258. */
  70259. getAgentVelocityToRef(index: number, result: Vector3): void;
  70260. /**
  70261. * remove a particular agent previously created
  70262. * @param index agent index returned by addAgent
  70263. */
  70264. removeAgent(index: number): void;
  70265. /**
  70266. * get the list of all agents attached to this crowd
  70267. * @returns list of agent indices
  70268. */
  70269. getAgents(): number[];
  70270. /**
  70271. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  70272. * @param deltaTime in seconds
  70273. */
  70274. update(deltaTime: number): void;
  70275. /**
  70276. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  70277. * @param index agent index returned by addAgent
  70278. * @param destination targeted world position
  70279. */
  70280. agentGoto(index: number, destination: Vector3): void;
  70281. /**
  70282. * Teleport the agent to a new position
  70283. * @param index agent index returned by addAgent
  70284. * @param destination targeted world position
  70285. */
  70286. agentTeleport(index: number, destination: Vector3): void;
  70287. /**
  70288. * Update agent parameters
  70289. * @param index agent index returned by addAgent
  70290. * @param parameters agent parameters
  70291. */
  70292. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  70293. /**
  70294. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70295. * The queries will try to find a solution within those bounds
  70296. * default is (1,1,1)
  70297. * @param extent x,y,z value that define the extent around the queries point of reference
  70298. */
  70299. setDefaultQueryExtent(extent: Vector3): void;
  70300. /**
  70301. * Get the Bounding box extent specified by setDefaultQueryExtent
  70302. * @returns the box extent values
  70303. */
  70304. getDefaultQueryExtent(): Vector3;
  70305. /**
  70306. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70307. * @param result output the box extent values
  70308. */
  70309. getDefaultQueryExtentToRef(result: Vector3): void;
  70310. /**
  70311. * Release all resources
  70312. */
  70313. dispose(): void;
  70314. }
  70315. /**
  70316. * Configures an agent
  70317. */
  70318. export interface IAgentParameters {
  70319. /**
  70320. * Agent radius. [Limit: >= 0]
  70321. */
  70322. radius: number;
  70323. /**
  70324. * Agent height. [Limit: > 0]
  70325. */
  70326. height: number;
  70327. /**
  70328. * Maximum allowed acceleration. [Limit: >= 0]
  70329. */
  70330. maxAcceleration: number;
  70331. /**
  70332. * Maximum allowed speed. [Limit: >= 0]
  70333. */
  70334. maxSpeed: number;
  70335. /**
  70336. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  70337. */
  70338. collisionQueryRange: number;
  70339. /**
  70340. * The path visibility optimization range. [Limit: > 0]
  70341. */
  70342. pathOptimizationRange: number;
  70343. /**
  70344. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  70345. */
  70346. separationWeight: number;
  70347. }
  70348. /**
  70349. * Configures the navigation mesh creation
  70350. */
  70351. export interface INavMeshParameters {
  70352. /**
  70353. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  70354. */
  70355. cs: number;
  70356. /**
  70357. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  70358. */
  70359. ch: number;
  70360. /**
  70361. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  70362. */
  70363. walkableSlopeAngle: number;
  70364. /**
  70365. * Minimum floor to 'ceiling' height that will still allow the floor area to
  70366. * be considered walkable. [Limit: >= 3] [Units: vx]
  70367. */
  70368. walkableHeight: number;
  70369. /**
  70370. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  70371. */
  70372. walkableClimb: number;
  70373. /**
  70374. * The distance to erode/shrink the walkable area of the heightfield away from
  70375. * obstructions. [Limit: >=0] [Units: vx]
  70376. */
  70377. walkableRadius: number;
  70378. /**
  70379. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  70380. */
  70381. maxEdgeLen: number;
  70382. /**
  70383. * The maximum distance a simplfied contour's border edges should deviate
  70384. * the original raw contour. [Limit: >=0] [Units: vx]
  70385. */
  70386. maxSimplificationError: number;
  70387. /**
  70388. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  70389. */
  70390. minRegionArea: number;
  70391. /**
  70392. * Any regions with a span count smaller than this value will, if possible,
  70393. * be merged with larger regions. [Limit: >=0] [Units: vx]
  70394. */
  70395. mergeRegionArea: number;
  70396. /**
  70397. * The maximum number of vertices allowed for polygons generated during the
  70398. * contour to polygon conversion process. [Limit: >= 3]
  70399. */
  70400. maxVertsPerPoly: number;
  70401. /**
  70402. * Sets the sampling distance to use when generating the detail mesh.
  70403. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  70404. */
  70405. detailSampleDist: number;
  70406. /**
  70407. * The maximum distance the detail mesh surface should deviate from heightfield
  70408. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  70409. */
  70410. detailSampleMaxError: number;
  70411. }
  70412. }
  70413. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  70414. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  70415. import { Mesh } from "babylonjs/Meshes/mesh";
  70416. import { Scene } from "babylonjs/scene";
  70417. import { Vector3 } from "babylonjs/Maths/math";
  70418. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70419. /**
  70420. * RecastJS navigation plugin
  70421. */
  70422. export class RecastJSPlugin implements INavigationEnginePlugin {
  70423. /**
  70424. * Reference to the Recast library
  70425. */
  70426. bjsRECAST: any;
  70427. /**
  70428. * plugin name
  70429. */
  70430. name: string;
  70431. /**
  70432. * the first navmesh created. We might extend this to support multiple navmeshes
  70433. */
  70434. navMesh: any;
  70435. /**
  70436. * Initializes the recastJS plugin
  70437. * @param recastInjection can be used to inject your own recast reference
  70438. */
  70439. constructor(recastInjection?: any);
  70440. /**
  70441. * Creates a navigation mesh
  70442. * @param meshes array of all the geometry used to compute the navigatio mesh
  70443. * @param parameters bunch of parameters used to filter geometry
  70444. */
  70445. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  70446. /**
  70447. * Create a navigation mesh debug mesh
  70448. * @param scene is where the mesh will be added
  70449. * @returns debug display mesh
  70450. */
  70451. createDebugNavMesh(scene: Scene): Mesh;
  70452. /**
  70453. * Get a navigation mesh constrained position, closest to the parameter position
  70454. * @param position world position
  70455. * @returns the closest point to position constrained by the navigation mesh
  70456. */
  70457. getClosestPoint(position: Vector3): Vector3;
  70458. /**
  70459. * Get a navigation mesh constrained position, closest to the parameter position
  70460. * @param position world position
  70461. * @param result output the closest point to position constrained by the navigation mesh
  70462. */
  70463. getClosestPointToRef(position: Vector3, result: Vector3): void;
  70464. /**
  70465. * Get a navigation mesh constrained position, within a particular radius
  70466. * @param position world position
  70467. * @param maxRadius the maximum distance to the constrained world position
  70468. * @returns the closest point to position constrained by the navigation mesh
  70469. */
  70470. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  70471. /**
  70472. * Get a navigation mesh constrained position, within a particular radius
  70473. * @param position world position
  70474. * @param maxRadius the maximum distance to the constrained world position
  70475. * @param result output the closest point to position constrained by the navigation mesh
  70476. */
  70477. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  70478. /**
  70479. * Compute the final position from a segment made of destination-position
  70480. * @param position world position
  70481. * @param destination world position
  70482. * @returns the resulting point along the navmesh
  70483. */
  70484. moveAlong(position: Vector3, destination: Vector3): Vector3;
  70485. /**
  70486. * Compute the final position from a segment made of destination-position
  70487. * @param position world position
  70488. * @param destination world position
  70489. * @param result output the resulting point along the navmesh
  70490. */
  70491. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  70492. /**
  70493. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  70494. * @param start world position
  70495. * @param end world position
  70496. * @returns array containing world position composing the path
  70497. */
  70498. computePath(start: Vector3, end: Vector3): Vector3[];
  70499. /**
  70500. * Create a new Crowd so you can add agents
  70501. * @param maxAgents the maximum agent count in the crowd
  70502. * @param maxAgentRadius the maximum radius an agent can have
  70503. * @param scene to attach the crowd to
  70504. * @returns the crowd you can add agents to
  70505. */
  70506. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  70507. /**
  70508. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70509. * The queries will try to find a solution within those bounds
  70510. * default is (1,1,1)
  70511. * @param extent x,y,z value that define the extent around the queries point of reference
  70512. */
  70513. setDefaultQueryExtent(extent: Vector3): void;
  70514. /**
  70515. * Get the Bounding box extent specified by setDefaultQueryExtent
  70516. * @returns the box extent values
  70517. */
  70518. getDefaultQueryExtent(): Vector3;
  70519. /**
  70520. * build the navmesh from a previously saved state using getNavmeshData
  70521. * @param data the Uint8Array returned by getNavmeshData
  70522. */
  70523. buildFromNavmeshData(data: Uint8Array): void;
  70524. /**
  70525. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  70526. * @returns data the Uint8Array that can be saved and reused
  70527. */
  70528. getNavmeshData(): Uint8Array;
  70529. /**
  70530. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70531. * @param result output the box extent values
  70532. */
  70533. getDefaultQueryExtentToRef(result: Vector3): void;
  70534. /**
  70535. * Disposes
  70536. */
  70537. dispose(): void;
  70538. /**
  70539. * If this plugin is supported
  70540. * @returns true if plugin is supported
  70541. */
  70542. isSupported(): boolean;
  70543. }
  70544. /**
  70545. * Recast detour crowd implementation
  70546. */
  70547. export class RecastJSCrowd implements ICrowd {
  70548. /**
  70549. * Recast/detour plugin
  70550. */
  70551. bjsRECASTPlugin: RecastJSPlugin;
  70552. /**
  70553. * Link to the detour crowd
  70554. */
  70555. recastCrowd: any;
  70556. /**
  70557. * One transform per agent
  70558. */
  70559. transforms: TransformNode[];
  70560. /**
  70561. * All agents created
  70562. */
  70563. agents: number[];
  70564. /**
  70565. * Link to the scene is kept to unregister the crowd from the scene
  70566. */
  70567. private _scene;
  70568. /**
  70569. * Observer for crowd updates
  70570. */
  70571. private _onBeforeAnimationsObserver;
  70572. /**
  70573. * Constructor
  70574. * @param plugin recastJS plugin
  70575. * @param maxAgents the maximum agent count in the crowd
  70576. * @param maxAgentRadius the maximum radius an agent can have
  70577. * @param scene to attach the crowd to
  70578. * @returns the crowd you can add agents to
  70579. */
  70580. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  70581. /**
  70582. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  70583. * You can attach anything to that node. The node position is updated in the scene update tick.
  70584. * @param pos world position that will be constrained by the navigation mesh
  70585. * @param parameters agent parameters
  70586. * @param transform hooked to the agent that will be update by the scene
  70587. * @returns agent index
  70588. */
  70589. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  70590. /**
  70591. * Returns the agent position in world space
  70592. * @param index agent index returned by addAgent
  70593. * @returns world space position
  70594. */
  70595. getAgentPosition(index: number): Vector3;
  70596. /**
  70597. * Returns the agent position result in world space
  70598. * @param index agent index returned by addAgent
  70599. * @param result output world space position
  70600. */
  70601. getAgentPositionToRef(index: number, result: Vector3): void;
  70602. /**
  70603. * Returns the agent velocity in world space
  70604. * @param index agent index returned by addAgent
  70605. * @returns world space velocity
  70606. */
  70607. getAgentVelocity(index: number): Vector3;
  70608. /**
  70609. * Returns the agent velocity result in world space
  70610. * @param index agent index returned by addAgent
  70611. * @param result output world space velocity
  70612. */
  70613. getAgentVelocityToRef(index: number, result: Vector3): void;
  70614. /**
  70615. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  70616. * @param index agent index returned by addAgent
  70617. * @param destination targeted world position
  70618. */
  70619. agentGoto(index: number, destination: Vector3): void;
  70620. /**
  70621. * Teleport the agent to a new position
  70622. * @param index agent index returned by addAgent
  70623. * @param destination targeted world position
  70624. */
  70625. agentTeleport(index: number, destination: Vector3): void;
  70626. /**
  70627. * Update agent parameters
  70628. * @param index agent index returned by addAgent
  70629. * @param parameters agent parameters
  70630. */
  70631. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  70632. /**
  70633. * remove a particular agent previously created
  70634. * @param index agent index returned by addAgent
  70635. */
  70636. removeAgent(index: number): void;
  70637. /**
  70638. * get the list of all agents attached to this crowd
  70639. * @returns list of agent indices
  70640. */
  70641. getAgents(): number[];
  70642. /**
  70643. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  70644. * @param deltaTime in seconds
  70645. */
  70646. update(deltaTime: number): void;
  70647. /**
  70648. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70649. * The queries will try to find a solution within those bounds
  70650. * default is (1,1,1)
  70651. * @param extent x,y,z value that define the extent around the queries point of reference
  70652. */
  70653. setDefaultQueryExtent(extent: Vector3): void;
  70654. /**
  70655. * Get the Bounding box extent specified by setDefaultQueryExtent
  70656. * @returns the box extent values
  70657. */
  70658. getDefaultQueryExtent(): Vector3;
  70659. /**
  70660. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70661. * @param result output the box extent values
  70662. */
  70663. getDefaultQueryExtentToRef(result: Vector3): void;
  70664. /**
  70665. * Release all resources
  70666. */
  70667. dispose(): void;
  70668. }
  70669. }
  70670. declare module "babylonjs/Navigation/Plugins/index" {
  70671. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  70672. }
  70673. declare module "babylonjs/Navigation/index" {
  70674. export * from "babylonjs/Navigation/INavigationEngine";
  70675. export * from "babylonjs/Navigation/Plugins/index";
  70676. }
  70677. declare module "babylonjs/Offline/database" {
  70678. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  70679. /**
  70680. * Class used to enable access to IndexedDB
  70681. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  70682. */
  70683. export class Database implements IOfflineProvider {
  70684. private _callbackManifestChecked;
  70685. private _currentSceneUrl;
  70686. private _db;
  70687. private _enableSceneOffline;
  70688. private _enableTexturesOffline;
  70689. private _manifestVersionFound;
  70690. private _mustUpdateRessources;
  70691. private _hasReachedQuota;
  70692. private _isSupported;
  70693. private _idbFactory;
  70694. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  70695. private static IsUASupportingBlobStorage;
  70696. /**
  70697. * Gets a boolean indicating if Database storate is enabled (off by default)
  70698. */
  70699. static IDBStorageEnabled: boolean;
  70700. /**
  70701. * Gets a boolean indicating if scene must be saved in the database
  70702. */
  70703. get enableSceneOffline(): boolean;
  70704. /**
  70705. * Gets a boolean indicating if textures must be saved in the database
  70706. */
  70707. get enableTexturesOffline(): boolean;
  70708. /**
  70709. * Creates a new Database
  70710. * @param urlToScene defines the url to load the scene
  70711. * @param callbackManifestChecked defines the callback to use when manifest is checked
  70712. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  70713. */
  70714. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  70715. private static _ParseURL;
  70716. private static _ReturnFullUrlLocation;
  70717. private _checkManifestFile;
  70718. /**
  70719. * Open the database and make it available
  70720. * @param successCallback defines the callback to call on success
  70721. * @param errorCallback defines the callback to call on error
  70722. */
  70723. open(successCallback: () => void, errorCallback: () => void): void;
  70724. /**
  70725. * Loads an image from the database
  70726. * @param url defines the url to load from
  70727. * @param image defines the target DOM image
  70728. */
  70729. loadImage(url: string, image: HTMLImageElement): void;
  70730. private _loadImageFromDBAsync;
  70731. private _saveImageIntoDBAsync;
  70732. private _checkVersionFromDB;
  70733. private _loadVersionFromDBAsync;
  70734. private _saveVersionIntoDBAsync;
  70735. /**
  70736. * Loads a file from database
  70737. * @param url defines the URL to load from
  70738. * @param sceneLoaded defines a callback to call on success
  70739. * @param progressCallBack defines a callback to call when progress changed
  70740. * @param errorCallback defines a callback to call on error
  70741. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  70742. */
  70743. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  70744. private _loadFileAsync;
  70745. private _saveFileAsync;
  70746. /**
  70747. * Validates if xhr data is correct
  70748. * @param xhr defines the request to validate
  70749. * @param dataType defines the expected data type
  70750. * @returns true if data is correct
  70751. */
  70752. private static _ValidateXHRData;
  70753. }
  70754. }
  70755. declare module "babylonjs/Offline/index" {
  70756. export * from "babylonjs/Offline/database";
  70757. export * from "babylonjs/Offline/IOfflineProvider";
  70758. }
  70759. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  70760. /** @hidden */
  70761. export var gpuUpdateParticlesPixelShader: {
  70762. name: string;
  70763. shader: string;
  70764. };
  70765. }
  70766. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  70767. /** @hidden */
  70768. export var gpuUpdateParticlesVertexShader: {
  70769. name: string;
  70770. shader: string;
  70771. };
  70772. }
  70773. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  70774. /** @hidden */
  70775. export var clipPlaneFragmentDeclaration2: {
  70776. name: string;
  70777. shader: string;
  70778. };
  70779. }
  70780. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  70781. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  70782. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  70783. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  70784. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  70785. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  70786. /** @hidden */
  70787. export var gpuRenderParticlesPixelShader: {
  70788. name: string;
  70789. shader: string;
  70790. };
  70791. }
  70792. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  70793. /** @hidden */
  70794. export var clipPlaneVertexDeclaration2: {
  70795. name: string;
  70796. shader: string;
  70797. };
  70798. }
  70799. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  70800. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  70801. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  70802. /** @hidden */
  70803. export var gpuRenderParticlesVertexShader: {
  70804. name: string;
  70805. shader: string;
  70806. };
  70807. }
  70808. declare module "babylonjs/Particles/gpuParticleSystem" {
  70809. import { Nullable } from "babylonjs/types";
  70810. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  70811. import { Observable } from "babylonjs/Misc/observable";
  70812. import { Matrix } from "babylonjs/Maths/math.vector";
  70813. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  70814. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70815. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  70816. import { IDisposable } from "babylonjs/scene";
  70817. import { Effect } from "babylonjs/Materials/effect";
  70818. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  70819. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  70820. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  70821. import { Scene } from "babylonjs/scene";
  70822. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  70823. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  70824. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  70825. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  70826. /**
  70827. * This represents a GPU particle system in Babylon
  70828. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  70829. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  70830. */
  70831. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  70832. /**
  70833. * The layer mask we are rendering the particles through.
  70834. */
  70835. layerMask: number;
  70836. private _capacity;
  70837. private _activeCount;
  70838. private _currentActiveCount;
  70839. private _accumulatedCount;
  70840. private _renderEffect;
  70841. private _updateEffect;
  70842. private _buffer0;
  70843. private _buffer1;
  70844. private _spriteBuffer;
  70845. private _updateVAO;
  70846. private _renderVAO;
  70847. private _targetIndex;
  70848. private _sourceBuffer;
  70849. private _targetBuffer;
  70850. private _currentRenderId;
  70851. private _started;
  70852. private _stopped;
  70853. private _timeDelta;
  70854. private _randomTexture;
  70855. private _randomTexture2;
  70856. private _attributesStrideSize;
  70857. private _updateEffectOptions;
  70858. private _randomTextureSize;
  70859. private _actualFrame;
  70860. private _customEffect;
  70861. private readonly _rawTextureWidth;
  70862. /**
  70863. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  70864. */
  70865. static get IsSupported(): boolean;
  70866. /**
  70867. * An event triggered when the system is disposed.
  70868. */
  70869. onDisposeObservable: Observable<IParticleSystem>;
  70870. /**
  70871. * Gets the maximum number of particles active at the same time.
  70872. * @returns The max number of active particles.
  70873. */
  70874. getCapacity(): number;
  70875. /**
  70876. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  70877. * to override the particles.
  70878. */
  70879. forceDepthWrite: boolean;
  70880. /**
  70881. * Gets or set the number of active particles
  70882. */
  70883. get activeParticleCount(): number;
  70884. set activeParticleCount(value: number);
  70885. private _preWarmDone;
  70886. /**
  70887. * Specifies if the particles are updated in emitter local space or world space.
  70888. */
  70889. isLocal: boolean;
  70890. /** Gets or sets a matrix to use to compute projection */
  70891. defaultProjectionMatrix: Matrix;
  70892. /**
  70893. * Is this system ready to be used/rendered
  70894. * @return true if the system is ready
  70895. */
  70896. isReady(): boolean;
  70897. /**
  70898. * Gets if the system has been started. (Note: this will still be true after stop is called)
  70899. * @returns True if it has been started, otherwise false.
  70900. */
  70901. isStarted(): boolean;
  70902. /**
  70903. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  70904. * @returns True if it has been stopped, otherwise false.
  70905. */
  70906. isStopped(): boolean;
  70907. /**
  70908. * Gets a boolean indicating that the system is stopping
  70909. * @returns true if the system is currently stopping
  70910. */
  70911. isStopping(): boolean;
  70912. /**
  70913. * Gets the number of particles active at the same time.
  70914. * @returns The number of active particles.
  70915. */
  70916. getActiveCount(): number;
  70917. /**
  70918. * Starts the particle system and begins to emit
  70919. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  70920. */
  70921. start(delay?: number): void;
  70922. /**
  70923. * Stops the particle system.
  70924. */
  70925. stop(): void;
  70926. /**
  70927. * Remove all active particles
  70928. */
  70929. reset(): void;
  70930. /**
  70931. * Returns the string "GPUParticleSystem"
  70932. * @returns a string containing the class name
  70933. */
  70934. getClassName(): string;
  70935. /**
  70936. * Gets the custom effect used to render the particles
  70937. * @param blendMode Blend mode for which the effect should be retrieved
  70938. * @returns The effect
  70939. */
  70940. getCustomEffect(blendMode?: number): Nullable<Effect>;
  70941. /**
  70942. * Sets the custom effect used to render the particles
  70943. * @param effect The effect to set
  70944. * @param blendMode Blend mode for which the effect should be set
  70945. */
  70946. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  70947. /** @hidden */
  70948. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  70949. /**
  70950. * Observable that will be called just before the particles are drawn
  70951. */
  70952. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  70953. /**
  70954. * Gets the name of the particle vertex shader
  70955. */
  70956. get vertexShaderName(): string;
  70957. private _colorGradientsTexture;
  70958. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  70959. /**
  70960. * Adds a new color gradient
  70961. * @param gradient defines the gradient to use (between 0 and 1)
  70962. * @param color1 defines the color to affect to the specified gradient
  70963. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  70964. * @returns the current particle system
  70965. */
  70966. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  70967. private _refreshColorGradient;
  70968. /** Force the system to rebuild all gradients that need to be resync */
  70969. forceRefreshGradients(): void;
  70970. /**
  70971. * Remove a specific color gradient
  70972. * @param gradient defines the gradient to remove
  70973. * @returns the current particle system
  70974. */
  70975. removeColorGradient(gradient: number): GPUParticleSystem;
  70976. private _angularSpeedGradientsTexture;
  70977. private _sizeGradientsTexture;
  70978. private _velocityGradientsTexture;
  70979. private _limitVelocityGradientsTexture;
  70980. private _dragGradientsTexture;
  70981. private _addFactorGradient;
  70982. /**
  70983. * Adds a new size gradient
  70984. * @param gradient defines the gradient to use (between 0 and 1)
  70985. * @param factor defines the size factor to affect to the specified gradient
  70986. * @returns the current particle system
  70987. */
  70988. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  70989. /**
  70990. * Remove a specific size gradient
  70991. * @param gradient defines the gradient to remove
  70992. * @returns the current particle system
  70993. */
  70994. removeSizeGradient(gradient: number): GPUParticleSystem;
  70995. private _refreshFactorGradient;
  70996. /**
  70997. * Adds a new angular speed gradient
  70998. * @param gradient defines the gradient to use (between 0 and 1)
  70999. * @param factor defines the angular speed to affect to the specified gradient
  71000. * @returns the current particle system
  71001. */
  71002. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  71003. /**
  71004. * Remove a specific angular speed gradient
  71005. * @param gradient defines the gradient to remove
  71006. * @returns the current particle system
  71007. */
  71008. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  71009. /**
  71010. * Adds a new velocity gradient
  71011. * @param gradient defines the gradient to use (between 0 and 1)
  71012. * @param factor defines the velocity to affect to the specified gradient
  71013. * @returns the current particle system
  71014. */
  71015. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  71016. /**
  71017. * Remove a specific velocity gradient
  71018. * @param gradient defines the gradient to remove
  71019. * @returns the current particle system
  71020. */
  71021. removeVelocityGradient(gradient: number): GPUParticleSystem;
  71022. /**
  71023. * Adds a new limit velocity gradient
  71024. * @param gradient defines the gradient to use (between 0 and 1)
  71025. * @param factor defines the limit velocity value to affect to the specified gradient
  71026. * @returns the current particle system
  71027. */
  71028. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  71029. /**
  71030. * Remove a specific limit velocity gradient
  71031. * @param gradient defines the gradient to remove
  71032. * @returns the current particle system
  71033. */
  71034. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  71035. /**
  71036. * Adds a new drag gradient
  71037. * @param gradient defines the gradient to use (between 0 and 1)
  71038. * @param factor defines the drag value to affect to the specified gradient
  71039. * @returns the current particle system
  71040. */
  71041. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  71042. /**
  71043. * Remove a specific drag gradient
  71044. * @param gradient defines the gradient to remove
  71045. * @returns the current particle system
  71046. */
  71047. removeDragGradient(gradient: number): GPUParticleSystem;
  71048. /**
  71049. * Not supported by GPUParticleSystem
  71050. * @param gradient defines the gradient to use (between 0 and 1)
  71051. * @param factor defines the emit rate value to affect to the specified gradient
  71052. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71053. * @returns the current particle system
  71054. */
  71055. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71056. /**
  71057. * Not supported by GPUParticleSystem
  71058. * @param gradient defines the gradient to remove
  71059. * @returns the current particle system
  71060. */
  71061. removeEmitRateGradient(gradient: number): IParticleSystem;
  71062. /**
  71063. * Not supported by GPUParticleSystem
  71064. * @param gradient defines the gradient to use (between 0 and 1)
  71065. * @param factor defines the start size value to affect to the specified gradient
  71066. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71067. * @returns the current particle system
  71068. */
  71069. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71070. /**
  71071. * Not supported by GPUParticleSystem
  71072. * @param gradient defines the gradient to remove
  71073. * @returns the current particle system
  71074. */
  71075. removeStartSizeGradient(gradient: number): IParticleSystem;
  71076. /**
  71077. * Not supported by GPUParticleSystem
  71078. * @param gradient defines the gradient to use (between 0 and 1)
  71079. * @param min defines the color remap minimal range
  71080. * @param max defines the color remap maximal range
  71081. * @returns the current particle system
  71082. */
  71083. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71084. /**
  71085. * Not supported by GPUParticleSystem
  71086. * @param gradient defines the gradient to remove
  71087. * @returns the current particle system
  71088. */
  71089. removeColorRemapGradient(): IParticleSystem;
  71090. /**
  71091. * Not supported by GPUParticleSystem
  71092. * @param gradient defines the gradient to use (between 0 and 1)
  71093. * @param min defines the alpha remap minimal range
  71094. * @param max defines the alpha remap maximal range
  71095. * @returns the current particle system
  71096. */
  71097. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71098. /**
  71099. * Not supported by GPUParticleSystem
  71100. * @param gradient defines the gradient to remove
  71101. * @returns the current particle system
  71102. */
  71103. removeAlphaRemapGradient(): IParticleSystem;
  71104. /**
  71105. * Not supported by GPUParticleSystem
  71106. * @param gradient defines the gradient to use (between 0 and 1)
  71107. * @param color defines the color to affect to the specified gradient
  71108. * @returns the current particle system
  71109. */
  71110. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  71111. /**
  71112. * Not supported by GPUParticleSystem
  71113. * @param gradient defines the gradient to remove
  71114. * @returns the current particle system
  71115. */
  71116. removeRampGradient(): IParticleSystem;
  71117. /**
  71118. * Not supported by GPUParticleSystem
  71119. * @returns the list of ramp gradients
  71120. */
  71121. getRampGradients(): Nullable<Array<Color3Gradient>>;
  71122. /**
  71123. * Not supported by GPUParticleSystem
  71124. * Gets or sets a boolean indicating that ramp gradients must be used
  71125. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  71126. */
  71127. get useRampGradients(): boolean;
  71128. set useRampGradients(value: boolean);
  71129. /**
  71130. * Not supported by GPUParticleSystem
  71131. * @param gradient defines the gradient to use (between 0 and 1)
  71132. * @param factor defines the life time factor to affect to the specified gradient
  71133. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71134. * @returns the current particle system
  71135. */
  71136. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71137. /**
  71138. * Not supported by GPUParticleSystem
  71139. * @param gradient defines the gradient to remove
  71140. * @returns the current particle system
  71141. */
  71142. removeLifeTimeGradient(gradient: number): IParticleSystem;
  71143. /**
  71144. * Instantiates a GPU particle system.
  71145. * 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.
  71146. * @param name The name of the particle system
  71147. * @param options The options used to create the system
  71148. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  71149. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  71150. * @param customEffect a custom effect used to change the way particles are rendered by default
  71151. */
  71152. constructor(name: string, options: Partial<{
  71153. capacity: number;
  71154. randomTextureSize: number;
  71155. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  71156. protected _reset(): void;
  71157. private _createUpdateVAO;
  71158. private _createRenderVAO;
  71159. private _initialize;
  71160. /** @hidden */
  71161. _recreateUpdateEffect(): void;
  71162. private _getEffect;
  71163. /**
  71164. * Fill the defines array according to the current settings of the particle system
  71165. * @param defines Array to be updated
  71166. * @param blendMode blend mode to take into account when updating the array
  71167. */
  71168. fillDefines(defines: Array<string>, blendMode?: number): void;
  71169. /**
  71170. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  71171. * @param uniforms Uniforms array to fill
  71172. * @param attributes Attributes array to fill
  71173. * @param samplers Samplers array to fill
  71174. */
  71175. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  71176. /** @hidden */
  71177. _recreateRenderEffect(): Effect;
  71178. /**
  71179. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  71180. * @param preWarm defines if we are in the pre-warmimg phase
  71181. */
  71182. animate(preWarm?: boolean): void;
  71183. private _createFactorGradientTexture;
  71184. private _createSizeGradientTexture;
  71185. private _createAngularSpeedGradientTexture;
  71186. private _createVelocityGradientTexture;
  71187. private _createLimitVelocityGradientTexture;
  71188. private _createDragGradientTexture;
  71189. private _createColorGradientTexture;
  71190. /**
  71191. * Renders the particle system in its current state
  71192. * @param preWarm defines if the system should only update the particles but not render them
  71193. * @returns the current number of particles
  71194. */
  71195. render(preWarm?: boolean): number;
  71196. /**
  71197. * Rebuilds the particle system
  71198. */
  71199. rebuild(): void;
  71200. private _releaseBuffers;
  71201. private _releaseVAOs;
  71202. /**
  71203. * Disposes the particle system and free the associated resources
  71204. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  71205. */
  71206. dispose(disposeTexture?: boolean): void;
  71207. /**
  71208. * Clones the particle system.
  71209. * @param name The name of the cloned object
  71210. * @param newEmitter The new emitter to use
  71211. * @returns the cloned particle system
  71212. */
  71213. clone(name: string, newEmitter: any): GPUParticleSystem;
  71214. /**
  71215. * Serializes the particle system to a JSON object
  71216. * @param serializeTexture defines if the texture must be serialized as well
  71217. * @returns the JSON object
  71218. */
  71219. serialize(serializeTexture?: boolean): any;
  71220. /**
  71221. * Parses a JSON object to create a GPU particle system.
  71222. * @param parsedParticleSystem The JSON object to parse
  71223. * @param sceneOrEngine The scene or the engine to create the particle system in
  71224. * @param rootUrl The root url to use to load external dependencies like texture
  71225. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  71226. * @returns the parsed GPU particle system
  71227. */
  71228. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  71229. }
  71230. }
  71231. declare module "babylonjs/Particles/particleSystemSet" {
  71232. import { Nullable } from "babylonjs/types";
  71233. import { Color3 } from "babylonjs/Maths/math.color";
  71234. import { TransformNode } from "babylonjs/Meshes/transformNode";
  71235. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71236. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71237. import { Scene, IDisposable } from "babylonjs/scene";
  71238. /**
  71239. * Represents a set of particle systems working together to create a specific effect
  71240. */
  71241. export class ParticleSystemSet implements IDisposable {
  71242. /**
  71243. * Gets or sets base Assets URL
  71244. */
  71245. static BaseAssetsUrl: string;
  71246. private _emitterCreationOptions;
  71247. private _emitterNode;
  71248. /**
  71249. * Gets the particle system list
  71250. */
  71251. systems: IParticleSystem[];
  71252. /**
  71253. * Gets the emitter node used with this set
  71254. */
  71255. get emitterNode(): Nullable<TransformNode>;
  71256. /**
  71257. * Creates a new emitter mesh as a sphere
  71258. * @param options defines the options used to create the sphere
  71259. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  71260. * @param scene defines the hosting scene
  71261. */
  71262. setEmitterAsSphere(options: {
  71263. diameter: number;
  71264. segments: number;
  71265. color: Color3;
  71266. }, renderingGroupId: number, scene: Scene): void;
  71267. /**
  71268. * Starts all particle systems of the set
  71269. * @param emitter defines an optional mesh to use as emitter for the particle systems
  71270. */
  71271. start(emitter?: AbstractMesh): void;
  71272. /**
  71273. * Release all associated resources
  71274. */
  71275. dispose(): void;
  71276. /**
  71277. * Serialize the set into a JSON compatible object
  71278. * @param serializeTexture defines if the texture must be serialized as well
  71279. * @returns a JSON compatible representation of the set
  71280. */
  71281. serialize(serializeTexture?: boolean): any;
  71282. /**
  71283. * Parse a new ParticleSystemSet from a serialized source
  71284. * @param data defines a JSON compatible representation of the set
  71285. * @param scene defines the hosting scene
  71286. * @param gpu defines if we want GPU particles or CPU particles
  71287. * @returns a new ParticleSystemSet
  71288. */
  71289. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  71290. }
  71291. }
  71292. declare module "babylonjs/Particles/particleHelper" {
  71293. import { Nullable } from "babylonjs/types";
  71294. import { Scene } from "babylonjs/scene";
  71295. import { Vector3 } from "babylonjs/Maths/math.vector";
  71296. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71297. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71298. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  71299. /**
  71300. * This class is made for on one-liner static method to help creating particle system set.
  71301. */
  71302. export class ParticleHelper {
  71303. /**
  71304. * Gets or sets base Assets URL
  71305. */
  71306. static BaseAssetsUrl: string;
  71307. /** Define the Url to load snippets */
  71308. static SnippetUrl: string;
  71309. /**
  71310. * Create a default particle system that you can tweak
  71311. * @param emitter defines the emitter to use
  71312. * @param capacity defines the system capacity (default is 500 particles)
  71313. * @param scene defines the hosting scene
  71314. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  71315. * @returns the new Particle system
  71316. */
  71317. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  71318. /**
  71319. * This is the main static method (one-liner) of this helper to create different particle systems
  71320. * @param type This string represents the type to the particle system to create
  71321. * @param scene The scene where the particle system should live
  71322. * @param gpu If the system will use gpu
  71323. * @returns the ParticleSystemSet created
  71324. */
  71325. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  71326. /**
  71327. * Static function used to export a particle system to a ParticleSystemSet variable.
  71328. * Please note that the emitter shape is not exported
  71329. * @param systems defines the particle systems to export
  71330. * @returns the created particle system set
  71331. */
  71332. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  71333. /**
  71334. * Creates a particle system from a snippet saved in a remote file
  71335. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  71336. * @param url defines the url to load from
  71337. * @param scene defines the hosting scene
  71338. * @param gpu If the system will use gpu
  71339. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  71340. * @returns a promise that will resolve to the new particle system
  71341. */
  71342. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  71343. /**
  71344. * Creates a particle system from a snippet saved by the particle system editor
  71345. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  71346. * @param scene defines the hosting scene
  71347. * @param gpu If the system will use gpu
  71348. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  71349. * @returns a promise that will resolve to the new particle system
  71350. */
  71351. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  71352. }
  71353. }
  71354. declare module "babylonjs/Particles/particleSystemComponent" {
  71355. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71356. import { Effect } from "babylonjs/Materials/effect";
  71357. import "babylonjs/Shaders/particles.vertex";
  71358. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  71359. module "babylonjs/Engines/engine" {
  71360. interface Engine {
  71361. /**
  71362. * Create an effect to use with particle systems.
  71363. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  71364. * the particle system for which you want to create a custom effect in the last parameter
  71365. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  71366. * @param uniformsNames defines a list of attribute names
  71367. * @param samplers defines an array of string used to represent textures
  71368. * @param defines defines the string containing the defines to use to compile the shaders
  71369. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  71370. * @param onCompiled defines a function to call when the effect creation is successful
  71371. * @param onError defines a function to call when the effect creation has failed
  71372. * @param particleSystem the particle system you want to create the effect for
  71373. * @returns the new Effect
  71374. */
  71375. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  71376. }
  71377. }
  71378. module "babylonjs/Meshes/mesh" {
  71379. interface Mesh {
  71380. /**
  71381. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  71382. * @returns an array of IParticleSystem
  71383. */
  71384. getEmittedParticleSystems(): IParticleSystem[];
  71385. /**
  71386. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  71387. * @returns an array of IParticleSystem
  71388. */
  71389. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  71390. }
  71391. }
  71392. }
  71393. declare module "babylonjs/Particles/pointsCloudSystem" {
  71394. import { Color4 } from "babylonjs/Maths/math";
  71395. import { Mesh } from "babylonjs/Meshes/mesh";
  71396. import { Scene, IDisposable } from "babylonjs/scene";
  71397. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  71398. /** Defines the 4 color options */
  71399. export enum PointColor {
  71400. /** color value */
  71401. Color = 2,
  71402. /** uv value */
  71403. UV = 1,
  71404. /** random value */
  71405. Random = 0,
  71406. /** stated value */
  71407. Stated = 3
  71408. }
  71409. /**
  71410. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  71411. * 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.
  71412. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  71413. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  71414. *
  71415. * Full documentation here : TO BE ENTERED
  71416. */
  71417. export class PointsCloudSystem implements IDisposable {
  71418. /**
  71419. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  71420. * Example : var p = SPS.particles[i];
  71421. */
  71422. particles: CloudPoint[];
  71423. /**
  71424. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  71425. */
  71426. nbParticles: number;
  71427. /**
  71428. * This a counter for your own usage. It's not set by any SPS functions.
  71429. */
  71430. counter: number;
  71431. /**
  71432. * The PCS name. This name is also given to the underlying mesh.
  71433. */
  71434. name: string;
  71435. /**
  71436. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  71437. */
  71438. mesh: Mesh;
  71439. /**
  71440. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  71441. * Please read :
  71442. */
  71443. vars: any;
  71444. /**
  71445. * @hidden
  71446. */
  71447. _size: number;
  71448. private _scene;
  71449. private _promises;
  71450. private _positions;
  71451. private _indices;
  71452. private _normals;
  71453. private _colors;
  71454. private _uvs;
  71455. private _indices32;
  71456. private _positions32;
  71457. private _colors32;
  71458. private _uvs32;
  71459. private _updatable;
  71460. private _isVisibilityBoxLocked;
  71461. private _alwaysVisible;
  71462. private _groups;
  71463. private _groupCounter;
  71464. private _computeParticleColor;
  71465. private _computeParticleTexture;
  71466. private _computeParticleRotation;
  71467. private _computeBoundingBox;
  71468. private _isReady;
  71469. /**
  71470. * Creates a PCS (Points Cloud System) object
  71471. * @param name (String) is the PCS name, this will be the underlying mesh name
  71472. * @param pointSize (number) is the size for each point
  71473. * @param scene (Scene) is the scene in which the PCS is added
  71474. * @param options defines the options of the PCS e.g.
  71475. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  71476. */
  71477. constructor(name: string, pointSize: number, scene: Scene, options?: {
  71478. updatable?: boolean;
  71479. });
  71480. /**
  71481. * Builds the PCS underlying mesh. Returns a standard Mesh.
  71482. * If no points were added to the PCS, the returned mesh is just a single point.
  71483. * @returns a promise for the created mesh
  71484. */
  71485. buildMeshAsync(): Promise<Mesh>;
  71486. /**
  71487. * @hidden
  71488. */
  71489. private _buildMesh;
  71490. private _addParticle;
  71491. private _randomUnitVector;
  71492. private _getColorIndicesForCoord;
  71493. private _setPointsColorOrUV;
  71494. private _colorFromTexture;
  71495. private _calculateDensity;
  71496. /**
  71497. * Adds points to the PCS in random positions within a unit sphere
  71498. * @param nb (positive integer) the number of particles to be created from this model
  71499. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  71500. * @returns the number of groups in the system
  71501. */
  71502. addPoints(nb: number, pointFunction?: any): number;
  71503. /**
  71504. * Adds points to the PCS from the surface of the model shape
  71505. * @param mesh is any Mesh object that will be used as a surface model for the points
  71506. * @param nb (positive integer) the number of particles to be created from this model
  71507. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  71508. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  71509. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  71510. * @returns the number of groups in the system
  71511. */
  71512. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  71513. /**
  71514. * Adds points to the PCS inside the model shape
  71515. * @param mesh is any Mesh object that will be used as a surface model for the points
  71516. * @param nb (positive integer) the number of particles to be created from this model
  71517. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  71518. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  71519. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  71520. * @returns the number of groups in the system
  71521. */
  71522. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  71523. /**
  71524. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  71525. * This method calls `updateParticle()` for each particle of the SPS.
  71526. * For an animated SPS, it is usually called within the render loop.
  71527. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  71528. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  71529. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  71530. * @returns the PCS.
  71531. */
  71532. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  71533. /**
  71534. * Disposes the PCS.
  71535. */
  71536. dispose(): void;
  71537. /**
  71538. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  71539. * doc :
  71540. * @returns the PCS.
  71541. */
  71542. refreshVisibleSize(): PointsCloudSystem;
  71543. /**
  71544. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  71545. * @param size the size (float) of the visibility box
  71546. * note : this doesn't lock the PCS mesh bounding box.
  71547. * doc :
  71548. */
  71549. setVisibilityBox(size: number): void;
  71550. /**
  71551. * Gets whether the PCS is always visible or not
  71552. * doc :
  71553. */
  71554. get isAlwaysVisible(): boolean;
  71555. /**
  71556. * Sets the PCS as always visible or not
  71557. * doc :
  71558. */
  71559. set isAlwaysVisible(val: boolean);
  71560. /**
  71561. * Tells to `setParticles()` to compute the particle rotations or not
  71562. * Default value : false. The PCS is faster when it's set to false
  71563. * Note : particle rotations are only applied to parent particles
  71564. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  71565. */
  71566. set computeParticleRotation(val: boolean);
  71567. /**
  71568. * Tells to `setParticles()` to compute the particle colors or not.
  71569. * Default value : true. The PCS is faster when it's set to false.
  71570. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  71571. */
  71572. set computeParticleColor(val: boolean);
  71573. set computeParticleTexture(val: boolean);
  71574. /**
  71575. * Gets if `setParticles()` computes the particle colors or not.
  71576. * Default value : false. The PCS is faster when it's set to false.
  71577. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  71578. */
  71579. get computeParticleColor(): boolean;
  71580. /**
  71581. * Gets if `setParticles()` computes the particle textures or not.
  71582. * Default value : false. The PCS is faster when it's set to false.
  71583. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  71584. */
  71585. get computeParticleTexture(): boolean;
  71586. /**
  71587. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  71588. */
  71589. set computeBoundingBox(val: boolean);
  71590. /**
  71591. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  71592. */
  71593. get computeBoundingBox(): boolean;
  71594. /**
  71595. * This function does nothing. It may be overwritten to set all the particle first values.
  71596. * The PCS doesn't call this function, you may have to call it by your own.
  71597. * doc :
  71598. */
  71599. initParticles(): void;
  71600. /**
  71601. * This function does nothing. It may be overwritten to recycle a particle
  71602. * The PCS doesn't call this function, you can to call it
  71603. * doc :
  71604. * @param particle The particle to recycle
  71605. * @returns the recycled particle
  71606. */
  71607. recycleParticle(particle: CloudPoint): CloudPoint;
  71608. /**
  71609. * Updates a particle : this function should be overwritten by the user.
  71610. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  71611. * doc :
  71612. * @example : just set a particle position or velocity and recycle conditions
  71613. * @param particle The particle to update
  71614. * @returns the updated particle
  71615. */
  71616. updateParticle(particle: CloudPoint): CloudPoint;
  71617. /**
  71618. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  71619. * This does nothing and may be overwritten by the user.
  71620. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  71621. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  71622. * @param update the boolean update value actually passed to setParticles()
  71623. */
  71624. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  71625. /**
  71626. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  71627. * This will be passed three parameters.
  71628. * This does nothing and may be overwritten by the user.
  71629. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  71630. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  71631. * @param update the boolean update value actually passed to setParticles()
  71632. */
  71633. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  71634. }
  71635. }
  71636. declare module "babylonjs/Particles/cloudPoint" {
  71637. import { Nullable } from "babylonjs/types";
  71638. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  71639. import { Mesh } from "babylonjs/Meshes/mesh";
  71640. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  71641. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  71642. /**
  71643. * Represents one particle of a points cloud system.
  71644. */
  71645. export class CloudPoint {
  71646. /**
  71647. * particle global index
  71648. */
  71649. idx: number;
  71650. /**
  71651. * The color of the particle
  71652. */
  71653. color: Nullable<Color4>;
  71654. /**
  71655. * The world space position of the particle.
  71656. */
  71657. position: Vector3;
  71658. /**
  71659. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  71660. */
  71661. rotation: Vector3;
  71662. /**
  71663. * The world space rotation quaternion of the particle.
  71664. */
  71665. rotationQuaternion: Nullable<Quaternion>;
  71666. /**
  71667. * The uv of the particle.
  71668. */
  71669. uv: Nullable<Vector2>;
  71670. /**
  71671. * The current speed of the particle.
  71672. */
  71673. velocity: Vector3;
  71674. /**
  71675. * The pivot point in the particle local space.
  71676. */
  71677. pivot: Vector3;
  71678. /**
  71679. * Must the particle be translated from its pivot point in its local space ?
  71680. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  71681. * Default : false
  71682. */
  71683. translateFromPivot: boolean;
  71684. /**
  71685. * Index of this particle in the global "positions" array (Internal use)
  71686. * @hidden
  71687. */
  71688. _pos: number;
  71689. /**
  71690. * @hidden Index of this particle in the global "indices" array (Internal use)
  71691. */
  71692. _ind: number;
  71693. /**
  71694. * Group this particle belongs to
  71695. */
  71696. _group: PointsGroup;
  71697. /**
  71698. * Group id of this particle
  71699. */
  71700. groupId: number;
  71701. /**
  71702. * Index of the particle in its group id (Internal use)
  71703. */
  71704. idxInGroup: number;
  71705. /**
  71706. * @hidden Particle BoundingInfo object (Internal use)
  71707. */
  71708. _boundingInfo: BoundingInfo;
  71709. /**
  71710. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  71711. */
  71712. _pcs: PointsCloudSystem;
  71713. /**
  71714. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  71715. */
  71716. _stillInvisible: boolean;
  71717. /**
  71718. * @hidden Last computed particle rotation matrix
  71719. */
  71720. _rotationMatrix: number[];
  71721. /**
  71722. * Parent particle Id, if any.
  71723. * Default null.
  71724. */
  71725. parentId: Nullable<number>;
  71726. /**
  71727. * @hidden Internal global position in the PCS.
  71728. */
  71729. _globalPosition: Vector3;
  71730. /**
  71731. * Creates a Point Cloud object.
  71732. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  71733. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  71734. * @param group (PointsGroup) is the group the particle belongs to
  71735. * @param groupId (integer) is the group identifier in the PCS.
  71736. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  71737. * @param pcs defines the PCS it is associated to
  71738. */
  71739. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  71740. /**
  71741. * get point size
  71742. */
  71743. get size(): Vector3;
  71744. /**
  71745. * Set point size
  71746. */
  71747. set size(scale: Vector3);
  71748. /**
  71749. * Legacy support, changed quaternion to rotationQuaternion
  71750. */
  71751. get quaternion(): Nullable<Quaternion>;
  71752. /**
  71753. * Legacy support, changed quaternion to rotationQuaternion
  71754. */
  71755. set quaternion(q: Nullable<Quaternion>);
  71756. /**
  71757. * Returns a boolean. True if the particle intersects a mesh, else false
  71758. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  71759. * @param target is the object (point or mesh) what the intersection is computed against
  71760. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  71761. * @returns true if it intersects
  71762. */
  71763. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  71764. /**
  71765. * get the rotation matrix of the particle
  71766. * @hidden
  71767. */
  71768. getRotationMatrix(m: Matrix): void;
  71769. }
  71770. /**
  71771. * Represents a group of points in a points cloud system
  71772. * * PCS internal tool, don't use it manually.
  71773. */
  71774. export class PointsGroup {
  71775. /**
  71776. * The group id
  71777. * @hidden
  71778. */
  71779. groupID: number;
  71780. /**
  71781. * image data for group (internal use)
  71782. * @hidden
  71783. */
  71784. _groupImageData: Nullable<ArrayBufferView>;
  71785. /**
  71786. * Image Width (internal use)
  71787. * @hidden
  71788. */
  71789. _groupImgWidth: number;
  71790. /**
  71791. * Image Height (internal use)
  71792. * @hidden
  71793. */
  71794. _groupImgHeight: number;
  71795. /**
  71796. * Custom position function (internal use)
  71797. * @hidden
  71798. */
  71799. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  71800. /**
  71801. * density per facet for surface points
  71802. * @hidden
  71803. */
  71804. _groupDensity: number[];
  71805. /**
  71806. * Only when points are colored by texture carries pointer to texture list array
  71807. * @hidden
  71808. */
  71809. _textureNb: number;
  71810. /**
  71811. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  71812. * PCS internal tool, don't use it manually.
  71813. * @hidden
  71814. */
  71815. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  71816. }
  71817. }
  71818. declare module "babylonjs/Particles/index" {
  71819. export * from "babylonjs/Particles/baseParticleSystem";
  71820. export * from "babylonjs/Particles/EmitterTypes/index";
  71821. export * from "babylonjs/Particles/gpuParticleSystem";
  71822. export * from "babylonjs/Particles/IParticleSystem";
  71823. export * from "babylonjs/Particles/particle";
  71824. export * from "babylonjs/Particles/particleHelper";
  71825. export * from "babylonjs/Particles/particleSystem";
  71826. import "babylonjs/Particles/particleSystemComponent";
  71827. export * from "babylonjs/Particles/particleSystemComponent";
  71828. export * from "babylonjs/Particles/particleSystemSet";
  71829. export * from "babylonjs/Particles/solidParticle";
  71830. export * from "babylonjs/Particles/solidParticleSystem";
  71831. export * from "babylonjs/Particles/cloudPoint";
  71832. export * from "babylonjs/Particles/pointsCloudSystem";
  71833. export * from "babylonjs/Particles/subEmitter";
  71834. }
  71835. declare module "babylonjs/Physics/physicsEngineComponent" {
  71836. import { Nullable } from "babylonjs/types";
  71837. import { Observable, Observer } from "babylonjs/Misc/observable";
  71838. import { Vector3 } from "babylonjs/Maths/math.vector";
  71839. import { Mesh } from "babylonjs/Meshes/mesh";
  71840. import { ISceneComponent } from "babylonjs/sceneComponent";
  71841. import { Scene } from "babylonjs/scene";
  71842. import { Node } from "babylonjs/node";
  71843. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  71844. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  71845. module "babylonjs/scene" {
  71846. interface Scene {
  71847. /** @hidden (Backing field) */
  71848. _physicsEngine: Nullable<IPhysicsEngine>;
  71849. /** @hidden */
  71850. _physicsTimeAccumulator: number;
  71851. /**
  71852. * Gets the current physics engine
  71853. * @returns a IPhysicsEngine or null if none attached
  71854. */
  71855. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  71856. /**
  71857. * Enables physics to the current scene
  71858. * @param gravity defines the scene's gravity for the physics engine
  71859. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  71860. * @return a boolean indicating if the physics engine was initialized
  71861. */
  71862. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  71863. /**
  71864. * Disables and disposes the physics engine associated with the scene
  71865. */
  71866. disablePhysicsEngine(): void;
  71867. /**
  71868. * Gets a boolean indicating if there is an active physics engine
  71869. * @returns a boolean indicating if there is an active physics engine
  71870. */
  71871. isPhysicsEnabled(): boolean;
  71872. /**
  71873. * Deletes a physics compound impostor
  71874. * @param compound defines the compound to delete
  71875. */
  71876. deleteCompoundImpostor(compound: any): void;
  71877. /**
  71878. * An event triggered when physic simulation is about to be run
  71879. */
  71880. onBeforePhysicsObservable: Observable<Scene>;
  71881. /**
  71882. * An event triggered when physic simulation has been done
  71883. */
  71884. onAfterPhysicsObservable: Observable<Scene>;
  71885. }
  71886. }
  71887. module "babylonjs/Meshes/abstractMesh" {
  71888. interface AbstractMesh {
  71889. /** @hidden */
  71890. _physicsImpostor: Nullable<PhysicsImpostor>;
  71891. /**
  71892. * Gets or sets impostor used for physic simulation
  71893. * @see https://doc.babylonjs.com/features/physics_engine
  71894. */
  71895. physicsImpostor: Nullable<PhysicsImpostor>;
  71896. /**
  71897. * Gets the current physics impostor
  71898. * @see https://doc.babylonjs.com/features/physics_engine
  71899. * @returns a physics impostor or null
  71900. */
  71901. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  71902. /** Apply a physic impulse to the mesh
  71903. * @param force defines the force to apply
  71904. * @param contactPoint defines where to apply the force
  71905. * @returns the current mesh
  71906. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  71907. */
  71908. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  71909. /**
  71910. * Creates a physic joint between two meshes
  71911. * @param otherMesh defines the other mesh to use
  71912. * @param pivot1 defines the pivot to use on this mesh
  71913. * @param pivot2 defines the pivot to use on the other mesh
  71914. * @param options defines additional options (can be plugin dependent)
  71915. * @returns the current mesh
  71916. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  71917. */
  71918. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  71919. /** @hidden */
  71920. _disposePhysicsObserver: Nullable<Observer<Node>>;
  71921. }
  71922. }
  71923. /**
  71924. * Defines the physics engine scene component responsible to manage a physics engine
  71925. */
  71926. export class PhysicsEngineSceneComponent implements ISceneComponent {
  71927. /**
  71928. * The component name helpful to identify the component in the list of scene components.
  71929. */
  71930. readonly name: string;
  71931. /**
  71932. * The scene the component belongs to.
  71933. */
  71934. scene: Scene;
  71935. /**
  71936. * Creates a new instance of the component for the given scene
  71937. * @param scene Defines the scene to register the component in
  71938. */
  71939. constructor(scene: Scene);
  71940. /**
  71941. * Registers the component in a given scene
  71942. */
  71943. register(): void;
  71944. /**
  71945. * Rebuilds the elements related to this component in case of
  71946. * context lost for instance.
  71947. */
  71948. rebuild(): void;
  71949. /**
  71950. * Disposes the component and the associated ressources
  71951. */
  71952. dispose(): void;
  71953. }
  71954. }
  71955. declare module "babylonjs/Physics/physicsHelper" {
  71956. import { Nullable } from "babylonjs/types";
  71957. import { Vector3 } from "babylonjs/Maths/math.vector";
  71958. import { Mesh } from "babylonjs/Meshes/mesh";
  71959. import { Scene } from "babylonjs/scene";
  71960. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  71961. /**
  71962. * A helper for physics simulations
  71963. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71964. */
  71965. export class PhysicsHelper {
  71966. private _scene;
  71967. private _physicsEngine;
  71968. /**
  71969. * Initializes the Physics helper
  71970. * @param scene Babylon.js scene
  71971. */
  71972. constructor(scene: Scene);
  71973. /**
  71974. * Applies a radial explosion impulse
  71975. * @param origin the origin of the explosion
  71976. * @param radiusOrEventOptions the radius or the options of radial explosion
  71977. * @param strength the explosion strength
  71978. * @param falloff possible options: Constant & Linear. Defaults to Constant
  71979. * @returns A physics radial explosion event, or null
  71980. */
  71981. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  71982. /**
  71983. * Applies a radial explosion force
  71984. * @param origin the origin of the explosion
  71985. * @param radiusOrEventOptions the radius or the options of radial explosion
  71986. * @param strength the explosion strength
  71987. * @param falloff possible options: Constant & Linear. Defaults to Constant
  71988. * @returns A physics radial explosion event, or null
  71989. */
  71990. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  71991. /**
  71992. * Creates a gravitational field
  71993. * @param origin the origin of the explosion
  71994. * @param radiusOrEventOptions the radius or the options of radial explosion
  71995. * @param strength the explosion strength
  71996. * @param falloff possible options: Constant & Linear. Defaults to Constant
  71997. * @returns A physics gravitational field event, or null
  71998. */
  71999. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  72000. /**
  72001. * Creates a physics updraft event
  72002. * @param origin the origin of the updraft
  72003. * @param radiusOrEventOptions the radius or the options of the updraft
  72004. * @param strength the strength of the updraft
  72005. * @param height the height of the updraft
  72006. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  72007. * @returns A physics updraft event, or null
  72008. */
  72009. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  72010. /**
  72011. * Creates a physics vortex event
  72012. * @param origin the of the vortex
  72013. * @param radiusOrEventOptions the radius or the options of the vortex
  72014. * @param strength the strength of the vortex
  72015. * @param height the height of the vortex
  72016. * @returns a Physics vortex event, or null
  72017. * A physics vortex event or null
  72018. */
  72019. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  72020. }
  72021. /**
  72022. * Represents a physics radial explosion event
  72023. */
  72024. class PhysicsRadialExplosionEvent {
  72025. private _scene;
  72026. private _options;
  72027. private _sphere;
  72028. private _dataFetched;
  72029. /**
  72030. * Initializes a radial explosioin event
  72031. * @param _scene BabylonJS scene
  72032. * @param _options The options for the vortex event
  72033. */
  72034. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  72035. /**
  72036. * Returns the data related to the radial explosion event (sphere).
  72037. * @returns The radial explosion event data
  72038. */
  72039. getData(): PhysicsRadialExplosionEventData;
  72040. /**
  72041. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  72042. * @param impostor A physics imposter
  72043. * @param origin the origin of the explosion
  72044. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  72045. */
  72046. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  72047. /**
  72048. * Triggers affecterd impostors callbacks
  72049. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  72050. */
  72051. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  72052. /**
  72053. * Disposes the sphere.
  72054. * @param force Specifies if the sphere should be disposed by force
  72055. */
  72056. dispose(force?: boolean): void;
  72057. /*** Helpers ***/
  72058. private _prepareSphere;
  72059. private _intersectsWithSphere;
  72060. }
  72061. /**
  72062. * Represents a gravitational field event
  72063. */
  72064. class PhysicsGravitationalFieldEvent {
  72065. private _physicsHelper;
  72066. private _scene;
  72067. private _origin;
  72068. private _options;
  72069. private _tickCallback;
  72070. private _sphere;
  72071. private _dataFetched;
  72072. /**
  72073. * Initializes the physics gravitational field event
  72074. * @param _physicsHelper A physics helper
  72075. * @param _scene BabylonJS scene
  72076. * @param _origin The origin position of the gravitational field event
  72077. * @param _options The options for the vortex event
  72078. */
  72079. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  72080. /**
  72081. * Returns the data related to the gravitational field event (sphere).
  72082. * @returns A gravitational field event
  72083. */
  72084. getData(): PhysicsGravitationalFieldEventData;
  72085. /**
  72086. * Enables the gravitational field.
  72087. */
  72088. enable(): void;
  72089. /**
  72090. * Disables the gravitational field.
  72091. */
  72092. disable(): void;
  72093. /**
  72094. * Disposes the sphere.
  72095. * @param force The force to dispose from the gravitational field event
  72096. */
  72097. dispose(force?: boolean): void;
  72098. private _tick;
  72099. }
  72100. /**
  72101. * Represents a physics updraft event
  72102. */
  72103. class PhysicsUpdraftEvent {
  72104. private _scene;
  72105. private _origin;
  72106. private _options;
  72107. private _physicsEngine;
  72108. private _originTop;
  72109. private _originDirection;
  72110. private _tickCallback;
  72111. private _cylinder;
  72112. private _cylinderPosition;
  72113. private _dataFetched;
  72114. /**
  72115. * Initializes the physics updraft event
  72116. * @param _scene BabylonJS scene
  72117. * @param _origin The origin position of the updraft
  72118. * @param _options The options for the updraft event
  72119. */
  72120. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  72121. /**
  72122. * Returns the data related to the updraft event (cylinder).
  72123. * @returns A physics updraft event
  72124. */
  72125. getData(): PhysicsUpdraftEventData;
  72126. /**
  72127. * Enables the updraft.
  72128. */
  72129. enable(): void;
  72130. /**
  72131. * Disables the updraft.
  72132. */
  72133. disable(): void;
  72134. /**
  72135. * Disposes the cylinder.
  72136. * @param force Specifies if the updraft should be disposed by force
  72137. */
  72138. dispose(force?: boolean): void;
  72139. private getImpostorHitData;
  72140. private _tick;
  72141. /*** Helpers ***/
  72142. private _prepareCylinder;
  72143. private _intersectsWithCylinder;
  72144. }
  72145. /**
  72146. * Represents a physics vortex event
  72147. */
  72148. class PhysicsVortexEvent {
  72149. private _scene;
  72150. private _origin;
  72151. private _options;
  72152. private _physicsEngine;
  72153. private _originTop;
  72154. private _tickCallback;
  72155. private _cylinder;
  72156. private _cylinderPosition;
  72157. private _dataFetched;
  72158. /**
  72159. * Initializes the physics vortex event
  72160. * @param _scene The BabylonJS scene
  72161. * @param _origin The origin position of the vortex
  72162. * @param _options The options for the vortex event
  72163. */
  72164. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  72165. /**
  72166. * Returns the data related to the vortex event (cylinder).
  72167. * @returns The physics vortex event data
  72168. */
  72169. getData(): PhysicsVortexEventData;
  72170. /**
  72171. * Enables the vortex.
  72172. */
  72173. enable(): void;
  72174. /**
  72175. * Disables the cortex.
  72176. */
  72177. disable(): void;
  72178. /**
  72179. * Disposes the sphere.
  72180. * @param force
  72181. */
  72182. dispose(force?: boolean): void;
  72183. private getImpostorHitData;
  72184. private _tick;
  72185. /*** Helpers ***/
  72186. private _prepareCylinder;
  72187. private _intersectsWithCylinder;
  72188. }
  72189. /**
  72190. * Options fot the radial explosion event
  72191. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72192. */
  72193. export class PhysicsRadialExplosionEventOptions {
  72194. /**
  72195. * The radius of the sphere for the radial explosion.
  72196. */
  72197. radius: number;
  72198. /**
  72199. * The strenth of the explosion.
  72200. */
  72201. strength: number;
  72202. /**
  72203. * The strenght of the force in correspondence to the distance of the affected object
  72204. */
  72205. falloff: PhysicsRadialImpulseFalloff;
  72206. /**
  72207. * Sphere options for the radial explosion.
  72208. */
  72209. sphere: {
  72210. segments: number;
  72211. diameter: number;
  72212. };
  72213. /**
  72214. * Sphere options for the radial explosion.
  72215. */
  72216. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  72217. }
  72218. /**
  72219. * Options fot the updraft event
  72220. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72221. */
  72222. export class PhysicsUpdraftEventOptions {
  72223. /**
  72224. * The radius of the cylinder for the vortex
  72225. */
  72226. radius: number;
  72227. /**
  72228. * The strenth of the updraft.
  72229. */
  72230. strength: number;
  72231. /**
  72232. * The height of the cylinder for the updraft.
  72233. */
  72234. height: number;
  72235. /**
  72236. * The mode for the the updraft.
  72237. */
  72238. updraftMode: PhysicsUpdraftMode;
  72239. }
  72240. /**
  72241. * Options fot the vortex event
  72242. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72243. */
  72244. export class PhysicsVortexEventOptions {
  72245. /**
  72246. * The radius of the cylinder for the vortex
  72247. */
  72248. radius: number;
  72249. /**
  72250. * The strenth of the vortex.
  72251. */
  72252. strength: number;
  72253. /**
  72254. * The height of the cylinder for the vortex.
  72255. */
  72256. height: number;
  72257. /**
  72258. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  72259. */
  72260. centripetalForceThreshold: number;
  72261. /**
  72262. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  72263. */
  72264. centripetalForceMultiplier: number;
  72265. /**
  72266. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  72267. */
  72268. centrifugalForceMultiplier: number;
  72269. /**
  72270. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  72271. */
  72272. updraftForceMultiplier: number;
  72273. }
  72274. /**
  72275. * The strenght of the force in correspondence to the distance of the affected object
  72276. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72277. */
  72278. export enum PhysicsRadialImpulseFalloff {
  72279. /** Defines that impulse is constant in strength across it's whole radius */
  72280. Constant = 0,
  72281. /** Defines that impulse gets weaker if it's further from the origin */
  72282. Linear = 1
  72283. }
  72284. /**
  72285. * The strength of the force in correspondence to the distance of the affected object
  72286. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72287. */
  72288. export enum PhysicsUpdraftMode {
  72289. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  72290. Center = 0,
  72291. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  72292. Perpendicular = 1
  72293. }
  72294. /**
  72295. * Interface for a physics hit data
  72296. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72297. */
  72298. export interface PhysicsHitData {
  72299. /**
  72300. * The force applied at the contact point
  72301. */
  72302. force: Vector3;
  72303. /**
  72304. * The contact point
  72305. */
  72306. contactPoint: Vector3;
  72307. /**
  72308. * The distance from the origin to the contact point
  72309. */
  72310. distanceFromOrigin: number;
  72311. }
  72312. /**
  72313. * Interface for radial explosion event data
  72314. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72315. */
  72316. export interface PhysicsRadialExplosionEventData {
  72317. /**
  72318. * A sphere used for the radial explosion event
  72319. */
  72320. sphere: Mesh;
  72321. }
  72322. /**
  72323. * Interface for gravitational field event data
  72324. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72325. */
  72326. export interface PhysicsGravitationalFieldEventData {
  72327. /**
  72328. * A sphere mesh used for the gravitational field event
  72329. */
  72330. sphere: Mesh;
  72331. }
  72332. /**
  72333. * Interface for updraft event data
  72334. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72335. */
  72336. export interface PhysicsUpdraftEventData {
  72337. /**
  72338. * A cylinder used for the updraft event
  72339. */
  72340. cylinder: Mesh;
  72341. }
  72342. /**
  72343. * Interface for vortex event data
  72344. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72345. */
  72346. export interface PhysicsVortexEventData {
  72347. /**
  72348. * A cylinder used for the vortex event
  72349. */
  72350. cylinder: Mesh;
  72351. }
  72352. /**
  72353. * Interface for an affected physics impostor
  72354. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72355. */
  72356. export interface PhysicsAffectedImpostorWithData {
  72357. /**
  72358. * The impostor affected by the effect
  72359. */
  72360. impostor: PhysicsImpostor;
  72361. /**
  72362. * The data about the hit/horce from the explosion
  72363. */
  72364. hitData: PhysicsHitData;
  72365. }
  72366. }
  72367. declare module "babylonjs/Physics/Plugins/index" {
  72368. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  72369. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  72370. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  72371. }
  72372. declare module "babylonjs/Physics/index" {
  72373. export * from "babylonjs/Physics/IPhysicsEngine";
  72374. export * from "babylonjs/Physics/physicsEngine";
  72375. export * from "babylonjs/Physics/physicsEngineComponent";
  72376. export * from "babylonjs/Physics/physicsHelper";
  72377. export * from "babylonjs/Physics/physicsImpostor";
  72378. export * from "babylonjs/Physics/physicsJoint";
  72379. export * from "babylonjs/Physics/Plugins/index";
  72380. }
  72381. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  72382. /** @hidden */
  72383. export var blackAndWhitePixelShader: {
  72384. name: string;
  72385. shader: string;
  72386. };
  72387. }
  72388. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  72389. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72390. import { Camera } from "babylonjs/Cameras/camera";
  72391. import { Engine } from "babylonjs/Engines/engine";
  72392. import "babylonjs/Shaders/blackAndWhite.fragment";
  72393. import { Nullable } from "babylonjs/types";
  72394. import { Scene } from "babylonjs/scene";
  72395. /**
  72396. * Post process used to render in black and white
  72397. */
  72398. export class BlackAndWhitePostProcess extends PostProcess {
  72399. /**
  72400. * Linear about to convert he result to black and white (default: 1)
  72401. */
  72402. degree: number;
  72403. /**
  72404. * Gets a string identifying the name of the class
  72405. * @returns "BlackAndWhitePostProcess" string
  72406. */
  72407. getClassName(): string;
  72408. /**
  72409. * Creates a black and white post process
  72410. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  72411. * @param name The name of the effect.
  72412. * @param options The required width/height ratio to downsize to before computing the render pass.
  72413. * @param camera The camera to apply the render pass to.
  72414. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72415. * @param engine The engine which the post process will be applied. (default: current engine)
  72416. * @param reusable If the post process can be reused on the same frame. (default: false)
  72417. */
  72418. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72419. /** @hidden */
  72420. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  72421. }
  72422. }
  72423. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  72424. import { Nullable } from "babylonjs/types";
  72425. import { Camera } from "babylonjs/Cameras/camera";
  72426. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72427. import { Engine } from "babylonjs/Engines/engine";
  72428. /**
  72429. * This represents a set of one or more post processes in Babylon.
  72430. * A post process can be used to apply a shader to a texture after it is rendered.
  72431. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72432. */
  72433. export class PostProcessRenderEffect {
  72434. private _postProcesses;
  72435. private _getPostProcesses;
  72436. private _singleInstance;
  72437. private _cameras;
  72438. private _indicesForCamera;
  72439. /**
  72440. * Name of the effect
  72441. * @hidden
  72442. */
  72443. _name: string;
  72444. /**
  72445. * Instantiates a post process render effect.
  72446. * A post process can be used to apply a shader to a texture after it is rendered.
  72447. * @param engine The engine the effect is tied to
  72448. * @param name The name of the effect
  72449. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  72450. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  72451. */
  72452. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  72453. /**
  72454. * Checks if all the post processes in the effect are supported.
  72455. */
  72456. get isSupported(): boolean;
  72457. /**
  72458. * Updates the current state of the effect
  72459. * @hidden
  72460. */
  72461. _update(): void;
  72462. /**
  72463. * Attaches the effect on cameras
  72464. * @param cameras The camera to attach to.
  72465. * @hidden
  72466. */
  72467. _attachCameras(cameras: Camera): void;
  72468. /**
  72469. * Attaches the effect on cameras
  72470. * @param cameras The camera to attach to.
  72471. * @hidden
  72472. */
  72473. _attachCameras(cameras: Camera[]): void;
  72474. /**
  72475. * Detaches the effect on cameras
  72476. * @param cameras The camera to detatch from.
  72477. * @hidden
  72478. */
  72479. _detachCameras(cameras: Camera): void;
  72480. /**
  72481. * Detatches the effect on cameras
  72482. * @param cameras The camera to detatch from.
  72483. * @hidden
  72484. */
  72485. _detachCameras(cameras: Camera[]): void;
  72486. /**
  72487. * Enables the effect on given cameras
  72488. * @param cameras The camera to enable.
  72489. * @hidden
  72490. */
  72491. _enable(cameras: Camera): void;
  72492. /**
  72493. * Enables the effect on given cameras
  72494. * @param cameras The camera to enable.
  72495. * @hidden
  72496. */
  72497. _enable(cameras: Nullable<Camera[]>): void;
  72498. /**
  72499. * Disables the effect on the given cameras
  72500. * @param cameras The camera to disable.
  72501. * @hidden
  72502. */
  72503. _disable(cameras: Camera): void;
  72504. /**
  72505. * Disables the effect on the given cameras
  72506. * @param cameras The camera to disable.
  72507. * @hidden
  72508. */
  72509. _disable(cameras: Nullable<Camera[]>): void;
  72510. /**
  72511. * Gets a list of the post processes contained in the effect.
  72512. * @param camera The camera to get the post processes on.
  72513. * @returns The list of the post processes in the effect.
  72514. */
  72515. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  72516. }
  72517. }
  72518. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  72519. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  72520. /** @hidden */
  72521. export var extractHighlightsPixelShader: {
  72522. name: string;
  72523. shader: string;
  72524. };
  72525. }
  72526. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  72527. import { Nullable } from "babylonjs/types";
  72528. import { Camera } from "babylonjs/Cameras/camera";
  72529. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72530. import { Engine } from "babylonjs/Engines/engine";
  72531. import "babylonjs/Shaders/extractHighlights.fragment";
  72532. /**
  72533. * 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.
  72534. */
  72535. export class ExtractHighlightsPostProcess extends PostProcess {
  72536. /**
  72537. * The luminance threshold, pixels below this value will be set to black.
  72538. */
  72539. threshold: number;
  72540. /** @hidden */
  72541. _exposure: number;
  72542. /**
  72543. * Post process which has the input texture to be used when performing highlight extraction
  72544. * @hidden
  72545. */
  72546. _inputPostProcess: Nullable<PostProcess>;
  72547. /**
  72548. * Gets a string identifying the name of the class
  72549. * @returns "ExtractHighlightsPostProcess" string
  72550. */
  72551. getClassName(): string;
  72552. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72553. }
  72554. }
  72555. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  72556. /** @hidden */
  72557. export var bloomMergePixelShader: {
  72558. name: string;
  72559. shader: string;
  72560. };
  72561. }
  72562. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  72563. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72564. import { Nullable } from "babylonjs/types";
  72565. import { Engine } from "babylonjs/Engines/engine";
  72566. import { Camera } from "babylonjs/Cameras/camera";
  72567. import "babylonjs/Shaders/bloomMerge.fragment";
  72568. /**
  72569. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  72570. */
  72571. export class BloomMergePostProcess extends PostProcess {
  72572. /** Weight of the bloom to be added to the original input. */
  72573. weight: number;
  72574. /**
  72575. * Gets a string identifying the name of the class
  72576. * @returns "BloomMergePostProcess" string
  72577. */
  72578. getClassName(): string;
  72579. /**
  72580. * Creates a new instance of @see BloomMergePostProcess
  72581. * @param name The name of the effect.
  72582. * @param originalFromInput Post process which's input will be used for the merge.
  72583. * @param blurred Blurred highlights post process which's output will be used.
  72584. * @param weight Weight of the bloom to be added to the original input.
  72585. * @param options The required width/height ratio to downsize to before computing the render pass.
  72586. * @param camera The camera to apply the render pass to.
  72587. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72588. * @param engine The engine which the post process will be applied. (default: current engine)
  72589. * @param reusable If the post process can be reused on the same frame. (default: false)
  72590. * @param textureType Type of textures used when performing the post process. (default: 0)
  72591. * @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)
  72592. */
  72593. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  72594. /** Weight of the bloom to be added to the original input. */
  72595. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72596. }
  72597. }
  72598. declare module "babylonjs/PostProcesses/bloomEffect" {
  72599. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  72600. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72601. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  72602. import { Camera } from "babylonjs/Cameras/camera";
  72603. import { Scene } from "babylonjs/scene";
  72604. /**
  72605. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  72606. */
  72607. export class BloomEffect extends PostProcessRenderEffect {
  72608. private bloomScale;
  72609. /**
  72610. * @hidden Internal
  72611. */
  72612. _effects: Array<PostProcess>;
  72613. /**
  72614. * @hidden Internal
  72615. */
  72616. _downscale: ExtractHighlightsPostProcess;
  72617. private _blurX;
  72618. private _blurY;
  72619. private _merge;
  72620. /**
  72621. * The luminance threshold to find bright areas of the image to bloom.
  72622. */
  72623. get threshold(): number;
  72624. set threshold(value: number);
  72625. /**
  72626. * The strength of the bloom.
  72627. */
  72628. get weight(): number;
  72629. set weight(value: number);
  72630. /**
  72631. * Specifies the size of the bloom blur kernel, relative to the final output size
  72632. */
  72633. get kernel(): number;
  72634. set kernel(value: number);
  72635. /**
  72636. * Creates a new instance of @see BloomEffect
  72637. * @param scene The scene the effect belongs to.
  72638. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  72639. * @param bloomKernel The size of the kernel to be used when applying the blur.
  72640. * @param bloomWeight The the strength of bloom.
  72641. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  72642. * @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)
  72643. */
  72644. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  72645. /**
  72646. * Disposes each of the internal effects for a given camera.
  72647. * @param camera The camera to dispose the effect on.
  72648. */
  72649. disposeEffects(camera: Camera): void;
  72650. /**
  72651. * @hidden Internal
  72652. */
  72653. _updateEffects(): void;
  72654. /**
  72655. * Internal
  72656. * @returns if all the contained post processes are ready.
  72657. * @hidden
  72658. */
  72659. _isReady(): boolean;
  72660. }
  72661. }
  72662. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  72663. /** @hidden */
  72664. export var chromaticAberrationPixelShader: {
  72665. name: string;
  72666. shader: string;
  72667. };
  72668. }
  72669. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  72670. import { Vector2 } from "babylonjs/Maths/math.vector";
  72671. import { Nullable } from "babylonjs/types";
  72672. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72673. import { Camera } from "babylonjs/Cameras/camera";
  72674. import { Engine } from "babylonjs/Engines/engine";
  72675. import "babylonjs/Shaders/chromaticAberration.fragment";
  72676. import { Scene } from "babylonjs/scene";
  72677. /**
  72678. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  72679. */
  72680. export class ChromaticAberrationPostProcess extends PostProcess {
  72681. /**
  72682. * The amount of seperation of rgb channels (default: 30)
  72683. */
  72684. aberrationAmount: number;
  72685. /**
  72686. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  72687. */
  72688. radialIntensity: number;
  72689. /**
  72690. * 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))
  72691. */
  72692. direction: Vector2;
  72693. /**
  72694. * 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))
  72695. */
  72696. centerPosition: Vector2;
  72697. /** The width of the screen to apply the effect on */
  72698. screenWidth: number;
  72699. /** The height of the screen to apply the effect on */
  72700. screenHeight: number;
  72701. /**
  72702. * Gets a string identifying the name of the class
  72703. * @returns "ChromaticAberrationPostProcess" string
  72704. */
  72705. getClassName(): string;
  72706. /**
  72707. * Creates a new instance ChromaticAberrationPostProcess
  72708. * @param name The name of the effect.
  72709. * @param screenWidth The width of the screen to apply the effect on.
  72710. * @param screenHeight The height of the screen to apply the effect on.
  72711. * @param options The required width/height ratio to downsize to before computing the render pass.
  72712. * @param camera The camera to apply the render pass to.
  72713. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72714. * @param engine The engine which the post process will be applied. (default: current engine)
  72715. * @param reusable If the post process can be reused on the same frame. (default: false)
  72716. * @param textureType Type of textures used when performing the post process. (default: 0)
  72717. * @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)
  72718. */
  72719. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72720. /** @hidden */
  72721. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  72722. }
  72723. }
  72724. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  72725. /** @hidden */
  72726. export var circleOfConfusionPixelShader: {
  72727. name: string;
  72728. shader: string;
  72729. };
  72730. }
  72731. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  72732. import { Nullable } from "babylonjs/types";
  72733. import { Engine } from "babylonjs/Engines/engine";
  72734. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72735. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  72736. import { Camera } from "babylonjs/Cameras/camera";
  72737. import "babylonjs/Shaders/circleOfConfusion.fragment";
  72738. /**
  72739. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  72740. */
  72741. export class CircleOfConfusionPostProcess extends PostProcess {
  72742. /**
  72743. * 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.
  72744. */
  72745. lensSize: number;
  72746. /**
  72747. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  72748. */
  72749. fStop: number;
  72750. /**
  72751. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  72752. */
  72753. focusDistance: number;
  72754. /**
  72755. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  72756. */
  72757. focalLength: number;
  72758. /**
  72759. * Gets a string identifying the name of the class
  72760. * @returns "CircleOfConfusionPostProcess" string
  72761. */
  72762. getClassName(): string;
  72763. private _depthTexture;
  72764. /**
  72765. * Creates a new instance CircleOfConfusionPostProcess
  72766. * @param name The name of the effect.
  72767. * @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.
  72768. * @param options The required width/height ratio to downsize to before computing the render pass.
  72769. * @param camera The camera to apply the render pass to.
  72770. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72771. * @param engine The engine which the post process will be applied. (default: current engine)
  72772. * @param reusable If the post process can be reused on the same frame. (default: false)
  72773. * @param textureType Type of textures used when performing the post process. (default: 0)
  72774. * @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)
  72775. */
  72776. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72777. /**
  72778. * 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.
  72779. */
  72780. set depthTexture(value: RenderTargetTexture);
  72781. }
  72782. }
  72783. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  72784. /** @hidden */
  72785. export var colorCorrectionPixelShader: {
  72786. name: string;
  72787. shader: string;
  72788. };
  72789. }
  72790. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  72791. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72792. import { Engine } from "babylonjs/Engines/engine";
  72793. import { Camera } from "babylonjs/Cameras/camera";
  72794. import "babylonjs/Shaders/colorCorrection.fragment";
  72795. import { Nullable } from "babylonjs/types";
  72796. import { Scene } from "babylonjs/scene";
  72797. /**
  72798. *
  72799. * This post-process allows the modification of rendered colors by using
  72800. * a 'look-up table' (LUT). This effect is also called Color Grading.
  72801. *
  72802. * The object needs to be provided an url to a texture containing the color
  72803. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  72804. * Use an image editing software to tweak the LUT to match your needs.
  72805. *
  72806. * For an example of a color LUT, see here:
  72807. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  72808. * For explanations on color grading, see here:
  72809. * @see http://udn.epicgames.com/Three/ColorGrading.html
  72810. *
  72811. */
  72812. export class ColorCorrectionPostProcess extends PostProcess {
  72813. private _colorTableTexture;
  72814. /**
  72815. * Gets the color table url used to create the LUT texture
  72816. */
  72817. colorTableUrl: string;
  72818. /**
  72819. * Gets a string identifying the name of the class
  72820. * @returns "ColorCorrectionPostProcess" string
  72821. */
  72822. getClassName(): string;
  72823. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72824. /** @hidden */
  72825. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  72826. }
  72827. }
  72828. declare module "babylonjs/Shaders/convolution.fragment" {
  72829. /** @hidden */
  72830. export var convolutionPixelShader: {
  72831. name: string;
  72832. shader: string;
  72833. };
  72834. }
  72835. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  72836. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72837. import { Nullable } from "babylonjs/types";
  72838. import { Camera } from "babylonjs/Cameras/camera";
  72839. import { Engine } from "babylonjs/Engines/engine";
  72840. import "babylonjs/Shaders/convolution.fragment";
  72841. import { Scene } from "babylonjs/scene";
  72842. /**
  72843. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  72844. * input texture to perform effects such as edge detection or sharpening
  72845. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  72846. */
  72847. export class ConvolutionPostProcess extends PostProcess {
  72848. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  72849. kernel: number[];
  72850. /**
  72851. * Gets a string identifying the name of the class
  72852. * @returns "ConvolutionPostProcess" string
  72853. */
  72854. getClassName(): string;
  72855. /**
  72856. * Creates a new instance ConvolutionPostProcess
  72857. * @param name The name of the effect.
  72858. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  72859. * @param options The required width/height ratio to downsize to before computing the render pass.
  72860. * @param camera The camera to apply the render pass to.
  72861. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72862. * @param engine The engine which the post process will be applied. (default: current engine)
  72863. * @param reusable If the post process can be reused on the same frame. (default: false)
  72864. * @param textureType Type of textures used when performing the post process. (default: 0)
  72865. */
  72866. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  72867. /** @hidden */
  72868. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  72869. /**
  72870. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72871. */
  72872. static EdgeDetect0Kernel: number[];
  72873. /**
  72874. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72875. */
  72876. static EdgeDetect1Kernel: number[];
  72877. /**
  72878. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72879. */
  72880. static EdgeDetect2Kernel: number[];
  72881. /**
  72882. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72883. */
  72884. static SharpenKernel: number[];
  72885. /**
  72886. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72887. */
  72888. static EmbossKernel: number[];
  72889. /**
  72890. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72891. */
  72892. static GaussianKernel: number[];
  72893. }
  72894. }
  72895. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  72896. import { Nullable } from "babylonjs/types";
  72897. import { Vector2 } from "babylonjs/Maths/math.vector";
  72898. import { Camera } from "babylonjs/Cameras/camera";
  72899. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72900. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  72901. import { Engine } from "babylonjs/Engines/engine";
  72902. import { Scene } from "babylonjs/scene";
  72903. /**
  72904. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  72905. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  72906. * based on samples that have a large difference in distance than the center pixel.
  72907. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  72908. */
  72909. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  72910. /**
  72911. * The direction the blur should be applied
  72912. */
  72913. direction: Vector2;
  72914. /**
  72915. * Gets a string identifying the name of the class
  72916. * @returns "DepthOfFieldBlurPostProcess" string
  72917. */
  72918. getClassName(): string;
  72919. /**
  72920. * Creates a new instance CircleOfConfusionPostProcess
  72921. * @param name The name of the effect.
  72922. * @param scene The scene the effect belongs to.
  72923. * @param direction The direction the blur should be applied.
  72924. * @param kernel The size of the kernel used to blur.
  72925. * @param options The required width/height ratio to downsize to before computing the render pass.
  72926. * @param camera The camera to apply the render pass to.
  72927. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  72928. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  72929. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72930. * @param engine The engine which the post process will be applied. (default: current engine)
  72931. * @param reusable If the post process can be reused on the same frame. (default: false)
  72932. * @param textureType Type of textures used when performing the post process. (default: 0)
  72933. * @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)
  72934. */
  72935. 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);
  72936. }
  72937. }
  72938. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  72939. /** @hidden */
  72940. export var depthOfFieldMergePixelShader: {
  72941. name: string;
  72942. shader: string;
  72943. };
  72944. }
  72945. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  72946. import { Nullable } from "babylonjs/types";
  72947. import { Camera } from "babylonjs/Cameras/camera";
  72948. import { Effect } from "babylonjs/Materials/effect";
  72949. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72950. import { Engine } from "babylonjs/Engines/engine";
  72951. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  72952. /**
  72953. * Options to be set when merging outputs from the default pipeline.
  72954. */
  72955. export class DepthOfFieldMergePostProcessOptions {
  72956. /**
  72957. * The original image to merge on top of
  72958. */
  72959. originalFromInput: PostProcess;
  72960. /**
  72961. * Parameters to perform the merge of the depth of field effect
  72962. */
  72963. depthOfField?: {
  72964. circleOfConfusion: PostProcess;
  72965. blurSteps: Array<PostProcess>;
  72966. };
  72967. /**
  72968. * Parameters to perform the merge of bloom effect
  72969. */
  72970. bloom?: {
  72971. blurred: PostProcess;
  72972. weight: number;
  72973. };
  72974. }
  72975. /**
  72976. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  72977. */
  72978. export class DepthOfFieldMergePostProcess extends PostProcess {
  72979. private blurSteps;
  72980. /**
  72981. * Gets a string identifying the name of the class
  72982. * @returns "DepthOfFieldMergePostProcess" string
  72983. */
  72984. getClassName(): string;
  72985. /**
  72986. * Creates a new instance of DepthOfFieldMergePostProcess
  72987. * @param name The name of the effect.
  72988. * @param originalFromInput Post process which's input will be used for the merge.
  72989. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  72990. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  72991. * @param options The required width/height ratio to downsize to before computing the render pass.
  72992. * @param camera The camera to apply the render pass to.
  72993. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72994. * @param engine The engine which the post process will be applied. (default: current engine)
  72995. * @param reusable If the post process can be reused on the same frame. (default: false)
  72996. * @param textureType Type of textures used when performing the post process. (default: 0)
  72997. * @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)
  72998. */
  72999. 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);
  73000. /**
  73001. * Updates the effect with the current post process compile time values and recompiles the shader.
  73002. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  73003. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  73004. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  73005. * @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
  73006. * @param onCompiled Called when the shader has been compiled.
  73007. * @param onError Called if there is an error when compiling a shader.
  73008. */
  73009. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  73010. }
  73011. }
  73012. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  73013. import { Nullable } from "babylonjs/types";
  73014. import { Camera } from "babylonjs/Cameras/camera";
  73015. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  73016. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73017. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  73018. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  73019. import { Scene } from "babylonjs/scene";
  73020. /**
  73021. * Specifies the level of max blur that should be applied when using the depth of field effect
  73022. */
  73023. export enum DepthOfFieldEffectBlurLevel {
  73024. /**
  73025. * Subtle blur
  73026. */
  73027. Low = 0,
  73028. /**
  73029. * Medium blur
  73030. */
  73031. Medium = 1,
  73032. /**
  73033. * Large blur
  73034. */
  73035. High = 2
  73036. }
  73037. /**
  73038. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  73039. */
  73040. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  73041. private _circleOfConfusion;
  73042. /**
  73043. * @hidden Internal, blurs from high to low
  73044. */
  73045. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  73046. private _depthOfFieldBlurY;
  73047. private _dofMerge;
  73048. /**
  73049. * @hidden Internal post processes in depth of field effect
  73050. */
  73051. _effects: Array<PostProcess>;
  73052. /**
  73053. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  73054. */
  73055. set focalLength(value: number);
  73056. get focalLength(): number;
  73057. /**
  73058. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  73059. */
  73060. set fStop(value: number);
  73061. get fStop(): number;
  73062. /**
  73063. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  73064. */
  73065. set focusDistance(value: number);
  73066. get focusDistance(): number;
  73067. /**
  73068. * 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.
  73069. */
  73070. set lensSize(value: number);
  73071. get lensSize(): number;
  73072. /**
  73073. * Creates a new instance DepthOfFieldEffect
  73074. * @param scene The scene the effect belongs to.
  73075. * @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.
  73076. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  73077. * @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)
  73078. */
  73079. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  73080. /**
  73081. * Get the current class name of the current effet
  73082. * @returns "DepthOfFieldEffect"
  73083. */
  73084. getClassName(): string;
  73085. /**
  73086. * 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.
  73087. */
  73088. set depthTexture(value: RenderTargetTexture);
  73089. /**
  73090. * Disposes each of the internal effects for a given camera.
  73091. * @param camera The camera to dispose the effect on.
  73092. */
  73093. disposeEffects(camera: Camera): void;
  73094. /**
  73095. * @hidden Internal
  73096. */
  73097. _updateEffects(): void;
  73098. /**
  73099. * Internal
  73100. * @returns if all the contained post processes are ready.
  73101. * @hidden
  73102. */
  73103. _isReady(): boolean;
  73104. }
  73105. }
  73106. declare module "babylonjs/Shaders/displayPass.fragment" {
  73107. /** @hidden */
  73108. export var displayPassPixelShader: {
  73109. name: string;
  73110. shader: string;
  73111. };
  73112. }
  73113. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  73114. import { Nullable } from "babylonjs/types";
  73115. import { Camera } from "babylonjs/Cameras/camera";
  73116. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73117. import { Engine } from "babylonjs/Engines/engine";
  73118. import "babylonjs/Shaders/displayPass.fragment";
  73119. import { Scene } from "babylonjs/scene";
  73120. /**
  73121. * DisplayPassPostProcess which produces an output the same as it's input
  73122. */
  73123. export class DisplayPassPostProcess extends PostProcess {
  73124. /**
  73125. * Gets a string identifying the name of the class
  73126. * @returns "DisplayPassPostProcess" string
  73127. */
  73128. getClassName(): string;
  73129. /**
  73130. * Creates the DisplayPassPostProcess
  73131. * @param name The name of the effect.
  73132. * @param options The required width/height ratio to downsize to before computing the render pass.
  73133. * @param camera The camera to apply the render pass to.
  73134. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73135. * @param engine The engine which the post process will be applied. (default: current engine)
  73136. * @param reusable If the post process can be reused on the same frame. (default: false)
  73137. */
  73138. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73139. /** @hidden */
  73140. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  73141. }
  73142. }
  73143. declare module "babylonjs/Shaders/filter.fragment" {
  73144. /** @hidden */
  73145. export var filterPixelShader: {
  73146. name: string;
  73147. shader: string;
  73148. };
  73149. }
  73150. declare module "babylonjs/PostProcesses/filterPostProcess" {
  73151. import { Nullable } from "babylonjs/types";
  73152. import { Matrix } from "babylonjs/Maths/math.vector";
  73153. import { Camera } from "babylonjs/Cameras/camera";
  73154. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73155. import { Engine } from "babylonjs/Engines/engine";
  73156. import "babylonjs/Shaders/filter.fragment";
  73157. import { Scene } from "babylonjs/scene";
  73158. /**
  73159. * Applies a kernel filter to the image
  73160. */
  73161. export class FilterPostProcess extends PostProcess {
  73162. /** The matrix to be applied to the image */
  73163. kernelMatrix: Matrix;
  73164. /**
  73165. * Gets a string identifying the name of the class
  73166. * @returns "FilterPostProcess" string
  73167. */
  73168. getClassName(): string;
  73169. /**
  73170. *
  73171. * @param name The name of the effect.
  73172. * @param kernelMatrix The matrix to be applied to the image
  73173. * @param options The required width/height ratio to downsize to before computing the render pass.
  73174. * @param camera The camera to apply the render pass to.
  73175. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73176. * @param engine The engine which the post process will be applied. (default: current engine)
  73177. * @param reusable If the post process can be reused on the same frame. (default: false)
  73178. */
  73179. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73180. /** @hidden */
  73181. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  73182. }
  73183. }
  73184. declare module "babylonjs/Shaders/fxaa.fragment" {
  73185. /** @hidden */
  73186. export var fxaaPixelShader: {
  73187. name: string;
  73188. shader: string;
  73189. };
  73190. }
  73191. declare module "babylonjs/Shaders/fxaa.vertex" {
  73192. /** @hidden */
  73193. export var fxaaVertexShader: {
  73194. name: string;
  73195. shader: string;
  73196. };
  73197. }
  73198. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  73199. import { Nullable } from "babylonjs/types";
  73200. import { Camera } from "babylonjs/Cameras/camera";
  73201. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73202. import { Engine } from "babylonjs/Engines/engine";
  73203. import "babylonjs/Shaders/fxaa.fragment";
  73204. import "babylonjs/Shaders/fxaa.vertex";
  73205. import { Scene } from "babylonjs/scene";
  73206. /**
  73207. * Fxaa post process
  73208. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  73209. */
  73210. export class FxaaPostProcess extends PostProcess {
  73211. /**
  73212. * Gets a string identifying the name of the class
  73213. * @returns "FxaaPostProcess" string
  73214. */
  73215. getClassName(): string;
  73216. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73217. private _getDefines;
  73218. /** @hidden */
  73219. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  73220. }
  73221. }
  73222. declare module "babylonjs/Shaders/grain.fragment" {
  73223. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  73224. /** @hidden */
  73225. export var grainPixelShader: {
  73226. name: string;
  73227. shader: string;
  73228. };
  73229. }
  73230. declare module "babylonjs/PostProcesses/grainPostProcess" {
  73231. import { Nullable } from "babylonjs/types";
  73232. import { Camera } from "babylonjs/Cameras/camera";
  73233. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73234. import { Engine } from "babylonjs/Engines/engine";
  73235. import "babylonjs/Shaders/grain.fragment";
  73236. import { Scene } from "babylonjs/scene";
  73237. /**
  73238. * The GrainPostProcess adds noise to the image at mid luminance levels
  73239. */
  73240. export class GrainPostProcess extends PostProcess {
  73241. /**
  73242. * The intensity of the grain added (default: 30)
  73243. */
  73244. intensity: number;
  73245. /**
  73246. * If the grain should be randomized on every frame
  73247. */
  73248. animated: boolean;
  73249. /**
  73250. * Gets a string identifying the name of the class
  73251. * @returns "GrainPostProcess" string
  73252. */
  73253. getClassName(): string;
  73254. /**
  73255. * Creates a new instance of @see GrainPostProcess
  73256. * @param name The name of the effect.
  73257. * @param options The required width/height ratio to downsize to before computing the render pass.
  73258. * @param camera The camera to apply the render pass to.
  73259. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73260. * @param engine The engine which the post process will be applied. (default: current engine)
  73261. * @param reusable If the post process can be reused on the same frame. (default: false)
  73262. * @param textureType Type of textures used when performing the post process. (default: 0)
  73263. * @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)
  73264. */
  73265. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73266. /** @hidden */
  73267. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  73268. }
  73269. }
  73270. declare module "babylonjs/Shaders/highlights.fragment" {
  73271. /** @hidden */
  73272. export var highlightsPixelShader: {
  73273. name: string;
  73274. shader: string;
  73275. };
  73276. }
  73277. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  73278. import { Nullable } from "babylonjs/types";
  73279. import { Camera } from "babylonjs/Cameras/camera";
  73280. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73281. import { Engine } from "babylonjs/Engines/engine";
  73282. import "babylonjs/Shaders/highlights.fragment";
  73283. /**
  73284. * Extracts highlights from the image
  73285. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73286. */
  73287. export class HighlightsPostProcess extends PostProcess {
  73288. /**
  73289. * Gets a string identifying the name of the class
  73290. * @returns "HighlightsPostProcess" string
  73291. */
  73292. getClassName(): string;
  73293. /**
  73294. * Extracts highlights from the image
  73295. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73296. * @param name The name of the effect.
  73297. * @param options The required width/height ratio to downsize to before computing the render pass.
  73298. * @param camera The camera to apply the render pass to.
  73299. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73300. * @param engine The engine which the post process will be applied. (default: current engine)
  73301. * @param reusable If the post process can be reused on the same frame. (default: false)
  73302. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  73303. */
  73304. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73305. }
  73306. }
  73307. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  73308. /** @hidden */
  73309. export var mrtFragmentDeclaration: {
  73310. name: string;
  73311. shader: string;
  73312. };
  73313. }
  73314. declare module "babylonjs/Shaders/geometry.fragment" {
  73315. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  73316. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  73317. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  73318. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  73319. /** @hidden */
  73320. export var geometryPixelShader: {
  73321. name: string;
  73322. shader: string;
  73323. };
  73324. }
  73325. declare module "babylonjs/Shaders/geometry.vertex" {
  73326. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  73327. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  73328. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  73329. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  73330. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  73331. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  73332. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  73333. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  73334. /** @hidden */
  73335. export var geometryVertexShader: {
  73336. name: string;
  73337. shader: string;
  73338. };
  73339. }
  73340. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  73341. import { Matrix } from "babylonjs/Maths/math.vector";
  73342. import { SubMesh } from "babylonjs/Meshes/subMesh";
  73343. import { Mesh } from "babylonjs/Meshes/mesh";
  73344. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  73345. import { Effect } from "babylonjs/Materials/effect";
  73346. import { Scene } from "babylonjs/scene";
  73347. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73348. import "babylonjs/Shaders/geometry.fragment";
  73349. import "babylonjs/Shaders/geometry.vertex";
  73350. /** @hidden */
  73351. interface ISavedTransformationMatrix {
  73352. world: Matrix;
  73353. viewProjection: Matrix;
  73354. }
  73355. /**
  73356. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  73357. */
  73358. export class GeometryBufferRenderer {
  73359. /**
  73360. * Constant used to retrieve the position texture index in the G-Buffer textures array
  73361. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  73362. */
  73363. static readonly POSITION_TEXTURE_TYPE: number;
  73364. /**
  73365. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  73366. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  73367. */
  73368. static readonly VELOCITY_TEXTURE_TYPE: number;
  73369. /**
  73370. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  73371. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  73372. */
  73373. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  73374. /**
  73375. * Dictionary used to store the previous transformation matrices of each rendered mesh
  73376. * in order to compute objects velocities when enableVelocity is set to "true"
  73377. * @hidden
  73378. */
  73379. _previousTransformationMatrices: {
  73380. [index: number]: ISavedTransformationMatrix;
  73381. };
  73382. /**
  73383. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  73384. * in order to compute objects velocities when enableVelocity is set to "true"
  73385. * @hidden
  73386. */
  73387. _previousBonesTransformationMatrices: {
  73388. [index: number]: Float32Array;
  73389. };
  73390. /**
  73391. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  73392. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  73393. */
  73394. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  73395. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  73396. renderTransparentMeshes: boolean;
  73397. private _scene;
  73398. private _resizeObserver;
  73399. private _multiRenderTarget;
  73400. private _ratio;
  73401. private _enablePosition;
  73402. private _enableVelocity;
  73403. private _enableReflectivity;
  73404. private _positionIndex;
  73405. private _velocityIndex;
  73406. private _reflectivityIndex;
  73407. protected _effect: Effect;
  73408. protected _cachedDefines: string;
  73409. /**
  73410. * Set the render list (meshes to be rendered) used in the G buffer.
  73411. */
  73412. set renderList(meshes: Mesh[]);
  73413. /**
  73414. * Gets wether or not G buffer are supported by the running hardware.
  73415. * This requires draw buffer supports
  73416. */
  73417. get isSupported(): boolean;
  73418. /**
  73419. * Returns the index of the given texture type in the G-Buffer textures array
  73420. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  73421. * @returns the index of the given texture type in the G-Buffer textures array
  73422. */
  73423. getTextureIndex(textureType: number): number;
  73424. /**
  73425. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  73426. */
  73427. get enablePosition(): boolean;
  73428. /**
  73429. * Sets whether or not objects positions are enabled for the G buffer.
  73430. */
  73431. set enablePosition(enable: boolean);
  73432. /**
  73433. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  73434. */
  73435. get enableVelocity(): boolean;
  73436. /**
  73437. * Sets wether or not objects velocities are enabled for the G buffer.
  73438. */
  73439. set enableVelocity(enable: boolean);
  73440. /**
  73441. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  73442. */
  73443. get enableReflectivity(): boolean;
  73444. /**
  73445. * Sets wether or not objects roughness are enabled for the G buffer.
  73446. */
  73447. set enableReflectivity(enable: boolean);
  73448. /**
  73449. * Gets the scene associated with the buffer.
  73450. */
  73451. get scene(): Scene;
  73452. /**
  73453. * Gets the ratio used by the buffer during its creation.
  73454. * How big is the buffer related to the main canvas.
  73455. */
  73456. get ratio(): number;
  73457. /** @hidden */
  73458. static _SceneComponentInitialization: (scene: Scene) => void;
  73459. /**
  73460. * Creates a new G Buffer for the scene
  73461. * @param scene The scene the buffer belongs to
  73462. * @param ratio How big is the buffer related to the main canvas.
  73463. */
  73464. constructor(scene: Scene, ratio?: number);
  73465. /**
  73466. * Checks wether everything is ready to render a submesh to the G buffer.
  73467. * @param subMesh the submesh to check readiness for
  73468. * @param useInstances is the mesh drawn using instance or not
  73469. * @returns true if ready otherwise false
  73470. */
  73471. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73472. /**
  73473. * Gets the current underlying G Buffer.
  73474. * @returns the buffer
  73475. */
  73476. getGBuffer(): MultiRenderTarget;
  73477. /**
  73478. * Gets the number of samples used to render the buffer (anti aliasing).
  73479. */
  73480. get samples(): number;
  73481. /**
  73482. * Sets the number of samples used to render the buffer (anti aliasing).
  73483. */
  73484. set samples(value: number);
  73485. /**
  73486. * Disposes the renderer and frees up associated resources.
  73487. */
  73488. dispose(): void;
  73489. protected _createRenderTargets(): void;
  73490. private _copyBonesTransformationMatrices;
  73491. }
  73492. }
  73493. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  73494. import { Nullable } from "babylonjs/types";
  73495. import { Scene } from "babylonjs/scene";
  73496. import { ISceneComponent } from "babylonjs/sceneComponent";
  73497. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  73498. module "babylonjs/scene" {
  73499. interface Scene {
  73500. /** @hidden (Backing field) */
  73501. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  73502. /**
  73503. * Gets or Sets the current geometry buffer associated to the scene.
  73504. */
  73505. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  73506. /**
  73507. * Enables a GeometryBufferRender and associates it with the scene
  73508. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  73509. * @returns the GeometryBufferRenderer
  73510. */
  73511. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  73512. /**
  73513. * Disables the GeometryBufferRender associated with the scene
  73514. */
  73515. disableGeometryBufferRenderer(): void;
  73516. }
  73517. }
  73518. /**
  73519. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  73520. * in several rendering techniques.
  73521. */
  73522. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  73523. /**
  73524. * The component name helpful to identify the component in the list of scene components.
  73525. */
  73526. readonly name: string;
  73527. /**
  73528. * The scene the component belongs to.
  73529. */
  73530. scene: Scene;
  73531. /**
  73532. * Creates a new instance of the component for the given scene
  73533. * @param scene Defines the scene to register the component in
  73534. */
  73535. constructor(scene: Scene);
  73536. /**
  73537. * Registers the component in a given scene
  73538. */
  73539. register(): void;
  73540. /**
  73541. * Rebuilds the elements related to this component in case of
  73542. * context lost for instance.
  73543. */
  73544. rebuild(): void;
  73545. /**
  73546. * Disposes the component and the associated ressources
  73547. */
  73548. dispose(): void;
  73549. private _gatherRenderTargets;
  73550. }
  73551. }
  73552. declare module "babylonjs/Shaders/motionBlur.fragment" {
  73553. /** @hidden */
  73554. export var motionBlurPixelShader: {
  73555. name: string;
  73556. shader: string;
  73557. };
  73558. }
  73559. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  73560. import { Nullable } from "babylonjs/types";
  73561. import { Camera } from "babylonjs/Cameras/camera";
  73562. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73563. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73564. import "babylonjs/Animations/animatable";
  73565. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  73566. import "babylonjs/Shaders/motionBlur.fragment";
  73567. import { Engine } from "babylonjs/Engines/engine";
  73568. import { Scene } from "babylonjs/scene";
  73569. /**
  73570. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  73571. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  73572. * As an example, all you have to do is to create the post-process:
  73573. * var mb = new BABYLON.MotionBlurPostProcess(
  73574. * 'mb', // The name of the effect.
  73575. * scene, // The scene containing the objects to blur according to their velocity.
  73576. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  73577. * camera // The camera to apply the render pass to.
  73578. * );
  73579. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  73580. */
  73581. export class MotionBlurPostProcess extends PostProcess {
  73582. /**
  73583. * Defines how much the image is blurred by the movement. Default value is equal to 1
  73584. */
  73585. motionStrength: number;
  73586. /**
  73587. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  73588. */
  73589. get motionBlurSamples(): number;
  73590. /**
  73591. * Sets the number of iterations to be used for motion blur quality
  73592. */
  73593. set motionBlurSamples(samples: number);
  73594. private _motionBlurSamples;
  73595. private _geometryBufferRenderer;
  73596. /**
  73597. * Gets a string identifying the name of the class
  73598. * @returns "MotionBlurPostProcess" string
  73599. */
  73600. getClassName(): string;
  73601. /**
  73602. * Creates a new instance MotionBlurPostProcess
  73603. * @param name The name of the effect.
  73604. * @param scene The scene containing the objects to blur according to their velocity.
  73605. * @param options The required width/height ratio to downsize to before computing the render pass.
  73606. * @param camera The camera to apply the render pass to.
  73607. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73608. * @param engine The engine which the post process will be applied. (default: current engine)
  73609. * @param reusable If the post process can be reused on the same frame. (default: false)
  73610. * @param textureType Type of textures used when performing the post process. (default: 0)
  73611. * @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)
  73612. */
  73613. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73614. /**
  73615. * Excludes the given skinned mesh from computing bones velocities.
  73616. * 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.
  73617. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  73618. */
  73619. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  73620. /**
  73621. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  73622. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  73623. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  73624. */
  73625. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  73626. /**
  73627. * Disposes the post process.
  73628. * @param camera The camera to dispose the post process on.
  73629. */
  73630. dispose(camera?: Camera): void;
  73631. /** @hidden */
  73632. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  73633. }
  73634. }
  73635. declare module "babylonjs/Shaders/refraction.fragment" {
  73636. /** @hidden */
  73637. export var refractionPixelShader: {
  73638. name: string;
  73639. shader: string;
  73640. };
  73641. }
  73642. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  73643. import { Color3 } from "babylonjs/Maths/math.color";
  73644. import { Camera } from "babylonjs/Cameras/camera";
  73645. import { Texture } from "babylonjs/Materials/Textures/texture";
  73646. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73647. import { Engine } from "babylonjs/Engines/engine";
  73648. import "babylonjs/Shaders/refraction.fragment";
  73649. import { Scene } from "babylonjs/scene";
  73650. /**
  73651. * Post process which applies a refractin texture
  73652. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  73653. */
  73654. export class RefractionPostProcess extends PostProcess {
  73655. private _refTexture;
  73656. private _ownRefractionTexture;
  73657. /** the base color of the refraction (used to taint the rendering) */
  73658. color: Color3;
  73659. /** simulated refraction depth */
  73660. depth: number;
  73661. /** the coefficient of the base color (0 to remove base color tainting) */
  73662. colorLevel: number;
  73663. /** Gets the url used to load the refraction texture */
  73664. refractionTextureUrl: string;
  73665. /**
  73666. * Gets or sets the refraction texture
  73667. * Please note that you are responsible for disposing the texture if you set it manually
  73668. */
  73669. get refractionTexture(): Texture;
  73670. set refractionTexture(value: Texture);
  73671. /**
  73672. * Gets a string identifying the name of the class
  73673. * @returns "RefractionPostProcess" string
  73674. */
  73675. getClassName(): string;
  73676. /**
  73677. * Initializes the RefractionPostProcess
  73678. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  73679. * @param name The name of the effect.
  73680. * @param refractionTextureUrl Url of the refraction texture to use
  73681. * @param color the base color of the refraction (used to taint the rendering)
  73682. * @param depth simulated refraction depth
  73683. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  73684. * @param camera The camera to apply the render pass to.
  73685. * @param options The required width/height ratio to downsize to before computing the render pass.
  73686. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73687. * @param engine The engine which the post process will be applied. (default: current engine)
  73688. * @param reusable If the post process can be reused on the same frame. (default: false)
  73689. */
  73690. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73691. /**
  73692. * Disposes of the post process
  73693. * @param camera Camera to dispose post process on
  73694. */
  73695. dispose(camera: Camera): void;
  73696. /** @hidden */
  73697. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  73698. }
  73699. }
  73700. declare module "babylonjs/Shaders/sharpen.fragment" {
  73701. /** @hidden */
  73702. export var sharpenPixelShader: {
  73703. name: string;
  73704. shader: string;
  73705. };
  73706. }
  73707. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  73708. import { Nullable } from "babylonjs/types";
  73709. import { Camera } from "babylonjs/Cameras/camera";
  73710. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73711. import "babylonjs/Shaders/sharpen.fragment";
  73712. import { Engine } from "babylonjs/Engines/engine";
  73713. import { Scene } from "babylonjs/scene";
  73714. /**
  73715. * The SharpenPostProcess applies a sharpen kernel to every pixel
  73716. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  73717. */
  73718. export class SharpenPostProcess extends PostProcess {
  73719. /**
  73720. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  73721. */
  73722. colorAmount: number;
  73723. /**
  73724. * How much sharpness should be applied (default: 0.3)
  73725. */
  73726. edgeAmount: number;
  73727. /**
  73728. * Gets a string identifying the name of the class
  73729. * @returns "SharpenPostProcess" string
  73730. */
  73731. getClassName(): string;
  73732. /**
  73733. * Creates a new instance ConvolutionPostProcess
  73734. * @param name The name of the effect.
  73735. * @param options The required width/height ratio to downsize to before computing the render pass.
  73736. * @param camera The camera to apply the render pass to.
  73737. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73738. * @param engine The engine which the post process will be applied. (default: current engine)
  73739. * @param reusable If the post process can be reused on the same frame. (default: false)
  73740. * @param textureType Type of textures used when performing the post process. (default: 0)
  73741. * @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)
  73742. */
  73743. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73744. /** @hidden */
  73745. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  73746. }
  73747. }
  73748. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  73749. import { Nullable } from "babylonjs/types";
  73750. import { Camera } from "babylonjs/Cameras/camera";
  73751. import { Engine } from "babylonjs/Engines/engine";
  73752. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  73753. import { IInspectable } from "babylonjs/Misc/iInspectable";
  73754. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  73755. /**
  73756. * PostProcessRenderPipeline
  73757. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73758. */
  73759. export class PostProcessRenderPipeline {
  73760. private engine;
  73761. private _renderEffects;
  73762. private _renderEffectsForIsolatedPass;
  73763. /**
  73764. * List of inspectable custom properties (used by the Inspector)
  73765. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  73766. */
  73767. inspectableCustomProperties: IInspectable[];
  73768. /**
  73769. * @hidden
  73770. */
  73771. protected _cameras: Camera[];
  73772. /** @hidden */
  73773. _name: string;
  73774. /**
  73775. * Gets pipeline name
  73776. */
  73777. get name(): string;
  73778. /** Gets the list of attached cameras */
  73779. get cameras(): Camera[];
  73780. /**
  73781. * Initializes a PostProcessRenderPipeline
  73782. * @param engine engine to add the pipeline to
  73783. * @param name name of the pipeline
  73784. */
  73785. constructor(engine: Engine, name: string);
  73786. /**
  73787. * Gets the class name
  73788. * @returns "PostProcessRenderPipeline"
  73789. */
  73790. getClassName(): string;
  73791. /**
  73792. * If all the render effects in the pipeline are supported
  73793. */
  73794. get isSupported(): boolean;
  73795. /**
  73796. * Adds an effect to the pipeline
  73797. * @param renderEffect the effect to add
  73798. */
  73799. addEffect(renderEffect: PostProcessRenderEffect): void;
  73800. /** @hidden */
  73801. _rebuild(): void;
  73802. /** @hidden */
  73803. _enableEffect(renderEffectName: string, cameras: Camera): void;
  73804. /** @hidden */
  73805. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  73806. /** @hidden */
  73807. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  73808. /** @hidden */
  73809. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  73810. /** @hidden */
  73811. _attachCameras(cameras: Camera, unique: boolean): void;
  73812. /** @hidden */
  73813. _attachCameras(cameras: Camera[], unique: boolean): void;
  73814. /** @hidden */
  73815. _detachCameras(cameras: Camera): void;
  73816. /** @hidden */
  73817. _detachCameras(cameras: Nullable<Camera[]>): void;
  73818. /** @hidden */
  73819. _update(): void;
  73820. /** @hidden */
  73821. _reset(): void;
  73822. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  73823. /**
  73824. * Sets the required values to the prepass renderer.
  73825. * @param prePassRenderer defines the prepass renderer to setup.
  73826. * @returns true if the pre pass is needed.
  73827. */
  73828. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  73829. /**
  73830. * Disposes of the pipeline
  73831. */
  73832. dispose(): void;
  73833. }
  73834. }
  73835. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  73836. import { Camera } from "babylonjs/Cameras/camera";
  73837. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73838. /**
  73839. * PostProcessRenderPipelineManager class
  73840. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73841. */
  73842. export class PostProcessRenderPipelineManager {
  73843. private _renderPipelines;
  73844. /**
  73845. * Initializes a PostProcessRenderPipelineManager
  73846. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73847. */
  73848. constructor();
  73849. /**
  73850. * Gets the list of supported render pipelines
  73851. */
  73852. get supportedPipelines(): PostProcessRenderPipeline[];
  73853. /**
  73854. * Adds a pipeline to the manager
  73855. * @param renderPipeline The pipeline to add
  73856. */
  73857. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  73858. /**
  73859. * Attaches a camera to the pipeline
  73860. * @param renderPipelineName The name of the pipeline to attach to
  73861. * @param cameras the camera to attach
  73862. * @param unique if the camera can be attached multiple times to the pipeline
  73863. */
  73864. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  73865. /**
  73866. * Detaches a camera from the pipeline
  73867. * @param renderPipelineName The name of the pipeline to detach from
  73868. * @param cameras the camera to detach
  73869. */
  73870. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  73871. /**
  73872. * Enables an effect by name on a pipeline
  73873. * @param renderPipelineName the name of the pipeline to enable the effect in
  73874. * @param renderEffectName the name of the effect to enable
  73875. * @param cameras the cameras that the effect should be enabled on
  73876. */
  73877. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  73878. /**
  73879. * Disables an effect by name on a pipeline
  73880. * @param renderPipelineName the name of the pipeline to disable the effect in
  73881. * @param renderEffectName the name of the effect to disable
  73882. * @param cameras the cameras that the effect should be disabled on
  73883. */
  73884. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  73885. /**
  73886. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  73887. */
  73888. update(): void;
  73889. /** @hidden */
  73890. _rebuild(): void;
  73891. /**
  73892. * Disposes of the manager and pipelines
  73893. */
  73894. dispose(): void;
  73895. }
  73896. }
  73897. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  73898. import { ISceneComponent } from "babylonjs/sceneComponent";
  73899. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  73900. import { Scene } from "babylonjs/scene";
  73901. module "babylonjs/scene" {
  73902. interface Scene {
  73903. /** @hidden (Backing field) */
  73904. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  73905. /**
  73906. * Gets the postprocess render pipeline manager
  73907. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73908. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  73909. */
  73910. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  73911. }
  73912. }
  73913. /**
  73914. * Defines the Render Pipeline scene component responsible to rendering pipelines
  73915. */
  73916. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  73917. /**
  73918. * The component name helpfull to identify the component in the list of scene components.
  73919. */
  73920. readonly name: string;
  73921. /**
  73922. * The scene the component belongs to.
  73923. */
  73924. scene: Scene;
  73925. /**
  73926. * Creates a new instance of the component for the given scene
  73927. * @param scene Defines the scene to register the component in
  73928. */
  73929. constructor(scene: Scene);
  73930. /**
  73931. * Registers the component in a given scene
  73932. */
  73933. register(): void;
  73934. /**
  73935. * Rebuilds the elements related to this component in case of
  73936. * context lost for instance.
  73937. */
  73938. rebuild(): void;
  73939. /**
  73940. * Disposes the component and the associated ressources
  73941. */
  73942. dispose(): void;
  73943. private _gatherRenderTargets;
  73944. }
  73945. }
  73946. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  73947. import { Nullable } from "babylonjs/types";
  73948. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  73949. import { Camera } from "babylonjs/Cameras/camera";
  73950. import { IDisposable } from "babylonjs/scene";
  73951. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  73952. import { Scene } from "babylonjs/scene";
  73953. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  73954. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  73955. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  73956. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  73957. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  73958. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73959. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  73960. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73961. import { Animation } from "babylonjs/Animations/animation";
  73962. /**
  73963. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  73964. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  73965. */
  73966. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  73967. private _scene;
  73968. private _camerasToBeAttached;
  73969. /**
  73970. * ID of the sharpen post process,
  73971. */
  73972. private readonly SharpenPostProcessId;
  73973. /**
  73974. * @ignore
  73975. * ID of the image processing post process;
  73976. */
  73977. readonly ImageProcessingPostProcessId: string;
  73978. /**
  73979. * @ignore
  73980. * ID of the Fast Approximate Anti-Aliasing post process;
  73981. */
  73982. readonly FxaaPostProcessId: string;
  73983. /**
  73984. * ID of the chromatic aberration post process,
  73985. */
  73986. private readonly ChromaticAberrationPostProcessId;
  73987. /**
  73988. * ID of the grain post process
  73989. */
  73990. private readonly GrainPostProcessId;
  73991. /**
  73992. * Sharpen post process which will apply a sharpen convolution to enhance edges
  73993. */
  73994. sharpen: SharpenPostProcess;
  73995. private _sharpenEffect;
  73996. private bloom;
  73997. /**
  73998. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  73999. */
  74000. depthOfField: DepthOfFieldEffect;
  74001. /**
  74002. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  74003. */
  74004. fxaa: FxaaPostProcess;
  74005. /**
  74006. * Image post processing pass used to perform operations such as tone mapping or color grading.
  74007. */
  74008. imageProcessing: ImageProcessingPostProcess;
  74009. /**
  74010. * Chromatic aberration post process which will shift rgb colors in the image
  74011. */
  74012. chromaticAberration: ChromaticAberrationPostProcess;
  74013. private _chromaticAberrationEffect;
  74014. /**
  74015. * Grain post process which add noise to the image
  74016. */
  74017. grain: GrainPostProcess;
  74018. private _grainEffect;
  74019. /**
  74020. * Glow post process which adds a glow to emissive areas of the image
  74021. */
  74022. private _glowLayer;
  74023. /**
  74024. * Animations which can be used to tweak settings over a period of time
  74025. */
  74026. animations: Animation[];
  74027. private _imageProcessingConfigurationObserver;
  74028. private _sharpenEnabled;
  74029. private _bloomEnabled;
  74030. private _depthOfFieldEnabled;
  74031. private _depthOfFieldBlurLevel;
  74032. private _fxaaEnabled;
  74033. private _imageProcessingEnabled;
  74034. private _defaultPipelineTextureType;
  74035. private _bloomScale;
  74036. private _chromaticAberrationEnabled;
  74037. private _grainEnabled;
  74038. private _buildAllowed;
  74039. /**
  74040. * Gets active scene
  74041. */
  74042. get scene(): Scene;
  74043. /**
  74044. * Enable or disable the sharpen process from the pipeline
  74045. */
  74046. set sharpenEnabled(enabled: boolean);
  74047. get sharpenEnabled(): boolean;
  74048. private _resizeObserver;
  74049. private _hardwareScaleLevel;
  74050. private _bloomKernel;
  74051. /**
  74052. * Specifies the size of the bloom blur kernel, relative to the final output size
  74053. */
  74054. get bloomKernel(): number;
  74055. set bloomKernel(value: number);
  74056. /**
  74057. * Specifies the weight of the bloom in the final rendering
  74058. */
  74059. private _bloomWeight;
  74060. /**
  74061. * Specifies the luma threshold for the area that will be blurred by the bloom
  74062. */
  74063. private _bloomThreshold;
  74064. private _hdr;
  74065. /**
  74066. * The strength of the bloom.
  74067. */
  74068. set bloomWeight(value: number);
  74069. get bloomWeight(): number;
  74070. /**
  74071. * The strength of the bloom.
  74072. */
  74073. set bloomThreshold(value: number);
  74074. get bloomThreshold(): number;
  74075. /**
  74076. * The scale of the bloom, lower value will provide better performance.
  74077. */
  74078. set bloomScale(value: number);
  74079. get bloomScale(): number;
  74080. /**
  74081. * Enable or disable the bloom from the pipeline
  74082. */
  74083. set bloomEnabled(enabled: boolean);
  74084. get bloomEnabled(): boolean;
  74085. private _rebuildBloom;
  74086. /**
  74087. * If the depth of field is enabled.
  74088. */
  74089. get depthOfFieldEnabled(): boolean;
  74090. set depthOfFieldEnabled(enabled: boolean);
  74091. /**
  74092. * Blur level of the depth of field effect. (Higher blur will effect performance)
  74093. */
  74094. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  74095. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  74096. /**
  74097. * If the anti aliasing is enabled.
  74098. */
  74099. set fxaaEnabled(enabled: boolean);
  74100. get fxaaEnabled(): boolean;
  74101. private _samples;
  74102. /**
  74103. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  74104. */
  74105. set samples(sampleCount: number);
  74106. get samples(): number;
  74107. /**
  74108. * If image processing is enabled.
  74109. */
  74110. set imageProcessingEnabled(enabled: boolean);
  74111. get imageProcessingEnabled(): boolean;
  74112. /**
  74113. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  74114. */
  74115. set glowLayerEnabled(enabled: boolean);
  74116. get glowLayerEnabled(): boolean;
  74117. /**
  74118. * Gets the glow layer (or null if not defined)
  74119. */
  74120. get glowLayer(): Nullable<GlowLayer>;
  74121. /**
  74122. * Enable or disable the chromaticAberration process from the pipeline
  74123. */
  74124. set chromaticAberrationEnabled(enabled: boolean);
  74125. get chromaticAberrationEnabled(): boolean;
  74126. /**
  74127. * Enable or disable the grain process from the pipeline
  74128. */
  74129. set grainEnabled(enabled: boolean);
  74130. get grainEnabled(): boolean;
  74131. /**
  74132. * @constructor
  74133. * @param name - The rendering pipeline name (default: "")
  74134. * @param hdr - If high dynamic range textures should be used (default: true)
  74135. * @param scene - The scene linked to this pipeline (default: the last created scene)
  74136. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  74137. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  74138. */
  74139. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  74140. /**
  74141. * Get the class name
  74142. * @returns "DefaultRenderingPipeline"
  74143. */
  74144. getClassName(): string;
  74145. /**
  74146. * Force the compilation of the entire pipeline.
  74147. */
  74148. prepare(): void;
  74149. private _hasCleared;
  74150. private _prevPostProcess;
  74151. private _prevPrevPostProcess;
  74152. private _setAutoClearAndTextureSharing;
  74153. private _depthOfFieldSceneObserver;
  74154. private _buildPipeline;
  74155. private _disposePostProcesses;
  74156. /**
  74157. * Adds a camera to the pipeline
  74158. * @param camera the camera to be added
  74159. */
  74160. addCamera(camera: Camera): void;
  74161. /**
  74162. * Removes a camera from the pipeline
  74163. * @param camera the camera to remove
  74164. */
  74165. removeCamera(camera: Camera): void;
  74166. /**
  74167. * Dispose of the pipeline and stop all post processes
  74168. */
  74169. dispose(): void;
  74170. /**
  74171. * Serialize the rendering pipeline (Used when exporting)
  74172. * @returns the serialized object
  74173. */
  74174. serialize(): any;
  74175. /**
  74176. * Parse the serialized pipeline
  74177. * @param source Source pipeline.
  74178. * @param scene The scene to load the pipeline to.
  74179. * @param rootUrl The URL of the serialized pipeline.
  74180. * @returns An instantiated pipeline from the serialized object.
  74181. */
  74182. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  74183. }
  74184. }
  74185. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  74186. /** @hidden */
  74187. export var lensHighlightsPixelShader: {
  74188. name: string;
  74189. shader: string;
  74190. };
  74191. }
  74192. declare module "babylonjs/Shaders/depthOfField.fragment" {
  74193. /** @hidden */
  74194. export var depthOfFieldPixelShader: {
  74195. name: string;
  74196. shader: string;
  74197. };
  74198. }
  74199. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  74200. import { Camera } from "babylonjs/Cameras/camera";
  74201. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74202. import { Scene } from "babylonjs/scene";
  74203. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74204. import "babylonjs/Shaders/chromaticAberration.fragment";
  74205. import "babylonjs/Shaders/lensHighlights.fragment";
  74206. import "babylonjs/Shaders/depthOfField.fragment";
  74207. /**
  74208. * BABYLON.JS Chromatic Aberration GLSL Shader
  74209. * Author: Olivier Guyot
  74210. * Separates very slightly R, G and B colors on the edges of the screen
  74211. * Inspired by Francois Tarlier & Martins Upitis
  74212. */
  74213. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  74214. /**
  74215. * @ignore
  74216. * The chromatic aberration PostProcess id in the pipeline
  74217. */
  74218. LensChromaticAberrationEffect: string;
  74219. /**
  74220. * @ignore
  74221. * The highlights enhancing PostProcess id in the pipeline
  74222. */
  74223. HighlightsEnhancingEffect: string;
  74224. /**
  74225. * @ignore
  74226. * The depth-of-field PostProcess id in the pipeline
  74227. */
  74228. LensDepthOfFieldEffect: string;
  74229. private _scene;
  74230. private _depthTexture;
  74231. private _grainTexture;
  74232. private _chromaticAberrationPostProcess;
  74233. private _highlightsPostProcess;
  74234. private _depthOfFieldPostProcess;
  74235. private _edgeBlur;
  74236. private _grainAmount;
  74237. private _chromaticAberration;
  74238. private _distortion;
  74239. private _highlightsGain;
  74240. private _highlightsThreshold;
  74241. private _dofDistance;
  74242. private _dofAperture;
  74243. private _dofDarken;
  74244. private _dofPentagon;
  74245. private _blurNoise;
  74246. /**
  74247. * @constructor
  74248. *
  74249. * Effect parameters are as follow:
  74250. * {
  74251. * chromatic_aberration: number; // from 0 to x (1 for realism)
  74252. * edge_blur: number; // from 0 to x (1 for realism)
  74253. * distortion: number; // from 0 to x (1 for realism)
  74254. * grain_amount: number; // from 0 to 1
  74255. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  74256. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  74257. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  74258. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  74259. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  74260. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  74261. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  74262. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  74263. * }
  74264. * Note: if an effect parameter is unset, effect is disabled
  74265. *
  74266. * @param name The rendering pipeline name
  74267. * @param parameters - An object containing all parameters (see above)
  74268. * @param scene The scene linked to this pipeline
  74269. * @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)
  74270. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74271. */
  74272. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  74273. /**
  74274. * Get the class name
  74275. * @returns "LensRenderingPipeline"
  74276. */
  74277. getClassName(): string;
  74278. /**
  74279. * Gets associated scene
  74280. */
  74281. get scene(): Scene;
  74282. /**
  74283. * Gets or sets the edge blur
  74284. */
  74285. get edgeBlur(): number;
  74286. set edgeBlur(value: number);
  74287. /**
  74288. * Gets or sets the grain amount
  74289. */
  74290. get grainAmount(): number;
  74291. set grainAmount(value: number);
  74292. /**
  74293. * Gets or sets the chromatic aberration amount
  74294. */
  74295. get chromaticAberration(): number;
  74296. set chromaticAberration(value: number);
  74297. /**
  74298. * Gets or sets the depth of field aperture
  74299. */
  74300. get dofAperture(): number;
  74301. set dofAperture(value: number);
  74302. /**
  74303. * Gets or sets the edge distortion
  74304. */
  74305. get edgeDistortion(): number;
  74306. set edgeDistortion(value: number);
  74307. /**
  74308. * Gets or sets the depth of field distortion
  74309. */
  74310. get dofDistortion(): number;
  74311. set dofDistortion(value: number);
  74312. /**
  74313. * Gets or sets the darken out of focus amount
  74314. */
  74315. get darkenOutOfFocus(): number;
  74316. set darkenOutOfFocus(value: number);
  74317. /**
  74318. * Gets or sets a boolean indicating if blur noise is enabled
  74319. */
  74320. get blurNoise(): boolean;
  74321. set blurNoise(value: boolean);
  74322. /**
  74323. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  74324. */
  74325. get pentagonBokeh(): boolean;
  74326. set pentagonBokeh(value: boolean);
  74327. /**
  74328. * Gets or sets the highlight grain amount
  74329. */
  74330. get highlightsGain(): number;
  74331. set highlightsGain(value: number);
  74332. /**
  74333. * Gets or sets the highlight threshold
  74334. */
  74335. get highlightsThreshold(): number;
  74336. set highlightsThreshold(value: number);
  74337. /**
  74338. * Sets the amount of blur at the edges
  74339. * @param amount blur amount
  74340. */
  74341. setEdgeBlur(amount: number): void;
  74342. /**
  74343. * Sets edge blur to 0
  74344. */
  74345. disableEdgeBlur(): void;
  74346. /**
  74347. * Sets the amout of grain
  74348. * @param amount Amount of grain
  74349. */
  74350. setGrainAmount(amount: number): void;
  74351. /**
  74352. * Set grain amount to 0
  74353. */
  74354. disableGrain(): void;
  74355. /**
  74356. * Sets the chromatic aberration amount
  74357. * @param amount amount of chromatic aberration
  74358. */
  74359. setChromaticAberration(amount: number): void;
  74360. /**
  74361. * Sets chromatic aberration amount to 0
  74362. */
  74363. disableChromaticAberration(): void;
  74364. /**
  74365. * Sets the EdgeDistortion amount
  74366. * @param amount amount of EdgeDistortion
  74367. */
  74368. setEdgeDistortion(amount: number): void;
  74369. /**
  74370. * Sets edge distortion to 0
  74371. */
  74372. disableEdgeDistortion(): void;
  74373. /**
  74374. * Sets the FocusDistance amount
  74375. * @param amount amount of FocusDistance
  74376. */
  74377. setFocusDistance(amount: number): void;
  74378. /**
  74379. * Disables depth of field
  74380. */
  74381. disableDepthOfField(): void;
  74382. /**
  74383. * Sets the Aperture amount
  74384. * @param amount amount of Aperture
  74385. */
  74386. setAperture(amount: number): void;
  74387. /**
  74388. * Sets the DarkenOutOfFocus amount
  74389. * @param amount amount of DarkenOutOfFocus
  74390. */
  74391. setDarkenOutOfFocus(amount: number): void;
  74392. private _pentagonBokehIsEnabled;
  74393. /**
  74394. * Creates a pentagon bokeh effect
  74395. */
  74396. enablePentagonBokeh(): void;
  74397. /**
  74398. * Disables the pentagon bokeh effect
  74399. */
  74400. disablePentagonBokeh(): void;
  74401. /**
  74402. * Enables noise blur
  74403. */
  74404. enableNoiseBlur(): void;
  74405. /**
  74406. * Disables noise blur
  74407. */
  74408. disableNoiseBlur(): void;
  74409. /**
  74410. * Sets the HighlightsGain amount
  74411. * @param amount amount of HighlightsGain
  74412. */
  74413. setHighlightsGain(amount: number): void;
  74414. /**
  74415. * Sets the HighlightsThreshold amount
  74416. * @param amount amount of HighlightsThreshold
  74417. */
  74418. setHighlightsThreshold(amount: number): void;
  74419. /**
  74420. * Disables highlights
  74421. */
  74422. disableHighlights(): void;
  74423. /**
  74424. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  74425. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  74426. */
  74427. dispose(disableDepthRender?: boolean): void;
  74428. private _createChromaticAberrationPostProcess;
  74429. private _createHighlightsPostProcess;
  74430. private _createDepthOfFieldPostProcess;
  74431. private _createGrainTexture;
  74432. }
  74433. }
  74434. declare module "babylonjs/Shaders/ssao2.fragment" {
  74435. /** @hidden */
  74436. export var ssao2PixelShader: {
  74437. name: string;
  74438. shader: string;
  74439. };
  74440. }
  74441. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  74442. /** @hidden */
  74443. export var ssaoCombinePixelShader: {
  74444. name: string;
  74445. shader: string;
  74446. };
  74447. }
  74448. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  74449. import { Camera } from "babylonjs/Cameras/camera";
  74450. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74451. import { Scene } from "babylonjs/scene";
  74452. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74453. import "babylonjs/Shaders/ssao2.fragment";
  74454. import "babylonjs/Shaders/ssaoCombine.fragment";
  74455. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  74456. /**
  74457. * Render pipeline to produce ssao effect
  74458. */
  74459. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  74460. /**
  74461. * @ignore
  74462. * The PassPostProcess id in the pipeline that contains the original scene color
  74463. */
  74464. SSAOOriginalSceneColorEffect: string;
  74465. /**
  74466. * @ignore
  74467. * The SSAO PostProcess id in the pipeline
  74468. */
  74469. SSAORenderEffect: string;
  74470. /**
  74471. * @ignore
  74472. * The horizontal blur PostProcess id in the pipeline
  74473. */
  74474. SSAOBlurHRenderEffect: string;
  74475. /**
  74476. * @ignore
  74477. * The vertical blur PostProcess id in the pipeline
  74478. */
  74479. SSAOBlurVRenderEffect: string;
  74480. /**
  74481. * @ignore
  74482. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  74483. */
  74484. SSAOCombineRenderEffect: string;
  74485. /**
  74486. * The output strength of the SSAO post-process. Default value is 1.0.
  74487. */
  74488. totalStrength: number;
  74489. /**
  74490. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  74491. */
  74492. maxZ: number;
  74493. /**
  74494. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  74495. */
  74496. minZAspect: number;
  74497. private _samples;
  74498. /**
  74499. * Number of samples used for the SSAO calculations. Default value is 8
  74500. */
  74501. set samples(n: number);
  74502. get samples(): number;
  74503. private _textureSamples;
  74504. /**
  74505. * Number of samples to use for antialiasing
  74506. */
  74507. set textureSamples(n: number);
  74508. get textureSamples(): number;
  74509. /**
  74510. * Force rendering the geometry through geometry buffer
  74511. */
  74512. private _forceGeometryBuffer;
  74513. /**
  74514. * Ratio object used for SSAO ratio and blur ratio
  74515. */
  74516. private _ratio;
  74517. /**
  74518. * Dynamically generated sphere sampler.
  74519. */
  74520. private _sampleSphere;
  74521. /**
  74522. * Blur filter offsets
  74523. */
  74524. private _samplerOffsets;
  74525. private _expensiveBlur;
  74526. /**
  74527. * If bilateral blur should be used
  74528. */
  74529. set expensiveBlur(b: boolean);
  74530. get expensiveBlur(): boolean;
  74531. /**
  74532. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  74533. */
  74534. radius: number;
  74535. /**
  74536. * The base color of the SSAO post-process
  74537. * The final result is "base + ssao" between [0, 1]
  74538. */
  74539. base: number;
  74540. /**
  74541. * Support test.
  74542. */
  74543. static get IsSupported(): boolean;
  74544. private _scene;
  74545. private _randomTexture;
  74546. private _originalColorPostProcess;
  74547. private _ssaoPostProcess;
  74548. private _blurHPostProcess;
  74549. private _blurVPostProcess;
  74550. private _ssaoCombinePostProcess;
  74551. private _prePassRenderer;
  74552. /**
  74553. * Gets active scene
  74554. */
  74555. get scene(): Scene;
  74556. /**
  74557. * @constructor
  74558. * @param name The rendering pipeline name
  74559. * @param scene The scene linked to this pipeline
  74560. * @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 }
  74561. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74562. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  74563. */
  74564. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  74565. /**
  74566. * Get the class name
  74567. * @returns "SSAO2RenderingPipeline"
  74568. */
  74569. getClassName(): string;
  74570. /**
  74571. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  74572. */
  74573. dispose(disableGeometryBufferRenderer?: boolean): void;
  74574. private _createBlurPostProcess;
  74575. /** @hidden */
  74576. _rebuild(): void;
  74577. private _bits;
  74578. private _radicalInverse_VdC;
  74579. private _hammersley;
  74580. private _hemisphereSample_uniform;
  74581. private _generateHemisphere;
  74582. private _getDefinesForSSAO;
  74583. private _createSSAOPostProcess;
  74584. private _createSSAOCombinePostProcess;
  74585. private _createRandomTexture;
  74586. /**
  74587. * Serialize the rendering pipeline (Used when exporting)
  74588. * @returns the serialized object
  74589. */
  74590. serialize(): any;
  74591. /**
  74592. * Parse the serialized pipeline
  74593. * @param source Source pipeline.
  74594. * @param scene The scene to load the pipeline to.
  74595. * @param rootUrl The URL of the serialized pipeline.
  74596. * @returns An instantiated pipeline from the serialized object.
  74597. */
  74598. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  74599. /**
  74600. * Sets the required values to the prepass renderer.
  74601. * @param prePassRenderer defines the prepass renderer to setup
  74602. * @returns true if the pre pass is needed.
  74603. */
  74604. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  74605. }
  74606. }
  74607. declare module "babylonjs/Shaders/ssao.fragment" {
  74608. /** @hidden */
  74609. export var ssaoPixelShader: {
  74610. name: string;
  74611. shader: string;
  74612. };
  74613. }
  74614. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  74615. import { Camera } from "babylonjs/Cameras/camera";
  74616. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74617. import { Scene } from "babylonjs/scene";
  74618. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74619. import "babylonjs/Shaders/ssao.fragment";
  74620. import "babylonjs/Shaders/ssaoCombine.fragment";
  74621. /**
  74622. * Render pipeline to produce ssao effect
  74623. */
  74624. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  74625. /**
  74626. * @ignore
  74627. * The PassPostProcess id in the pipeline that contains the original scene color
  74628. */
  74629. SSAOOriginalSceneColorEffect: string;
  74630. /**
  74631. * @ignore
  74632. * The SSAO PostProcess id in the pipeline
  74633. */
  74634. SSAORenderEffect: string;
  74635. /**
  74636. * @ignore
  74637. * The horizontal blur PostProcess id in the pipeline
  74638. */
  74639. SSAOBlurHRenderEffect: string;
  74640. /**
  74641. * @ignore
  74642. * The vertical blur PostProcess id in the pipeline
  74643. */
  74644. SSAOBlurVRenderEffect: string;
  74645. /**
  74646. * @ignore
  74647. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  74648. */
  74649. SSAOCombineRenderEffect: string;
  74650. /**
  74651. * The output strength of the SSAO post-process. Default value is 1.0.
  74652. */
  74653. totalStrength: number;
  74654. /**
  74655. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  74656. */
  74657. radius: number;
  74658. /**
  74659. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  74660. * Must not be equal to fallOff and superior to fallOff.
  74661. * Default value is 0.0075
  74662. */
  74663. area: number;
  74664. /**
  74665. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  74666. * Must not be equal to area and inferior to area.
  74667. * Default value is 0.000001
  74668. */
  74669. fallOff: number;
  74670. /**
  74671. * The base color of the SSAO post-process
  74672. * The final result is "base + ssao" between [0, 1]
  74673. */
  74674. base: number;
  74675. private _scene;
  74676. private _depthTexture;
  74677. private _randomTexture;
  74678. private _originalColorPostProcess;
  74679. private _ssaoPostProcess;
  74680. private _blurHPostProcess;
  74681. private _blurVPostProcess;
  74682. private _ssaoCombinePostProcess;
  74683. private _firstUpdate;
  74684. /**
  74685. * Gets active scene
  74686. */
  74687. get scene(): Scene;
  74688. /**
  74689. * @constructor
  74690. * @param name - The rendering pipeline name
  74691. * @param scene - The scene linked to this pipeline
  74692. * @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 }
  74693. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  74694. */
  74695. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  74696. /**
  74697. * Get the class name
  74698. * @returns "SSAORenderingPipeline"
  74699. */
  74700. getClassName(): string;
  74701. /**
  74702. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  74703. */
  74704. dispose(disableDepthRender?: boolean): void;
  74705. private _createBlurPostProcess;
  74706. /** @hidden */
  74707. _rebuild(): void;
  74708. private _createSSAOPostProcess;
  74709. private _createSSAOCombinePostProcess;
  74710. private _createRandomTexture;
  74711. }
  74712. }
  74713. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  74714. /** @hidden */
  74715. export var screenSpaceReflectionPixelShader: {
  74716. name: string;
  74717. shader: string;
  74718. };
  74719. }
  74720. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  74721. import { Nullable } from "babylonjs/types";
  74722. import { Camera } from "babylonjs/Cameras/camera";
  74723. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74724. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  74725. import { Engine } from "babylonjs/Engines/engine";
  74726. import { Scene } from "babylonjs/scene";
  74727. /**
  74728. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  74729. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  74730. */
  74731. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  74732. /**
  74733. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  74734. */
  74735. threshold: number;
  74736. /**
  74737. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  74738. */
  74739. strength: number;
  74740. /**
  74741. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  74742. */
  74743. reflectionSpecularFalloffExponent: number;
  74744. /**
  74745. * 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]
  74746. */
  74747. step: number;
  74748. /**
  74749. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  74750. */
  74751. roughnessFactor: number;
  74752. private _geometryBufferRenderer;
  74753. private _enableSmoothReflections;
  74754. private _reflectionSamples;
  74755. private _smoothSteps;
  74756. /**
  74757. * Gets a string identifying the name of the class
  74758. * @returns "ScreenSpaceReflectionPostProcess" string
  74759. */
  74760. getClassName(): string;
  74761. /**
  74762. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  74763. * @param name The name of the effect.
  74764. * @param scene The scene containing the objects to calculate reflections.
  74765. * @param options The required width/height ratio to downsize to before computing the render pass.
  74766. * @param camera The camera to apply the render pass to.
  74767. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74768. * @param engine The engine which the post process will be applied. (default: current engine)
  74769. * @param reusable If the post process can be reused on the same frame. (default: false)
  74770. * @param textureType Type of textures used when performing the post process. (default: 0)
  74771. * @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)
  74772. */
  74773. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74774. /**
  74775. * Gets wether or not smoothing reflections is enabled.
  74776. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  74777. */
  74778. get enableSmoothReflections(): boolean;
  74779. /**
  74780. * Sets wether or not smoothing reflections is enabled.
  74781. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  74782. */
  74783. set enableSmoothReflections(enabled: boolean);
  74784. /**
  74785. * Gets the number of samples taken while computing reflections. More samples count is high,
  74786. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  74787. */
  74788. get reflectionSamples(): number;
  74789. /**
  74790. * Sets the number of samples taken while computing reflections. More samples count is high,
  74791. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  74792. */
  74793. set reflectionSamples(samples: number);
  74794. /**
  74795. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  74796. * more the post-process will require GPU power and can generate a drop in FPS.
  74797. * Default value (5.0) work pretty well in all cases but can be adjusted.
  74798. */
  74799. get smoothSteps(): number;
  74800. set smoothSteps(steps: number);
  74801. private _updateEffectDefines;
  74802. /** @hidden */
  74803. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  74804. }
  74805. }
  74806. declare module "babylonjs/Shaders/standard.fragment" {
  74807. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  74808. /** @hidden */
  74809. export var standardPixelShader: {
  74810. name: string;
  74811. shader: string;
  74812. };
  74813. }
  74814. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  74815. import { Nullable } from "babylonjs/types";
  74816. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  74817. import { Camera } from "babylonjs/Cameras/camera";
  74818. import { Texture } from "babylonjs/Materials/Textures/texture";
  74819. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74820. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74821. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  74822. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  74823. import { IDisposable } from "babylonjs/scene";
  74824. import { SpotLight } from "babylonjs/Lights/spotLight";
  74825. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  74826. import { Scene } from "babylonjs/scene";
  74827. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  74828. import { Animation } from "babylonjs/Animations/animation";
  74829. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74830. import "babylonjs/Shaders/standard.fragment";
  74831. /**
  74832. * Standard rendering pipeline
  74833. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  74834. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  74835. */
  74836. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  74837. /**
  74838. * Public members
  74839. */
  74840. /**
  74841. * Post-process which contains the original scene color before the pipeline applies all the effects
  74842. */
  74843. originalPostProcess: Nullable<PostProcess>;
  74844. /**
  74845. * Post-process used to down scale an image x4
  74846. */
  74847. downSampleX4PostProcess: Nullable<PostProcess>;
  74848. /**
  74849. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  74850. */
  74851. brightPassPostProcess: Nullable<PostProcess>;
  74852. /**
  74853. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  74854. */
  74855. blurHPostProcesses: PostProcess[];
  74856. /**
  74857. * Post-process array storing all the vertical blur post-processes used by the pipeline
  74858. */
  74859. blurVPostProcesses: PostProcess[];
  74860. /**
  74861. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  74862. */
  74863. textureAdderPostProcess: Nullable<PostProcess>;
  74864. /**
  74865. * Post-process used to create volumetric lighting effect
  74866. */
  74867. volumetricLightPostProcess: Nullable<PostProcess>;
  74868. /**
  74869. * Post-process used to smooth the previous volumetric light post-process on the X axis
  74870. */
  74871. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  74872. /**
  74873. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  74874. */
  74875. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  74876. /**
  74877. * Post-process used to merge the volumetric light effect and the real scene color
  74878. */
  74879. volumetricLightMergePostProces: Nullable<PostProcess>;
  74880. /**
  74881. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  74882. */
  74883. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  74884. /**
  74885. * Base post-process used to calculate the average luminance of the final image for HDR
  74886. */
  74887. luminancePostProcess: Nullable<PostProcess>;
  74888. /**
  74889. * Post-processes used to create down sample post-processes in order to get
  74890. * the average luminance of the final image for HDR
  74891. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  74892. */
  74893. luminanceDownSamplePostProcesses: PostProcess[];
  74894. /**
  74895. * Post-process used to create a HDR effect (light adaptation)
  74896. */
  74897. hdrPostProcess: Nullable<PostProcess>;
  74898. /**
  74899. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  74900. */
  74901. textureAdderFinalPostProcess: Nullable<PostProcess>;
  74902. /**
  74903. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  74904. */
  74905. lensFlareFinalPostProcess: Nullable<PostProcess>;
  74906. /**
  74907. * Post-process used to merge the final HDR post-process and the real scene color
  74908. */
  74909. hdrFinalPostProcess: Nullable<PostProcess>;
  74910. /**
  74911. * Post-process used to create a lens flare effect
  74912. */
  74913. lensFlarePostProcess: Nullable<PostProcess>;
  74914. /**
  74915. * Post-process that merges the result of the lens flare post-process and the real scene color
  74916. */
  74917. lensFlareComposePostProcess: Nullable<PostProcess>;
  74918. /**
  74919. * Post-process used to create a motion blur effect
  74920. */
  74921. motionBlurPostProcess: Nullable<PostProcess>;
  74922. /**
  74923. * Post-process used to create a depth of field effect
  74924. */
  74925. depthOfFieldPostProcess: Nullable<PostProcess>;
  74926. /**
  74927. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  74928. */
  74929. fxaaPostProcess: Nullable<FxaaPostProcess>;
  74930. /**
  74931. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  74932. */
  74933. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  74934. /**
  74935. * Represents the brightness threshold in order to configure the illuminated surfaces
  74936. */
  74937. brightThreshold: number;
  74938. /**
  74939. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  74940. */
  74941. blurWidth: number;
  74942. /**
  74943. * Sets if the blur for highlighted surfaces must be only horizontal
  74944. */
  74945. horizontalBlur: boolean;
  74946. /**
  74947. * Gets the overall exposure used by the pipeline
  74948. */
  74949. get exposure(): number;
  74950. /**
  74951. * Sets the overall exposure used by the pipeline
  74952. */
  74953. set exposure(value: number);
  74954. /**
  74955. * Texture used typically to simulate "dirty" on camera lens
  74956. */
  74957. lensTexture: Nullable<Texture>;
  74958. /**
  74959. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  74960. */
  74961. volumetricLightCoefficient: number;
  74962. /**
  74963. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  74964. */
  74965. volumetricLightPower: number;
  74966. /**
  74967. * Used the set the blur intensity to smooth the volumetric lights
  74968. */
  74969. volumetricLightBlurScale: number;
  74970. /**
  74971. * Light (spot or directional) used to generate the volumetric lights rays
  74972. * The source light must have a shadow generate so the pipeline can get its
  74973. * depth map
  74974. */
  74975. sourceLight: Nullable<SpotLight | DirectionalLight>;
  74976. /**
  74977. * For eye adaptation, represents the minimum luminance the eye can see
  74978. */
  74979. hdrMinimumLuminance: number;
  74980. /**
  74981. * For eye adaptation, represents the decrease luminance speed
  74982. */
  74983. hdrDecreaseRate: number;
  74984. /**
  74985. * For eye adaptation, represents the increase luminance speed
  74986. */
  74987. hdrIncreaseRate: number;
  74988. /**
  74989. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  74990. */
  74991. get hdrAutoExposure(): boolean;
  74992. /**
  74993. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  74994. */
  74995. set hdrAutoExposure(value: boolean);
  74996. /**
  74997. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  74998. */
  74999. lensColorTexture: Nullable<Texture>;
  75000. /**
  75001. * The overall strengh for the lens flare effect
  75002. */
  75003. lensFlareStrength: number;
  75004. /**
  75005. * Dispersion coefficient for lens flare ghosts
  75006. */
  75007. lensFlareGhostDispersal: number;
  75008. /**
  75009. * Main lens flare halo width
  75010. */
  75011. lensFlareHaloWidth: number;
  75012. /**
  75013. * Based on the lens distortion effect, defines how much the lens flare result
  75014. * is distorted
  75015. */
  75016. lensFlareDistortionStrength: number;
  75017. /**
  75018. * Configures the blur intensity used for for lens flare (halo)
  75019. */
  75020. lensFlareBlurWidth: number;
  75021. /**
  75022. * Lens star texture must be used to simulate rays on the flares and is available
  75023. * in the documentation
  75024. */
  75025. lensStarTexture: Nullable<Texture>;
  75026. /**
  75027. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  75028. * flare effect by taking account of the dirt texture
  75029. */
  75030. lensFlareDirtTexture: Nullable<Texture>;
  75031. /**
  75032. * Represents the focal length for the depth of field effect
  75033. */
  75034. depthOfFieldDistance: number;
  75035. /**
  75036. * Represents the blur intensity for the blurred part of the depth of field effect
  75037. */
  75038. depthOfFieldBlurWidth: number;
  75039. /**
  75040. * Gets how much the image is blurred by the movement while using the motion blur post-process
  75041. */
  75042. get motionStrength(): number;
  75043. /**
  75044. * Sets how much the image is blurred by the movement while using the motion blur post-process
  75045. */
  75046. set motionStrength(strength: number);
  75047. /**
  75048. * Gets wether or not the motion blur post-process is object based or screen based.
  75049. */
  75050. get objectBasedMotionBlur(): boolean;
  75051. /**
  75052. * Sets wether or not the motion blur post-process should be object based or screen based
  75053. */
  75054. set objectBasedMotionBlur(value: boolean);
  75055. /**
  75056. * List of animations for the pipeline (IAnimatable implementation)
  75057. */
  75058. animations: Animation[];
  75059. /**
  75060. * Private members
  75061. */
  75062. private _scene;
  75063. private _currentDepthOfFieldSource;
  75064. private _basePostProcess;
  75065. private _fixedExposure;
  75066. private _currentExposure;
  75067. private _hdrAutoExposure;
  75068. private _hdrCurrentLuminance;
  75069. private _motionStrength;
  75070. private _isObjectBasedMotionBlur;
  75071. private _floatTextureType;
  75072. private _camerasToBeAttached;
  75073. private _ratio;
  75074. private _bloomEnabled;
  75075. private _depthOfFieldEnabled;
  75076. private _vlsEnabled;
  75077. private _lensFlareEnabled;
  75078. private _hdrEnabled;
  75079. private _motionBlurEnabled;
  75080. private _fxaaEnabled;
  75081. private _screenSpaceReflectionsEnabled;
  75082. private _motionBlurSamples;
  75083. private _volumetricLightStepsCount;
  75084. private _samples;
  75085. /**
  75086. * @ignore
  75087. * Specifies if the bloom pipeline is enabled
  75088. */
  75089. get BloomEnabled(): boolean;
  75090. set BloomEnabled(enabled: boolean);
  75091. /**
  75092. * @ignore
  75093. * Specifies if the depth of field pipeline is enabed
  75094. */
  75095. get DepthOfFieldEnabled(): boolean;
  75096. set DepthOfFieldEnabled(enabled: boolean);
  75097. /**
  75098. * @ignore
  75099. * Specifies if the lens flare pipeline is enabed
  75100. */
  75101. get LensFlareEnabled(): boolean;
  75102. set LensFlareEnabled(enabled: boolean);
  75103. /**
  75104. * @ignore
  75105. * Specifies if the HDR pipeline is enabled
  75106. */
  75107. get HDREnabled(): boolean;
  75108. set HDREnabled(enabled: boolean);
  75109. /**
  75110. * @ignore
  75111. * Specifies if the volumetric lights scattering effect is enabled
  75112. */
  75113. get VLSEnabled(): boolean;
  75114. set VLSEnabled(enabled: boolean);
  75115. /**
  75116. * @ignore
  75117. * Specifies if the motion blur effect is enabled
  75118. */
  75119. get MotionBlurEnabled(): boolean;
  75120. set MotionBlurEnabled(enabled: boolean);
  75121. /**
  75122. * Specifies if anti-aliasing is enabled
  75123. */
  75124. get fxaaEnabled(): boolean;
  75125. set fxaaEnabled(enabled: boolean);
  75126. /**
  75127. * Specifies if screen space reflections are enabled.
  75128. */
  75129. get screenSpaceReflectionsEnabled(): boolean;
  75130. set screenSpaceReflectionsEnabled(enabled: boolean);
  75131. /**
  75132. * Specifies the number of steps used to calculate the volumetric lights
  75133. * Typically in interval [50, 200]
  75134. */
  75135. get volumetricLightStepsCount(): number;
  75136. set volumetricLightStepsCount(count: number);
  75137. /**
  75138. * Specifies the number of samples used for the motion blur effect
  75139. * Typically in interval [16, 64]
  75140. */
  75141. get motionBlurSamples(): number;
  75142. set motionBlurSamples(samples: number);
  75143. /**
  75144. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  75145. */
  75146. get samples(): number;
  75147. set samples(sampleCount: number);
  75148. /**
  75149. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  75150. * @constructor
  75151. * @param name The rendering pipeline name
  75152. * @param scene The scene linked to this pipeline
  75153. * @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)
  75154. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  75155. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75156. */
  75157. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  75158. private _buildPipeline;
  75159. private _createDownSampleX4PostProcess;
  75160. private _createBrightPassPostProcess;
  75161. private _createBlurPostProcesses;
  75162. private _createTextureAdderPostProcess;
  75163. private _createVolumetricLightPostProcess;
  75164. private _createLuminancePostProcesses;
  75165. private _createHdrPostProcess;
  75166. private _createLensFlarePostProcess;
  75167. private _createDepthOfFieldPostProcess;
  75168. private _createMotionBlurPostProcess;
  75169. private _getDepthTexture;
  75170. private _disposePostProcesses;
  75171. /**
  75172. * Dispose of the pipeline and stop all post processes
  75173. */
  75174. dispose(): void;
  75175. /**
  75176. * Serialize the rendering pipeline (Used when exporting)
  75177. * @returns the serialized object
  75178. */
  75179. serialize(): any;
  75180. /**
  75181. * Parse the serialized pipeline
  75182. * @param source Source pipeline.
  75183. * @param scene The scene to load the pipeline to.
  75184. * @param rootUrl The URL of the serialized pipeline.
  75185. * @returns An instantiated pipeline from the serialized object.
  75186. */
  75187. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  75188. /**
  75189. * Luminance steps
  75190. */
  75191. static LuminanceSteps: number;
  75192. }
  75193. }
  75194. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  75195. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  75196. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  75197. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  75198. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  75199. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  75200. }
  75201. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  75202. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  75203. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  75204. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75205. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  75206. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75207. }
  75208. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  75209. /** @hidden */
  75210. export var stereoscopicInterlacePixelShader: {
  75211. name: string;
  75212. shader: string;
  75213. };
  75214. }
  75215. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  75216. import { Camera } from "babylonjs/Cameras/camera";
  75217. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75218. import { Engine } from "babylonjs/Engines/engine";
  75219. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  75220. /**
  75221. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  75222. */
  75223. export class StereoscopicInterlacePostProcessI extends PostProcess {
  75224. private _stepSize;
  75225. private _passedProcess;
  75226. /**
  75227. * Gets a string identifying the name of the class
  75228. * @returns "StereoscopicInterlacePostProcessI" string
  75229. */
  75230. getClassName(): string;
  75231. /**
  75232. * Initializes a StereoscopicInterlacePostProcessI
  75233. * @param name The name of the effect.
  75234. * @param rigCameras The rig cameras to be appled to the post process
  75235. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  75236. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  75237. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75238. * @param engine The engine which the post process will be applied. (default: current engine)
  75239. * @param reusable If the post process can be reused on the same frame. (default: false)
  75240. */
  75241. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  75242. }
  75243. /**
  75244. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  75245. */
  75246. export class StereoscopicInterlacePostProcess extends PostProcess {
  75247. private _stepSize;
  75248. private _passedProcess;
  75249. /**
  75250. * Gets a string identifying the name of the class
  75251. * @returns "StereoscopicInterlacePostProcess" string
  75252. */
  75253. getClassName(): string;
  75254. /**
  75255. * Initializes a StereoscopicInterlacePostProcess
  75256. * @param name The name of the effect.
  75257. * @param rigCameras The rig cameras to be appled to the post process
  75258. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  75259. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75260. * @param engine The engine which the post process will be applied. (default: current engine)
  75261. * @param reusable If the post process can be reused on the same frame. (default: false)
  75262. */
  75263. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  75264. }
  75265. }
  75266. declare module "babylonjs/Shaders/tonemap.fragment" {
  75267. /** @hidden */
  75268. export var tonemapPixelShader: {
  75269. name: string;
  75270. shader: string;
  75271. };
  75272. }
  75273. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  75274. import { Camera } from "babylonjs/Cameras/camera";
  75275. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75276. import "babylonjs/Shaders/tonemap.fragment";
  75277. import { Engine } from "babylonjs/Engines/engine";
  75278. /** Defines operator used for tonemapping */
  75279. export enum TonemappingOperator {
  75280. /** Hable */
  75281. Hable = 0,
  75282. /** Reinhard */
  75283. Reinhard = 1,
  75284. /** HejiDawson */
  75285. HejiDawson = 2,
  75286. /** Photographic */
  75287. Photographic = 3
  75288. }
  75289. /**
  75290. * Defines a post process to apply tone mapping
  75291. */
  75292. export class TonemapPostProcess extends PostProcess {
  75293. private _operator;
  75294. /** Defines the required exposure adjustement */
  75295. exposureAdjustment: number;
  75296. /**
  75297. * Gets a string identifying the name of the class
  75298. * @returns "TonemapPostProcess" string
  75299. */
  75300. getClassName(): string;
  75301. /**
  75302. * Creates a new TonemapPostProcess
  75303. * @param name defines the name of the postprocess
  75304. * @param _operator defines the operator to use
  75305. * @param exposureAdjustment defines the required exposure adjustement
  75306. * @param camera defines the camera to use (can be null)
  75307. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  75308. * @param engine defines the hosting engine (can be ignore if camera is set)
  75309. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  75310. */
  75311. constructor(name: string, _operator: TonemappingOperator,
  75312. /** Defines the required exposure adjustement */
  75313. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  75314. }
  75315. }
  75316. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  75317. /** @hidden */
  75318. export var volumetricLightScatteringPixelShader: {
  75319. name: string;
  75320. shader: string;
  75321. };
  75322. }
  75323. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  75324. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  75325. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  75326. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  75327. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  75328. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  75329. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  75330. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  75331. /** @hidden */
  75332. export var volumetricLightScatteringPassVertexShader: {
  75333. name: string;
  75334. shader: string;
  75335. };
  75336. }
  75337. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  75338. /** @hidden */
  75339. export var volumetricLightScatteringPassPixelShader: {
  75340. name: string;
  75341. shader: string;
  75342. };
  75343. }
  75344. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  75345. import { Vector3 } from "babylonjs/Maths/math.vector";
  75346. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75347. import { Mesh } from "babylonjs/Meshes/mesh";
  75348. import { Camera } from "babylonjs/Cameras/camera";
  75349. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  75350. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75351. import { Scene } from "babylonjs/scene";
  75352. import "babylonjs/Meshes/Builders/planeBuilder";
  75353. import "babylonjs/Shaders/depth.vertex";
  75354. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  75355. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  75356. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  75357. import { Engine } from "babylonjs/Engines/engine";
  75358. /**
  75359. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  75360. */
  75361. export class VolumetricLightScatteringPostProcess extends PostProcess {
  75362. private _volumetricLightScatteringPass;
  75363. private _volumetricLightScatteringRTT;
  75364. private _viewPort;
  75365. private _screenCoordinates;
  75366. private _cachedDefines;
  75367. /**
  75368. * If not undefined, the mesh position is computed from the attached node position
  75369. */
  75370. attachedNode: {
  75371. position: Vector3;
  75372. };
  75373. /**
  75374. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  75375. */
  75376. customMeshPosition: Vector3;
  75377. /**
  75378. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  75379. */
  75380. useCustomMeshPosition: boolean;
  75381. /**
  75382. * If the post-process should inverse the light scattering direction
  75383. */
  75384. invert: boolean;
  75385. /**
  75386. * The internal mesh used by the post-process
  75387. */
  75388. mesh: Mesh;
  75389. /**
  75390. * @hidden
  75391. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  75392. */
  75393. get useDiffuseColor(): boolean;
  75394. set useDiffuseColor(useDiffuseColor: boolean);
  75395. /**
  75396. * Array containing the excluded meshes not rendered in the internal pass
  75397. */
  75398. excludedMeshes: AbstractMesh[];
  75399. /**
  75400. * Controls the overall intensity of the post-process
  75401. */
  75402. exposure: number;
  75403. /**
  75404. * Dissipates each sample's contribution in range [0, 1]
  75405. */
  75406. decay: number;
  75407. /**
  75408. * Controls the overall intensity of each sample
  75409. */
  75410. weight: number;
  75411. /**
  75412. * Controls the density of each sample
  75413. */
  75414. density: number;
  75415. /**
  75416. * @constructor
  75417. * @param name The post-process name
  75418. * @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)
  75419. * @param camera The camera that the post-process will be attached to
  75420. * @param mesh The mesh used to create the light scattering
  75421. * @param samples The post-process quality, default 100
  75422. * @param samplingModeThe post-process filtering mode
  75423. * @param engine The babylon engine
  75424. * @param reusable If the post-process is reusable
  75425. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  75426. */
  75427. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  75428. /**
  75429. * Returns the string "VolumetricLightScatteringPostProcess"
  75430. * @returns "VolumetricLightScatteringPostProcess"
  75431. */
  75432. getClassName(): string;
  75433. private _isReady;
  75434. /**
  75435. * Sets the new light position for light scattering effect
  75436. * @param position The new custom light position
  75437. */
  75438. setCustomMeshPosition(position: Vector3): void;
  75439. /**
  75440. * Returns the light position for light scattering effect
  75441. * @return Vector3 The custom light position
  75442. */
  75443. getCustomMeshPosition(): Vector3;
  75444. /**
  75445. * Disposes the internal assets and detaches the post-process from the camera
  75446. */
  75447. dispose(camera: Camera): void;
  75448. /**
  75449. * Returns the render target texture used by the post-process
  75450. * @return the render target texture used by the post-process
  75451. */
  75452. getPass(): RenderTargetTexture;
  75453. private _meshExcluded;
  75454. private _createPass;
  75455. private _updateMeshScreenCoordinates;
  75456. /**
  75457. * Creates a default mesh for the Volumeric Light Scattering post-process
  75458. * @param name The mesh name
  75459. * @param scene The scene where to create the mesh
  75460. * @return the default mesh
  75461. */
  75462. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  75463. }
  75464. }
  75465. declare module "babylonjs/Shaders/screenSpaceCurvature.fragment" {
  75466. /** @hidden */
  75467. export var screenSpaceCurvaturePixelShader: {
  75468. name: string;
  75469. shader: string;
  75470. };
  75471. }
  75472. declare module "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess" {
  75473. import { Nullable } from "babylonjs/types";
  75474. import { Camera } from "babylonjs/Cameras/camera";
  75475. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75476. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  75477. import "babylonjs/Shaders/screenSpaceCurvature.fragment";
  75478. import { Engine } from "babylonjs/Engines/engine";
  75479. import { Scene } from "babylonjs/scene";
  75480. /**
  75481. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  75482. */
  75483. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  75484. /**
  75485. * Defines how much ridge the curvature effect displays.
  75486. */
  75487. ridge: number;
  75488. /**
  75489. * Defines how much valley the curvature effect displays.
  75490. */
  75491. valley: number;
  75492. private _geometryBufferRenderer;
  75493. /**
  75494. * Gets a string identifying the name of the class
  75495. * @returns "ScreenSpaceCurvaturePostProcess" string
  75496. */
  75497. getClassName(): string;
  75498. /**
  75499. * Creates a new instance ScreenSpaceCurvaturePostProcess
  75500. * @param name The name of the effect.
  75501. * @param scene The scene containing the objects to blur according to their velocity.
  75502. * @param options The required width/height ratio to downsize to before computing the render pass.
  75503. * @param camera The camera to apply the render pass to.
  75504. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75505. * @param engine The engine which the post process will be applied. (default: current engine)
  75506. * @param reusable If the post process can be reused on the same frame. (default: false)
  75507. * @param textureType Type of textures used when performing the post process. (default: 0)
  75508. * @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)
  75509. */
  75510. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  75511. /**
  75512. * Support test.
  75513. */
  75514. static get IsSupported(): boolean;
  75515. /** @hidden */
  75516. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  75517. }
  75518. }
  75519. declare module "babylonjs/PostProcesses/index" {
  75520. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  75521. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  75522. export * from "babylonjs/PostProcesses/bloomEffect";
  75523. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  75524. export * from "babylonjs/PostProcesses/blurPostProcess";
  75525. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  75526. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  75527. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  75528. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  75529. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  75530. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  75531. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  75532. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  75533. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  75534. export * from "babylonjs/PostProcesses/filterPostProcess";
  75535. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  75536. export * from "babylonjs/PostProcesses/grainPostProcess";
  75537. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  75538. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  75539. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  75540. export * from "babylonjs/PostProcesses/passPostProcess";
  75541. export * from "babylonjs/PostProcesses/postProcess";
  75542. export * from "babylonjs/PostProcesses/postProcessManager";
  75543. export * from "babylonjs/PostProcesses/refractionPostProcess";
  75544. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  75545. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  75546. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  75547. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  75548. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  75549. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  75550. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  75551. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  75552. export * from "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess";
  75553. }
  75554. declare module "babylonjs/Probes/index" {
  75555. export * from "babylonjs/Probes/reflectionProbe";
  75556. }
  75557. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  75558. import { Scene } from "babylonjs/scene";
  75559. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75560. import { SmartArray } from "babylonjs/Misc/smartArray";
  75561. import { ISceneComponent } from "babylonjs/sceneComponent";
  75562. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  75563. import "babylonjs/Meshes/Builders/boxBuilder";
  75564. import "babylonjs/Shaders/color.fragment";
  75565. import "babylonjs/Shaders/color.vertex";
  75566. import { Color3 } from "babylonjs/Maths/math.color";
  75567. import { Observable } from "babylonjs/Misc/observable";
  75568. module "babylonjs/scene" {
  75569. interface Scene {
  75570. /** @hidden (Backing field) */
  75571. _boundingBoxRenderer: BoundingBoxRenderer;
  75572. /** @hidden (Backing field) */
  75573. _forceShowBoundingBoxes: boolean;
  75574. /**
  75575. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  75576. */
  75577. forceShowBoundingBoxes: boolean;
  75578. /**
  75579. * Gets the bounding box renderer associated with the scene
  75580. * @returns a BoundingBoxRenderer
  75581. */
  75582. getBoundingBoxRenderer(): BoundingBoxRenderer;
  75583. }
  75584. }
  75585. module "babylonjs/Meshes/abstractMesh" {
  75586. interface AbstractMesh {
  75587. /** @hidden (Backing field) */
  75588. _showBoundingBox: boolean;
  75589. /**
  75590. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  75591. */
  75592. showBoundingBox: boolean;
  75593. }
  75594. }
  75595. /**
  75596. * Component responsible of rendering the bounding box of the meshes in a scene.
  75597. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  75598. */
  75599. export class BoundingBoxRenderer implements ISceneComponent {
  75600. /**
  75601. * The component name helpfull to identify the component in the list of scene components.
  75602. */
  75603. readonly name: string;
  75604. /**
  75605. * The scene the component belongs to.
  75606. */
  75607. scene: Scene;
  75608. /**
  75609. * Color of the bounding box lines placed in front of an object
  75610. */
  75611. frontColor: Color3;
  75612. /**
  75613. * Color of the bounding box lines placed behind an object
  75614. */
  75615. backColor: Color3;
  75616. /**
  75617. * Defines if the renderer should show the back lines or not
  75618. */
  75619. showBackLines: boolean;
  75620. /**
  75621. * Observable raised before rendering a bounding box
  75622. */
  75623. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  75624. /**
  75625. * Observable raised after rendering a bounding box
  75626. */
  75627. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  75628. /**
  75629. * @hidden
  75630. */
  75631. renderList: SmartArray<BoundingBox>;
  75632. private _colorShader;
  75633. private _vertexBuffers;
  75634. private _indexBuffer;
  75635. private _fillIndexBuffer;
  75636. private _fillIndexData;
  75637. /**
  75638. * Instantiates a new bounding box renderer in a scene.
  75639. * @param scene the scene the renderer renders in
  75640. */
  75641. constructor(scene: Scene);
  75642. /**
  75643. * Registers the component in a given scene
  75644. */
  75645. register(): void;
  75646. private _evaluateSubMesh;
  75647. private _activeMesh;
  75648. private _prepareRessources;
  75649. private _createIndexBuffer;
  75650. /**
  75651. * Rebuilds the elements related to this component in case of
  75652. * context lost for instance.
  75653. */
  75654. rebuild(): void;
  75655. /**
  75656. * @hidden
  75657. */
  75658. reset(): void;
  75659. /**
  75660. * Render the bounding boxes of a specific rendering group
  75661. * @param renderingGroupId defines the rendering group to render
  75662. */
  75663. render(renderingGroupId: number): void;
  75664. /**
  75665. * In case of occlusion queries, we can render the occlusion bounding box through this method
  75666. * @param mesh Define the mesh to render the occlusion bounding box for
  75667. */
  75668. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  75669. /**
  75670. * Dispose and release the resources attached to this renderer.
  75671. */
  75672. dispose(): void;
  75673. }
  75674. }
  75675. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  75676. import { Nullable } from "babylonjs/types";
  75677. import { Scene } from "babylonjs/scene";
  75678. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  75679. import { Camera } from "babylonjs/Cameras/camera";
  75680. import { ISceneComponent } from "babylonjs/sceneComponent";
  75681. module "babylonjs/scene" {
  75682. interface Scene {
  75683. /** @hidden (Backing field) */
  75684. _depthRenderer: {
  75685. [id: string]: DepthRenderer;
  75686. };
  75687. /**
  75688. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  75689. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  75690. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  75691. * @returns the created depth renderer
  75692. */
  75693. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  75694. /**
  75695. * Disables a depth renderer for a given camera
  75696. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  75697. */
  75698. disableDepthRenderer(camera?: Nullable<Camera>): void;
  75699. }
  75700. }
  75701. /**
  75702. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  75703. * in several rendering techniques.
  75704. */
  75705. export class DepthRendererSceneComponent implements ISceneComponent {
  75706. /**
  75707. * The component name helpfull to identify the component in the list of scene components.
  75708. */
  75709. readonly name: string;
  75710. /**
  75711. * The scene the component belongs to.
  75712. */
  75713. scene: Scene;
  75714. /**
  75715. * Creates a new instance of the component for the given scene
  75716. * @param scene Defines the scene to register the component in
  75717. */
  75718. constructor(scene: Scene);
  75719. /**
  75720. * Registers the component in a given scene
  75721. */
  75722. register(): void;
  75723. /**
  75724. * Rebuilds the elements related to this component in case of
  75725. * context lost for instance.
  75726. */
  75727. rebuild(): void;
  75728. /**
  75729. * Disposes the component and the associated ressources
  75730. */
  75731. dispose(): void;
  75732. private _gatherRenderTargets;
  75733. private _gatherActiveCameraRenderTargets;
  75734. }
  75735. }
  75736. declare module "babylonjs/Rendering/prePassRendererSceneComponent" {
  75737. import { Nullable } from "babylonjs/types";
  75738. import { Scene } from "babylonjs/scene";
  75739. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  75740. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  75741. import { AbstractScene } from "babylonjs/abstractScene";
  75742. module "babylonjs/abstractScene" {
  75743. interface AbstractScene {
  75744. /** @hidden (Backing field) */
  75745. _prePassRenderer: Nullable<PrePassRenderer>;
  75746. /**
  75747. * Gets or Sets the current prepass renderer associated to the scene.
  75748. */
  75749. prePassRenderer: Nullable<PrePassRenderer>;
  75750. /**
  75751. * Enables the prepass and associates it with the scene
  75752. * @returns the PrePassRenderer
  75753. */
  75754. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  75755. /**
  75756. * Disables the prepass associated with the scene
  75757. */
  75758. disablePrePassRenderer(): void;
  75759. }
  75760. }
  75761. /**
  75762. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  75763. * in several rendering techniques.
  75764. */
  75765. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  75766. /**
  75767. * The component name helpful to identify the component in the list of scene components.
  75768. */
  75769. readonly name: string;
  75770. /**
  75771. * The scene the component belongs to.
  75772. */
  75773. scene: Scene;
  75774. /**
  75775. * Creates a new instance of the component for the given scene
  75776. * @param scene Defines the scene to register the component in
  75777. */
  75778. constructor(scene: Scene);
  75779. /**
  75780. * Registers the component in a given scene
  75781. */
  75782. register(): void;
  75783. private _beforeCameraDraw;
  75784. private _afterCameraDraw;
  75785. private _beforeClearStage;
  75786. /**
  75787. * Serializes the component data to the specified json object
  75788. * @param serializationObject The object to serialize to
  75789. */
  75790. serialize(serializationObject: any): void;
  75791. /**
  75792. * Adds all the elements from the container to the scene
  75793. * @param container the container holding the elements
  75794. */
  75795. addFromContainer(container: AbstractScene): void;
  75796. /**
  75797. * Removes all the elements in the container from the scene
  75798. * @param container contains the elements to remove
  75799. * @param dispose if the removed element should be disposed (default: false)
  75800. */
  75801. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  75802. /**
  75803. * Rebuilds the elements related to this component in case of
  75804. * context lost for instance.
  75805. */
  75806. rebuild(): void;
  75807. /**
  75808. * Disposes the component and the associated ressources
  75809. */
  75810. dispose(): void;
  75811. }
  75812. }
  75813. declare module "babylonjs/Shaders/outline.fragment" {
  75814. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  75815. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  75816. /** @hidden */
  75817. export var outlinePixelShader: {
  75818. name: string;
  75819. shader: string;
  75820. };
  75821. }
  75822. declare module "babylonjs/Shaders/outline.vertex" {
  75823. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  75824. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  75825. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  75826. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  75827. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  75828. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  75829. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  75830. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  75831. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  75832. /** @hidden */
  75833. export var outlineVertexShader: {
  75834. name: string;
  75835. shader: string;
  75836. };
  75837. }
  75838. declare module "babylonjs/Rendering/outlineRenderer" {
  75839. import { SubMesh } from "babylonjs/Meshes/subMesh";
  75840. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  75841. import { Scene } from "babylonjs/scene";
  75842. import { ISceneComponent } from "babylonjs/sceneComponent";
  75843. import "babylonjs/Shaders/outline.fragment";
  75844. import "babylonjs/Shaders/outline.vertex";
  75845. module "babylonjs/scene" {
  75846. interface Scene {
  75847. /** @hidden */
  75848. _outlineRenderer: OutlineRenderer;
  75849. /**
  75850. * Gets the outline renderer associated with the scene
  75851. * @returns a OutlineRenderer
  75852. */
  75853. getOutlineRenderer(): OutlineRenderer;
  75854. }
  75855. }
  75856. module "babylonjs/Meshes/abstractMesh" {
  75857. interface AbstractMesh {
  75858. /** @hidden (Backing field) */
  75859. _renderOutline: boolean;
  75860. /**
  75861. * Gets or sets a boolean indicating if the outline must be rendered as well
  75862. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  75863. */
  75864. renderOutline: boolean;
  75865. /** @hidden (Backing field) */
  75866. _renderOverlay: boolean;
  75867. /**
  75868. * Gets or sets a boolean indicating if the overlay must be rendered as well
  75869. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  75870. */
  75871. renderOverlay: boolean;
  75872. }
  75873. }
  75874. /**
  75875. * This class is responsible to draw bothe outline/overlay of meshes.
  75876. * It should not be used directly but through the available method on mesh.
  75877. */
  75878. export class OutlineRenderer implements ISceneComponent {
  75879. /**
  75880. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  75881. */
  75882. private static _StencilReference;
  75883. /**
  75884. * The name of the component. Each component must have a unique name.
  75885. */
  75886. name: string;
  75887. /**
  75888. * The scene the component belongs to.
  75889. */
  75890. scene: Scene;
  75891. /**
  75892. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  75893. */
  75894. zOffset: number;
  75895. private _engine;
  75896. private _effect;
  75897. private _cachedDefines;
  75898. private _savedDepthWrite;
  75899. /**
  75900. * Instantiates a new outline renderer. (There could be only one per scene).
  75901. * @param scene Defines the scene it belongs to
  75902. */
  75903. constructor(scene: Scene);
  75904. /**
  75905. * Register the component to one instance of a scene.
  75906. */
  75907. register(): void;
  75908. /**
  75909. * Rebuilds the elements related to this component in case of
  75910. * context lost for instance.
  75911. */
  75912. rebuild(): void;
  75913. /**
  75914. * Disposes the component and the associated ressources.
  75915. */
  75916. dispose(): void;
  75917. /**
  75918. * Renders the outline in the canvas.
  75919. * @param subMesh Defines the sumesh to render
  75920. * @param batch Defines the batch of meshes in case of instances
  75921. * @param useOverlay Defines if the rendering is for the overlay or the outline
  75922. */
  75923. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  75924. /**
  75925. * Returns whether or not the outline renderer is ready for a given submesh.
  75926. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  75927. * @param subMesh Defines the submesh to check readyness for
  75928. * @param useInstances Defines wheter wee are trying to render instances or not
  75929. * @returns true if ready otherwise false
  75930. */
  75931. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  75932. private _beforeRenderingMesh;
  75933. private _afterRenderingMesh;
  75934. }
  75935. }
  75936. declare module "babylonjs/Rendering/index" {
  75937. export * from "babylonjs/Rendering/boundingBoxRenderer";
  75938. export * from "babylonjs/Rendering/depthRenderer";
  75939. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  75940. export * from "babylonjs/Rendering/edgesRenderer";
  75941. export * from "babylonjs/Rendering/geometryBufferRenderer";
  75942. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  75943. export * from "babylonjs/Rendering/prePassRenderer";
  75944. export * from "babylonjs/Rendering/prePassRendererSceneComponent";
  75945. export * from "babylonjs/Rendering/outlineRenderer";
  75946. export * from "babylonjs/Rendering/renderingGroup";
  75947. export * from "babylonjs/Rendering/renderingManager";
  75948. export * from "babylonjs/Rendering/utilityLayerRenderer";
  75949. }
  75950. declare module "babylonjs/Sprites/ISprites" {
  75951. /**
  75952. * Defines the basic options interface of a Sprite Frame Source Size.
  75953. */
  75954. export interface ISpriteJSONSpriteSourceSize {
  75955. /**
  75956. * number of the original width of the Frame
  75957. */
  75958. w: number;
  75959. /**
  75960. * number of the original height of the Frame
  75961. */
  75962. h: number;
  75963. }
  75964. /**
  75965. * Defines the basic options interface of a Sprite Frame Data.
  75966. */
  75967. export interface ISpriteJSONSpriteFrameData {
  75968. /**
  75969. * number of the x offset of the Frame
  75970. */
  75971. x: number;
  75972. /**
  75973. * number of the y offset of the Frame
  75974. */
  75975. y: number;
  75976. /**
  75977. * number of the width of the Frame
  75978. */
  75979. w: number;
  75980. /**
  75981. * number of the height of the Frame
  75982. */
  75983. h: number;
  75984. }
  75985. /**
  75986. * Defines the basic options interface of a JSON Sprite.
  75987. */
  75988. export interface ISpriteJSONSprite {
  75989. /**
  75990. * string name of the Frame
  75991. */
  75992. filename: string;
  75993. /**
  75994. * ISpriteJSONSpriteFrame basic object of the frame data
  75995. */
  75996. frame: ISpriteJSONSpriteFrameData;
  75997. /**
  75998. * boolean to flag is the frame was rotated.
  75999. */
  76000. rotated: boolean;
  76001. /**
  76002. * boolean to flag is the frame was trimmed.
  76003. */
  76004. trimmed: boolean;
  76005. /**
  76006. * ISpriteJSONSpriteFrame basic object of the source data
  76007. */
  76008. spriteSourceSize: ISpriteJSONSpriteFrameData;
  76009. /**
  76010. * ISpriteJSONSpriteFrame basic object of the source data
  76011. */
  76012. sourceSize: ISpriteJSONSpriteSourceSize;
  76013. }
  76014. /**
  76015. * Defines the basic options interface of a JSON atlas.
  76016. */
  76017. export interface ISpriteJSONAtlas {
  76018. /**
  76019. * Array of objects that contain the frame data.
  76020. */
  76021. frames: Array<ISpriteJSONSprite>;
  76022. /**
  76023. * object basic object containing the sprite meta data.
  76024. */
  76025. meta?: object;
  76026. }
  76027. }
  76028. declare module "babylonjs/Shaders/spriteMap.fragment" {
  76029. /** @hidden */
  76030. export var spriteMapPixelShader: {
  76031. name: string;
  76032. shader: string;
  76033. };
  76034. }
  76035. declare module "babylonjs/Shaders/spriteMap.vertex" {
  76036. /** @hidden */
  76037. export var spriteMapVertexShader: {
  76038. name: string;
  76039. shader: string;
  76040. };
  76041. }
  76042. declare module "babylonjs/Sprites/spriteMap" {
  76043. import { IDisposable, Scene } from "babylonjs/scene";
  76044. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  76045. import { Texture } from "babylonjs/Materials/Textures/texture";
  76046. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  76047. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  76048. import "babylonjs/Meshes/Builders/planeBuilder";
  76049. import "babylonjs/Shaders/spriteMap.fragment";
  76050. import "babylonjs/Shaders/spriteMap.vertex";
  76051. /**
  76052. * Defines the basic options interface of a SpriteMap
  76053. */
  76054. export interface ISpriteMapOptions {
  76055. /**
  76056. * Vector2 of the number of cells in the grid.
  76057. */
  76058. stageSize?: Vector2;
  76059. /**
  76060. * Vector2 of the size of the output plane in World Units.
  76061. */
  76062. outputSize?: Vector2;
  76063. /**
  76064. * Vector3 of the position of the output plane in World Units.
  76065. */
  76066. outputPosition?: Vector3;
  76067. /**
  76068. * Vector3 of the rotation of the output plane.
  76069. */
  76070. outputRotation?: Vector3;
  76071. /**
  76072. * number of layers that the system will reserve in resources.
  76073. */
  76074. layerCount?: number;
  76075. /**
  76076. * number of max animation frames a single cell will reserve in resources.
  76077. */
  76078. maxAnimationFrames?: number;
  76079. /**
  76080. * number cell index of the base tile when the system compiles.
  76081. */
  76082. baseTile?: number;
  76083. /**
  76084. * boolean flip the sprite after its been repositioned by the framing data.
  76085. */
  76086. flipU?: boolean;
  76087. /**
  76088. * Vector3 scalar of the global RGB values of the SpriteMap.
  76089. */
  76090. colorMultiply?: Vector3;
  76091. }
  76092. /**
  76093. * Defines the IDisposable interface in order to be cleanable from resources.
  76094. */
  76095. export interface ISpriteMap extends IDisposable {
  76096. /**
  76097. * String name of the SpriteMap.
  76098. */
  76099. name: string;
  76100. /**
  76101. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  76102. */
  76103. atlasJSON: ISpriteJSONAtlas;
  76104. /**
  76105. * Texture of the SpriteMap.
  76106. */
  76107. spriteSheet: Texture;
  76108. /**
  76109. * The parameters to initialize the SpriteMap with.
  76110. */
  76111. options: ISpriteMapOptions;
  76112. }
  76113. /**
  76114. * Class used to manage a grid restricted sprite deployment on an Output plane.
  76115. */
  76116. export class SpriteMap implements ISpriteMap {
  76117. /** The Name of the spriteMap */
  76118. name: string;
  76119. /** The JSON file with the frame and meta data */
  76120. atlasJSON: ISpriteJSONAtlas;
  76121. /** The systems Sprite Sheet Texture */
  76122. spriteSheet: Texture;
  76123. /** Arguments passed with the Constructor */
  76124. options: ISpriteMapOptions;
  76125. /** Public Sprite Storage array, parsed from atlasJSON */
  76126. sprites: Array<ISpriteJSONSprite>;
  76127. /** Returns the Number of Sprites in the System */
  76128. get spriteCount(): number;
  76129. /** Returns the Position of Output Plane*/
  76130. get position(): Vector3;
  76131. /** Returns the Position of Output Plane*/
  76132. set position(v: Vector3);
  76133. /** Returns the Rotation of Output Plane*/
  76134. get rotation(): Vector3;
  76135. /** Returns the Rotation of Output Plane*/
  76136. set rotation(v: Vector3);
  76137. /** Sets the AnimationMap*/
  76138. get animationMap(): RawTexture;
  76139. /** Sets the AnimationMap*/
  76140. set animationMap(v: RawTexture);
  76141. /** Scene that the SpriteMap was created in */
  76142. private _scene;
  76143. /** Texture Buffer of Float32 that holds tile frame data*/
  76144. private _frameMap;
  76145. /** Texture Buffers of Float32 that holds tileMap data*/
  76146. private _tileMaps;
  76147. /** Texture Buffer of Float32 that holds Animation Data*/
  76148. private _animationMap;
  76149. /** Custom ShaderMaterial Central to the System*/
  76150. private _material;
  76151. /** Custom ShaderMaterial Central to the System*/
  76152. private _output;
  76153. /** Systems Time Ticker*/
  76154. private _time;
  76155. /**
  76156. * Creates a new SpriteMap
  76157. * @param name defines the SpriteMaps Name
  76158. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  76159. * @param spriteSheet is the Texture that the Sprites are on.
  76160. * @param options a basic deployment configuration
  76161. * @param scene The Scene that the map is deployed on
  76162. */
  76163. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  76164. /**
  76165. * Returns tileID location
  76166. * @returns Vector2 the cell position ID
  76167. */
  76168. getTileID(): Vector2;
  76169. /**
  76170. * Gets the UV location of the mouse over the SpriteMap.
  76171. * @returns Vector2 the UV position of the mouse interaction
  76172. */
  76173. getMousePosition(): Vector2;
  76174. /**
  76175. * Creates the "frame" texture Buffer
  76176. * -------------------------------------
  76177. * Structure of frames
  76178. * "filename": "Falling-Water-2.png",
  76179. * "frame": {"x":69,"y":103,"w":24,"h":32},
  76180. * "rotated": true,
  76181. * "trimmed": true,
  76182. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  76183. * "sourceSize": {"w":32,"h":32}
  76184. * @returns RawTexture of the frameMap
  76185. */
  76186. private _createFrameBuffer;
  76187. /**
  76188. * Creates the tileMap texture Buffer
  76189. * @param buffer normally and array of numbers, or a false to generate from scratch
  76190. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  76191. * @returns RawTexture of the tileMap
  76192. */
  76193. private _createTileBuffer;
  76194. /**
  76195. * Modifies the data of the tileMaps
  76196. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  76197. * @param pos is the iVector2 Coordinates of the Tile
  76198. * @param tile The SpriteIndex of the new Tile
  76199. */
  76200. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  76201. /**
  76202. * Creates the animationMap texture Buffer
  76203. * @param buffer normally and array of numbers, or a false to generate from scratch
  76204. * @returns RawTexture of the animationMap
  76205. */
  76206. private _createTileAnimationBuffer;
  76207. /**
  76208. * Modifies the data of the animationMap
  76209. * @param cellID is the Index of the Sprite
  76210. * @param _frame is the target Animation frame
  76211. * @param toCell is the Target Index of the next frame of the animation
  76212. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  76213. * @param speed is a global scalar of the time variable on the map.
  76214. */
  76215. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  76216. /**
  76217. * Exports the .tilemaps file
  76218. */
  76219. saveTileMaps(): void;
  76220. /**
  76221. * Imports the .tilemaps file
  76222. * @param url of the .tilemaps file
  76223. */
  76224. loadTileMaps(url: string): void;
  76225. /**
  76226. * Release associated resources
  76227. */
  76228. dispose(): void;
  76229. }
  76230. }
  76231. declare module "babylonjs/Sprites/spritePackedManager" {
  76232. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  76233. import { Scene } from "babylonjs/scene";
  76234. /**
  76235. * Class used to manage multiple sprites of different sizes on the same spritesheet
  76236. * @see https://doc.babylonjs.com/babylon101/sprites
  76237. */
  76238. export class SpritePackedManager extends SpriteManager {
  76239. /** defines the packed manager's name */
  76240. name: string;
  76241. /**
  76242. * Creates a new sprite manager from a packed sprite sheet
  76243. * @param name defines the manager's name
  76244. * @param imgUrl defines the sprite sheet url
  76245. * @param capacity defines the maximum allowed number of sprites
  76246. * @param scene defines the hosting scene
  76247. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  76248. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  76249. * @param samplingMode defines the smapling mode to use with spritesheet
  76250. * @param fromPacked set to true; do not alter
  76251. */
  76252. constructor(
  76253. /** defines the packed manager's name */
  76254. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  76255. }
  76256. }
  76257. declare module "babylonjs/Sprites/index" {
  76258. export * from "babylonjs/Sprites/sprite";
  76259. export * from "babylonjs/Sprites/ISprites";
  76260. export * from "babylonjs/Sprites/spriteManager";
  76261. export * from "babylonjs/Sprites/spriteMap";
  76262. export * from "babylonjs/Sprites/spritePackedManager";
  76263. export * from "babylonjs/Sprites/spriteSceneComponent";
  76264. }
  76265. declare module "babylonjs/States/index" {
  76266. export * from "babylonjs/States/alphaCullingState";
  76267. export * from "babylonjs/States/depthCullingState";
  76268. export * from "babylonjs/States/stencilState";
  76269. }
  76270. declare module "babylonjs/Misc/assetsManager" {
  76271. import { Scene } from "babylonjs/scene";
  76272. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76273. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  76274. import { Skeleton } from "babylonjs/Bones/skeleton";
  76275. import { Observable } from "babylonjs/Misc/observable";
  76276. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  76277. import { Texture } from "babylonjs/Materials/Textures/texture";
  76278. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  76279. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  76280. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  76281. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  76282. import { AssetContainer } from "babylonjs/assetContainer";
  76283. /**
  76284. * Defines the list of states available for a task inside a AssetsManager
  76285. */
  76286. export enum AssetTaskState {
  76287. /**
  76288. * Initialization
  76289. */
  76290. INIT = 0,
  76291. /**
  76292. * Running
  76293. */
  76294. RUNNING = 1,
  76295. /**
  76296. * Done
  76297. */
  76298. DONE = 2,
  76299. /**
  76300. * Error
  76301. */
  76302. ERROR = 3
  76303. }
  76304. /**
  76305. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  76306. */
  76307. export abstract class AbstractAssetTask {
  76308. /**
  76309. * Task name
  76310. */ name: string;
  76311. /**
  76312. * Callback called when the task is successful
  76313. */
  76314. onSuccess: (task: any) => void;
  76315. /**
  76316. * Callback called when the task is not successful
  76317. */
  76318. onError: (task: any, message?: string, exception?: any) => void;
  76319. /**
  76320. * Creates a new AssetsManager
  76321. * @param name defines the name of the task
  76322. */
  76323. constructor(
  76324. /**
  76325. * Task name
  76326. */ name: string);
  76327. private _isCompleted;
  76328. private _taskState;
  76329. private _errorObject;
  76330. /**
  76331. * Get if the task is completed
  76332. */
  76333. get isCompleted(): boolean;
  76334. /**
  76335. * Gets the current state of the task
  76336. */
  76337. get taskState(): AssetTaskState;
  76338. /**
  76339. * Gets the current error object (if task is in error)
  76340. */
  76341. get errorObject(): {
  76342. message?: string;
  76343. exception?: any;
  76344. };
  76345. /**
  76346. * Internal only
  76347. * @hidden
  76348. */
  76349. _setErrorObject(message?: string, exception?: any): void;
  76350. /**
  76351. * Execute the current task
  76352. * @param scene defines the scene where you want your assets to be loaded
  76353. * @param onSuccess is a callback called when the task is successfully executed
  76354. * @param onError is a callback called if an error occurs
  76355. */
  76356. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76357. /**
  76358. * Execute the current task
  76359. * @param scene defines the scene where you want your assets to be loaded
  76360. * @param onSuccess is a callback called when the task is successfully executed
  76361. * @param onError is a callback called if an error occurs
  76362. */
  76363. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76364. /**
  76365. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  76366. * This can be used with failed tasks that have the reason for failure fixed.
  76367. */
  76368. reset(): void;
  76369. private onErrorCallback;
  76370. private onDoneCallback;
  76371. }
  76372. /**
  76373. * Define the interface used by progress events raised during assets loading
  76374. */
  76375. export interface IAssetsProgressEvent {
  76376. /**
  76377. * Defines the number of remaining tasks to process
  76378. */
  76379. remainingCount: number;
  76380. /**
  76381. * Defines the total number of tasks
  76382. */
  76383. totalCount: number;
  76384. /**
  76385. * Defines the task that was just processed
  76386. */
  76387. task: AbstractAssetTask;
  76388. }
  76389. /**
  76390. * Class used to share progress information about assets loading
  76391. */
  76392. export class AssetsProgressEvent implements IAssetsProgressEvent {
  76393. /**
  76394. * Defines the number of remaining tasks to process
  76395. */
  76396. remainingCount: number;
  76397. /**
  76398. * Defines the total number of tasks
  76399. */
  76400. totalCount: number;
  76401. /**
  76402. * Defines the task that was just processed
  76403. */
  76404. task: AbstractAssetTask;
  76405. /**
  76406. * Creates a AssetsProgressEvent
  76407. * @param remainingCount defines the number of remaining tasks to process
  76408. * @param totalCount defines the total number of tasks
  76409. * @param task defines the task that was just processed
  76410. */
  76411. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  76412. }
  76413. /**
  76414. * Define a task used by AssetsManager to load assets into a container
  76415. */
  76416. export class ContainerAssetTask extends AbstractAssetTask {
  76417. /**
  76418. * Defines the name of the task
  76419. */
  76420. name: string;
  76421. /**
  76422. * Defines the list of mesh's names you want to load
  76423. */
  76424. meshesNames: any;
  76425. /**
  76426. * Defines the root url to use as a base to load your meshes and associated resources
  76427. */
  76428. rootUrl: string;
  76429. /**
  76430. * Defines the filename or File of the scene to load from
  76431. */
  76432. sceneFilename: string | File;
  76433. /**
  76434. * Get the loaded asset container
  76435. */
  76436. loadedContainer: AssetContainer;
  76437. /**
  76438. * Gets the list of loaded meshes
  76439. */
  76440. loadedMeshes: Array<AbstractMesh>;
  76441. /**
  76442. * Gets the list of loaded particle systems
  76443. */
  76444. loadedParticleSystems: Array<IParticleSystem>;
  76445. /**
  76446. * Gets the list of loaded skeletons
  76447. */
  76448. loadedSkeletons: Array<Skeleton>;
  76449. /**
  76450. * Gets the list of loaded animation groups
  76451. */
  76452. loadedAnimationGroups: Array<AnimationGroup>;
  76453. /**
  76454. * Callback called when the task is successful
  76455. */
  76456. onSuccess: (task: ContainerAssetTask) => void;
  76457. /**
  76458. * Callback called when the task is successful
  76459. */
  76460. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  76461. /**
  76462. * Creates a new ContainerAssetTask
  76463. * @param name defines the name of the task
  76464. * @param meshesNames defines the list of mesh's names you want to load
  76465. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  76466. * @param sceneFilename defines the filename or File of the scene to load from
  76467. */
  76468. constructor(
  76469. /**
  76470. * Defines the name of the task
  76471. */
  76472. name: string,
  76473. /**
  76474. * Defines the list of mesh's names you want to load
  76475. */
  76476. meshesNames: any,
  76477. /**
  76478. * Defines the root url to use as a base to load your meshes and associated resources
  76479. */
  76480. rootUrl: string,
  76481. /**
  76482. * Defines the filename or File of the scene to load from
  76483. */
  76484. sceneFilename: string | File);
  76485. /**
  76486. * Execute the current task
  76487. * @param scene defines the scene where you want your assets to be loaded
  76488. * @param onSuccess is a callback called when the task is successfully executed
  76489. * @param onError is a callback called if an error occurs
  76490. */
  76491. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76492. }
  76493. /**
  76494. * Define a task used by AssetsManager to load meshes
  76495. */
  76496. export class MeshAssetTask extends AbstractAssetTask {
  76497. /**
  76498. * Defines the name of the task
  76499. */
  76500. name: string;
  76501. /**
  76502. * Defines the list of mesh's names you want to load
  76503. */
  76504. meshesNames: any;
  76505. /**
  76506. * Defines the root url to use as a base to load your meshes and associated resources
  76507. */
  76508. rootUrl: string;
  76509. /**
  76510. * Defines the filename or File of the scene to load from
  76511. */
  76512. sceneFilename: string | File;
  76513. /**
  76514. * Gets the list of loaded meshes
  76515. */
  76516. loadedMeshes: Array<AbstractMesh>;
  76517. /**
  76518. * Gets the list of loaded particle systems
  76519. */
  76520. loadedParticleSystems: Array<IParticleSystem>;
  76521. /**
  76522. * Gets the list of loaded skeletons
  76523. */
  76524. loadedSkeletons: Array<Skeleton>;
  76525. /**
  76526. * Gets the list of loaded animation groups
  76527. */
  76528. loadedAnimationGroups: Array<AnimationGroup>;
  76529. /**
  76530. * Callback called when the task is successful
  76531. */
  76532. onSuccess: (task: MeshAssetTask) => void;
  76533. /**
  76534. * Callback called when the task is successful
  76535. */
  76536. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  76537. /**
  76538. * Creates a new MeshAssetTask
  76539. * @param name defines the name of the task
  76540. * @param meshesNames defines the list of mesh's names you want to load
  76541. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  76542. * @param sceneFilename defines the filename or File of the scene to load from
  76543. */
  76544. constructor(
  76545. /**
  76546. * Defines the name of the task
  76547. */
  76548. name: string,
  76549. /**
  76550. * Defines the list of mesh's names you want to load
  76551. */
  76552. meshesNames: any,
  76553. /**
  76554. * Defines the root url to use as a base to load your meshes and associated resources
  76555. */
  76556. rootUrl: string,
  76557. /**
  76558. * Defines the filename or File of the scene to load from
  76559. */
  76560. sceneFilename: string | File);
  76561. /**
  76562. * Execute the current task
  76563. * @param scene defines the scene where you want your assets to be loaded
  76564. * @param onSuccess is a callback called when the task is successfully executed
  76565. * @param onError is a callback called if an error occurs
  76566. */
  76567. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76568. }
  76569. /**
  76570. * Define a task used by AssetsManager to load text content
  76571. */
  76572. export class TextFileAssetTask extends AbstractAssetTask {
  76573. /**
  76574. * Defines the name of the task
  76575. */
  76576. name: string;
  76577. /**
  76578. * Defines the location of the file to load
  76579. */
  76580. url: string;
  76581. /**
  76582. * Gets the loaded text string
  76583. */
  76584. text: string;
  76585. /**
  76586. * Callback called when the task is successful
  76587. */
  76588. onSuccess: (task: TextFileAssetTask) => void;
  76589. /**
  76590. * Callback called when the task is successful
  76591. */
  76592. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  76593. /**
  76594. * Creates a new TextFileAssetTask object
  76595. * @param name defines the name of the task
  76596. * @param url defines the location of the file to load
  76597. */
  76598. constructor(
  76599. /**
  76600. * Defines the name of the task
  76601. */
  76602. name: string,
  76603. /**
  76604. * Defines the location of the file to load
  76605. */
  76606. url: string);
  76607. /**
  76608. * Execute the current task
  76609. * @param scene defines the scene where you want your assets to be loaded
  76610. * @param onSuccess is a callback called when the task is successfully executed
  76611. * @param onError is a callback called if an error occurs
  76612. */
  76613. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76614. }
  76615. /**
  76616. * Define a task used by AssetsManager to load binary data
  76617. */
  76618. export class BinaryFileAssetTask extends AbstractAssetTask {
  76619. /**
  76620. * Defines the name of the task
  76621. */
  76622. name: string;
  76623. /**
  76624. * Defines the location of the file to load
  76625. */
  76626. url: string;
  76627. /**
  76628. * Gets the lodaded data (as an array buffer)
  76629. */
  76630. data: ArrayBuffer;
  76631. /**
  76632. * Callback called when the task is successful
  76633. */
  76634. onSuccess: (task: BinaryFileAssetTask) => void;
  76635. /**
  76636. * Callback called when the task is successful
  76637. */
  76638. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  76639. /**
  76640. * Creates a new BinaryFileAssetTask object
  76641. * @param name defines the name of the new task
  76642. * @param url defines the location of the file to load
  76643. */
  76644. constructor(
  76645. /**
  76646. * Defines the name of the task
  76647. */
  76648. name: string,
  76649. /**
  76650. * Defines the location of the file to load
  76651. */
  76652. url: string);
  76653. /**
  76654. * Execute the current task
  76655. * @param scene defines the scene where you want your assets to be loaded
  76656. * @param onSuccess is a callback called when the task is successfully executed
  76657. * @param onError is a callback called if an error occurs
  76658. */
  76659. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76660. }
  76661. /**
  76662. * Define a task used by AssetsManager to load images
  76663. */
  76664. export class ImageAssetTask extends AbstractAssetTask {
  76665. /**
  76666. * Defines the name of the task
  76667. */
  76668. name: string;
  76669. /**
  76670. * Defines the location of the image to load
  76671. */
  76672. url: string;
  76673. /**
  76674. * Gets the loaded images
  76675. */
  76676. image: HTMLImageElement;
  76677. /**
  76678. * Callback called when the task is successful
  76679. */
  76680. onSuccess: (task: ImageAssetTask) => void;
  76681. /**
  76682. * Callback called when the task is successful
  76683. */
  76684. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  76685. /**
  76686. * Creates a new ImageAssetTask
  76687. * @param name defines the name of the task
  76688. * @param url defines the location of the image to load
  76689. */
  76690. constructor(
  76691. /**
  76692. * Defines the name of the task
  76693. */
  76694. name: string,
  76695. /**
  76696. * Defines the location of the image to load
  76697. */
  76698. url: string);
  76699. /**
  76700. * Execute the current task
  76701. * @param scene defines the scene where you want your assets to be loaded
  76702. * @param onSuccess is a callback called when the task is successfully executed
  76703. * @param onError is a callback called if an error occurs
  76704. */
  76705. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76706. }
  76707. /**
  76708. * Defines the interface used by texture loading tasks
  76709. */
  76710. export interface ITextureAssetTask<TEX extends BaseTexture> {
  76711. /**
  76712. * Gets the loaded texture
  76713. */
  76714. texture: TEX;
  76715. }
  76716. /**
  76717. * Define a task used by AssetsManager to load 2D textures
  76718. */
  76719. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  76720. /**
  76721. * Defines the name of the task
  76722. */
  76723. name: string;
  76724. /**
  76725. * Defines the location of the file to load
  76726. */
  76727. url: string;
  76728. /**
  76729. * Defines if mipmap should not be generated (default is false)
  76730. */
  76731. noMipmap?: boolean | undefined;
  76732. /**
  76733. * Defines if texture must be inverted on Y axis (default is true)
  76734. */
  76735. invertY: boolean;
  76736. /**
  76737. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  76738. */
  76739. samplingMode: number;
  76740. /**
  76741. * Gets the loaded texture
  76742. */
  76743. texture: Texture;
  76744. /**
  76745. * Callback called when the task is successful
  76746. */
  76747. onSuccess: (task: TextureAssetTask) => void;
  76748. /**
  76749. * Callback called when the task is successful
  76750. */
  76751. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  76752. /**
  76753. * Creates a new TextureAssetTask object
  76754. * @param name defines the name of the task
  76755. * @param url defines the location of the file to load
  76756. * @param noMipmap defines if mipmap should not be generated (default is false)
  76757. * @param invertY defines if texture must be inverted on Y axis (default is true)
  76758. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  76759. */
  76760. constructor(
  76761. /**
  76762. * Defines the name of the task
  76763. */
  76764. name: string,
  76765. /**
  76766. * Defines the location of the file to load
  76767. */
  76768. url: string,
  76769. /**
  76770. * Defines if mipmap should not be generated (default is false)
  76771. */
  76772. noMipmap?: boolean | undefined,
  76773. /**
  76774. * Defines if texture must be inverted on Y axis (default is true)
  76775. */
  76776. invertY?: boolean,
  76777. /**
  76778. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  76779. */
  76780. samplingMode?: number);
  76781. /**
  76782. * Execute the current task
  76783. * @param scene defines the scene where you want your assets to be loaded
  76784. * @param onSuccess is a callback called when the task is successfully executed
  76785. * @param onError is a callback called if an error occurs
  76786. */
  76787. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76788. }
  76789. /**
  76790. * Define a task used by AssetsManager to load cube textures
  76791. */
  76792. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  76793. /**
  76794. * Defines the name of the task
  76795. */
  76796. name: string;
  76797. /**
  76798. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  76799. */
  76800. url: string;
  76801. /**
  76802. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  76803. */
  76804. extensions?: string[] | undefined;
  76805. /**
  76806. * Defines if mipmaps should not be generated (default is false)
  76807. */
  76808. noMipmap?: boolean | undefined;
  76809. /**
  76810. * Defines the explicit list of files (undefined by default)
  76811. */
  76812. files?: string[] | undefined;
  76813. /**
  76814. * Gets the loaded texture
  76815. */
  76816. texture: CubeTexture;
  76817. /**
  76818. * Callback called when the task is successful
  76819. */
  76820. onSuccess: (task: CubeTextureAssetTask) => void;
  76821. /**
  76822. * Callback called when the task is successful
  76823. */
  76824. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  76825. /**
  76826. * Creates a new CubeTextureAssetTask
  76827. * @param name defines the name of the task
  76828. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  76829. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  76830. * @param noMipmap defines if mipmaps should not be generated (default is false)
  76831. * @param files defines the explicit list of files (undefined by default)
  76832. */
  76833. constructor(
  76834. /**
  76835. * Defines the name of the task
  76836. */
  76837. name: string,
  76838. /**
  76839. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  76840. */
  76841. url: string,
  76842. /**
  76843. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  76844. */
  76845. extensions?: string[] | undefined,
  76846. /**
  76847. * Defines if mipmaps should not be generated (default is false)
  76848. */
  76849. noMipmap?: boolean | undefined,
  76850. /**
  76851. * Defines the explicit list of files (undefined by default)
  76852. */
  76853. files?: string[] | undefined);
  76854. /**
  76855. * Execute the current task
  76856. * @param scene defines the scene where you want your assets to be loaded
  76857. * @param onSuccess is a callback called when the task is successfully executed
  76858. * @param onError is a callback called if an error occurs
  76859. */
  76860. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76861. }
  76862. /**
  76863. * Define a task used by AssetsManager to load HDR cube textures
  76864. */
  76865. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  76866. /**
  76867. * Defines the name of the task
  76868. */
  76869. name: string;
  76870. /**
  76871. * Defines the location of the file to load
  76872. */
  76873. url: string;
  76874. /**
  76875. * Defines the desired size (the more it increases the longer the generation will be)
  76876. */
  76877. size: number;
  76878. /**
  76879. * Defines if mipmaps should not be generated (default is false)
  76880. */
  76881. noMipmap: boolean;
  76882. /**
  76883. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  76884. */
  76885. generateHarmonics: boolean;
  76886. /**
  76887. * 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)
  76888. */
  76889. gammaSpace: boolean;
  76890. /**
  76891. * Internal Use Only
  76892. */
  76893. reserved: boolean;
  76894. /**
  76895. * Gets the loaded texture
  76896. */
  76897. texture: HDRCubeTexture;
  76898. /**
  76899. * Callback called when the task is successful
  76900. */
  76901. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  76902. /**
  76903. * Callback called when the task is successful
  76904. */
  76905. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  76906. /**
  76907. * Creates a new HDRCubeTextureAssetTask object
  76908. * @param name defines the name of the task
  76909. * @param url defines the location of the file to load
  76910. * @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.
  76911. * @param noMipmap defines if mipmaps should not be generated (default is false)
  76912. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  76913. * @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)
  76914. * @param reserved Internal use only
  76915. */
  76916. constructor(
  76917. /**
  76918. * Defines the name of the task
  76919. */
  76920. name: string,
  76921. /**
  76922. * Defines the location of the file to load
  76923. */
  76924. url: string,
  76925. /**
  76926. * Defines the desired size (the more it increases the longer the generation will be)
  76927. */
  76928. size: number,
  76929. /**
  76930. * Defines if mipmaps should not be generated (default is false)
  76931. */
  76932. noMipmap?: boolean,
  76933. /**
  76934. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  76935. */
  76936. generateHarmonics?: boolean,
  76937. /**
  76938. * 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)
  76939. */
  76940. gammaSpace?: boolean,
  76941. /**
  76942. * Internal Use Only
  76943. */
  76944. reserved?: boolean);
  76945. /**
  76946. * Execute the current task
  76947. * @param scene defines the scene where you want your assets to be loaded
  76948. * @param onSuccess is a callback called when the task is successfully executed
  76949. * @param onError is a callback called if an error occurs
  76950. */
  76951. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76952. }
  76953. /**
  76954. * Define a task used by AssetsManager to load Equirectangular cube textures
  76955. */
  76956. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  76957. /**
  76958. * Defines the name of the task
  76959. */
  76960. name: string;
  76961. /**
  76962. * Defines the location of the file to load
  76963. */
  76964. url: string;
  76965. /**
  76966. * Defines the desired size (the more it increases the longer the generation will be)
  76967. */
  76968. size: number;
  76969. /**
  76970. * Defines if mipmaps should not be generated (default is false)
  76971. */
  76972. noMipmap: boolean;
  76973. /**
  76974. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  76975. * but the standard material would require them in Gamma space) (default is true)
  76976. */
  76977. gammaSpace: boolean;
  76978. /**
  76979. * Gets the loaded texture
  76980. */
  76981. texture: EquiRectangularCubeTexture;
  76982. /**
  76983. * Callback called when the task is successful
  76984. */
  76985. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  76986. /**
  76987. * Callback called when the task is successful
  76988. */
  76989. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  76990. /**
  76991. * Creates a new EquiRectangularCubeTextureAssetTask object
  76992. * @param name defines the name of the task
  76993. * @param url defines the location of the file to load
  76994. * @param size defines the desired size (the more it increases the longer the generation will be)
  76995. * If the size is omitted this implies you are using a preprocessed cubemap.
  76996. * @param noMipmap defines if mipmaps should not be generated (default is false)
  76997. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  76998. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  76999. * (default is true)
  77000. */
  77001. constructor(
  77002. /**
  77003. * Defines the name of the task
  77004. */
  77005. name: string,
  77006. /**
  77007. * Defines the location of the file to load
  77008. */
  77009. url: string,
  77010. /**
  77011. * Defines the desired size (the more it increases the longer the generation will be)
  77012. */
  77013. size: number,
  77014. /**
  77015. * Defines if mipmaps should not be generated (default is false)
  77016. */
  77017. noMipmap?: boolean,
  77018. /**
  77019. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  77020. * but the standard material would require them in Gamma space) (default is true)
  77021. */
  77022. gammaSpace?: boolean);
  77023. /**
  77024. * Execute the current task
  77025. * @param scene defines the scene where you want your assets to be loaded
  77026. * @param onSuccess is a callback called when the task is successfully executed
  77027. * @param onError is a callback called if an error occurs
  77028. */
  77029. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77030. }
  77031. /**
  77032. * This class can be used to easily import assets into a scene
  77033. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  77034. */
  77035. export class AssetsManager {
  77036. private _scene;
  77037. private _isLoading;
  77038. protected _tasks: AbstractAssetTask[];
  77039. protected _waitingTasksCount: number;
  77040. protected _totalTasksCount: number;
  77041. /**
  77042. * Callback called when all tasks are processed
  77043. */
  77044. onFinish: (tasks: AbstractAssetTask[]) => void;
  77045. /**
  77046. * Callback called when a task is successful
  77047. */
  77048. onTaskSuccess: (task: AbstractAssetTask) => void;
  77049. /**
  77050. * Callback called when a task had an error
  77051. */
  77052. onTaskError: (task: AbstractAssetTask) => void;
  77053. /**
  77054. * Callback called when a task is done (whatever the result is)
  77055. */
  77056. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  77057. /**
  77058. * Observable called when all tasks are processed
  77059. */
  77060. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  77061. /**
  77062. * Observable called when a task had an error
  77063. */
  77064. onTaskErrorObservable: Observable<AbstractAssetTask>;
  77065. /**
  77066. * Observable called when all tasks were executed
  77067. */
  77068. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  77069. /**
  77070. * Observable called when a task is done (whatever the result is)
  77071. */
  77072. onProgressObservable: Observable<IAssetsProgressEvent>;
  77073. /**
  77074. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  77075. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  77076. */
  77077. useDefaultLoadingScreen: boolean;
  77078. /**
  77079. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  77080. * when all assets have been downloaded.
  77081. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  77082. */
  77083. autoHideLoadingUI: boolean;
  77084. /**
  77085. * Creates a new AssetsManager
  77086. * @param scene defines the scene to work on
  77087. */
  77088. constructor(scene: Scene);
  77089. /**
  77090. * Add a ContainerAssetTask to the list of active tasks
  77091. * @param taskName defines the name of the new task
  77092. * @param meshesNames defines the name of meshes to load
  77093. * @param rootUrl defines the root url to use to locate files
  77094. * @param sceneFilename defines the filename of the scene file
  77095. * @returns a new ContainerAssetTask object
  77096. */
  77097. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  77098. /**
  77099. * Add a MeshAssetTask to the list of active tasks
  77100. * @param taskName defines the name of the new task
  77101. * @param meshesNames defines the name of meshes to load
  77102. * @param rootUrl defines the root url to use to locate files
  77103. * @param sceneFilename defines the filename of the scene file
  77104. * @returns a new MeshAssetTask object
  77105. */
  77106. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  77107. /**
  77108. * Add a TextFileAssetTask to the list of active tasks
  77109. * @param taskName defines the name of the new task
  77110. * @param url defines the url of the file to load
  77111. * @returns a new TextFileAssetTask object
  77112. */
  77113. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  77114. /**
  77115. * Add a BinaryFileAssetTask to the list of active tasks
  77116. * @param taskName defines the name of the new task
  77117. * @param url defines the url of the file to load
  77118. * @returns a new BinaryFileAssetTask object
  77119. */
  77120. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  77121. /**
  77122. * Add a ImageAssetTask to the list of active tasks
  77123. * @param taskName defines the name of the new task
  77124. * @param url defines the url of the file to load
  77125. * @returns a new ImageAssetTask object
  77126. */
  77127. addImageTask(taskName: string, url: string): ImageAssetTask;
  77128. /**
  77129. * Add a TextureAssetTask to the list of active tasks
  77130. * @param taskName defines the name of the new task
  77131. * @param url defines the url of the file to load
  77132. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77133. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  77134. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  77135. * @returns a new TextureAssetTask object
  77136. */
  77137. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  77138. /**
  77139. * Add a CubeTextureAssetTask to the list of active tasks
  77140. * @param taskName defines the name of the new task
  77141. * @param url defines the url of the file to load
  77142. * @param extensions defines the extension to use to load the cube map (can be null)
  77143. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77144. * @param files defines the list of files to load (can be null)
  77145. * @returns a new CubeTextureAssetTask object
  77146. */
  77147. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  77148. /**
  77149. *
  77150. * Add a HDRCubeTextureAssetTask to the list of active tasks
  77151. * @param taskName defines the name of the new task
  77152. * @param url defines the url of the file to load
  77153. * @param size defines the size you want for the cubemap (can be null)
  77154. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77155. * @param generateHarmonics defines if you want to automatically generate (true by default)
  77156. * @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)
  77157. * @param reserved Internal use only
  77158. * @returns a new HDRCubeTextureAssetTask object
  77159. */
  77160. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  77161. /**
  77162. *
  77163. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  77164. * @param taskName defines the name of the new task
  77165. * @param url defines the url of the file to load
  77166. * @param size defines the size you want for the cubemap (can be null)
  77167. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77168. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  77169. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  77170. * @returns a new EquiRectangularCubeTextureAssetTask object
  77171. */
  77172. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  77173. /**
  77174. * Remove a task from the assets manager.
  77175. * @param task the task to remove
  77176. */
  77177. removeTask(task: AbstractAssetTask): void;
  77178. private _decreaseWaitingTasksCount;
  77179. private _runTask;
  77180. /**
  77181. * Reset the AssetsManager and remove all tasks
  77182. * @return the current instance of the AssetsManager
  77183. */
  77184. reset(): AssetsManager;
  77185. /**
  77186. * Start the loading process
  77187. * @return the current instance of the AssetsManager
  77188. */
  77189. load(): AssetsManager;
  77190. /**
  77191. * Start the loading process as an async operation
  77192. * @return a promise returning the list of failed tasks
  77193. */
  77194. loadAsync(): Promise<void>;
  77195. }
  77196. }
  77197. declare module "babylonjs/Misc/deferred" {
  77198. /**
  77199. * Wrapper class for promise with external resolve and reject.
  77200. */
  77201. export class Deferred<T> {
  77202. /**
  77203. * The promise associated with this deferred object.
  77204. */
  77205. readonly promise: Promise<T>;
  77206. private _resolve;
  77207. private _reject;
  77208. /**
  77209. * The resolve method of the promise associated with this deferred object.
  77210. */
  77211. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  77212. /**
  77213. * The reject method of the promise associated with this deferred object.
  77214. */
  77215. get reject(): (reason?: any) => void;
  77216. /**
  77217. * Constructor for this deferred object.
  77218. */
  77219. constructor();
  77220. }
  77221. }
  77222. declare module "babylonjs/Misc/meshExploder" {
  77223. import { Mesh } from "babylonjs/Meshes/mesh";
  77224. /**
  77225. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  77226. */
  77227. export class MeshExploder {
  77228. private _centerMesh;
  77229. private _meshes;
  77230. private _meshesOrigins;
  77231. private _toCenterVectors;
  77232. private _scaledDirection;
  77233. private _newPosition;
  77234. private _centerPosition;
  77235. /**
  77236. * Explodes meshes from a center mesh.
  77237. * @param meshes The meshes to explode.
  77238. * @param centerMesh The mesh to be center of explosion.
  77239. */
  77240. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  77241. private _setCenterMesh;
  77242. /**
  77243. * Get class name
  77244. * @returns "MeshExploder"
  77245. */
  77246. getClassName(): string;
  77247. /**
  77248. * "Exploded meshes"
  77249. * @returns Array of meshes with the centerMesh at index 0.
  77250. */
  77251. getMeshes(): Array<Mesh>;
  77252. /**
  77253. * Explodes meshes giving a specific direction
  77254. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  77255. */
  77256. explode(direction?: number): void;
  77257. }
  77258. }
  77259. declare module "babylonjs/Misc/filesInput" {
  77260. import { Engine } from "babylonjs/Engines/engine";
  77261. import { Scene } from "babylonjs/scene";
  77262. import { ISceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  77263. import { Nullable } from "babylonjs/types";
  77264. /**
  77265. * Class used to help managing file picking and drag'n'drop
  77266. */
  77267. export class FilesInput {
  77268. /**
  77269. * List of files ready to be loaded
  77270. */
  77271. static get FilesToLoad(): {
  77272. [key: string]: File;
  77273. };
  77274. /**
  77275. * Callback called when a file is processed
  77276. */
  77277. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  77278. private _engine;
  77279. private _currentScene;
  77280. private _sceneLoadedCallback;
  77281. private _progressCallback;
  77282. private _additionalRenderLoopLogicCallback;
  77283. private _textureLoadingCallback;
  77284. private _startingProcessingFilesCallback;
  77285. private _onReloadCallback;
  77286. private _errorCallback;
  77287. private _elementToMonitor;
  77288. private _sceneFileToLoad;
  77289. private _filesToLoad;
  77290. /**
  77291. * Creates a new FilesInput
  77292. * @param engine defines the rendering engine
  77293. * @param scene defines the hosting scene
  77294. * @param sceneLoadedCallback callback called when scene is loaded
  77295. * @param progressCallback callback called to track progress
  77296. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  77297. * @param textureLoadingCallback callback called when a texture is loading
  77298. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  77299. * @param onReloadCallback callback called when a reload is requested
  77300. * @param errorCallback callback call if an error occurs
  77301. */
  77302. 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>);
  77303. private _dragEnterHandler;
  77304. private _dragOverHandler;
  77305. private _dropHandler;
  77306. /**
  77307. * Calls this function to listen to drag'n'drop events on a specific DOM element
  77308. * @param elementToMonitor defines the DOM element to track
  77309. */
  77310. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  77311. /** Gets the current list of files to load */
  77312. get filesToLoad(): File[];
  77313. /**
  77314. * Release all associated resources
  77315. */
  77316. dispose(): void;
  77317. private renderFunction;
  77318. private drag;
  77319. private drop;
  77320. private _traverseFolder;
  77321. private _processFiles;
  77322. /**
  77323. * Load files from a drop event
  77324. * @param event defines the drop event to use as source
  77325. */
  77326. loadFiles(event: any): void;
  77327. private _processReload;
  77328. /**
  77329. * Reload the current scene from the loaded files
  77330. */
  77331. reload(): void;
  77332. }
  77333. }
  77334. declare module "babylonjs/Misc/HighDynamicRange/index" {
  77335. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  77336. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  77337. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  77338. }
  77339. declare module "babylonjs/Misc/sceneOptimizer" {
  77340. import { Scene, IDisposable } from "babylonjs/scene";
  77341. import { Observable } from "babylonjs/Misc/observable";
  77342. /**
  77343. * Defines the root class used to create scene optimization to use with SceneOptimizer
  77344. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77345. */
  77346. export class SceneOptimization {
  77347. /**
  77348. * Defines the priority of this optimization (0 by default which means first in the list)
  77349. */
  77350. priority: number;
  77351. /**
  77352. * Gets a string describing the action executed by the current optimization
  77353. * @returns description string
  77354. */
  77355. getDescription(): string;
  77356. /**
  77357. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77358. * @param scene defines the current scene where to apply this optimization
  77359. * @param optimizer defines the current optimizer
  77360. * @returns true if everything that can be done was applied
  77361. */
  77362. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77363. /**
  77364. * Creates the SceneOptimization object
  77365. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77366. * @param desc defines the description associated with the optimization
  77367. */
  77368. constructor(
  77369. /**
  77370. * Defines the priority of this optimization (0 by default which means first in the list)
  77371. */
  77372. priority?: number);
  77373. }
  77374. /**
  77375. * Defines an optimization used to reduce the size of render target textures
  77376. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77377. */
  77378. export class TextureOptimization extends SceneOptimization {
  77379. /**
  77380. * Defines the priority of this optimization (0 by default which means first in the list)
  77381. */
  77382. priority: number;
  77383. /**
  77384. * 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
  77385. */
  77386. maximumSize: number;
  77387. /**
  77388. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  77389. */
  77390. step: number;
  77391. /**
  77392. * Gets a string describing the action executed by the current optimization
  77393. * @returns description string
  77394. */
  77395. getDescription(): string;
  77396. /**
  77397. * Creates the TextureOptimization object
  77398. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77399. * @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
  77400. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  77401. */
  77402. constructor(
  77403. /**
  77404. * Defines the priority of this optimization (0 by default which means first in the list)
  77405. */
  77406. priority?: number,
  77407. /**
  77408. * 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
  77409. */
  77410. maximumSize?: number,
  77411. /**
  77412. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  77413. */
  77414. step?: number);
  77415. /**
  77416. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77417. * @param scene defines the current scene where to apply this optimization
  77418. * @param optimizer defines the current optimizer
  77419. * @returns true if everything that can be done was applied
  77420. */
  77421. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77422. }
  77423. /**
  77424. * Defines an optimization used to increase or decrease the rendering resolution
  77425. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77426. */
  77427. export class HardwareScalingOptimization extends SceneOptimization {
  77428. /**
  77429. * Defines the priority of this optimization (0 by default which means first in the list)
  77430. */
  77431. priority: number;
  77432. /**
  77433. * Defines the maximum scale to use (2 by default)
  77434. */
  77435. maximumScale: number;
  77436. /**
  77437. * Defines the step to use between two passes (0.5 by default)
  77438. */
  77439. step: number;
  77440. private _currentScale;
  77441. private _directionOffset;
  77442. /**
  77443. * Gets a string describing the action executed by the current optimization
  77444. * @return description string
  77445. */
  77446. getDescription(): string;
  77447. /**
  77448. * Creates the HardwareScalingOptimization object
  77449. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77450. * @param maximumScale defines the maximum scale to use (2 by default)
  77451. * @param step defines the step to use between two passes (0.5 by default)
  77452. */
  77453. constructor(
  77454. /**
  77455. * Defines the priority of this optimization (0 by default which means first in the list)
  77456. */
  77457. priority?: number,
  77458. /**
  77459. * Defines the maximum scale to use (2 by default)
  77460. */
  77461. maximumScale?: number,
  77462. /**
  77463. * Defines the step to use between two passes (0.5 by default)
  77464. */
  77465. step?: number);
  77466. /**
  77467. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77468. * @param scene defines the current scene where to apply this optimization
  77469. * @param optimizer defines the current optimizer
  77470. * @returns true if everything that can be done was applied
  77471. */
  77472. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77473. }
  77474. /**
  77475. * Defines an optimization used to remove shadows
  77476. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77477. */
  77478. export class ShadowsOptimization extends SceneOptimization {
  77479. /**
  77480. * Gets a string describing the action executed by the current optimization
  77481. * @return description string
  77482. */
  77483. getDescription(): string;
  77484. /**
  77485. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77486. * @param scene defines the current scene where to apply this optimization
  77487. * @param optimizer defines the current optimizer
  77488. * @returns true if everything that can be done was applied
  77489. */
  77490. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77491. }
  77492. /**
  77493. * Defines an optimization used to turn post-processes off
  77494. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77495. */
  77496. export class PostProcessesOptimization extends SceneOptimization {
  77497. /**
  77498. * Gets a string describing the action executed by the current optimization
  77499. * @return description string
  77500. */
  77501. getDescription(): string;
  77502. /**
  77503. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77504. * @param scene defines the current scene where to apply this optimization
  77505. * @param optimizer defines the current optimizer
  77506. * @returns true if everything that can be done was applied
  77507. */
  77508. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77509. }
  77510. /**
  77511. * Defines an optimization used to turn lens flares off
  77512. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77513. */
  77514. export class LensFlaresOptimization extends SceneOptimization {
  77515. /**
  77516. * Gets a string describing the action executed by the current optimization
  77517. * @return description string
  77518. */
  77519. getDescription(): string;
  77520. /**
  77521. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77522. * @param scene defines the current scene where to apply this optimization
  77523. * @param optimizer defines the current optimizer
  77524. * @returns true if everything that can be done was applied
  77525. */
  77526. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77527. }
  77528. /**
  77529. * Defines an optimization based on user defined callback.
  77530. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77531. */
  77532. export class CustomOptimization extends SceneOptimization {
  77533. /**
  77534. * Callback called to apply the custom optimization.
  77535. */
  77536. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  77537. /**
  77538. * Callback called to get custom description
  77539. */
  77540. onGetDescription: () => string;
  77541. /**
  77542. * Gets a string describing the action executed by the current optimization
  77543. * @returns description string
  77544. */
  77545. getDescription(): string;
  77546. /**
  77547. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77548. * @param scene defines the current scene where to apply this optimization
  77549. * @param optimizer defines the current optimizer
  77550. * @returns true if everything that can be done was applied
  77551. */
  77552. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77553. }
  77554. /**
  77555. * Defines an optimization used to turn particles off
  77556. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77557. */
  77558. export class ParticlesOptimization extends SceneOptimization {
  77559. /**
  77560. * Gets a string describing the action executed by the current optimization
  77561. * @return description string
  77562. */
  77563. getDescription(): string;
  77564. /**
  77565. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77566. * @param scene defines the current scene where to apply this optimization
  77567. * @param optimizer defines the current optimizer
  77568. * @returns true if everything that can be done was applied
  77569. */
  77570. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77571. }
  77572. /**
  77573. * Defines an optimization used to turn render targets off
  77574. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77575. */
  77576. export class RenderTargetsOptimization extends SceneOptimization {
  77577. /**
  77578. * Gets a string describing the action executed by the current optimization
  77579. * @return description string
  77580. */
  77581. getDescription(): string;
  77582. /**
  77583. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77584. * @param scene defines the current scene where to apply this optimization
  77585. * @param optimizer defines the current optimizer
  77586. * @returns true if everything that can be done was applied
  77587. */
  77588. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77589. }
  77590. /**
  77591. * Defines an optimization used to merge meshes with compatible materials
  77592. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77593. */
  77594. export class MergeMeshesOptimization extends SceneOptimization {
  77595. private static _UpdateSelectionTree;
  77596. /**
  77597. * Gets or sets a boolean which defines if optimization octree has to be updated
  77598. */
  77599. static get UpdateSelectionTree(): boolean;
  77600. /**
  77601. * Gets or sets a boolean which defines if optimization octree has to be updated
  77602. */
  77603. static set UpdateSelectionTree(value: boolean);
  77604. /**
  77605. * Gets a string describing the action executed by the current optimization
  77606. * @return description string
  77607. */
  77608. getDescription(): string;
  77609. private _canBeMerged;
  77610. /**
  77611. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77612. * @param scene defines the current scene where to apply this optimization
  77613. * @param optimizer defines the current optimizer
  77614. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  77615. * @returns true if everything that can be done was applied
  77616. */
  77617. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  77618. }
  77619. /**
  77620. * Defines a list of options used by SceneOptimizer
  77621. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77622. */
  77623. export class SceneOptimizerOptions {
  77624. /**
  77625. * Defines the target frame rate to reach (60 by default)
  77626. */
  77627. targetFrameRate: number;
  77628. /**
  77629. * Defines the interval between two checkes (2000ms by default)
  77630. */
  77631. trackerDuration: number;
  77632. /**
  77633. * Gets the list of optimizations to apply
  77634. */
  77635. optimizations: SceneOptimization[];
  77636. /**
  77637. * Creates a new list of options used by SceneOptimizer
  77638. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  77639. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  77640. */
  77641. constructor(
  77642. /**
  77643. * Defines the target frame rate to reach (60 by default)
  77644. */
  77645. targetFrameRate?: number,
  77646. /**
  77647. * Defines the interval between two checkes (2000ms by default)
  77648. */
  77649. trackerDuration?: number);
  77650. /**
  77651. * Add a new optimization
  77652. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  77653. * @returns the current SceneOptimizerOptions
  77654. */
  77655. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  77656. /**
  77657. * Add a new custom optimization
  77658. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  77659. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  77660. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77661. * @returns the current SceneOptimizerOptions
  77662. */
  77663. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  77664. /**
  77665. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  77666. * @param targetFrameRate defines the target frame rate (60 by default)
  77667. * @returns a SceneOptimizerOptions object
  77668. */
  77669. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  77670. /**
  77671. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  77672. * @param targetFrameRate defines the target frame rate (60 by default)
  77673. * @returns a SceneOptimizerOptions object
  77674. */
  77675. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  77676. /**
  77677. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  77678. * @param targetFrameRate defines the target frame rate (60 by default)
  77679. * @returns a SceneOptimizerOptions object
  77680. */
  77681. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  77682. }
  77683. /**
  77684. * Class used to run optimizations in order to reach a target frame rate
  77685. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77686. */
  77687. export class SceneOptimizer implements IDisposable {
  77688. private _isRunning;
  77689. private _options;
  77690. private _scene;
  77691. private _currentPriorityLevel;
  77692. private _targetFrameRate;
  77693. private _trackerDuration;
  77694. private _currentFrameRate;
  77695. private _sceneDisposeObserver;
  77696. private _improvementMode;
  77697. /**
  77698. * Defines an observable called when the optimizer reaches the target frame rate
  77699. */
  77700. onSuccessObservable: Observable<SceneOptimizer>;
  77701. /**
  77702. * Defines an observable called when the optimizer enables an optimization
  77703. */
  77704. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  77705. /**
  77706. * Defines an observable called when the optimizer is not able to reach the target frame rate
  77707. */
  77708. onFailureObservable: Observable<SceneOptimizer>;
  77709. /**
  77710. * Gets a boolean indicating if the optimizer is in improvement mode
  77711. */
  77712. get isInImprovementMode(): boolean;
  77713. /**
  77714. * Gets the current priority level (0 at start)
  77715. */
  77716. get currentPriorityLevel(): number;
  77717. /**
  77718. * Gets the current frame rate checked by the SceneOptimizer
  77719. */
  77720. get currentFrameRate(): number;
  77721. /**
  77722. * Gets or sets the current target frame rate (60 by default)
  77723. */
  77724. get targetFrameRate(): number;
  77725. /**
  77726. * Gets or sets the current target frame rate (60 by default)
  77727. */
  77728. set targetFrameRate(value: number);
  77729. /**
  77730. * Gets or sets the current interval between two checks (every 2000ms by default)
  77731. */
  77732. get trackerDuration(): number;
  77733. /**
  77734. * Gets or sets the current interval between two checks (every 2000ms by default)
  77735. */
  77736. set trackerDuration(value: number);
  77737. /**
  77738. * Gets the list of active optimizations
  77739. */
  77740. get optimizations(): SceneOptimization[];
  77741. /**
  77742. * Creates a new SceneOptimizer
  77743. * @param scene defines the scene to work on
  77744. * @param options defines the options to use with the SceneOptimizer
  77745. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  77746. * @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)
  77747. */
  77748. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  77749. /**
  77750. * Stops the current optimizer
  77751. */
  77752. stop(): void;
  77753. /**
  77754. * Reset the optimizer to initial step (current priority level = 0)
  77755. */
  77756. reset(): void;
  77757. /**
  77758. * Start the optimizer. By default it will try to reach a specific framerate
  77759. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  77760. */
  77761. start(): void;
  77762. private _checkCurrentState;
  77763. /**
  77764. * Release all resources
  77765. */
  77766. dispose(): void;
  77767. /**
  77768. * Helper function to create a SceneOptimizer with one single line of code
  77769. * @param scene defines the scene to work on
  77770. * @param options defines the options to use with the SceneOptimizer
  77771. * @param onSuccess defines a callback to call on success
  77772. * @param onFailure defines a callback to call on failure
  77773. * @returns the new SceneOptimizer object
  77774. */
  77775. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  77776. }
  77777. }
  77778. declare module "babylonjs/Misc/sceneSerializer" {
  77779. import { Scene } from "babylonjs/scene";
  77780. /**
  77781. * Class used to serialize a scene into a string
  77782. */
  77783. export class SceneSerializer {
  77784. /**
  77785. * Clear cache used by a previous serialization
  77786. */
  77787. static ClearCache(): void;
  77788. /**
  77789. * Serialize a scene into a JSON compatible object
  77790. * @param scene defines the scene to serialize
  77791. * @returns a JSON compatible object
  77792. */
  77793. static Serialize(scene: Scene): any;
  77794. /**
  77795. * Serialize a mesh into a JSON compatible object
  77796. * @param toSerialize defines the mesh to serialize
  77797. * @param withParents defines if parents must be serialized as well
  77798. * @param withChildren defines if children must be serialized as well
  77799. * @returns a JSON compatible object
  77800. */
  77801. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  77802. }
  77803. }
  77804. declare module "babylonjs/Misc/textureTools" {
  77805. import { Texture } from "babylonjs/Materials/Textures/texture";
  77806. /**
  77807. * Class used to host texture specific utilities
  77808. */
  77809. export class TextureTools {
  77810. /**
  77811. * Uses the GPU to create a copy texture rescaled at a given size
  77812. * @param texture Texture to copy from
  77813. * @param width defines the desired width
  77814. * @param height defines the desired height
  77815. * @param useBilinearMode defines if bilinear mode has to be used
  77816. * @return the generated texture
  77817. */
  77818. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  77819. }
  77820. }
  77821. declare module "babylonjs/Misc/videoRecorder" {
  77822. import { Nullable } from "babylonjs/types";
  77823. import { Engine } from "babylonjs/Engines/engine";
  77824. /**
  77825. * This represents the different options available for the video capture.
  77826. */
  77827. export interface VideoRecorderOptions {
  77828. /** Defines the mime type of the video. */
  77829. mimeType: string;
  77830. /** Defines the FPS the video should be recorded at. */
  77831. fps: number;
  77832. /** Defines the chunk size for the recording data. */
  77833. recordChunckSize: number;
  77834. /** The audio tracks to attach to the recording. */
  77835. audioTracks?: MediaStreamTrack[];
  77836. }
  77837. /**
  77838. * This can help with recording videos from BabylonJS.
  77839. * This is based on the available WebRTC functionalities of the browser.
  77840. *
  77841. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  77842. */
  77843. export class VideoRecorder {
  77844. private static readonly _defaultOptions;
  77845. /**
  77846. * Returns whether or not the VideoRecorder is available in your browser.
  77847. * @param engine Defines the Babylon Engine.
  77848. * @returns true if supported otherwise false.
  77849. */
  77850. static IsSupported(engine: Engine): boolean;
  77851. private readonly _options;
  77852. private _canvas;
  77853. private _mediaRecorder;
  77854. private _recordedChunks;
  77855. private _fileName;
  77856. private _resolve;
  77857. private _reject;
  77858. /**
  77859. * True when a recording is already in progress.
  77860. */
  77861. get isRecording(): boolean;
  77862. /**
  77863. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  77864. * @param engine Defines the BabylonJS Engine you wish to record.
  77865. * @param options Defines options that can be used to customize the capture.
  77866. */
  77867. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  77868. /**
  77869. * Stops the current recording before the default capture timeout passed in the startRecording function.
  77870. */
  77871. stopRecording(): void;
  77872. /**
  77873. * Starts recording the canvas for a max duration specified in parameters.
  77874. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  77875. * If null no automatic download will start and you can rely on the promise to get the data back.
  77876. * @param maxDuration Defines the maximum recording time in seconds.
  77877. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  77878. * @return A promise callback at the end of the recording with the video data in Blob.
  77879. */
  77880. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  77881. /**
  77882. * Releases internal resources used during the recording.
  77883. */
  77884. dispose(): void;
  77885. private _handleDataAvailable;
  77886. private _handleError;
  77887. private _handleStop;
  77888. }
  77889. }
  77890. declare module "babylonjs/Misc/screenshotTools" {
  77891. import { Camera } from "babylonjs/Cameras/camera";
  77892. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  77893. import { Engine } from "babylonjs/Engines/engine";
  77894. /**
  77895. * Class containing a set of static utilities functions for screenshots
  77896. */
  77897. export class ScreenshotTools {
  77898. /**
  77899. * Captures a screenshot of the current rendering
  77900. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  77901. * @param engine defines the rendering engine
  77902. * @param camera defines the source camera
  77903. * @param size This parameter can be set to a single number or to an object with the
  77904. * following (optional) properties: precision, width, height. If a single number is passed,
  77905. * it will be used for both width and height. If an object is passed, the screenshot size
  77906. * will be derived from the parameters. The precision property is a multiplier allowing
  77907. * rendering at a higher or lower resolution
  77908. * @param successCallback defines the callback receives a single parameter which contains the
  77909. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  77910. * src parameter of an <img> to display it
  77911. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  77912. * Check your browser for supported MIME types
  77913. */
  77914. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  77915. /**
  77916. * Captures a screenshot of the current rendering
  77917. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  77918. * @param engine defines the rendering engine
  77919. * @param camera defines the source camera
  77920. * @param size This parameter can be set to a single number or to an object with the
  77921. * following (optional) properties: precision, width, height. If a single number is passed,
  77922. * it will be used for both width and height. If an object is passed, the screenshot size
  77923. * will be derived from the parameters. The precision property is a multiplier allowing
  77924. * rendering at a higher or lower resolution
  77925. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  77926. * Check your browser for supported MIME types
  77927. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  77928. * to the src parameter of an <img> to display it
  77929. */
  77930. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  77931. /**
  77932. * Generates an image screenshot from the specified camera.
  77933. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  77934. * @param engine The engine to use for rendering
  77935. * @param camera The camera to use for rendering
  77936. * @param size This parameter can be set to a single number or to an object with the
  77937. * following (optional) properties: precision, width, height. If a single number is passed,
  77938. * it will be used for both width and height. If an object is passed, the screenshot size
  77939. * will be derived from the parameters. The precision property is a multiplier allowing
  77940. * rendering at a higher or lower resolution
  77941. * @param successCallback The callback receives a single parameter which contains the
  77942. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  77943. * src parameter of an <img> to display it
  77944. * @param mimeType The MIME type of the screenshot image (default: image/png).
  77945. * Check your browser for supported MIME types
  77946. * @param samples Texture samples (default: 1)
  77947. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  77948. * @param fileName A name for for the downloaded file.
  77949. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  77950. */
  77951. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  77952. /**
  77953. * Generates an image screenshot from the specified camera.
  77954. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  77955. * @param engine The engine to use for rendering
  77956. * @param camera The camera to use for rendering
  77957. * @param size This parameter can be set to a single number or to an object with the
  77958. * following (optional) properties: precision, width, height. If a single number is passed,
  77959. * it will be used for both width and height. If an object is passed, the screenshot size
  77960. * will be derived from the parameters. The precision property is a multiplier allowing
  77961. * rendering at a higher or lower resolution
  77962. * @param mimeType The MIME type of the screenshot image (default: image/png).
  77963. * Check your browser for supported MIME types
  77964. * @param samples Texture samples (default: 1)
  77965. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  77966. * @param fileName A name for for the downloaded file.
  77967. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  77968. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  77969. * to the src parameter of an <img> to display it
  77970. */
  77971. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  77972. /**
  77973. * Gets height and width for screenshot size
  77974. * @private
  77975. */
  77976. private static _getScreenshotSize;
  77977. }
  77978. }
  77979. declare module "babylonjs/Misc/dataReader" {
  77980. /**
  77981. * Interface for a data buffer
  77982. */
  77983. export interface IDataBuffer {
  77984. /**
  77985. * Reads bytes from the data buffer.
  77986. * @param byteOffset The byte offset to read
  77987. * @param byteLength The byte length to read
  77988. * @returns A promise that resolves when the bytes are read
  77989. */
  77990. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  77991. /**
  77992. * The byte length of the buffer.
  77993. */
  77994. readonly byteLength: number;
  77995. }
  77996. /**
  77997. * Utility class for reading from a data buffer
  77998. */
  77999. export class DataReader {
  78000. /**
  78001. * The data buffer associated with this data reader.
  78002. */
  78003. readonly buffer: IDataBuffer;
  78004. /**
  78005. * The current byte offset from the beginning of the data buffer.
  78006. */
  78007. byteOffset: number;
  78008. private _dataView;
  78009. private _dataByteOffset;
  78010. /**
  78011. * Constructor
  78012. * @param buffer The buffer to read
  78013. */
  78014. constructor(buffer: IDataBuffer);
  78015. /**
  78016. * Loads the given byte length.
  78017. * @param byteLength The byte length to load
  78018. * @returns A promise that resolves when the load is complete
  78019. */
  78020. loadAsync(byteLength: number): Promise<void>;
  78021. /**
  78022. * Read a unsigned 32-bit integer from the currently loaded data range.
  78023. * @returns The 32-bit integer read
  78024. */
  78025. readUint32(): number;
  78026. /**
  78027. * Read a byte array from the currently loaded data range.
  78028. * @param byteLength The byte length to read
  78029. * @returns The byte array read
  78030. */
  78031. readUint8Array(byteLength: number): Uint8Array;
  78032. /**
  78033. * Read a string from the currently loaded data range.
  78034. * @param byteLength The byte length to read
  78035. * @returns The string read
  78036. */
  78037. readString(byteLength: number): string;
  78038. /**
  78039. * Skips the given byte length the currently loaded data range.
  78040. * @param byteLength The byte length to skip
  78041. */
  78042. skipBytes(byteLength: number): void;
  78043. }
  78044. }
  78045. declare module "babylonjs/Misc/dataStorage" {
  78046. /**
  78047. * Class for storing data to local storage if available or in-memory storage otherwise
  78048. */
  78049. export class DataStorage {
  78050. private static _Storage;
  78051. private static _GetStorage;
  78052. /**
  78053. * Reads a string from the data storage
  78054. * @param key The key to read
  78055. * @param defaultValue The value if the key doesn't exist
  78056. * @returns The string value
  78057. */
  78058. static ReadString(key: string, defaultValue: string): string;
  78059. /**
  78060. * Writes a string to the data storage
  78061. * @param key The key to write
  78062. * @param value The value to write
  78063. */
  78064. static WriteString(key: string, value: string): void;
  78065. /**
  78066. * Reads a boolean from the data storage
  78067. * @param key The key to read
  78068. * @param defaultValue The value if the key doesn't exist
  78069. * @returns The boolean value
  78070. */
  78071. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  78072. /**
  78073. * Writes a boolean to the data storage
  78074. * @param key The key to write
  78075. * @param value The value to write
  78076. */
  78077. static WriteBoolean(key: string, value: boolean): void;
  78078. /**
  78079. * Reads a number from the data storage
  78080. * @param key The key to read
  78081. * @param defaultValue The value if the key doesn't exist
  78082. * @returns The number value
  78083. */
  78084. static ReadNumber(key: string, defaultValue: number): number;
  78085. /**
  78086. * Writes a number to the data storage
  78087. * @param key The key to write
  78088. * @param value The value to write
  78089. */
  78090. static WriteNumber(key: string, value: number): void;
  78091. }
  78092. }
  78093. declare module "babylonjs/Misc/sceneRecorder" {
  78094. import { Scene } from "babylonjs/scene";
  78095. /**
  78096. * Class used to record delta files between 2 scene states
  78097. */
  78098. export class SceneRecorder {
  78099. private _trackedScene;
  78100. private _savedJSON;
  78101. /**
  78102. * Track a given scene. This means the current scene state will be considered the original state
  78103. * @param scene defines the scene to track
  78104. */
  78105. track(scene: Scene): void;
  78106. /**
  78107. * Get the delta between current state and original state
  78108. * @returns a string containing the delta
  78109. */
  78110. getDelta(): any;
  78111. private _compareArray;
  78112. private _compareObjects;
  78113. private _compareCollections;
  78114. private static GetShadowGeneratorById;
  78115. /**
  78116. * Apply a given delta to a given scene
  78117. * @param deltaJSON defines the JSON containing the delta
  78118. * @param scene defines the scene to apply the delta to
  78119. */
  78120. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  78121. private static _ApplyPropertiesToEntity;
  78122. private static _ApplyDeltaForEntity;
  78123. }
  78124. }
  78125. declare module "babylonjs/Misc/index" {
  78126. export * from "babylonjs/Misc/andOrNotEvaluator";
  78127. export * from "babylonjs/Misc/assetsManager";
  78128. export * from "babylonjs/Misc/basis";
  78129. export * from "babylonjs/Misc/dds";
  78130. export * from "babylonjs/Misc/decorators";
  78131. export * from "babylonjs/Misc/deferred";
  78132. export * from "babylonjs/Misc/environmentTextureTools";
  78133. export * from "babylonjs/Misc/meshExploder";
  78134. export * from "babylonjs/Misc/filesInput";
  78135. export * from "babylonjs/Misc/HighDynamicRange/index";
  78136. export * from "babylonjs/Misc/khronosTextureContainer";
  78137. export * from "babylonjs/Misc/observable";
  78138. export * from "babylonjs/Misc/performanceMonitor";
  78139. export * from "babylonjs/Misc/promise";
  78140. export * from "babylonjs/Misc/sceneOptimizer";
  78141. export * from "babylonjs/Misc/sceneSerializer";
  78142. export * from "babylonjs/Misc/smartArray";
  78143. export * from "babylonjs/Misc/stringDictionary";
  78144. export * from "babylonjs/Misc/tags";
  78145. export * from "babylonjs/Misc/textureTools";
  78146. export * from "babylonjs/Misc/tga";
  78147. export * from "babylonjs/Misc/tools";
  78148. export * from "babylonjs/Misc/videoRecorder";
  78149. export * from "babylonjs/Misc/virtualJoystick";
  78150. export * from "babylonjs/Misc/workerPool";
  78151. export * from "babylonjs/Misc/logger";
  78152. export * from "babylonjs/Misc/typeStore";
  78153. export * from "babylonjs/Misc/filesInputStore";
  78154. export * from "babylonjs/Misc/deepCopier";
  78155. export * from "babylonjs/Misc/pivotTools";
  78156. export * from "babylonjs/Misc/precisionDate";
  78157. export * from "babylonjs/Misc/screenshotTools";
  78158. export * from "babylonjs/Misc/typeStore";
  78159. export * from "babylonjs/Misc/webRequest";
  78160. export * from "babylonjs/Misc/iInspectable";
  78161. export * from "babylonjs/Misc/brdfTextureTools";
  78162. export * from "babylonjs/Misc/rgbdTextureTools";
  78163. export * from "babylonjs/Misc/gradients";
  78164. export * from "babylonjs/Misc/perfCounter";
  78165. export * from "babylonjs/Misc/fileRequest";
  78166. export * from "babylonjs/Misc/customAnimationFrameRequester";
  78167. export * from "babylonjs/Misc/retryStrategy";
  78168. export * from "babylonjs/Misc/interfaces/screenshotSize";
  78169. export * from "babylonjs/Misc/canvasGenerator";
  78170. export * from "babylonjs/Misc/fileTools";
  78171. export * from "babylonjs/Misc/stringTools";
  78172. export * from "babylonjs/Misc/dataReader";
  78173. export * from "babylonjs/Misc/minMaxReducer";
  78174. export * from "babylonjs/Misc/depthReducer";
  78175. export * from "babylonjs/Misc/dataStorage";
  78176. export * from "babylonjs/Misc/sceneRecorder";
  78177. }
  78178. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  78179. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  78180. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78181. import { Observable } from "babylonjs/Misc/observable";
  78182. import { Matrix } from "babylonjs/Maths/math.vector";
  78183. import { TransformNode } from "babylonjs/Meshes/transformNode";
  78184. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78185. /**
  78186. * An interface for all Hit test features
  78187. */
  78188. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  78189. /**
  78190. * Triggered when new babylon (transformed) hit test results are available
  78191. */
  78192. onHitTestResultObservable: Observable<T[]>;
  78193. }
  78194. /**
  78195. * Options used for hit testing
  78196. */
  78197. export interface IWebXRLegacyHitTestOptions {
  78198. /**
  78199. * Only test when user interacted with the scene. Default - hit test every frame
  78200. */
  78201. testOnPointerDownOnly?: boolean;
  78202. /**
  78203. * The node to use to transform the local results to world coordinates
  78204. */
  78205. worldParentNode?: TransformNode;
  78206. }
  78207. /**
  78208. * Interface defining the babylon result of raycasting/hit-test
  78209. */
  78210. export interface IWebXRLegacyHitResult {
  78211. /**
  78212. * Transformation matrix that can be applied to a node that will put it in the hit point location
  78213. */
  78214. transformationMatrix: Matrix;
  78215. /**
  78216. * The native hit test result
  78217. */
  78218. xrHitResult: XRHitResult | XRHitTestResult;
  78219. }
  78220. /**
  78221. * The currently-working hit-test module.
  78222. * Hit test (or Ray-casting) is used to interact with the real world.
  78223. * For further information read here - https://github.com/immersive-web/hit-test
  78224. */
  78225. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  78226. /**
  78227. * options to use when constructing this feature
  78228. */
  78229. readonly options: IWebXRLegacyHitTestOptions;
  78230. private _direction;
  78231. private _mat;
  78232. private _onSelectEnabled;
  78233. private _origin;
  78234. /**
  78235. * The module's name
  78236. */
  78237. static readonly Name: string;
  78238. /**
  78239. * The (Babylon) version of this module.
  78240. * This is an integer representing the implementation version.
  78241. * This number does not correspond to the WebXR specs version
  78242. */
  78243. static readonly Version: number;
  78244. /**
  78245. * Populated with the last native XR Hit Results
  78246. */
  78247. lastNativeXRHitResults: XRHitResult[];
  78248. /**
  78249. * Triggered when new babylon (transformed) hit test results are available
  78250. */
  78251. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  78252. /**
  78253. * Creates a new instance of the (legacy version) hit test feature
  78254. * @param _xrSessionManager an instance of WebXRSessionManager
  78255. * @param options options to use when constructing this feature
  78256. */
  78257. constructor(_xrSessionManager: WebXRSessionManager,
  78258. /**
  78259. * options to use when constructing this feature
  78260. */
  78261. options?: IWebXRLegacyHitTestOptions);
  78262. /**
  78263. * execute a hit test with an XR Ray
  78264. *
  78265. * @param xrSession a native xrSession that will execute this hit test
  78266. * @param xrRay the ray (position and direction) to use for ray-casting
  78267. * @param referenceSpace native XR reference space to use for the hit-test
  78268. * @param filter filter function that will filter the results
  78269. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  78270. */
  78271. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  78272. /**
  78273. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  78274. * @param event the (select) event to use to select with
  78275. * @param referenceSpace the reference space to use for this hit test
  78276. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  78277. */
  78278. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  78279. /**
  78280. * attach this feature
  78281. * Will usually be called by the features manager
  78282. *
  78283. * @returns true if successful.
  78284. */
  78285. attach(): boolean;
  78286. /**
  78287. * detach this feature.
  78288. * Will usually be called by the features manager
  78289. *
  78290. * @returns true if successful.
  78291. */
  78292. detach(): boolean;
  78293. /**
  78294. * Dispose this feature and all of the resources attached
  78295. */
  78296. dispose(): void;
  78297. protected _onXRFrame(frame: XRFrame): void;
  78298. private _onHitTestResults;
  78299. private _onSelect;
  78300. }
  78301. }
  78302. declare module "babylonjs/XR/features/WebXRHitTest" {
  78303. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78304. import { Observable } from "babylonjs/Misc/observable";
  78305. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  78306. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78307. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult, IWebXRHitTestFeature } from "babylonjs/XR/features/WebXRHitTestLegacy";
  78308. /**
  78309. * Options used for hit testing (version 2)
  78310. */
  78311. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  78312. /**
  78313. * Do not create a permanent hit test. Will usually be used when only
  78314. * transient inputs are needed.
  78315. */
  78316. disablePermanentHitTest?: boolean;
  78317. /**
  78318. * Enable transient (for example touch-based) hit test inspections
  78319. */
  78320. enableTransientHitTest?: boolean;
  78321. /**
  78322. * Offset ray for the permanent hit test
  78323. */
  78324. offsetRay?: Vector3;
  78325. /**
  78326. * Offset ray for the transient hit test
  78327. */
  78328. transientOffsetRay?: Vector3;
  78329. /**
  78330. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  78331. */
  78332. useReferenceSpace?: boolean;
  78333. /**
  78334. * Override the default entity type(s) of the hit-test result
  78335. */
  78336. entityTypes?: XRHitTestTrackableType[];
  78337. }
  78338. /**
  78339. * Interface defining the babylon result of hit-test
  78340. */
  78341. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  78342. /**
  78343. * The input source that generated this hit test (if transient)
  78344. */
  78345. inputSource?: XRInputSource;
  78346. /**
  78347. * Is this a transient hit test
  78348. */
  78349. isTransient?: boolean;
  78350. /**
  78351. * Position of the hit test result
  78352. */
  78353. position: Vector3;
  78354. /**
  78355. * Rotation of the hit test result
  78356. */
  78357. rotationQuaternion: Quaternion;
  78358. /**
  78359. * The native hit test result
  78360. */
  78361. xrHitResult: XRHitTestResult;
  78362. }
  78363. /**
  78364. * The currently-working hit-test module.
  78365. * Hit test (or Ray-casting) is used to interact with the real world.
  78366. * For further information read here - https://github.com/immersive-web/hit-test
  78367. *
  78368. * Tested on chrome (mobile) 80.
  78369. */
  78370. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  78371. /**
  78372. * options to use when constructing this feature
  78373. */
  78374. readonly options: IWebXRHitTestOptions;
  78375. private _tmpMat;
  78376. private _tmpPos;
  78377. private _tmpQuat;
  78378. private _transientXrHitTestSource;
  78379. private _xrHitTestSource;
  78380. private initHitTestSource;
  78381. /**
  78382. * The module's name
  78383. */
  78384. static readonly Name: string;
  78385. /**
  78386. * The (Babylon) version of this module.
  78387. * This is an integer representing the implementation version.
  78388. * This number does not correspond to the WebXR specs version
  78389. */
  78390. static readonly Version: number;
  78391. /**
  78392. * When set to true, each hit test will have its own position/rotation objects
  78393. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  78394. * the developers will clone them or copy them as they see fit.
  78395. */
  78396. autoCloneTransformation: boolean;
  78397. /**
  78398. * Triggered when new babylon (transformed) hit test results are available
  78399. */
  78400. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  78401. /**
  78402. * Use this to temporarily pause hit test checks.
  78403. */
  78404. paused: boolean;
  78405. /**
  78406. * Creates a new instance of the hit test feature
  78407. * @param _xrSessionManager an instance of WebXRSessionManager
  78408. * @param options options to use when constructing this feature
  78409. */
  78410. constructor(_xrSessionManager: WebXRSessionManager,
  78411. /**
  78412. * options to use when constructing this feature
  78413. */
  78414. options?: IWebXRHitTestOptions);
  78415. /**
  78416. * attach this feature
  78417. * Will usually be called by the features manager
  78418. *
  78419. * @returns true if successful.
  78420. */
  78421. attach(): boolean;
  78422. /**
  78423. * detach this feature.
  78424. * Will usually be called by the features manager
  78425. *
  78426. * @returns true if successful.
  78427. */
  78428. detach(): boolean;
  78429. /**
  78430. * Dispose this feature and all of the resources attached
  78431. */
  78432. dispose(): void;
  78433. protected _onXRFrame(frame: XRFrame): void;
  78434. private _processWebXRHitTestResult;
  78435. }
  78436. }
  78437. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  78438. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78439. import { Observable } from "babylonjs/Misc/observable";
  78440. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  78441. import { TransformNode } from "babylonjs/Meshes/transformNode";
  78442. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78443. import { IWebXRHitResult } from "babylonjs/XR/features/WebXRHitTest";
  78444. /**
  78445. * Configuration options of the anchor system
  78446. */
  78447. export interface IWebXRAnchorSystemOptions {
  78448. /**
  78449. * a node that will be used to convert local to world coordinates
  78450. */
  78451. worldParentNode?: TransformNode;
  78452. /**
  78453. * If set to true a reference of the created anchors will be kept until the next session starts
  78454. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  78455. */
  78456. doNotRemoveAnchorsOnSessionEnded?: boolean;
  78457. }
  78458. /**
  78459. * A babylon container for an XR Anchor
  78460. */
  78461. export interface IWebXRAnchor {
  78462. /**
  78463. * A babylon-assigned ID for this anchor
  78464. */
  78465. id: number;
  78466. /**
  78467. * Transformation matrix to apply to an object attached to this anchor
  78468. */
  78469. transformationMatrix: Matrix;
  78470. /**
  78471. * The native anchor object
  78472. */
  78473. xrAnchor: XRAnchor;
  78474. /**
  78475. * if defined, this object will be constantly updated by the anchor's position and rotation
  78476. */
  78477. attachedNode?: TransformNode;
  78478. }
  78479. /**
  78480. * An implementation of the anchor system for WebXR.
  78481. * For further information see https://github.com/immersive-web/anchors/
  78482. */
  78483. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  78484. private _options;
  78485. private _lastFrameDetected;
  78486. private _trackedAnchors;
  78487. private _referenceSpaceForFrameAnchors;
  78488. private _futureAnchors;
  78489. /**
  78490. * The module's name
  78491. */
  78492. static readonly Name: string;
  78493. /**
  78494. * The (Babylon) version of this module.
  78495. * This is an integer representing the implementation version.
  78496. * This number does not correspond to the WebXR specs version
  78497. */
  78498. static readonly Version: number;
  78499. /**
  78500. * Observers registered here will be executed when a new anchor was added to the session
  78501. */
  78502. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  78503. /**
  78504. * Observers registered here will be executed when an anchor was removed from the session
  78505. */
  78506. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  78507. /**
  78508. * Observers registered here will be executed when an existing anchor updates
  78509. * This can execute N times every frame
  78510. */
  78511. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  78512. /**
  78513. * Set the reference space to use for anchor creation, when not using a hit test.
  78514. * Will default to the session's reference space if not defined
  78515. */
  78516. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  78517. /**
  78518. * constructs a new anchor system
  78519. * @param _xrSessionManager an instance of WebXRSessionManager
  78520. * @param _options configuration object for this feature
  78521. */
  78522. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  78523. private _tmpVector;
  78524. private _tmpQuaternion;
  78525. private _populateTmpTransformation;
  78526. /**
  78527. * Create a new anchor point using a hit test result at a specific point in the scene
  78528. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  78529. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  78530. *
  78531. * @param hitTestResult The hit test result to use for this anchor creation
  78532. * @param position an optional position offset for this anchor
  78533. * @param rotationQuaternion an optional rotation offset for this anchor
  78534. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  78535. */
  78536. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  78537. /**
  78538. * Add a new anchor at a specific position and rotation
  78539. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  78540. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  78541. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  78542. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  78543. *
  78544. * @param position the position in which to add an anchor
  78545. * @param rotationQuaternion an optional rotation for the anchor transformation
  78546. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  78547. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  78548. */
  78549. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  78550. /**
  78551. * detach this feature.
  78552. * Will usually be called by the features manager
  78553. *
  78554. * @returns true if successful.
  78555. */
  78556. detach(): boolean;
  78557. /**
  78558. * Dispose this feature and all of the resources attached
  78559. */
  78560. dispose(): void;
  78561. protected _onXRFrame(frame: XRFrame): void;
  78562. /**
  78563. * avoiding using Array.find for global support.
  78564. * @param xrAnchor the plane to find in the array
  78565. */
  78566. private _findIndexInAnchorArray;
  78567. private _updateAnchorWithXRFrame;
  78568. private _createAnchorAtTransformation;
  78569. }
  78570. }
  78571. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  78572. import { TransformNode } from "babylonjs/Meshes/transformNode";
  78573. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78574. import { Observable } from "babylonjs/Misc/observable";
  78575. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  78576. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78577. /**
  78578. * Options used in the plane detector module
  78579. */
  78580. export interface IWebXRPlaneDetectorOptions {
  78581. /**
  78582. * The node to use to transform the local results to world coordinates
  78583. */
  78584. worldParentNode?: TransformNode;
  78585. /**
  78586. * If set to true a reference of the created planes will be kept until the next session starts
  78587. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  78588. */
  78589. doNotRemovePlanesOnSessionEnded?: boolean;
  78590. }
  78591. /**
  78592. * A babylon interface for a WebXR plane.
  78593. * A Plane is actually a polygon, built from N points in space
  78594. *
  78595. * Supported in chrome 79, not supported in canary 81 ATM
  78596. */
  78597. export interface IWebXRPlane {
  78598. /**
  78599. * a babylon-assigned ID for this polygon
  78600. */
  78601. id: number;
  78602. /**
  78603. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  78604. */
  78605. polygonDefinition: Array<Vector3>;
  78606. /**
  78607. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  78608. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  78609. */
  78610. transformationMatrix: Matrix;
  78611. /**
  78612. * the native xr-plane object
  78613. */
  78614. xrPlane: XRPlane;
  78615. }
  78616. /**
  78617. * The plane detector is used to detect planes in the real world when in AR
  78618. * For more information see https://github.com/immersive-web/real-world-geometry/
  78619. */
  78620. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  78621. private _options;
  78622. private _detectedPlanes;
  78623. private _enabled;
  78624. private _lastFrameDetected;
  78625. /**
  78626. * The module's name
  78627. */
  78628. static readonly Name: string;
  78629. /**
  78630. * The (Babylon) version of this module.
  78631. * This is an integer representing the implementation version.
  78632. * This number does not correspond to the WebXR specs version
  78633. */
  78634. static readonly Version: number;
  78635. /**
  78636. * Observers registered here will be executed when a new plane was added to the session
  78637. */
  78638. onPlaneAddedObservable: Observable<IWebXRPlane>;
  78639. /**
  78640. * Observers registered here will be executed when a plane is no longer detected in the session
  78641. */
  78642. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  78643. /**
  78644. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  78645. * This can execute N times every frame
  78646. */
  78647. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  78648. /**
  78649. * construct a new Plane Detector
  78650. * @param _xrSessionManager an instance of xr Session manager
  78651. * @param _options configuration to use when constructing this feature
  78652. */
  78653. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  78654. /**
  78655. * detach this feature.
  78656. * Will usually be called by the features manager
  78657. *
  78658. * @returns true if successful.
  78659. */
  78660. detach(): boolean;
  78661. /**
  78662. * Dispose this feature and all of the resources attached
  78663. */
  78664. dispose(): void;
  78665. protected _onXRFrame(frame: XRFrame): void;
  78666. private _init;
  78667. private _updatePlaneWithXRPlane;
  78668. /**
  78669. * avoiding using Array.find for global support.
  78670. * @param xrPlane the plane to find in the array
  78671. */
  78672. private findIndexInPlaneArray;
  78673. }
  78674. }
  78675. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  78676. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78677. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  78678. import { Observable } from "babylonjs/Misc/observable";
  78679. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78680. /**
  78681. * Options interface for the background remover plugin
  78682. */
  78683. export interface IWebXRBackgroundRemoverOptions {
  78684. /**
  78685. * Further background meshes to disable when entering AR
  78686. */
  78687. backgroundMeshes?: AbstractMesh[];
  78688. /**
  78689. * flags to configure the removal of the environment helper.
  78690. * If not set, the entire background will be removed. If set, flags should be set as well.
  78691. */
  78692. environmentHelperRemovalFlags?: {
  78693. /**
  78694. * Should the skybox be removed (default false)
  78695. */
  78696. skyBox?: boolean;
  78697. /**
  78698. * Should the ground be removed (default false)
  78699. */
  78700. ground?: boolean;
  78701. };
  78702. /**
  78703. * don't disable the environment helper
  78704. */
  78705. ignoreEnvironmentHelper?: boolean;
  78706. }
  78707. /**
  78708. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  78709. */
  78710. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  78711. /**
  78712. * read-only options to be used in this module
  78713. */
  78714. readonly options: IWebXRBackgroundRemoverOptions;
  78715. /**
  78716. * The module's name
  78717. */
  78718. static readonly Name: string;
  78719. /**
  78720. * The (Babylon) version of this module.
  78721. * This is an integer representing the implementation version.
  78722. * This number does not correspond to the WebXR specs version
  78723. */
  78724. static readonly Version: number;
  78725. /**
  78726. * registered observers will be triggered when the background state changes
  78727. */
  78728. onBackgroundStateChangedObservable: Observable<boolean>;
  78729. /**
  78730. * constructs a new background remover module
  78731. * @param _xrSessionManager the session manager for this module
  78732. * @param options read-only options to be used in this module
  78733. */
  78734. constructor(_xrSessionManager: WebXRSessionManager,
  78735. /**
  78736. * read-only options to be used in this module
  78737. */
  78738. options?: IWebXRBackgroundRemoverOptions);
  78739. /**
  78740. * attach this feature
  78741. * Will usually be called by the features manager
  78742. *
  78743. * @returns true if successful.
  78744. */
  78745. attach(): boolean;
  78746. /**
  78747. * detach this feature.
  78748. * Will usually be called by the features manager
  78749. *
  78750. * @returns true if successful.
  78751. */
  78752. detach(): boolean;
  78753. /**
  78754. * Dispose this feature and all of the resources attached
  78755. */
  78756. dispose(): void;
  78757. protected _onXRFrame(_xrFrame: XRFrame): void;
  78758. private _setBackgroundState;
  78759. }
  78760. }
  78761. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  78762. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78763. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  78764. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  78765. import { WebXRInput } from "babylonjs/XR/webXRInput";
  78766. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78767. import { Nullable } from "babylonjs/types";
  78768. /**
  78769. * Options for the controller physics feature
  78770. */
  78771. export class IWebXRControllerPhysicsOptions {
  78772. /**
  78773. * Should the headset get its own impostor
  78774. */
  78775. enableHeadsetImpostor?: boolean;
  78776. /**
  78777. * Optional parameters for the headset impostor
  78778. */
  78779. headsetImpostorParams?: {
  78780. /**
  78781. * The type of impostor to create. Default is sphere
  78782. */
  78783. impostorType: number;
  78784. /**
  78785. * the size of the impostor. Defaults to 10cm
  78786. */
  78787. impostorSize?: number | {
  78788. width: number;
  78789. height: number;
  78790. depth: number;
  78791. };
  78792. /**
  78793. * Friction definitions
  78794. */
  78795. friction?: number;
  78796. /**
  78797. * Restitution
  78798. */
  78799. restitution?: number;
  78800. };
  78801. /**
  78802. * The physics properties of the future impostors
  78803. */
  78804. physicsProperties?: {
  78805. /**
  78806. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  78807. * Note that this requires a physics engine that supports mesh impostors!
  78808. */
  78809. useControllerMesh?: boolean;
  78810. /**
  78811. * The type of impostor to create. Default is sphere
  78812. */
  78813. impostorType?: number;
  78814. /**
  78815. * the size of the impostor. Defaults to 10cm
  78816. */
  78817. impostorSize?: number | {
  78818. width: number;
  78819. height: number;
  78820. depth: number;
  78821. };
  78822. /**
  78823. * Friction definitions
  78824. */
  78825. friction?: number;
  78826. /**
  78827. * Restitution
  78828. */
  78829. restitution?: number;
  78830. };
  78831. /**
  78832. * the xr input to use with this pointer selection
  78833. */
  78834. xrInput: WebXRInput;
  78835. }
  78836. /**
  78837. * Add physics impostor to your webxr controllers,
  78838. * including naive calculation of their linear and angular velocity
  78839. */
  78840. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  78841. private readonly _options;
  78842. private _attachController;
  78843. private _controllers;
  78844. private _debugMode;
  78845. private _delta;
  78846. private _headsetImpostor?;
  78847. private _headsetMesh?;
  78848. private _lastTimestamp;
  78849. private _tmpQuaternion;
  78850. private _tmpVector;
  78851. /**
  78852. * The module's name
  78853. */
  78854. static readonly Name: string;
  78855. /**
  78856. * The (Babylon) version of this module.
  78857. * This is an integer representing the implementation version.
  78858. * This number does not correspond to the webxr specs version
  78859. */
  78860. static readonly Version: number;
  78861. /**
  78862. * Construct a new Controller Physics Feature
  78863. * @param _xrSessionManager the corresponding xr session manager
  78864. * @param _options options to create this feature with
  78865. */
  78866. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  78867. /**
  78868. * @hidden
  78869. * enable debugging - will show console outputs and the impostor mesh
  78870. */
  78871. _enablePhysicsDebug(): void;
  78872. /**
  78873. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  78874. * @param xrController the controller to add
  78875. */
  78876. addController(xrController: WebXRInputSource): void;
  78877. /**
  78878. * attach this feature
  78879. * Will usually be called by the features manager
  78880. *
  78881. * @returns true if successful.
  78882. */
  78883. attach(): boolean;
  78884. /**
  78885. * detach this feature.
  78886. * Will usually be called by the features manager
  78887. *
  78888. * @returns true if successful.
  78889. */
  78890. detach(): boolean;
  78891. /**
  78892. * Get the headset impostor, if enabled
  78893. * @returns the impostor
  78894. */
  78895. getHeadsetImpostor(): PhysicsImpostor | undefined;
  78896. /**
  78897. * Get the physics impostor of a specific controller.
  78898. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  78899. * @param controller the controller or the controller id of which to get the impostor
  78900. * @returns the impostor or null
  78901. */
  78902. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  78903. /**
  78904. * Update the physics properties provided in the constructor
  78905. * @param newProperties the new properties object
  78906. */
  78907. setPhysicsProperties(newProperties: {
  78908. impostorType?: number;
  78909. impostorSize?: number | {
  78910. width: number;
  78911. height: number;
  78912. depth: number;
  78913. };
  78914. friction?: number;
  78915. restitution?: number;
  78916. }): void;
  78917. protected _onXRFrame(_xrFrame: any): void;
  78918. private _detachController;
  78919. }
  78920. }
  78921. declare module "babylonjs/XR/features/index" {
  78922. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  78923. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  78924. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  78925. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  78926. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  78927. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  78928. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  78929. export * from "babylonjs/XR/features/WebXRHitTest";
  78930. }
  78931. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  78932. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  78933. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  78934. import { Scene } from "babylonjs/scene";
  78935. /**
  78936. * The motion controller class for all microsoft mixed reality controllers
  78937. */
  78938. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  78939. protected readonly _mapping: {
  78940. defaultButton: {
  78941. valueNodeName: string;
  78942. unpressedNodeName: string;
  78943. pressedNodeName: string;
  78944. };
  78945. defaultAxis: {
  78946. valueNodeName: string;
  78947. minNodeName: string;
  78948. maxNodeName: string;
  78949. };
  78950. buttons: {
  78951. "xr-standard-trigger": {
  78952. rootNodeName: string;
  78953. componentProperty: string;
  78954. states: string[];
  78955. };
  78956. "xr-standard-squeeze": {
  78957. rootNodeName: string;
  78958. componentProperty: string;
  78959. states: string[];
  78960. };
  78961. "xr-standard-touchpad": {
  78962. rootNodeName: string;
  78963. labelAnchorNodeName: string;
  78964. touchPointNodeName: string;
  78965. };
  78966. "xr-standard-thumbstick": {
  78967. rootNodeName: string;
  78968. componentProperty: string;
  78969. states: string[];
  78970. };
  78971. };
  78972. axes: {
  78973. "xr-standard-touchpad": {
  78974. "x-axis": {
  78975. rootNodeName: string;
  78976. };
  78977. "y-axis": {
  78978. rootNodeName: string;
  78979. };
  78980. };
  78981. "xr-standard-thumbstick": {
  78982. "x-axis": {
  78983. rootNodeName: string;
  78984. };
  78985. "y-axis": {
  78986. rootNodeName: string;
  78987. };
  78988. };
  78989. };
  78990. };
  78991. /**
  78992. * The base url used to load the left and right controller models
  78993. */
  78994. static MODEL_BASE_URL: string;
  78995. /**
  78996. * The name of the left controller model file
  78997. */
  78998. static MODEL_LEFT_FILENAME: string;
  78999. /**
  79000. * The name of the right controller model file
  79001. */
  79002. static MODEL_RIGHT_FILENAME: string;
  79003. profileId: string;
  79004. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  79005. protected _getFilenameAndPath(): {
  79006. filename: string;
  79007. path: string;
  79008. };
  79009. protected _getModelLoadingConstraints(): boolean;
  79010. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  79011. protected _setRootMesh(meshes: AbstractMesh[]): void;
  79012. protected _updateModel(): void;
  79013. }
  79014. }
  79015. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  79016. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  79017. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79018. import { Scene } from "babylonjs/scene";
  79019. /**
  79020. * The motion controller class for oculus touch (quest, rift).
  79021. * This class supports legacy mapping as well the standard xr mapping
  79022. */
  79023. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  79024. private _forceLegacyControllers;
  79025. private _modelRootNode;
  79026. /**
  79027. * The base url used to load the left and right controller models
  79028. */
  79029. static MODEL_BASE_URL: string;
  79030. /**
  79031. * The name of the left controller model file
  79032. */
  79033. static MODEL_LEFT_FILENAME: string;
  79034. /**
  79035. * The name of the right controller model file
  79036. */
  79037. static MODEL_RIGHT_FILENAME: string;
  79038. /**
  79039. * Base Url for the Quest controller model.
  79040. */
  79041. static QUEST_MODEL_BASE_URL: string;
  79042. profileId: string;
  79043. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  79044. protected _getFilenameAndPath(): {
  79045. filename: string;
  79046. path: string;
  79047. };
  79048. protected _getModelLoadingConstraints(): boolean;
  79049. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  79050. protected _setRootMesh(meshes: AbstractMesh[]): void;
  79051. protected _updateModel(): void;
  79052. /**
  79053. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  79054. * between the touch and touch 2.
  79055. */
  79056. private _isQuest;
  79057. }
  79058. }
  79059. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  79060. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  79061. import { Scene } from "babylonjs/scene";
  79062. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79063. /**
  79064. * The motion controller class for the standard HTC-Vive controllers
  79065. */
  79066. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  79067. private _modelRootNode;
  79068. /**
  79069. * The base url used to load the left and right controller models
  79070. */
  79071. static MODEL_BASE_URL: string;
  79072. /**
  79073. * File name for the controller model.
  79074. */
  79075. static MODEL_FILENAME: string;
  79076. profileId: string;
  79077. /**
  79078. * Create a new Vive motion controller object
  79079. * @param scene the scene to use to create this controller
  79080. * @param gamepadObject the corresponding gamepad object
  79081. * @param handedness the handedness of the controller
  79082. */
  79083. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  79084. protected _getFilenameAndPath(): {
  79085. filename: string;
  79086. path: string;
  79087. };
  79088. protected _getModelLoadingConstraints(): boolean;
  79089. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  79090. protected _setRootMesh(meshes: AbstractMesh[]): void;
  79091. protected _updateModel(): void;
  79092. }
  79093. }
  79094. declare module "babylonjs/XR/motionController/index" {
  79095. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  79096. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  79097. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  79098. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  79099. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  79100. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  79101. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  79102. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  79103. }
  79104. declare module "babylonjs/XR/index" {
  79105. export * from "babylonjs/XR/webXRCamera";
  79106. export * from "babylonjs/XR/webXREnterExitUI";
  79107. export * from "babylonjs/XR/webXRExperienceHelper";
  79108. export * from "babylonjs/XR/webXRInput";
  79109. export * from "babylonjs/XR/webXRInputSource";
  79110. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  79111. export * from "babylonjs/XR/webXRTypes";
  79112. export * from "babylonjs/XR/webXRSessionManager";
  79113. export * from "babylonjs/XR/webXRDefaultExperience";
  79114. export * from "babylonjs/XR/webXRFeaturesManager";
  79115. export * from "babylonjs/XR/features/index";
  79116. export * from "babylonjs/XR/motionController/index";
  79117. }
  79118. declare module "babylonjs/index" {
  79119. export * from "babylonjs/abstractScene";
  79120. export * from "babylonjs/Actions/index";
  79121. export * from "babylonjs/Animations/index";
  79122. export * from "babylonjs/assetContainer";
  79123. export * from "babylonjs/Audio/index";
  79124. export * from "babylonjs/Behaviors/index";
  79125. export * from "babylonjs/Bones/index";
  79126. export * from "babylonjs/Cameras/index";
  79127. export * from "babylonjs/Collisions/index";
  79128. export * from "babylonjs/Culling/index";
  79129. export * from "babylonjs/Debug/index";
  79130. export * from "babylonjs/DeviceInput/index";
  79131. export * from "babylonjs/Engines/index";
  79132. export * from "babylonjs/Events/index";
  79133. export * from "babylonjs/Gamepads/index";
  79134. export * from "babylonjs/Gizmos/index";
  79135. export * from "babylonjs/Helpers/index";
  79136. export * from "babylonjs/Instrumentation/index";
  79137. export * from "babylonjs/Layers/index";
  79138. export * from "babylonjs/LensFlares/index";
  79139. export * from "babylonjs/Lights/index";
  79140. export * from "babylonjs/Loading/index";
  79141. export * from "babylonjs/Materials/index";
  79142. export * from "babylonjs/Maths/index";
  79143. export * from "babylonjs/Meshes/index";
  79144. export * from "babylonjs/Morph/index";
  79145. export * from "babylonjs/Navigation/index";
  79146. export * from "babylonjs/node";
  79147. export * from "babylonjs/Offline/index";
  79148. export * from "babylonjs/Particles/index";
  79149. export * from "babylonjs/Physics/index";
  79150. export * from "babylonjs/PostProcesses/index";
  79151. export * from "babylonjs/Probes/index";
  79152. export * from "babylonjs/Rendering/index";
  79153. export * from "babylonjs/scene";
  79154. export * from "babylonjs/sceneComponent";
  79155. export * from "babylonjs/Sprites/index";
  79156. export * from "babylonjs/States/index";
  79157. export * from "babylonjs/Misc/index";
  79158. export * from "babylonjs/XR/index";
  79159. export * from "babylonjs/types";
  79160. }
  79161. declare module "babylonjs/Animations/pathCursor" {
  79162. import { Vector3 } from "babylonjs/Maths/math.vector";
  79163. import { Path2 } from "babylonjs/Maths/math.path";
  79164. /**
  79165. * A cursor which tracks a point on a path
  79166. */
  79167. export class PathCursor {
  79168. private path;
  79169. /**
  79170. * Stores path cursor callbacks for when an onchange event is triggered
  79171. */
  79172. private _onchange;
  79173. /**
  79174. * The value of the path cursor
  79175. */
  79176. value: number;
  79177. /**
  79178. * The animation array of the path cursor
  79179. */
  79180. animations: Animation[];
  79181. /**
  79182. * Initializes the path cursor
  79183. * @param path The path to track
  79184. */
  79185. constructor(path: Path2);
  79186. /**
  79187. * Gets the cursor point on the path
  79188. * @returns A point on the path cursor at the cursor location
  79189. */
  79190. getPoint(): Vector3;
  79191. /**
  79192. * Moves the cursor ahead by the step amount
  79193. * @param step The amount to move the cursor forward
  79194. * @returns This path cursor
  79195. */
  79196. moveAhead(step?: number): PathCursor;
  79197. /**
  79198. * Moves the cursor behind by the step amount
  79199. * @param step The amount to move the cursor back
  79200. * @returns This path cursor
  79201. */
  79202. moveBack(step?: number): PathCursor;
  79203. /**
  79204. * Moves the cursor by the step amount
  79205. * If the step amount is greater than one, an exception is thrown
  79206. * @param step The amount to move the cursor
  79207. * @returns This path cursor
  79208. */
  79209. move(step: number): PathCursor;
  79210. /**
  79211. * Ensures that the value is limited between zero and one
  79212. * @returns This path cursor
  79213. */
  79214. private ensureLimits;
  79215. /**
  79216. * Runs onchange callbacks on change (used by the animation engine)
  79217. * @returns This path cursor
  79218. */
  79219. private raiseOnChange;
  79220. /**
  79221. * Executes a function on change
  79222. * @param f A path cursor onchange callback
  79223. * @returns This path cursor
  79224. */
  79225. onchange(f: (cursor: PathCursor) => void): PathCursor;
  79226. }
  79227. }
  79228. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  79229. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  79230. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  79231. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  79232. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  79233. }
  79234. declare module "babylonjs/Engines/Processors/Expressions/index" {
  79235. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  79236. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  79237. }
  79238. declare module "babylonjs/Engines/Processors/index" {
  79239. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  79240. export * from "babylonjs/Engines/Processors/Expressions/index";
  79241. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  79242. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  79243. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  79244. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  79245. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  79246. export * from "babylonjs/Engines/Processors/shaderProcessor";
  79247. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  79248. }
  79249. declare module "babylonjs/Legacy/legacy" {
  79250. import * as Babylon from "babylonjs/index";
  79251. export * from "babylonjs/index";
  79252. }
  79253. declare module "babylonjs/Shaders/blur.fragment" {
  79254. /** @hidden */
  79255. export var blurPixelShader: {
  79256. name: string;
  79257. shader: string;
  79258. };
  79259. }
  79260. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  79261. /** @hidden */
  79262. export var pointCloudVertexDeclaration: {
  79263. name: string;
  79264. shader: string;
  79265. };
  79266. }
  79267. declare module "babylonjs" {
  79268. export * from "babylonjs/Legacy/legacy";
  79269. }
  79270. declare module BABYLON {
  79271. /** Alias type for value that can be null */
  79272. export type Nullable<T> = T | null;
  79273. /**
  79274. * Alias type for number that are floats
  79275. * @ignorenaming
  79276. */
  79277. export type float = number;
  79278. /**
  79279. * Alias type for number that are doubles.
  79280. * @ignorenaming
  79281. */
  79282. export type double = number;
  79283. /**
  79284. * Alias type for number that are integer
  79285. * @ignorenaming
  79286. */
  79287. export type int = number;
  79288. /** Alias type for number array or Float32Array */
  79289. export type FloatArray = number[] | Float32Array;
  79290. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  79291. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  79292. /**
  79293. * Alias for types that can be used by a Buffer or VertexBuffer.
  79294. */
  79295. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  79296. /**
  79297. * Alias type for primitive types
  79298. * @ignorenaming
  79299. */
  79300. type Primitive = undefined | null | boolean | string | number | Function;
  79301. /**
  79302. * Type modifier to make all the properties of an object Readonly
  79303. */
  79304. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  79305. /**
  79306. * Type modifier to make all the properties of an object Readonly recursively
  79307. */
  79308. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  79309. /**
  79310. * Type modifier to make object properties readonly.
  79311. */
  79312. export type DeepImmutableObject<T> = {
  79313. readonly [K in keyof T]: DeepImmutable<T[K]>;
  79314. };
  79315. /** @hidden */
  79316. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  79317. }
  79318. }
  79319. declare module BABYLON {
  79320. /**
  79321. * A class serves as a medium between the observable and its observers
  79322. */
  79323. export class EventState {
  79324. /**
  79325. * Create a new EventState
  79326. * @param mask defines the mask associated with this state
  79327. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  79328. * @param target defines the original target of the state
  79329. * @param currentTarget defines the current target of the state
  79330. */
  79331. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  79332. /**
  79333. * Initialize the current event state
  79334. * @param mask defines the mask associated with this state
  79335. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  79336. * @param target defines the original target of the state
  79337. * @param currentTarget defines the current target of the state
  79338. * @returns the current event state
  79339. */
  79340. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  79341. /**
  79342. * An Observer can set this property to true to prevent subsequent observers of being notified
  79343. */
  79344. skipNextObservers: boolean;
  79345. /**
  79346. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79347. */
  79348. mask: number;
  79349. /**
  79350. * The object that originally notified the event
  79351. */
  79352. target?: any;
  79353. /**
  79354. * The current object in the bubbling phase
  79355. */
  79356. currentTarget?: any;
  79357. /**
  79358. * This will be populated with the return value of the last function that was executed.
  79359. * If it is the first function in the callback chain it will be the event data.
  79360. */
  79361. lastReturnValue?: any;
  79362. }
  79363. /**
  79364. * Represent an Observer registered to a given Observable object.
  79365. */
  79366. export class Observer<T> {
  79367. /**
  79368. * Defines the callback to call when the observer is notified
  79369. */
  79370. callback: (eventData: T, eventState: EventState) => void;
  79371. /**
  79372. * Defines the mask of the observer (used to filter notifications)
  79373. */
  79374. mask: number;
  79375. /**
  79376. * Defines the current scope used to restore the JS context
  79377. */
  79378. scope: any;
  79379. /** @hidden */
  79380. _willBeUnregistered: boolean;
  79381. /**
  79382. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  79383. */
  79384. unregisterOnNextCall: boolean;
  79385. /**
  79386. * Creates a new observer
  79387. * @param callback defines the callback to call when the observer is notified
  79388. * @param mask defines the mask of the observer (used to filter notifications)
  79389. * @param scope defines the current scope used to restore the JS context
  79390. */
  79391. constructor(
  79392. /**
  79393. * Defines the callback to call when the observer is notified
  79394. */
  79395. callback: (eventData: T, eventState: EventState) => void,
  79396. /**
  79397. * Defines the mask of the observer (used to filter notifications)
  79398. */
  79399. mask: number,
  79400. /**
  79401. * Defines the current scope used to restore the JS context
  79402. */
  79403. scope?: any);
  79404. }
  79405. /**
  79406. * Represent a list of observers registered to multiple Observables object.
  79407. */
  79408. export class MultiObserver<T> {
  79409. private _observers;
  79410. private _observables;
  79411. /**
  79412. * Release associated resources
  79413. */
  79414. dispose(): void;
  79415. /**
  79416. * Raise a callback when one of the observable will notify
  79417. * @param observables defines a list of observables to watch
  79418. * @param callback defines the callback to call on notification
  79419. * @param mask defines the mask used to filter notifications
  79420. * @param scope defines the current scope used to restore the JS context
  79421. * @returns the new MultiObserver
  79422. */
  79423. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  79424. }
  79425. /**
  79426. * The Observable class is a simple implementation of the Observable pattern.
  79427. *
  79428. * 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.
  79429. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  79430. * 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).
  79431. * 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.
  79432. */
  79433. export class Observable<T> {
  79434. private _observers;
  79435. private _eventState;
  79436. private _onObserverAdded;
  79437. /**
  79438. * Gets the list of observers
  79439. */
  79440. get observers(): Array<Observer<T>>;
  79441. /**
  79442. * Creates a new observable
  79443. * @param onObserverAdded defines a callback to call when a new observer is added
  79444. */
  79445. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  79446. /**
  79447. * Create a new Observer with the specified callback
  79448. * @param callback the callback that will be executed for that Observer
  79449. * @param mask the mask used to filter observers
  79450. * @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.
  79451. * @param scope optional scope for the callback to be called from
  79452. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  79453. * @returns the new observer created for the callback
  79454. */
  79455. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  79456. /**
  79457. * Create a new Observer with the specified callback and unregisters after the next notification
  79458. * @param callback the callback that will be executed for that Observer
  79459. * @returns the new observer created for the callback
  79460. */
  79461. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  79462. /**
  79463. * Remove an Observer from the Observable object
  79464. * @param observer the instance of the Observer to remove
  79465. * @returns false if it doesn't belong to this Observable
  79466. */
  79467. remove(observer: Nullable<Observer<T>>): boolean;
  79468. /**
  79469. * Remove a callback from the Observable object
  79470. * @param callback the callback to remove
  79471. * @param scope optional scope. If used only the callbacks with this scope will be removed
  79472. * @returns false if it doesn't belong to this Observable
  79473. */
  79474. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  79475. private _deferUnregister;
  79476. private _remove;
  79477. /**
  79478. * Moves the observable to the top of the observer list making it get called first when notified
  79479. * @param observer the observer to move
  79480. */
  79481. makeObserverTopPriority(observer: Observer<T>): void;
  79482. /**
  79483. * Moves the observable to the bottom of the observer list making it get called last when notified
  79484. * @param observer the observer to move
  79485. */
  79486. makeObserverBottomPriority(observer: Observer<T>): void;
  79487. /**
  79488. * Notify all Observers by calling their respective callback with the given data
  79489. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  79490. * @param eventData defines the data to send to all observers
  79491. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  79492. * @param target defines the original target of the state
  79493. * @param currentTarget defines the current target of the state
  79494. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  79495. */
  79496. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  79497. /**
  79498. * Calling this will execute each callback, expecting it to be a promise or return a value.
  79499. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  79500. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  79501. * and it is crucial that all callbacks will be executed.
  79502. * The order of the callbacks is kept, callbacks are not executed parallel.
  79503. *
  79504. * @param eventData The data to be sent to each callback
  79505. * @param mask is used to filter observers defaults to -1
  79506. * @param target defines the callback target (see EventState)
  79507. * @param currentTarget defines he current object in the bubbling phase
  79508. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  79509. */
  79510. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  79511. /**
  79512. * Notify a specific observer
  79513. * @param observer defines the observer to notify
  79514. * @param eventData defines the data to be sent to each callback
  79515. * @param mask is used to filter observers defaults to -1
  79516. */
  79517. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  79518. /**
  79519. * Gets a boolean indicating if the observable has at least one observer
  79520. * @returns true is the Observable has at least one Observer registered
  79521. */
  79522. hasObservers(): boolean;
  79523. /**
  79524. * Clear the list of observers
  79525. */
  79526. clear(): void;
  79527. /**
  79528. * Clone the current observable
  79529. * @returns a new observable
  79530. */
  79531. clone(): Observable<T>;
  79532. /**
  79533. * Does this observable handles observer registered with a given mask
  79534. * @param mask defines the mask to be tested
  79535. * @return whether or not one observer registered with the given mask is handeled
  79536. **/
  79537. hasSpecificMask(mask?: number): boolean;
  79538. }
  79539. }
  79540. declare module BABYLON {
  79541. /**
  79542. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  79543. * Babylon.js
  79544. */
  79545. export class DomManagement {
  79546. /**
  79547. * Checks if the window object exists
  79548. * @returns true if the window object exists
  79549. */
  79550. static IsWindowObjectExist(): boolean;
  79551. /**
  79552. * Checks if the navigator object exists
  79553. * @returns true if the navigator object exists
  79554. */
  79555. static IsNavigatorAvailable(): boolean;
  79556. /**
  79557. * Check if the document object exists
  79558. * @returns true if the document object exists
  79559. */
  79560. static IsDocumentAvailable(): boolean;
  79561. /**
  79562. * Extracts text content from a DOM element hierarchy
  79563. * @param element defines the root element
  79564. * @returns a string
  79565. */
  79566. static GetDOMTextContent(element: HTMLElement): string;
  79567. }
  79568. }
  79569. declare module BABYLON {
  79570. /**
  79571. * Logger used througouht the application to allow configuration of
  79572. * the log level required for the messages.
  79573. */
  79574. export class Logger {
  79575. /**
  79576. * No log
  79577. */
  79578. static readonly NoneLogLevel: number;
  79579. /**
  79580. * Only message logs
  79581. */
  79582. static readonly MessageLogLevel: number;
  79583. /**
  79584. * Only warning logs
  79585. */
  79586. static readonly WarningLogLevel: number;
  79587. /**
  79588. * Only error logs
  79589. */
  79590. static readonly ErrorLogLevel: number;
  79591. /**
  79592. * All logs
  79593. */
  79594. static readonly AllLogLevel: number;
  79595. private static _LogCache;
  79596. /**
  79597. * Gets a value indicating the number of loading errors
  79598. * @ignorenaming
  79599. */
  79600. static errorsCount: number;
  79601. /**
  79602. * Callback called when a new log is added
  79603. */
  79604. static OnNewCacheEntry: (entry: string) => void;
  79605. private static _AddLogEntry;
  79606. private static _FormatMessage;
  79607. private static _LogDisabled;
  79608. private static _LogEnabled;
  79609. private static _WarnDisabled;
  79610. private static _WarnEnabled;
  79611. private static _ErrorDisabled;
  79612. private static _ErrorEnabled;
  79613. /**
  79614. * Log a message to the console
  79615. */
  79616. static Log: (message: string) => void;
  79617. /**
  79618. * Write a warning message to the console
  79619. */
  79620. static Warn: (message: string) => void;
  79621. /**
  79622. * Write an error message to the console
  79623. */
  79624. static Error: (message: string) => void;
  79625. /**
  79626. * Gets current log cache (list of logs)
  79627. */
  79628. static get LogCache(): string;
  79629. /**
  79630. * Clears the log cache
  79631. */
  79632. static ClearLogCache(): void;
  79633. /**
  79634. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  79635. */
  79636. static set LogLevels(level: number);
  79637. }
  79638. }
  79639. declare module BABYLON {
  79640. /** @hidden */
  79641. export class _TypeStore {
  79642. /** @hidden */
  79643. static RegisteredTypes: {
  79644. [key: string]: Object;
  79645. };
  79646. /** @hidden */
  79647. static GetClass(fqdn: string): any;
  79648. }
  79649. }
  79650. declare module BABYLON {
  79651. /**
  79652. * Helper to manipulate strings
  79653. */
  79654. export class StringTools {
  79655. /**
  79656. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  79657. * @param str Source string
  79658. * @param suffix Suffix to search for in the source string
  79659. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  79660. */
  79661. static EndsWith(str: string, suffix: string): boolean;
  79662. /**
  79663. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  79664. * @param str Source string
  79665. * @param suffix Suffix to search for in the source string
  79666. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  79667. */
  79668. static StartsWith(str: string, suffix: string): boolean;
  79669. /**
  79670. * Decodes a buffer into a string
  79671. * @param buffer The buffer to decode
  79672. * @returns The decoded string
  79673. */
  79674. static Decode(buffer: Uint8Array | Uint16Array): string;
  79675. /**
  79676. * Encode a buffer to a base64 string
  79677. * @param buffer defines the buffer to encode
  79678. * @returns the encoded string
  79679. */
  79680. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  79681. /**
  79682. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  79683. * @param num the number to convert and pad
  79684. * @param length the expected length of the string
  79685. * @returns the padded string
  79686. */
  79687. static PadNumber(num: number, length: number): string;
  79688. }
  79689. }
  79690. declare module BABYLON {
  79691. /**
  79692. * Class containing a set of static utilities functions for deep copy.
  79693. */
  79694. export class DeepCopier {
  79695. /**
  79696. * Tries to copy an object by duplicating every property
  79697. * @param source defines the source object
  79698. * @param destination defines the target object
  79699. * @param doNotCopyList defines a list of properties to avoid
  79700. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  79701. */
  79702. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  79703. }
  79704. }
  79705. declare module BABYLON {
  79706. /**
  79707. * Class containing a set of static utilities functions for precision date
  79708. */
  79709. export class PrecisionDate {
  79710. /**
  79711. * Gets either window.performance.now() if supported or Date.now() else
  79712. */
  79713. static get Now(): number;
  79714. }
  79715. }
  79716. declare module BABYLON {
  79717. /** @hidden */
  79718. export class _DevTools {
  79719. static WarnImport(name: string): string;
  79720. }
  79721. }
  79722. declare module BABYLON {
  79723. /**
  79724. * Interface used to define the mechanism to get data from the network
  79725. */
  79726. export interface IWebRequest {
  79727. /**
  79728. * Returns client's response url
  79729. */
  79730. responseURL: string;
  79731. /**
  79732. * Returns client's status
  79733. */
  79734. status: number;
  79735. /**
  79736. * Returns client's status as a text
  79737. */
  79738. statusText: string;
  79739. }
  79740. }
  79741. declare module BABYLON {
  79742. /**
  79743. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  79744. */
  79745. export class WebRequest implements IWebRequest {
  79746. private _xhr;
  79747. /**
  79748. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  79749. * i.e. when loading files, where the server/service expects an Authorization header
  79750. */
  79751. static CustomRequestHeaders: {
  79752. [key: string]: string;
  79753. };
  79754. /**
  79755. * Add callback functions in this array to update all the requests before they get sent to the network
  79756. */
  79757. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  79758. private _injectCustomRequestHeaders;
  79759. /**
  79760. * Gets or sets a function to be called when loading progress changes
  79761. */
  79762. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  79763. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  79764. /**
  79765. * Returns client's state
  79766. */
  79767. get readyState(): number;
  79768. /**
  79769. * Returns client's status
  79770. */
  79771. get status(): number;
  79772. /**
  79773. * Returns client's status as a text
  79774. */
  79775. get statusText(): string;
  79776. /**
  79777. * Returns client's response
  79778. */
  79779. get response(): any;
  79780. /**
  79781. * Returns client's response url
  79782. */
  79783. get responseURL(): string;
  79784. /**
  79785. * Returns client's response as text
  79786. */
  79787. get responseText(): string;
  79788. /**
  79789. * Gets or sets the expected response type
  79790. */
  79791. get responseType(): XMLHttpRequestResponseType;
  79792. set responseType(value: XMLHttpRequestResponseType);
  79793. /** @hidden */
  79794. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  79795. /** @hidden */
  79796. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  79797. /**
  79798. * Cancels any network activity
  79799. */
  79800. abort(): void;
  79801. /**
  79802. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  79803. * @param body defines an optional request body
  79804. */
  79805. send(body?: Document | BodyInit | null): void;
  79806. /**
  79807. * Sets the request method, request URL
  79808. * @param method defines the method to use (GET, POST, etc..)
  79809. * @param url defines the url to connect with
  79810. */
  79811. open(method: string, url: string): void;
  79812. /**
  79813. * Sets the value of a request header.
  79814. * @param name The name of the header whose value is to be set
  79815. * @param value The value to set as the body of the header
  79816. */
  79817. setRequestHeader(name: string, value: string): void;
  79818. /**
  79819. * Get the string containing the text of a particular header's value.
  79820. * @param name The name of the header
  79821. * @returns The string containing the text of the given header name
  79822. */
  79823. getResponseHeader(name: string): Nullable<string>;
  79824. }
  79825. }
  79826. declare module BABYLON {
  79827. /**
  79828. * File request interface
  79829. */
  79830. export interface IFileRequest {
  79831. /**
  79832. * Raised when the request is complete (success or error).
  79833. */
  79834. onCompleteObservable: Observable<IFileRequest>;
  79835. /**
  79836. * Aborts the request for a file.
  79837. */
  79838. abort: () => void;
  79839. }
  79840. }
  79841. declare module BABYLON {
  79842. /**
  79843. * Define options used to create a render target texture
  79844. */
  79845. export class RenderTargetCreationOptions {
  79846. /**
  79847. * Specifies is mipmaps must be generated
  79848. */
  79849. generateMipMaps?: boolean;
  79850. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  79851. generateDepthBuffer?: boolean;
  79852. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  79853. generateStencilBuffer?: boolean;
  79854. /** Defines texture type (int by default) */
  79855. type?: number;
  79856. /** Defines sampling mode (trilinear by default) */
  79857. samplingMode?: number;
  79858. /** Defines format (RGBA by default) */
  79859. format?: number;
  79860. }
  79861. }
  79862. declare module BABYLON {
  79863. /** Defines the cross module used constants to avoid circular dependncies */
  79864. export class Constants {
  79865. /** Defines that alpha blending is disabled */
  79866. static readonly ALPHA_DISABLE: number;
  79867. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  79868. static readonly ALPHA_ADD: number;
  79869. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  79870. static readonly ALPHA_COMBINE: number;
  79871. /** Defines that alpha blending is DEST - SRC * DEST */
  79872. static readonly ALPHA_SUBTRACT: number;
  79873. /** Defines that alpha blending is SRC * DEST */
  79874. static readonly ALPHA_MULTIPLY: number;
  79875. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  79876. static readonly ALPHA_MAXIMIZED: number;
  79877. /** Defines that alpha blending is SRC + DEST */
  79878. static readonly ALPHA_ONEONE: number;
  79879. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  79880. static readonly ALPHA_PREMULTIPLIED: number;
  79881. /**
  79882. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  79883. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  79884. */
  79885. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  79886. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  79887. static readonly ALPHA_INTERPOLATE: number;
  79888. /**
  79889. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  79890. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  79891. */
  79892. static readonly ALPHA_SCREENMODE: number;
  79893. /**
  79894. * Defines that alpha blending is SRC + DST
  79895. * Alpha will be set to SRC ALPHA + DST ALPHA
  79896. */
  79897. static readonly ALPHA_ONEONE_ONEONE: number;
  79898. /**
  79899. * Defines that alpha blending is SRC * DST ALPHA + DST
  79900. * Alpha will be set to 0
  79901. */
  79902. static readonly ALPHA_ALPHATOCOLOR: number;
  79903. /**
  79904. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  79905. */
  79906. static readonly ALPHA_REVERSEONEMINUS: number;
  79907. /**
  79908. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  79909. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  79910. */
  79911. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  79912. /**
  79913. * Defines that alpha blending is SRC + DST
  79914. * Alpha will be set to SRC ALPHA
  79915. */
  79916. static readonly ALPHA_ONEONE_ONEZERO: number;
  79917. /**
  79918. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  79919. * Alpha will be set to DST ALPHA
  79920. */
  79921. static readonly ALPHA_EXCLUSION: number;
  79922. /** Defines that alpha blending equation a SUM */
  79923. static readonly ALPHA_EQUATION_ADD: number;
  79924. /** Defines that alpha blending equation a SUBSTRACTION */
  79925. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  79926. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  79927. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  79928. /** Defines that alpha blending equation a MAX operation */
  79929. static readonly ALPHA_EQUATION_MAX: number;
  79930. /** Defines that alpha blending equation a MIN operation */
  79931. static readonly ALPHA_EQUATION_MIN: number;
  79932. /**
  79933. * Defines that alpha blending equation a DARKEN operation:
  79934. * It takes the min of the src and sums the alpha channels.
  79935. */
  79936. static readonly ALPHA_EQUATION_DARKEN: number;
  79937. /** Defines that the ressource is not delayed*/
  79938. static readonly DELAYLOADSTATE_NONE: number;
  79939. /** Defines that the ressource was successfully delay loaded */
  79940. static readonly DELAYLOADSTATE_LOADED: number;
  79941. /** Defines that the ressource is currently delay loading */
  79942. static readonly DELAYLOADSTATE_LOADING: number;
  79943. /** Defines that the ressource is delayed and has not started loading */
  79944. static readonly DELAYLOADSTATE_NOTLOADED: number;
  79945. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  79946. static readonly NEVER: number;
  79947. /** 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 */
  79948. static readonly ALWAYS: number;
  79949. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  79950. static readonly LESS: number;
  79951. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  79952. static readonly EQUAL: number;
  79953. /** 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 */
  79954. static readonly LEQUAL: number;
  79955. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  79956. static readonly GREATER: number;
  79957. /** 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 */
  79958. static readonly GEQUAL: number;
  79959. /** 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 */
  79960. static readonly NOTEQUAL: number;
  79961. /** Passed to stencilOperation to specify that stencil value must be kept */
  79962. static readonly KEEP: number;
  79963. /** Passed to stencilOperation to specify that stencil value must be replaced */
  79964. static readonly REPLACE: number;
  79965. /** Passed to stencilOperation to specify that stencil value must be incremented */
  79966. static readonly INCR: number;
  79967. /** Passed to stencilOperation to specify that stencil value must be decremented */
  79968. static readonly DECR: number;
  79969. /** Passed to stencilOperation to specify that stencil value must be inverted */
  79970. static readonly INVERT: number;
  79971. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  79972. static readonly INCR_WRAP: number;
  79973. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  79974. static readonly DECR_WRAP: number;
  79975. /** Texture is not repeating outside of 0..1 UVs */
  79976. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  79977. /** Texture is repeating outside of 0..1 UVs */
  79978. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  79979. /** Texture is repeating and mirrored */
  79980. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  79981. /** ALPHA */
  79982. static readonly TEXTUREFORMAT_ALPHA: number;
  79983. /** LUMINANCE */
  79984. static readonly TEXTUREFORMAT_LUMINANCE: number;
  79985. /** LUMINANCE_ALPHA */
  79986. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  79987. /** RGB */
  79988. static readonly TEXTUREFORMAT_RGB: number;
  79989. /** RGBA */
  79990. static readonly TEXTUREFORMAT_RGBA: number;
  79991. /** RED */
  79992. static readonly TEXTUREFORMAT_RED: number;
  79993. /** RED (2nd reference) */
  79994. static readonly TEXTUREFORMAT_R: number;
  79995. /** RG */
  79996. static readonly TEXTUREFORMAT_RG: number;
  79997. /** RED_INTEGER */
  79998. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  79999. /** RED_INTEGER (2nd reference) */
  80000. static readonly TEXTUREFORMAT_R_INTEGER: number;
  80001. /** RG_INTEGER */
  80002. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  80003. /** RGB_INTEGER */
  80004. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  80005. /** RGBA_INTEGER */
  80006. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  80007. /** UNSIGNED_BYTE */
  80008. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  80009. /** UNSIGNED_BYTE (2nd reference) */
  80010. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  80011. /** FLOAT */
  80012. static readonly TEXTURETYPE_FLOAT: number;
  80013. /** HALF_FLOAT */
  80014. static readonly TEXTURETYPE_HALF_FLOAT: number;
  80015. /** BYTE */
  80016. static readonly TEXTURETYPE_BYTE: number;
  80017. /** SHORT */
  80018. static readonly TEXTURETYPE_SHORT: number;
  80019. /** UNSIGNED_SHORT */
  80020. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  80021. /** INT */
  80022. static readonly TEXTURETYPE_INT: number;
  80023. /** UNSIGNED_INT */
  80024. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  80025. /** UNSIGNED_SHORT_4_4_4_4 */
  80026. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  80027. /** UNSIGNED_SHORT_5_5_5_1 */
  80028. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  80029. /** UNSIGNED_SHORT_5_6_5 */
  80030. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  80031. /** UNSIGNED_INT_2_10_10_10_REV */
  80032. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  80033. /** UNSIGNED_INT_24_8 */
  80034. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  80035. /** UNSIGNED_INT_10F_11F_11F_REV */
  80036. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  80037. /** UNSIGNED_INT_5_9_9_9_REV */
  80038. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  80039. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  80040. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  80041. /** nearest is mag = nearest and min = nearest and no mip */
  80042. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  80043. /** mag = nearest and min = nearest and mip = none */
  80044. static readonly TEXTURE_NEAREST_NEAREST: number;
  80045. /** Bilinear is mag = linear and min = linear and no mip */
  80046. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  80047. /** mag = linear and min = linear and mip = none */
  80048. static readonly TEXTURE_LINEAR_LINEAR: number;
  80049. /** Trilinear is mag = linear and min = linear and mip = linear */
  80050. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  80051. /** Trilinear is mag = linear and min = linear and mip = linear */
  80052. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  80053. /** mag = nearest and min = nearest and mip = nearest */
  80054. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  80055. /** mag = nearest and min = linear and mip = nearest */
  80056. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  80057. /** mag = nearest and min = linear and mip = linear */
  80058. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  80059. /** mag = nearest and min = linear and mip = none */
  80060. static readonly TEXTURE_NEAREST_LINEAR: number;
  80061. /** nearest is mag = nearest and min = nearest and mip = linear */
  80062. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  80063. /** mag = linear and min = nearest and mip = nearest */
  80064. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  80065. /** mag = linear and min = nearest and mip = linear */
  80066. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  80067. /** Bilinear is mag = linear and min = linear and mip = nearest */
  80068. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  80069. /** mag = linear and min = nearest and mip = none */
  80070. static readonly TEXTURE_LINEAR_NEAREST: number;
  80071. /** Explicit coordinates mode */
  80072. static readonly TEXTURE_EXPLICIT_MODE: number;
  80073. /** Spherical coordinates mode */
  80074. static readonly TEXTURE_SPHERICAL_MODE: number;
  80075. /** Planar coordinates mode */
  80076. static readonly TEXTURE_PLANAR_MODE: number;
  80077. /** Cubic coordinates mode */
  80078. static readonly TEXTURE_CUBIC_MODE: number;
  80079. /** Projection coordinates mode */
  80080. static readonly TEXTURE_PROJECTION_MODE: number;
  80081. /** Skybox coordinates mode */
  80082. static readonly TEXTURE_SKYBOX_MODE: number;
  80083. /** Inverse Cubic coordinates mode */
  80084. static readonly TEXTURE_INVCUBIC_MODE: number;
  80085. /** Equirectangular coordinates mode */
  80086. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  80087. /** Equirectangular Fixed coordinates mode */
  80088. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  80089. /** Equirectangular Fixed Mirrored coordinates mode */
  80090. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  80091. /** Offline (baking) quality for texture filtering */
  80092. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  80093. /** High quality for texture filtering */
  80094. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  80095. /** Medium quality for texture filtering */
  80096. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  80097. /** Low quality for texture filtering */
  80098. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  80099. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  80100. static readonly SCALEMODE_FLOOR: number;
  80101. /** Defines that texture rescaling will look for the nearest power of 2 size */
  80102. static readonly SCALEMODE_NEAREST: number;
  80103. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  80104. static readonly SCALEMODE_CEILING: number;
  80105. /**
  80106. * The dirty texture flag value
  80107. */
  80108. static readonly MATERIAL_TextureDirtyFlag: number;
  80109. /**
  80110. * The dirty light flag value
  80111. */
  80112. static readonly MATERIAL_LightDirtyFlag: number;
  80113. /**
  80114. * The dirty fresnel flag value
  80115. */
  80116. static readonly MATERIAL_FresnelDirtyFlag: number;
  80117. /**
  80118. * The dirty attribute flag value
  80119. */
  80120. static readonly MATERIAL_AttributesDirtyFlag: number;
  80121. /**
  80122. * The dirty misc flag value
  80123. */
  80124. static readonly MATERIAL_MiscDirtyFlag: number;
  80125. /**
  80126. * The all dirty flag value
  80127. */
  80128. static readonly MATERIAL_AllDirtyFlag: number;
  80129. /**
  80130. * Returns the triangle fill mode
  80131. */
  80132. static readonly MATERIAL_TriangleFillMode: number;
  80133. /**
  80134. * Returns the wireframe mode
  80135. */
  80136. static readonly MATERIAL_WireFrameFillMode: number;
  80137. /**
  80138. * Returns the point fill mode
  80139. */
  80140. static readonly MATERIAL_PointFillMode: number;
  80141. /**
  80142. * Returns the point list draw mode
  80143. */
  80144. static readonly MATERIAL_PointListDrawMode: number;
  80145. /**
  80146. * Returns the line list draw mode
  80147. */
  80148. static readonly MATERIAL_LineListDrawMode: number;
  80149. /**
  80150. * Returns the line loop draw mode
  80151. */
  80152. static readonly MATERIAL_LineLoopDrawMode: number;
  80153. /**
  80154. * Returns the line strip draw mode
  80155. */
  80156. static readonly MATERIAL_LineStripDrawMode: number;
  80157. /**
  80158. * Returns the triangle strip draw mode
  80159. */
  80160. static readonly MATERIAL_TriangleStripDrawMode: number;
  80161. /**
  80162. * Returns the triangle fan draw mode
  80163. */
  80164. static readonly MATERIAL_TriangleFanDrawMode: number;
  80165. /**
  80166. * Stores the clock-wise side orientation
  80167. */
  80168. static readonly MATERIAL_ClockWiseSideOrientation: number;
  80169. /**
  80170. * Stores the counter clock-wise side orientation
  80171. */
  80172. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  80173. /**
  80174. * Nothing
  80175. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80176. */
  80177. static readonly ACTION_NothingTrigger: number;
  80178. /**
  80179. * On pick
  80180. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80181. */
  80182. static readonly ACTION_OnPickTrigger: number;
  80183. /**
  80184. * On left pick
  80185. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80186. */
  80187. static readonly ACTION_OnLeftPickTrigger: number;
  80188. /**
  80189. * On right pick
  80190. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80191. */
  80192. static readonly ACTION_OnRightPickTrigger: number;
  80193. /**
  80194. * On center pick
  80195. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80196. */
  80197. static readonly ACTION_OnCenterPickTrigger: number;
  80198. /**
  80199. * On pick down
  80200. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80201. */
  80202. static readonly ACTION_OnPickDownTrigger: number;
  80203. /**
  80204. * On double pick
  80205. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80206. */
  80207. static readonly ACTION_OnDoublePickTrigger: number;
  80208. /**
  80209. * On pick up
  80210. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80211. */
  80212. static readonly ACTION_OnPickUpTrigger: number;
  80213. /**
  80214. * On pick out.
  80215. * This trigger will only be raised if you also declared a OnPickDown
  80216. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80217. */
  80218. static readonly ACTION_OnPickOutTrigger: number;
  80219. /**
  80220. * On long press
  80221. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80222. */
  80223. static readonly ACTION_OnLongPressTrigger: number;
  80224. /**
  80225. * On pointer over
  80226. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80227. */
  80228. static readonly ACTION_OnPointerOverTrigger: number;
  80229. /**
  80230. * On pointer out
  80231. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80232. */
  80233. static readonly ACTION_OnPointerOutTrigger: number;
  80234. /**
  80235. * On every frame
  80236. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80237. */
  80238. static readonly ACTION_OnEveryFrameTrigger: number;
  80239. /**
  80240. * On intersection enter
  80241. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80242. */
  80243. static readonly ACTION_OnIntersectionEnterTrigger: number;
  80244. /**
  80245. * On intersection exit
  80246. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80247. */
  80248. static readonly ACTION_OnIntersectionExitTrigger: number;
  80249. /**
  80250. * On key down
  80251. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80252. */
  80253. static readonly ACTION_OnKeyDownTrigger: number;
  80254. /**
  80255. * On key up
  80256. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80257. */
  80258. static readonly ACTION_OnKeyUpTrigger: number;
  80259. /**
  80260. * Billboard mode will only apply to Y axis
  80261. */
  80262. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  80263. /**
  80264. * Billboard mode will apply to all axes
  80265. */
  80266. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  80267. /**
  80268. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  80269. */
  80270. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  80271. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  80272. * Test order :
  80273. * Is the bounding sphere outside the frustum ?
  80274. * If not, are the bounding box vertices outside the frustum ?
  80275. * It not, then the cullable object is in the frustum.
  80276. */
  80277. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  80278. /** Culling strategy : Bounding Sphere Only.
  80279. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  80280. * It's also less accurate than the standard because some not visible objects can still be selected.
  80281. * Test : is the bounding sphere outside the frustum ?
  80282. * If not, then the cullable object is in the frustum.
  80283. */
  80284. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  80285. /** Culling strategy : Optimistic Inclusion.
  80286. * This in an inclusion test first, then the standard exclusion test.
  80287. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  80288. * 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.
  80289. * Anyway, it's as accurate as the standard strategy.
  80290. * Test :
  80291. * Is the cullable object bounding sphere center in the frustum ?
  80292. * If not, apply the default culling strategy.
  80293. */
  80294. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  80295. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  80296. * This in an inclusion test first, then the bounding sphere only exclusion test.
  80297. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  80298. * 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.
  80299. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  80300. * Test :
  80301. * Is the cullable object bounding sphere center in the frustum ?
  80302. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  80303. */
  80304. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  80305. /**
  80306. * No logging while loading
  80307. */
  80308. static readonly SCENELOADER_NO_LOGGING: number;
  80309. /**
  80310. * Minimal logging while loading
  80311. */
  80312. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  80313. /**
  80314. * Summary logging while loading
  80315. */
  80316. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  80317. /**
  80318. * Detailled logging while loading
  80319. */
  80320. static readonly SCENELOADER_DETAILED_LOGGING: number;
  80321. /**
  80322. * Prepass texture index for color
  80323. */
  80324. static readonly PREPASS_COLOR_INDEX: number;
  80325. /**
  80326. * Prepass texture index for irradiance
  80327. */
  80328. static readonly PREPASS_IRRADIANCE_INDEX: number;
  80329. /**
  80330. * Prepass texture index for depth + normal
  80331. */
  80332. static readonly PREPASS_DEPTHNORMAL_INDEX: number;
  80333. /**
  80334. * Prepass texture index for albedo
  80335. */
  80336. static readonly PREPASS_ALBEDO_INDEX: number;
  80337. }
  80338. }
  80339. declare module BABYLON {
  80340. /**
  80341. * This represents the required contract to create a new type of texture loader.
  80342. */
  80343. export interface IInternalTextureLoader {
  80344. /**
  80345. * Defines wether the loader supports cascade loading the different faces.
  80346. */
  80347. supportCascades: boolean;
  80348. /**
  80349. * This returns if the loader support the current file information.
  80350. * @param extension defines the file extension of the file being loaded
  80351. * @param mimeType defines the optional mime type of the file being loaded
  80352. * @returns true if the loader can load the specified file
  80353. */
  80354. canLoad(extension: string, mimeType?: string): boolean;
  80355. /**
  80356. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  80357. * @param data contains the texture data
  80358. * @param texture defines the BabylonJS internal texture
  80359. * @param createPolynomials will be true if polynomials have been requested
  80360. * @param onLoad defines the callback to trigger once the texture is ready
  80361. * @param onError defines the callback to trigger in case of error
  80362. */
  80363. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  80364. /**
  80365. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  80366. * @param data contains the texture data
  80367. * @param texture defines the BabylonJS internal texture
  80368. * @param callback defines the method to call once ready to upload
  80369. */
  80370. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  80371. }
  80372. }
  80373. declare module BABYLON {
  80374. /**
  80375. * Class used to store and describe the pipeline context associated with an effect
  80376. */
  80377. export interface IPipelineContext {
  80378. /**
  80379. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  80380. */
  80381. isAsync: boolean;
  80382. /**
  80383. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  80384. */
  80385. isReady: boolean;
  80386. /** @hidden */
  80387. _getVertexShaderCode(): string | null;
  80388. /** @hidden */
  80389. _getFragmentShaderCode(): string | null;
  80390. /** @hidden */
  80391. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  80392. }
  80393. }
  80394. declare module BABYLON {
  80395. /**
  80396. * Class used to store gfx data (like WebGLBuffer)
  80397. */
  80398. export class DataBuffer {
  80399. /**
  80400. * Gets or sets the number of objects referencing this buffer
  80401. */
  80402. references: number;
  80403. /** Gets or sets the size of the underlying buffer */
  80404. capacity: number;
  80405. /**
  80406. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  80407. */
  80408. is32Bits: boolean;
  80409. /**
  80410. * Gets the underlying buffer
  80411. */
  80412. get underlyingResource(): any;
  80413. }
  80414. }
  80415. declare module BABYLON {
  80416. /** @hidden */
  80417. export interface IShaderProcessor {
  80418. attributeProcessor?: (attribute: string) => string;
  80419. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  80420. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  80421. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  80422. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  80423. lineProcessor?: (line: string, isFragment: boolean) => string;
  80424. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  80425. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  80426. }
  80427. }
  80428. declare module BABYLON {
  80429. /** @hidden */
  80430. export interface ProcessingOptions {
  80431. defines: string[];
  80432. indexParameters: any;
  80433. isFragment: boolean;
  80434. shouldUseHighPrecisionShader: boolean;
  80435. supportsUniformBuffers: boolean;
  80436. shadersRepository: string;
  80437. includesShadersStore: {
  80438. [key: string]: string;
  80439. };
  80440. processor?: IShaderProcessor;
  80441. version: string;
  80442. platformName: string;
  80443. lookForClosingBracketForUniformBuffer?: boolean;
  80444. }
  80445. }
  80446. declare module BABYLON {
  80447. /** @hidden */
  80448. export class ShaderCodeNode {
  80449. line: string;
  80450. children: ShaderCodeNode[];
  80451. additionalDefineKey?: string;
  80452. additionalDefineValue?: string;
  80453. isValid(preprocessors: {
  80454. [key: string]: string;
  80455. }): boolean;
  80456. process(preprocessors: {
  80457. [key: string]: string;
  80458. }, options: ProcessingOptions): string;
  80459. }
  80460. }
  80461. declare module BABYLON {
  80462. /** @hidden */
  80463. export class ShaderCodeCursor {
  80464. private _lines;
  80465. lineIndex: number;
  80466. get currentLine(): string;
  80467. get canRead(): boolean;
  80468. set lines(value: string[]);
  80469. }
  80470. }
  80471. declare module BABYLON {
  80472. /** @hidden */
  80473. export class ShaderCodeConditionNode extends ShaderCodeNode {
  80474. process(preprocessors: {
  80475. [key: string]: string;
  80476. }, options: ProcessingOptions): string;
  80477. }
  80478. }
  80479. declare module BABYLON {
  80480. /** @hidden */
  80481. export class ShaderDefineExpression {
  80482. isTrue(preprocessors: {
  80483. [key: string]: string;
  80484. }): boolean;
  80485. private static _OperatorPriority;
  80486. private static _Stack;
  80487. static postfixToInfix(postfix: string[]): string;
  80488. static infixToPostfix(infix: string): string[];
  80489. }
  80490. }
  80491. declare module BABYLON {
  80492. /** @hidden */
  80493. export class ShaderCodeTestNode extends ShaderCodeNode {
  80494. testExpression: ShaderDefineExpression;
  80495. isValid(preprocessors: {
  80496. [key: string]: string;
  80497. }): boolean;
  80498. }
  80499. }
  80500. declare module BABYLON {
  80501. /** @hidden */
  80502. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  80503. define: string;
  80504. not: boolean;
  80505. constructor(define: string, not?: boolean);
  80506. isTrue(preprocessors: {
  80507. [key: string]: string;
  80508. }): boolean;
  80509. }
  80510. }
  80511. declare module BABYLON {
  80512. /** @hidden */
  80513. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  80514. leftOperand: ShaderDefineExpression;
  80515. rightOperand: ShaderDefineExpression;
  80516. isTrue(preprocessors: {
  80517. [key: string]: string;
  80518. }): boolean;
  80519. }
  80520. }
  80521. declare module BABYLON {
  80522. /** @hidden */
  80523. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  80524. leftOperand: ShaderDefineExpression;
  80525. rightOperand: ShaderDefineExpression;
  80526. isTrue(preprocessors: {
  80527. [key: string]: string;
  80528. }): boolean;
  80529. }
  80530. }
  80531. declare module BABYLON {
  80532. /** @hidden */
  80533. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  80534. define: string;
  80535. operand: string;
  80536. testValue: string;
  80537. constructor(define: string, operand: string, testValue: string);
  80538. isTrue(preprocessors: {
  80539. [key: string]: string;
  80540. }): boolean;
  80541. }
  80542. }
  80543. declare module BABYLON {
  80544. /**
  80545. * Class used to enable access to offline support
  80546. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  80547. */
  80548. export interface IOfflineProvider {
  80549. /**
  80550. * Gets a boolean indicating if scene must be saved in the database
  80551. */
  80552. enableSceneOffline: boolean;
  80553. /**
  80554. * Gets a boolean indicating if textures must be saved in the database
  80555. */
  80556. enableTexturesOffline: boolean;
  80557. /**
  80558. * Open the offline support and make it available
  80559. * @param successCallback defines the callback to call on success
  80560. * @param errorCallback defines the callback to call on error
  80561. */
  80562. open(successCallback: () => void, errorCallback: () => void): void;
  80563. /**
  80564. * Loads an image from the offline support
  80565. * @param url defines the url to load from
  80566. * @param image defines the target DOM image
  80567. */
  80568. loadImage(url: string, image: HTMLImageElement): void;
  80569. /**
  80570. * Loads a file from offline support
  80571. * @param url defines the URL to load from
  80572. * @param sceneLoaded defines a callback to call on success
  80573. * @param progressCallBack defines a callback to call when progress changed
  80574. * @param errorCallback defines a callback to call on error
  80575. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  80576. */
  80577. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  80578. }
  80579. }
  80580. declare module BABYLON {
  80581. /**
  80582. * Class used to help managing file picking and drag'n'drop
  80583. * File Storage
  80584. */
  80585. export class FilesInputStore {
  80586. /**
  80587. * List of files ready to be loaded
  80588. */
  80589. static FilesToLoad: {
  80590. [key: string]: File;
  80591. };
  80592. }
  80593. }
  80594. declare module BABYLON {
  80595. /**
  80596. * Class used to define a retry strategy when error happens while loading assets
  80597. */
  80598. export class RetryStrategy {
  80599. /**
  80600. * Function used to defines an exponential back off strategy
  80601. * @param maxRetries defines the maximum number of retries (3 by default)
  80602. * @param baseInterval defines the interval between retries
  80603. * @returns the strategy function to use
  80604. */
  80605. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  80606. }
  80607. }
  80608. declare module BABYLON {
  80609. /**
  80610. * @ignore
  80611. * Application error to support additional information when loading a file
  80612. */
  80613. export abstract class BaseError extends Error {
  80614. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  80615. }
  80616. }
  80617. declare module BABYLON {
  80618. /** @ignore */
  80619. export class LoadFileError extends BaseError {
  80620. request?: WebRequest;
  80621. file?: File;
  80622. /**
  80623. * Creates a new LoadFileError
  80624. * @param message defines the message of the error
  80625. * @param request defines the optional web request
  80626. * @param file defines the optional file
  80627. */
  80628. constructor(message: string, object?: WebRequest | File);
  80629. }
  80630. /** @ignore */
  80631. export class RequestFileError extends BaseError {
  80632. request: WebRequest;
  80633. /**
  80634. * Creates a new LoadFileError
  80635. * @param message defines the message of the error
  80636. * @param request defines the optional web request
  80637. */
  80638. constructor(message: string, request: WebRequest);
  80639. }
  80640. /** @ignore */
  80641. export class ReadFileError extends BaseError {
  80642. file: File;
  80643. /**
  80644. * Creates a new ReadFileError
  80645. * @param message defines the message of the error
  80646. * @param file defines the optional file
  80647. */
  80648. constructor(message: string, file: File);
  80649. }
  80650. /**
  80651. * @hidden
  80652. */
  80653. export class FileTools {
  80654. /**
  80655. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  80656. */
  80657. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  80658. /**
  80659. * Gets or sets the base URL to use to load assets
  80660. */
  80661. static BaseUrl: string;
  80662. /**
  80663. * Default behaviour for cors in the application.
  80664. * It can be a string if the expected behavior is identical in the entire app.
  80665. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  80666. */
  80667. static CorsBehavior: string | ((url: string | string[]) => string);
  80668. /**
  80669. * Gets or sets a function used to pre-process url before using them to load assets
  80670. */
  80671. static PreprocessUrl: (url: string) => string;
  80672. /**
  80673. * Removes unwanted characters from an url
  80674. * @param url defines the url to clean
  80675. * @returns the cleaned url
  80676. */
  80677. private static _CleanUrl;
  80678. /**
  80679. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  80680. * @param url define the url we are trying
  80681. * @param element define the dom element where to configure the cors policy
  80682. */
  80683. static SetCorsBehavior(url: string | string[], element: {
  80684. crossOrigin: string | null;
  80685. }): void;
  80686. /**
  80687. * Loads an image as an HTMLImageElement.
  80688. * @param input url string, ArrayBuffer, or Blob to load
  80689. * @param onLoad callback called when the image successfully loads
  80690. * @param onError callback called when the image fails to load
  80691. * @param offlineProvider offline provider for caching
  80692. * @param mimeType optional mime type
  80693. * @returns the HTMLImageElement of the loaded image
  80694. */
  80695. 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>;
  80696. /**
  80697. * Reads a file from a File object
  80698. * @param file defines the file to load
  80699. * @param onSuccess defines the callback to call when data is loaded
  80700. * @param onProgress defines the callback to call during loading process
  80701. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  80702. * @param onError defines the callback to call when an error occurs
  80703. * @returns a file request object
  80704. */
  80705. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  80706. /**
  80707. * Loads a file from a url
  80708. * @param url url to load
  80709. * @param onSuccess callback called when the file successfully loads
  80710. * @param onProgress callback called while file is loading (if the server supports this mode)
  80711. * @param offlineProvider defines the offline provider for caching
  80712. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  80713. * @param onError callback called when the file fails to load
  80714. * @returns a file request object
  80715. */
  80716. 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;
  80717. /**
  80718. * Loads a file
  80719. * @param url url to load
  80720. * @param onSuccess callback called when the file successfully loads
  80721. * @param onProgress callback called while file is loading (if the server supports this mode)
  80722. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  80723. * @param onError callback called when the file fails to load
  80724. * @param onOpened callback called when the web request is opened
  80725. * @returns a file request object
  80726. */
  80727. 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;
  80728. /**
  80729. * Checks if the loaded document was accessed via `file:`-Protocol.
  80730. * @returns boolean
  80731. */
  80732. static IsFileURL(): boolean;
  80733. }
  80734. }
  80735. declare module BABYLON {
  80736. /** @hidden */
  80737. export class ShaderProcessor {
  80738. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  80739. private static _ProcessPrecision;
  80740. private static _ExtractOperation;
  80741. private static _BuildSubExpression;
  80742. private static _BuildExpression;
  80743. private static _MoveCursorWithinIf;
  80744. private static _MoveCursor;
  80745. private static _EvaluatePreProcessors;
  80746. private static _PreparePreProcessors;
  80747. private static _ProcessShaderConversion;
  80748. private static _ProcessIncludes;
  80749. /**
  80750. * Loads a file from a url
  80751. * @param url url to load
  80752. * @param onSuccess callback called when the file successfully loads
  80753. * @param onProgress callback called while file is loading (if the server supports this mode)
  80754. * @param offlineProvider defines the offline provider for caching
  80755. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  80756. * @param onError callback called when the file fails to load
  80757. * @returns a file request object
  80758. * @hidden
  80759. */
  80760. 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;
  80761. }
  80762. }
  80763. declare module BABYLON {
  80764. /**
  80765. * @hidden
  80766. */
  80767. export interface IColor4Like {
  80768. r: float;
  80769. g: float;
  80770. b: float;
  80771. a: float;
  80772. }
  80773. /**
  80774. * @hidden
  80775. */
  80776. export interface IColor3Like {
  80777. r: float;
  80778. g: float;
  80779. b: float;
  80780. }
  80781. /**
  80782. * @hidden
  80783. */
  80784. export interface IVector4Like {
  80785. x: float;
  80786. y: float;
  80787. z: float;
  80788. w: float;
  80789. }
  80790. /**
  80791. * @hidden
  80792. */
  80793. export interface IVector3Like {
  80794. x: float;
  80795. y: float;
  80796. z: float;
  80797. }
  80798. /**
  80799. * @hidden
  80800. */
  80801. export interface IVector2Like {
  80802. x: float;
  80803. y: float;
  80804. }
  80805. /**
  80806. * @hidden
  80807. */
  80808. export interface IMatrixLike {
  80809. toArray(): DeepImmutable<Float32Array | Array<number>>;
  80810. updateFlag: int;
  80811. }
  80812. /**
  80813. * @hidden
  80814. */
  80815. export interface IViewportLike {
  80816. x: float;
  80817. y: float;
  80818. width: float;
  80819. height: float;
  80820. }
  80821. /**
  80822. * @hidden
  80823. */
  80824. export interface IPlaneLike {
  80825. normal: IVector3Like;
  80826. d: float;
  80827. normalize(): void;
  80828. }
  80829. }
  80830. declare module BABYLON {
  80831. /**
  80832. * Interface used to define common properties for effect fallbacks
  80833. */
  80834. export interface IEffectFallbacks {
  80835. /**
  80836. * Removes the defines that should be removed when falling back.
  80837. * @param currentDefines defines the current define statements for the shader.
  80838. * @param effect defines the current effect we try to compile
  80839. * @returns The resulting defines with defines of the current rank removed.
  80840. */
  80841. reduce(currentDefines: string, effect: Effect): string;
  80842. /**
  80843. * Removes the fallback from the bound mesh.
  80844. */
  80845. unBindMesh(): void;
  80846. /**
  80847. * Checks to see if more fallbacks are still availible.
  80848. */
  80849. hasMoreFallbacks: boolean;
  80850. }
  80851. }
  80852. declare module BABYLON {
  80853. /**
  80854. * Class used to evalaute queries containing `and` and `or` operators
  80855. */
  80856. export class AndOrNotEvaluator {
  80857. /**
  80858. * Evaluate a query
  80859. * @param query defines the query to evaluate
  80860. * @param evaluateCallback defines the callback used to filter result
  80861. * @returns true if the query matches
  80862. */
  80863. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  80864. private static _HandleParenthesisContent;
  80865. private static _SimplifyNegation;
  80866. }
  80867. }
  80868. declare module BABYLON {
  80869. /**
  80870. * Class used to store custom tags
  80871. */
  80872. export class Tags {
  80873. /**
  80874. * Adds support for tags on the given object
  80875. * @param obj defines the object to use
  80876. */
  80877. static EnableFor(obj: any): void;
  80878. /**
  80879. * Removes tags support
  80880. * @param obj defines the object to use
  80881. */
  80882. static DisableFor(obj: any): void;
  80883. /**
  80884. * Gets a boolean indicating if the given object has tags
  80885. * @param obj defines the object to use
  80886. * @returns a boolean
  80887. */
  80888. static HasTags(obj: any): boolean;
  80889. /**
  80890. * Gets the tags available on a given object
  80891. * @param obj defines the object to use
  80892. * @param asString defines if the tags must be returned as a string instead of an array of strings
  80893. * @returns the tags
  80894. */
  80895. static GetTags(obj: any, asString?: boolean): any;
  80896. /**
  80897. * Adds tags to an object
  80898. * @param obj defines the object to use
  80899. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  80900. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  80901. */
  80902. static AddTagsTo(obj: any, tagsString: string): void;
  80903. /**
  80904. * @hidden
  80905. */
  80906. static _AddTagTo(obj: any, tag: string): void;
  80907. /**
  80908. * Removes specific tags from a specific object
  80909. * @param obj defines the object to use
  80910. * @param tagsString defines the tags to remove
  80911. */
  80912. static RemoveTagsFrom(obj: any, tagsString: string): void;
  80913. /**
  80914. * @hidden
  80915. */
  80916. static _RemoveTagFrom(obj: any, tag: string): void;
  80917. /**
  80918. * Defines if tags hosted on an object match a given query
  80919. * @param obj defines the object to use
  80920. * @param tagsQuery defines the tag query
  80921. * @returns a boolean
  80922. */
  80923. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  80924. }
  80925. }
  80926. declare module BABYLON {
  80927. /**
  80928. * Scalar computation library
  80929. */
  80930. export class Scalar {
  80931. /**
  80932. * Two pi constants convenient for computation.
  80933. */
  80934. static TwoPi: number;
  80935. /**
  80936. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  80937. * @param a number
  80938. * @param b number
  80939. * @param epsilon (default = 1.401298E-45)
  80940. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  80941. */
  80942. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80943. /**
  80944. * Returns a string : the upper case translation of the number i to hexadecimal.
  80945. * @param i number
  80946. * @returns the upper case translation of the number i to hexadecimal.
  80947. */
  80948. static ToHex(i: number): string;
  80949. /**
  80950. * Returns -1 if value is negative and +1 is value is positive.
  80951. * @param value the value
  80952. * @returns the value itself if it's equal to zero.
  80953. */
  80954. static Sign(value: number): number;
  80955. /**
  80956. * Returns the value itself if it's between min and max.
  80957. * Returns min if the value is lower than min.
  80958. * Returns max if the value is greater than max.
  80959. * @param value the value to clmap
  80960. * @param min the min value to clamp to (default: 0)
  80961. * @param max the max value to clamp to (default: 1)
  80962. * @returns the clamped value
  80963. */
  80964. static Clamp(value: number, min?: number, max?: number): number;
  80965. /**
  80966. * the log2 of value.
  80967. * @param value the value to compute log2 of
  80968. * @returns the log2 of value.
  80969. */
  80970. static Log2(value: number): number;
  80971. /**
  80972. * Loops the value, so that it is never larger than length and never smaller than 0.
  80973. *
  80974. * This is similar to the modulo operator but it works with floating point numbers.
  80975. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  80976. * With t = 5 and length = 2.5, the result would be 0.0.
  80977. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  80978. * @param value the value
  80979. * @param length the length
  80980. * @returns the looped value
  80981. */
  80982. static Repeat(value: number, length: number): number;
  80983. /**
  80984. * Normalize the value between 0.0 and 1.0 using min and max values
  80985. * @param value value to normalize
  80986. * @param min max to normalize between
  80987. * @param max min to normalize between
  80988. * @returns the normalized value
  80989. */
  80990. static Normalize(value: number, min: number, max: number): number;
  80991. /**
  80992. * Denormalize the value from 0.0 and 1.0 using min and max values
  80993. * @param normalized value to denormalize
  80994. * @param min max to denormalize between
  80995. * @param max min to denormalize between
  80996. * @returns the denormalized value
  80997. */
  80998. static Denormalize(normalized: number, min: number, max: number): number;
  80999. /**
  81000. * Calculates the shortest difference between two given angles given in degrees.
  81001. * @param current current angle in degrees
  81002. * @param target target angle in degrees
  81003. * @returns the delta
  81004. */
  81005. static DeltaAngle(current: number, target: number): number;
  81006. /**
  81007. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  81008. * @param tx value
  81009. * @param length length
  81010. * @returns The returned value will move back and forth between 0 and length
  81011. */
  81012. static PingPong(tx: number, length: number): number;
  81013. /**
  81014. * Interpolates between min and max with smoothing at the limits.
  81015. *
  81016. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  81017. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  81018. * @param from from
  81019. * @param to to
  81020. * @param tx value
  81021. * @returns the smooth stepped value
  81022. */
  81023. static SmoothStep(from: number, to: number, tx: number): number;
  81024. /**
  81025. * Moves a value current towards target.
  81026. *
  81027. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  81028. * Negative values of maxDelta pushes the value away from target.
  81029. * @param current current value
  81030. * @param target target value
  81031. * @param maxDelta max distance to move
  81032. * @returns resulting value
  81033. */
  81034. static MoveTowards(current: number, target: number, maxDelta: number): number;
  81035. /**
  81036. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  81037. *
  81038. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  81039. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  81040. * @param current current value
  81041. * @param target target value
  81042. * @param maxDelta max distance to move
  81043. * @returns resulting angle
  81044. */
  81045. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  81046. /**
  81047. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  81048. * @param start start value
  81049. * @param end target value
  81050. * @param amount amount to lerp between
  81051. * @returns the lerped value
  81052. */
  81053. static Lerp(start: number, end: number, amount: number): number;
  81054. /**
  81055. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  81056. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  81057. * @param start start value
  81058. * @param end target value
  81059. * @param amount amount to lerp between
  81060. * @returns the lerped value
  81061. */
  81062. static LerpAngle(start: number, end: number, amount: number): number;
  81063. /**
  81064. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  81065. * @param a start value
  81066. * @param b target value
  81067. * @param value value between a and b
  81068. * @returns the inverseLerp value
  81069. */
  81070. static InverseLerp(a: number, b: number, value: number): number;
  81071. /**
  81072. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  81073. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  81074. * @param value1 spline value
  81075. * @param tangent1 spline value
  81076. * @param value2 spline value
  81077. * @param tangent2 spline value
  81078. * @param amount input value
  81079. * @returns hermite result
  81080. */
  81081. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  81082. /**
  81083. * Returns a random float number between and min and max values
  81084. * @param min min value of random
  81085. * @param max max value of random
  81086. * @returns random value
  81087. */
  81088. static RandomRange(min: number, max: number): number;
  81089. /**
  81090. * This function returns percentage of a number in a given range.
  81091. *
  81092. * RangeToPercent(40,20,60) will return 0.5 (50%)
  81093. * RangeToPercent(34,0,100) will return 0.34 (34%)
  81094. * @param number to convert to percentage
  81095. * @param min min range
  81096. * @param max max range
  81097. * @returns the percentage
  81098. */
  81099. static RangeToPercent(number: number, min: number, max: number): number;
  81100. /**
  81101. * This function returns number that corresponds to the percentage in a given range.
  81102. *
  81103. * PercentToRange(0.34,0,100) will return 34.
  81104. * @param percent to convert to number
  81105. * @param min min range
  81106. * @param max max range
  81107. * @returns the number
  81108. */
  81109. static PercentToRange(percent: number, min: number, max: number): number;
  81110. /**
  81111. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  81112. * @param angle The angle to normalize in radian.
  81113. * @return The converted angle.
  81114. */
  81115. static NormalizeRadians(angle: number): number;
  81116. }
  81117. }
  81118. declare module BABYLON {
  81119. /**
  81120. * Constant used to convert a value to gamma space
  81121. * @ignorenaming
  81122. */
  81123. export const ToGammaSpace: number;
  81124. /**
  81125. * Constant used to convert a value to linear space
  81126. * @ignorenaming
  81127. */
  81128. export const ToLinearSpace = 2.2;
  81129. /**
  81130. * Constant used to define the minimal number value in Babylon.js
  81131. * @ignorenaming
  81132. */
  81133. let Epsilon: number;
  81134. }
  81135. declare module BABYLON {
  81136. /**
  81137. * Class used to represent a viewport on screen
  81138. */
  81139. export class Viewport {
  81140. /** viewport left coordinate */
  81141. x: number;
  81142. /** viewport top coordinate */
  81143. y: number;
  81144. /**viewport width */
  81145. width: number;
  81146. /** viewport height */
  81147. height: number;
  81148. /**
  81149. * Creates a Viewport object located at (x, y) and sized (width, height)
  81150. * @param x defines viewport left coordinate
  81151. * @param y defines viewport top coordinate
  81152. * @param width defines the viewport width
  81153. * @param height defines the viewport height
  81154. */
  81155. constructor(
  81156. /** viewport left coordinate */
  81157. x: number,
  81158. /** viewport top coordinate */
  81159. y: number,
  81160. /**viewport width */
  81161. width: number,
  81162. /** viewport height */
  81163. height: number);
  81164. /**
  81165. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  81166. * @param renderWidth defines the rendering width
  81167. * @param renderHeight defines the rendering height
  81168. * @returns a new Viewport
  81169. */
  81170. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  81171. /**
  81172. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  81173. * @param renderWidth defines the rendering width
  81174. * @param renderHeight defines the rendering height
  81175. * @param ref defines the target viewport
  81176. * @returns the current viewport
  81177. */
  81178. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  81179. /**
  81180. * Returns a new Viewport copied from the current one
  81181. * @returns a new Viewport
  81182. */
  81183. clone(): Viewport;
  81184. }
  81185. }
  81186. declare module BABYLON {
  81187. /**
  81188. * Class containing a set of static utilities functions for arrays.
  81189. */
  81190. export class ArrayTools {
  81191. /**
  81192. * Returns an array of the given size filled with element built from the given constructor and the paramters
  81193. * @param size the number of element to construct and put in the array
  81194. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  81195. * @returns a new array filled with new objects
  81196. */
  81197. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  81198. }
  81199. }
  81200. declare module BABYLON {
  81201. /**
  81202. * Represents a plane by the equation ax + by + cz + d = 0
  81203. */
  81204. export class Plane {
  81205. private static _TmpMatrix;
  81206. /**
  81207. * Normal of the plane (a,b,c)
  81208. */
  81209. normal: Vector3;
  81210. /**
  81211. * d component of the plane
  81212. */
  81213. d: number;
  81214. /**
  81215. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  81216. * @param a a component of the plane
  81217. * @param b b component of the plane
  81218. * @param c c component of the plane
  81219. * @param d d component of the plane
  81220. */
  81221. constructor(a: number, b: number, c: number, d: number);
  81222. /**
  81223. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  81224. */
  81225. asArray(): number[];
  81226. /**
  81227. * @returns a new plane copied from the current Plane.
  81228. */
  81229. clone(): Plane;
  81230. /**
  81231. * @returns the string "Plane".
  81232. */
  81233. getClassName(): string;
  81234. /**
  81235. * @returns the Plane hash code.
  81236. */
  81237. getHashCode(): number;
  81238. /**
  81239. * Normalize the current Plane in place.
  81240. * @returns the updated Plane.
  81241. */
  81242. normalize(): Plane;
  81243. /**
  81244. * Applies a transformation the plane and returns the result
  81245. * @param transformation the transformation matrix to be applied to the plane
  81246. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  81247. */
  81248. transform(transformation: DeepImmutable<Matrix>): Plane;
  81249. /**
  81250. * Compute the dot product between the point and the plane normal
  81251. * @param point point to calculate the dot product with
  81252. * @returns the dot product (float) of the point coordinates and the plane normal.
  81253. */
  81254. dotCoordinate(point: DeepImmutable<Vector3>): number;
  81255. /**
  81256. * Updates the current Plane from the plane defined by the three given points.
  81257. * @param point1 one of the points used to contruct the plane
  81258. * @param point2 one of the points used to contruct the plane
  81259. * @param point3 one of the points used to contruct the plane
  81260. * @returns the updated Plane.
  81261. */
  81262. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  81263. /**
  81264. * Checks if the plane is facing a given direction
  81265. * @param direction the direction to check if the plane is facing
  81266. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  81267. * @returns True is the vector "direction" is the same side than the plane normal.
  81268. */
  81269. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  81270. /**
  81271. * Calculates the distance to a point
  81272. * @param point point to calculate distance to
  81273. * @returns the signed distance (float) from the given point to the Plane.
  81274. */
  81275. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  81276. /**
  81277. * Creates a plane from an array
  81278. * @param array the array to create a plane from
  81279. * @returns a new Plane from the given array.
  81280. */
  81281. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  81282. /**
  81283. * Creates a plane from three points
  81284. * @param point1 point used to create the plane
  81285. * @param point2 point used to create the plane
  81286. * @param point3 point used to create the plane
  81287. * @returns a new Plane defined by the three given points.
  81288. */
  81289. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  81290. /**
  81291. * Creates a plane from an origin point and a normal
  81292. * @param origin origin of the plane to be constructed
  81293. * @param normal normal of the plane to be constructed
  81294. * @returns a new Plane the normal vector to this plane at the given origin point.
  81295. * Note : the vector "normal" is updated because normalized.
  81296. */
  81297. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  81298. /**
  81299. * Calculates the distance from a plane and a point
  81300. * @param origin origin of the plane to be constructed
  81301. * @param normal normal of the plane to be constructed
  81302. * @param point point to calculate distance to
  81303. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  81304. */
  81305. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  81306. }
  81307. }
  81308. declare module BABYLON {
  81309. /** @hidden */
  81310. export class PerformanceConfigurator {
  81311. /** @hidden */
  81312. static MatrixUse64Bits: boolean;
  81313. /** @hidden */
  81314. static MatrixTrackPrecisionChange: boolean;
  81315. /** @hidden */
  81316. static MatrixCurrentType: any;
  81317. /** @hidden */
  81318. static MatrixTrackedMatrices: Array<any> | null;
  81319. /** @hidden */
  81320. static SetMatrixPrecision(use64bits: boolean): void;
  81321. }
  81322. }
  81323. declare module BABYLON {
  81324. /**
  81325. * Class representing a vector containing 2 coordinates
  81326. */
  81327. export class Vector2 {
  81328. /** defines the first coordinate */
  81329. x: number;
  81330. /** defines the second coordinate */
  81331. y: number;
  81332. /**
  81333. * Creates a new Vector2 from the given x and y coordinates
  81334. * @param x defines the first coordinate
  81335. * @param y defines the second coordinate
  81336. */
  81337. constructor(
  81338. /** defines the first coordinate */
  81339. x?: number,
  81340. /** defines the second coordinate */
  81341. y?: number);
  81342. /**
  81343. * Gets a string with the Vector2 coordinates
  81344. * @returns a string with the Vector2 coordinates
  81345. */
  81346. toString(): string;
  81347. /**
  81348. * Gets class name
  81349. * @returns the string "Vector2"
  81350. */
  81351. getClassName(): string;
  81352. /**
  81353. * Gets current vector hash code
  81354. * @returns the Vector2 hash code as a number
  81355. */
  81356. getHashCode(): number;
  81357. /**
  81358. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  81359. * @param array defines the source array
  81360. * @param index defines the offset in source array
  81361. * @returns the current Vector2
  81362. */
  81363. toArray(array: FloatArray, index?: number): Vector2;
  81364. /**
  81365. * Update the current vector from an array
  81366. * @param array defines the destination array
  81367. * @param index defines the offset in the destination array
  81368. * @returns the current Vector3
  81369. */
  81370. fromArray(array: FloatArray, index?: number): Vector2;
  81371. /**
  81372. * Copy the current vector to an array
  81373. * @returns a new array with 2 elements: the Vector2 coordinates.
  81374. */
  81375. asArray(): number[];
  81376. /**
  81377. * Sets the Vector2 coordinates with the given Vector2 coordinates
  81378. * @param source defines the source Vector2
  81379. * @returns the current updated Vector2
  81380. */
  81381. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  81382. /**
  81383. * Sets the Vector2 coordinates with the given floats
  81384. * @param x defines the first coordinate
  81385. * @param y defines the second coordinate
  81386. * @returns the current updated Vector2
  81387. */
  81388. copyFromFloats(x: number, y: number): Vector2;
  81389. /**
  81390. * Sets the Vector2 coordinates with the given floats
  81391. * @param x defines the first coordinate
  81392. * @param y defines the second coordinate
  81393. * @returns the current updated Vector2
  81394. */
  81395. set(x: number, y: number): Vector2;
  81396. /**
  81397. * Add another vector with the current one
  81398. * @param otherVector defines the other vector
  81399. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  81400. */
  81401. add(otherVector: DeepImmutable<Vector2>): Vector2;
  81402. /**
  81403. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  81404. * @param otherVector defines the other vector
  81405. * @param result defines the target vector
  81406. * @returns the unmodified current Vector2
  81407. */
  81408. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  81409. /**
  81410. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  81411. * @param otherVector defines the other vector
  81412. * @returns the current updated Vector2
  81413. */
  81414. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  81415. /**
  81416. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  81417. * @param otherVector defines the other vector
  81418. * @returns a new Vector2
  81419. */
  81420. addVector3(otherVector: Vector3): Vector2;
  81421. /**
  81422. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  81423. * @param otherVector defines the other vector
  81424. * @returns a new Vector2
  81425. */
  81426. subtract(otherVector: Vector2): Vector2;
  81427. /**
  81428. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  81429. * @param otherVector defines the other vector
  81430. * @param result defines the target vector
  81431. * @returns the unmodified current Vector2
  81432. */
  81433. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  81434. /**
  81435. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  81436. * @param otherVector defines the other vector
  81437. * @returns the current updated Vector2
  81438. */
  81439. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  81440. /**
  81441. * Multiplies in place the current Vector2 coordinates by the given ones
  81442. * @param otherVector defines the other vector
  81443. * @returns the current updated Vector2
  81444. */
  81445. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  81446. /**
  81447. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  81448. * @param otherVector defines the other vector
  81449. * @returns a new Vector2
  81450. */
  81451. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  81452. /**
  81453. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  81454. * @param otherVector defines the other vector
  81455. * @param result defines the target vector
  81456. * @returns the unmodified current Vector2
  81457. */
  81458. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  81459. /**
  81460. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  81461. * @param x defines the first coordinate
  81462. * @param y defines the second coordinate
  81463. * @returns a new Vector2
  81464. */
  81465. multiplyByFloats(x: number, y: number): Vector2;
  81466. /**
  81467. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  81468. * @param otherVector defines the other vector
  81469. * @returns a new Vector2
  81470. */
  81471. divide(otherVector: Vector2): Vector2;
  81472. /**
  81473. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  81474. * @param otherVector defines the other vector
  81475. * @param result defines the target vector
  81476. * @returns the unmodified current Vector2
  81477. */
  81478. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  81479. /**
  81480. * Divides the current Vector2 coordinates by the given ones
  81481. * @param otherVector defines the other vector
  81482. * @returns the current updated Vector2
  81483. */
  81484. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  81485. /**
  81486. * Gets a new Vector2 with current Vector2 negated coordinates
  81487. * @returns a new Vector2
  81488. */
  81489. negate(): Vector2;
  81490. /**
  81491. * Negate this vector in place
  81492. * @returns this
  81493. */
  81494. negateInPlace(): Vector2;
  81495. /**
  81496. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  81497. * @param result defines the Vector3 object where to store the result
  81498. * @returns the current Vector2
  81499. */
  81500. negateToRef(result: Vector2): Vector2;
  81501. /**
  81502. * Multiply the Vector2 coordinates by scale
  81503. * @param scale defines the scaling factor
  81504. * @returns the current updated Vector2
  81505. */
  81506. scaleInPlace(scale: number): Vector2;
  81507. /**
  81508. * Returns a new Vector2 scaled by "scale" from the current Vector2
  81509. * @param scale defines the scaling factor
  81510. * @returns a new Vector2
  81511. */
  81512. scale(scale: number): Vector2;
  81513. /**
  81514. * Scale the current Vector2 values by a factor to a given Vector2
  81515. * @param scale defines the scale factor
  81516. * @param result defines the Vector2 object where to store the result
  81517. * @returns the unmodified current Vector2
  81518. */
  81519. scaleToRef(scale: number, result: Vector2): Vector2;
  81520. /**
  81521. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  81522. * @param scale defines the scale factor
  81523. * @param result defines the Vector2 object where to store the result
  81524. * @returns the unmodified current Vector2
  81525. */
  81526. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  81527. /**
  81528. * Gets a boolean if two vectors are equals
  81529. * @param otherVector defines the other vector
  81530. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  81531. */
  81532. equals(otherVector: DeepImmutable<Vector2>): boolean;
  81533. /**
  81534. * Gets a boolean if two vectors are equals (using an epsilon value)
  81535. * @param otherVector defines the other vector
  81536. * @param epsilon defines the minimal distance to consider equality
  81537. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  81538. */
  81539. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  81540. /**
  81541. * Gets a new Vector2 from current Vector2 floored values
  81542. * @returns a new Vector2
  81543. */
  81544. floor(): Vector2;
  81545. /**
  81546. * Gets a new Vector2 from current Vector2 floored values
  81547. * @returns a new Vector2
  81548. */
  81549. fract(): Vector2;
  81550. /**
  81551. * Gets the length of the vector
  81552. * @returns the vector length (float)
  81553. */
  81554. length(): number;
  81555. /**
  81556. * Gets the vector squared length
  81557. * @returns the vector squared length (float)
  81558. */
  81559. lengthSquared(): number;
  81560. /**
  81561. * Normalize the vector
  81562. * @returns the current updated Vector2
  81563. */
  81564. normalize(): Vector2;
  81565. /**
  81566. * Gets a new Vector2 copied from the Vector2
  81567. * @returns a new Vector2
  81568. */
  81569. clone(): Vector2;
  81570. /**
  81571. * Gets a new Vector2(0, 0)
  81572. * @returns a new Vector2
  81573. */
  81574. static Zero(): Vector2;
  81575. /**
  81576. * Gets a new Vector2(1, 1)
  81577. * @returns a new Vector2
  81578. */
  81579. static One(): Vector2;
  81580. /**
  81581. * Gets a new Vector2 set from the given index element of the given array
  81582. * @param array defines the data source
  81583. * @param offset defines the offset in the data source
  81584. * @returns a new Vector2
  81585. */
  81586. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  81587. /**
  81588. * Sets "result" from the given index element of the given array
  81589. * @param array defines the data source
  81590. * @param offset defines the offset in the data source
  81591. * @param result defines the target vector
  81592. */
  81593. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  81594. /**
  81595. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  81596. * @param value1 defines 1st point of control
  81597. * @param value2 defines 2nd point of control
  81598. * @param value3 defines 3rd point of control
  81599. * @param value4 defines 4th point of control
  81600. * @param amount defines the interpolation factor
  81601. * @returns a new Vector2
  81602. */
  81603. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  81604. /**
  81605. * 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".
  81606. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  81607. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  81608. * @param value defines the value to clamp
  81609. * @param min defines the lower limit
  81610. * @param max defines the upper limit
  81611. * @returns a new Vector2
  81612. */
  81613. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  81614. /**
  81615. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  81616. * @param value1 defines the 1st control point
  81617. * @param tangent1 defines the outgoing tangent
  81618. * @param value2 defines the 2nd control point
  81619. * @param tangent2 defines the incoming tangent
  81620. * @param amount defines the interpolation factor
  81621. * @returns a new Vector2
  81622. */
  81623. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  81624. /**
  81625. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  81626. * @param start defines the start vector
  81627. * @param end defines the end vector
  81628. * @param amount defines the interpolation factor
  81629. * @returns a new Vector2
  81630. */
  81631. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  81632. /**
  81633. * Gets the dot product of the vector "left" and the vector "right"
  81634. * @param left defines first vector
  81635. * @param right defines second vector
  81636. * @returns the dot product (float)
  81637. */
  81638. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  81639. /**
  81640. * Returns a new Vector2 equal to the normalized given vector
  81641. * @param vector defines the vector to normalize
  81642. * @returns a new Vector2
  81643. */
  81644. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  81645. /**
  81646. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  81647. * @param left defines 1st vector
  81648. * @param right defines 2nd vector
  81649. * @returns a new Vector2
  81650. */
  81651. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  81652. /**
  81653. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  81654. * @param left defines 1st vector
  81655. * @param right defines 2nd vector
  81656. * @returns a new Vector2
  81657. */
  81658. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  81659. /**
  81660. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  81661. * @param vector defines the vector to transform
  81662. * @param transformation defines the matrix to apply
  81663. * @returns a new Vector2
  81664. */
  81665. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  81666. /**
  81667. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  81668. * @param vector defines the vector to transform
  81669. * @param transformation defines the matrix to apply
  81670. * @param result defines the target vector
  81671. */
  81672. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  81673. /**
  81674. * Determines if a given vector is included in a triangle
  81675. * @param p defines the vector to test
  81676. * @param p0 defines 1st triangle point
  81677. * @param p1 defines 2nd triangle point
  81678. * @param p2 defines 3rd triangle point
  81679. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  81680. */
  81681. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  81682. /**
  81683. * Gets the distance between the vectors "value1" and "value2"
  81684. * @param value1 defines first vector
  81685. * @param value2 defines second vector
  81686. * @returns the distance between vectors
  81687. */
  81688. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  81689. /**
  81690. * Returns the squared distance between the vectors "value1" and "value2"
  81691. * @param value1 defines first vector
  81692. * @param value2 defines second vector
  81693. * @returns the squared distance between vectors
  81694. */
  81695. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  81696. /**
  81697. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  81698. * @param value1 defines first vector
  81699. * @param value2 defines second vector
  81700. * @returns a new Vector2
  81701. */
  81702. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  81703. /**
  81704. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  81705. * @param p defines the middle point
  81706. * @param segA defines one point of the segment
  81707. * @param segB defines the other point of the segment
  81708. * @returns the shortest distance
  81709. */
  81710. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  81711. }
  81712. /**
  81713. * Class used to store (x,y,z) vector representation
  81714. * A Vector3 is the main object used in 3D geometry
  81715. * It can represent etiher the coordinates of a point the space, either a direction
  81716. * Reminder: js uses a left handed forward facing system
  81717. */
  81718. export class Vector3 {
  81719. private static _UpReadOnly;
  81720. private static _ZeroReadOnly;
  81721. /** @hidden */
  81722. _x: number;
  81723. /** @hidden */
  81724. _y: number;
  81725. /** @hidden */
  81726. _z: number;
  81727. /** @hidden */
  81728. _isDirty: boolean;
  81729. /** Gets or sets the x coordinate */
  81730. get x(): number;
  81731. set x(value: number);
  81732. /** Gets or sets the y coordinate */
  81733. get y(): number;
  81734. set y(value: number);
  81735. /** Gets or sets the z coordinate */
  81736. get z(): number;
  81737. set z(value: number);
  81738. /**
  81739. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  81740. * @param x defines the first coordinates (on X axis)
  81741. * @param y defines the second coordinates (on Y axis)
  81742. * @param z defines the third coordinates (on Z axis)
  81743. */
  81744. constructor(x?: number, y?: number, z?: number);
  81745. /**
  81746. * Creates a string representation of the Vector3
  81747. * @returns a string with the Vector3 coordinates.
  81748. */
  81749. toString(): string;
  81750. /**
  81751. * Gets the class name
  81752. * @returns the string "Vector3"
  81753. */
  81754. getClassName(): string;
  81755. /**
  81756. * Creates the Vector3 hash code
  81757. * @returns a number which tends to be unique between Vector3 instances
  81758. */
  81759. getHashCode(): number;
  81760. /**
  81761. * Creates an array containing three elements : the coordinates of the Vector3
  81762. * @returns a new array of numbers
  81763. */
  81764. asArray(): number[];
  81765. /**
  81766. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  81767. * @param array defines the destination array
  81768. * @param index defines the offset in the destination array
  81769. * @returns the current Vector3
  81770. */
  81771. toArray(array: FloatArray, index?: number): Vector3;
  81772. /**
  81773. * Update the current vector from an array
  81774. * @param array defines the destination array
  81775. * @param index defines the offset in the destination array
  81776. * @returns the current Vector3
  81777. */
  81778. fromArray(array: FloatArray, index?: number): Vector3;
  81779. /**
  81780. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  81781. * @returns a new Quaternion object, computed from the Vector3 coordinates
  81782. */
  81783. toQuaternion(): Quaternion;
  81784. /**
  81785. * Adds the given vector to the current Vector3
  81786. * @param otherVector defines the second operand
  81787. * @returns the current updated Vector3
  81788. */
  81789. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  81790. /**
  81791. * Adds the given coordinates to the current Vector3
  81792. * @param x defines the x coordinate of the operand
  81793. * @param y defines the y coordinate of the operand
  81794. * @param z defines the z coordinate of the operand
  81795. * @returns the current updated Vector3
  81796. */
  81797. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  81798. /**
  81799. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  81800. * @param otherVector defines the second operand
  81801. * @returns the resulting Vector3
  81802. */
  81803. add(otherVector: DeepImmutable<Vector3>): Vector3;
  81804. /**
  81805. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  81806. * @param otherVector defines the second operand
  81807. * @param result defines the Vector3 object where to store the result
  81808. * @returns the current Vector3
  81809. */
  81810. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  81811. /**
  81812. * Subtract the given vector from the current Vector3
  81813. * @param otherVector defines the second operand
  81814. * @returns the current updated Vector3
  81815. */
  81816. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  81817. /**
  81818. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  81819. * @param otherVector defines the second operand
  81820. * @returns the resulting Vector3
  81821. */
  81822. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  81823. /**
  81824. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  81825. * @param otherVector defines the second operand
  81826. * @param result defines the Vector3 object where to store the result
  81827. * @returns the current Vector3
  81828. */
  81829. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  81830. /**
  81831. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  81832. * @param x defines the x coordinate of the operand
  81833. * @param y defines the y coordinate of the operand
  81834. * @param z defines the z coordinate of the operand
  81835. * @returns the resulting Vector3
  81836. */
  81837. subtractFromFloats(x: number, y: number, z: number): Vector3;
  81838. /**
  81839. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  81840. * @param x defines the x coordinate of the operand
  81841. * @param y defines the y coordinate of the operand
  81842. * @param z defines the z coordinate of the operand
  81843. * @param result defines the Vector3 object where to store the result
  81844. * @returns the current Vector3
  81845. */
  81846. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  81847. /**
  81848. * Gets a new Vector3 set with the current Vector3 negated coordinates
  81849. * @returns a new Vector3
  81850. */
  81851. negate(): Vector3;
  81852. /**
  81853. * Negate this vector in place
  81854. * @returns this
  81855. */
  81856. negateInPlace(): Vector3;
  81857. /**
  81858. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  81859. * @param result defines the Vector3 object where to store the result
  81860. * @returns the current Vector3
  81861. */
  81862. negateToRef(result: Vector3): Vector3;
  81863. /**
  81864. * Multiplies the Vector3 coordinates by the float "scale"
  81865. * @param scale defines the multiplier factor
  81866. * @returns the current updated Vector3
  81867. */
  81868. scaleInPlace(scale: number): Vector3;
  81869. /**
  81870. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  81871. * @param scale defines the multiplier factor
  81872. * @returns a new Vector3
  81873. */
  81874. scale(scale: number): Vector3;
  81875. /**
  81876. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  81877. * @param scale defines the multiplier factor
  81878. * @param result defines the Vector3 object where to store the result
  81879. * @returns the current Vector3
  81880. */
  81881. scaleToRef(scale: number, result: Vector3): Vector3;
  81882. /**
  81883. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  81884. * @param scale defines the scale factor
  81885. * @param result defines the Vector3 object where to store the result
  81886. * @returns the unmodified current Vector3
  81887. */
  81888. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  81889. /**
  81890. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  81891. * @param origin defines the origin of the projection ray
  81892. * @param plane defines the plane to project to
  81893. * @returns the projected vector3
  81894. */
  81895. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  81896. /**
  81897. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  81898. * @param origin defines the origin of the projection ray
  81899. * @param plane defines the plane to project to
  81900. * @param result defines the Vector3 where to store the result
  81901. */
  81902. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  81903. /**
  81904. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  81905. * @param otherVector defines the second operand
  81906. * @returns true if both vectors are equals
  81907. */
  81908. equals(otherVector: DeepImmutable<Vector3>): boolean;
  81909. /**
  81910. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  81911. * @param otherVector defines the second operand
  81912. * @param epsilon defines the minimal distance to define values as equals
  81913. * @returns true if both vectors are distant less than epsilon
  81914. */
  81915. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  81916. /**
  81917. * Returns true if the current Vector3 coordinates equals the given floats
  81918. * @param x defines the x coordinate of the operand
  81919. * @param y defines the y coordinate of the operand
  81920. * @param z defines the z coordinate of the operand
  81921. * @returns true if both vectors are equals
  81922. */
  81923. equalsToFloats(x: number, y: number, z: number): boolean;
  81924. /**
  81925. * Multiplies the current Vector3 coordinates by the given ones
  81926. * @param otherVector defines the second operand
  81927. * @returns the current updated Vector3
  81928. */
  81929. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  81930. /**
  81931. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  81932. * @param otherVector defines the second operand
  81933. * @returns the new Vector3
  81934. */
  81935. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  81936. /**
  81937. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  81938. * @param otherVector defines the second operand
  81939. * @param result defines the Vector3 object where to store the result
  81940. * @returns the current Vector3
  81941. */
  81942. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  81943. /**
  81944. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  81945. * @param x defines the x coordinate of the operand
  81946. * @param y defines the y coordinate of the operand
  81947. * @param z defines the z coordinate of the operand
  81948. * @returns the new Vector3
  81949. */
  81950. multiplyByFloats(x: number, y: number, z: number): Vector3;
  81951. /**
  81952. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  81953. * @param otherVector defines the second operand
  81954. * @returns the new Vector3
  81955. */
  81956. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  81957. /**
  81958. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  81959. * @param otherVector defines the second operand
  81960. * @param result defines the Vector3 object where to store the result
  81961. * @returns the current Vector3
  81962. */
  81963. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  81964. /**
  81965. * Divides the current Vector3 coordinates by the given ones.
  81966. * @param otherVector defines the second operand
  81967. * @returns the current updated Vector3
  81968. */
  81969. divideInPlace(otherVector: Vector3): Vector3;
  81970. /**
  81971. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  81972. * @param other defines the second operand
  81973. * @returns the current updated Vector3
  81974. */
  81975. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  81976. /**
  81977. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  81978. * @param other defines the second operand
  81979. * @returns the current updated Vector3
  81980. */
  81981. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  81982. /**
  81983. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  81984. * @param x defines the x coordinate of the operand
  81985. * @param y defines the y coordinate of the operand
  81986. * @param z defines the z coordinate of the operand
  81987. * @returns the current updated Vector3
  81988. */
  81989. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  81990. /**
  81991. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  81992. * @param x defines the x coordinate of the operand
  81993. * @param y defines the y coordinate of the operand
  81994. * @param z defines the z coordinate of the operand
  81995. * @returns the current updated Vector3
  81996. */
  81997. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  81998. /**
  81999. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  82000. * Check if is non uniform within a certain amount of decimal places to account for this
  82001. * @param epsilon the amount the values can differ
  82002. * @returns if the the vector is non uniform to a certain number of decimal places
  82003. */
  82004. isNonUniformWithinEpsilon(epsilon: number): boolean;
  82005. /**
  82006. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  82007. */
  82008. get isNonUniform(): boolean;
  82009. /**
  82010. * Gets a new Vector3 from current Vector3 floored values
  82011. * @returns a new Vector3
  82012. */
  82013. floor(): Vector3;
  82014. /**
  82015. * Gets a new Vector3 from current Vector3 floored values
  82016. * @returns a new Vector3
  82017. */
  82018. fract(): Vector3;
  82019. /**
  82020. * Gets the length of the Vector3
  82021. * @returns the length of the Vector3
  82022. */
  82023. length(): number;
  82024. /**
  82025. * Gets the squared length of the Vector3
  82026. * @returns squared length of the Vector3
  82027. */
  82028. lengthSquared(): number;
  82029. /**
  82030. * Normalize the current Vector3.
  82031. * Please note that this is an in place operation.
  82032. * @returns the current updated Vector3
  82033. */
  82034. normalize(): Vector3;
  82035. /**
  82036. * Reorders the x y z properties of the vector in place
  82037. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  82038. * @returns the current updated vector
  82039. */
  82040. reorderInPlace(order: string): this;
  82041. /**
  82042. * Rotates the vector around 0,0,0 by a quaternion
  82043. * @param quaternion the rotation quaternion
  82044. * @param result vector to store the result
  82045. * @returns the resulting vector
  82046. */
  82047. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  82048. /**
  82049. * Rotates a vector around a given point
  82050. * @param quaternion the rotation quaternion
  82051. * @param point the point to rotate around
  82052. * @param result vector to store the result
  82053. * @returns the resulting vector
  82054. */
  82055. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  82056. /**
  82057. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  82058. * The cross product is then orthogonal to both current and "other"
  82059. * @param other defines the right operand
  82060. * @returns the cross product
  82061. */
  82062. cross(other: Vector3): Vector3;
  82063. /**
  82064. * Normalize the current Vector3 with the given input length.
  82065. * Please note that this is an in place operation.
  82066. * @param len the length of the vector
  82067. * @returns the current updated Vector3
  82068. */
  82069. normalizeFromLength(len: number): Vector3;
  82070. /**
  82071. * Normalize the current Vector3 to a new vector
  82072. * @returns the new Vector3
  82073. */
  82074. normalizeToNew(): Vector3;
  82075. /**
  82076. * Normalize the current Vector3 to the reference
  82077. * @param reference define the Vector3 to update
  82078. * @returns the updated Vector3
  82079. */
  82080. normalizeToRef(reference: Vector3): Vector3;
  82081. /**
  82082. * Creates a new Vector3 copied from the current Vector3
  82083. * @returns the new Vector3
  82084. */
  82085. clone(): Vector3;
  82086. /**
  82087. * Copies the given vector coordinates to the current Vector3 ones
  82088. * @param source defines the source Vector3
  82089. * @returns the current updated Vector3
  82090. */
  82091. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  82092. /**
  82093. * Copies the given floats to the current Vector3 coordinates
  82094. * @param x defines the x coordinate of the operand
  82095. * @param y defines the y coordinate of the operand
  82096. * @param z defines the z coordinate of the operand
  82097. * @returns the current updated Vector3
  82098. */
  82099. copyFromFloats(x: number, y: number, z: number): Vector3;
  82100. /**
  82101. * Copies the given floats to the current Vector3 coordinates
  82102. * @param x defines the x coordinate of the operand
  82103. * @param y defines the y coordinate of the operand
  82104. * @param z defines the z coordinate of the operand
  82105. * @returns the current updated Vector3
  82106. */
  82107. set(x: number, y: number, z: number): Vector3;
  82108. /**
  82109. * Copies the given float to the current Vector3 coordinates
  82110. * @param v defines the x, y and z coordinates of the operand
  82111. * @returns the current updated Vector3
  82112. */
  82113. setAll(v: number): Vector3;
  82114. /**
  82115. * Get the clip factor between two vectors
  82116. * @param vector0 defines the first operand
  82117. * @param vector1 defines the second operand
  82118. * @param axis defines the axis to use
  82119. * @param size defines the size along the axis
  82120. * @returns the clip factor
  82121. */
  82122. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  82123. /**
  82124. * Get angle between two vectors
  82125. * @param vector0 angle between vector0 and vector1
  82126. * @param vector1 angle between vector0 and vector1
  82127. * @param normal direction of the normal
  82128. * @return the angle between vector0 and vector1
  82129. */
  82130. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  82131. /**
  82132. * Returns a new Vector3 set from the index "offset" of the given array
  82133. * @param array defines the source array
  82134. * @param offset defines the offset in the source array
  82135. * @returns the new Vector3
  82136. */
  82137. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  82138. /**
  82139. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  82140. * @param array defines the source array
  82141. * @param offset defines the offset in the source array
  82142. * @returns the new Vector3
  82143. * @deprecated Please use FromArray instead.
  82144. */
  82145. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  82146. /**
  82147. * Sets the given vector "result" with the element values from the index "offset" of the given array
  82148. * @param array defines the source array
  82149. * @param offset defines the offset in the source array
  82150. * @param result defines the Vector3 where to store the result
  82151. */
  82152. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  82153. /**
  82154. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  82155. * @param array defines the source array
  82156. * @param offset defines the offset in the source array
  82157. * @param result defines the Vector3 where to store the result
  82158. * @deprecated Please use FromArrayToRef instead.
  82159. */
  82160. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  82161. /**
  82162. * Sets the given vector "result" with the given floats.
  82163. * @param x defines the x coordinate of the source
  82164. * @param y defines the y coordinate of the source
  82165. * @param z defines the z coordinate of the source
  82166. * @param result defines the Vector3 where to store the result
  82167. */
  82168. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  82169. /**
  82170. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  82171. * @returns a new empty Vector3
  82172. */
  82173. static Zero(): Vector3;
  82174. /**
  82175. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  82176. * @returns a new unit Vector3
  82177. */
  82178. static One(): Vector3;
  82179. /**
  82180. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  82181. * @returns a new up Vector3
  82182. */
  82183. static Up(): Vector3;
  82184. /**
  82185. * Gets a up Vector3 that must not be updated
  82186. */
  82187. static get UpReadOnly(): DeepImmutable<Vector3>;
  82188. /**
  82189. * Gets a zero Vector3 that must not be updated
  82190. */
  82191. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  82192. /**
  82193. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  82194. * @returns a new down Vector3
  82195. */
  82196. static Down(): Vector3;
  82197. /**
  82198. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  82199. * @param rightHandedSystem is the scene right-handed (negative z)
  82200. * @returns a new forward Vector3
  82201. */
  82202. static Forward(rightHandedSystem?: boolean): Vector3;
  82203. /**
  82204. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  82205. * @param rightHandedSystem is the scene right-handed (negative-z)
  82206. * @returns a new forward Vector3
  82207. */
  82208. static Backward(rightHandedSystem?: boolean): Vector3;
  82209. /**
  82210. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  82211. * @returns a new right Vector3
  82212. */
  82213. static Right(): Vector3;
  82214. /**
  82215. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  82216. * @returns a new left Vector3
  82217. */
  82218. static Left(): Vector3;
  82219. /**
  82220. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  82221. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  82222. * @param vector defines the Vector3 to transform
  82223. * @param transformation defines the transformation matrix
  82224. * @returns the transformed Vector3
  82225. */
  82226. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  82227. /**
  82228. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  82229. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  82230. * @param vector defines the Vector3 to transform
  82231. * @param transformation defines the transformation matrix
  82232. * @param result defines the Vector3 where to store the result
  82233. */
  82234. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  82235. /**
  82236. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  82237. * This method computes tranformed coordinates only, not transformed direction vectors
  82238. * @param x define the x coordinate of the source vector
  82239. * @param y define the y coordinate of the source vector
  82240. * @param z define the z coordinate of the source vector
  82241. * @param transformation defines the transformation matrix
  82242. * @param result defines the Vector3 where to store the result
  82243. */
  82244. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  82245. /**
  82246. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  82247. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  82248. * @param vector defines the Vector3 to transform
  82249. * @param transformation defines the transformation matrix
  82250. * @returns the new Vector3
  82251. */
  82252. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  82253. /**
  82254. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  82255. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  82256. * @param vector defines the Vector3 to transform
  82257. * @param transformation defines the transformation matrix
  82258. * @param result defines the Vector3 where to store the result
  82259. */
  82260. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  82261. /**
  82262. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  82263. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  82264. * @param x define the x coordinate of the source vector
  82265. * @param y define the y coordinate of the source vector
  82266. * @param z define the z coordinate of the source vector
  82267. * @param transformation defines the transformation matrix
  82268. * @param result defines the Vector3 where to store the result
  82269. */
  82270. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  82271. /**
  82272. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  82273. * @param value1 defines the first control point
  82274. * @param value2 defines the second control point
  82275. * @param value3 defines the third control point
  82276. * @param value4 defines the fourth control point
  82277. * @param amount defines the amount on the spline to use
  82278. * @returns the new Vector3
  82279. */
  82280. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  82281. /**
  82282. * 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"
  82283. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  82284. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  82285. * @param value defines the current value
  82286. * @param min defines the lower range value
  82287. * @param max defines the upper range value
  82288. * @returns the new Vector3
  82289. */
  82290. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  82291. /**
  82292. * 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"
  82293. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  82294. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  82295. * @param value defines the current value
  82296. * @param min defines the lower range value
  82297. * @param max defines the upper range value
  82298. * @param result defines the Vector3 where to store the result
  82299. */
  82300. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  82301. /**
  82302. * Checks if a given vector is inside a specific range
  82303. * @param v defines the vector to test
  82304. * @param min defines the minimum range
  82305. * @param max defines the maximum range
  82306. */
  82307. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  82308. /**
  82309. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  82310. * @param value1 defines the first control point
  82311. * @param tangent1 defines the first tangent vector
  82312. * @param value2 defines the second control point
  82313. * @param tangent2 defines the second tangent vector
  82314. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  82315. * @returns the new Vector3
  82316. */
  82317. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  82318. /**
  82319. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  82320. * @param start defines the start value
  82321. * @param end defines the end value
  82322. * @param amount max defines amount between both (between 0 and 1)
  82323. * @returns the new Vector3
  82324. */
  82325. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  82326. /**
  82327. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  82328. * @param start defines the start value
  82329. * @param end defines the end value
  82330. * @param amount max defines amount between both (between 0 and 1)
  82331. * @param result defines the Vector3 where to store the result
  82332. */
  82333. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  82334. /**
  82335. * Returns the dot product (float) between the vectors "left" and "right"
  82336. * @param left defines the left operand
  82337. * @param right defines the right operand
  82338. * @returns the dot product
  82339. */
  82340. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  82341. /**
  82342. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  82343. * The cross product is then orthogonal to both "left" and "right"
  82344. * @param left defines the left operand
  82345. * @param right defines the right operand
  82346. * @returns the cross product
  82347. */
  82348. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  82349. /**
  82350. * Sets the given vector "result" with the cross product of "left" and "right"
  82351. * The cross product is then orthogonal to both "left" and "right"
  82352. * @param left defines the left operand
  82353. * @param right defines the right operand
  82354. * @param result defines the Vector3 where to store the result
  82355. */
  82356. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  82357. /**
  82358. * Returns a new Vector3 as the normalization of the given vector
  82359. * @param vector defines the Vector3 to normalize
  82360. * @returns the new Vector3
  82361. */
  82362. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  82363. /**
  82364. * Sets the given vector "result" with the normalization of the given first vector
  82365. * @param vector defines the Vector3 to normalize
  82366. * @param result defines the Vector3 where to store the result
  82367. */
  82368. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  82369. /**
  82370. * Project a Vector3 onto screen space
  82371. * @param vector defines the Vector3 to project
  82372. * @param world defines the world matrix to use
  82373. * @param transform defines the transform (view x projection) matrix to use
  82374. * @param viewport defines the screen viewport to use
  82375. * @returns the new Vector3
  82376. */
  82377. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  82378. /** @hidden */
  82379. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  82380. /**
  82381. * Unproject from screen space to object space
  82382. * @param source defines the screen space Vector3 to use
  82383. * @param viewportWidth defines the current width of the viewport
  82384. * @param viewportHeight defines the current height of the viewport
  82385. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  82386. * @param transform defines the transform (view x projection) matrix to use
  82387. * @returns the new Vector3
  82388. */
  82389. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  82390. /**
  82391. * Unproject from screen space to object space
  82392. * @param source defines the screen space Vector3 to use
  82393. * @param viewportWidth defines the current width of the viewport
  82394. * @param viewportHeight defines the current height of the viewport
  82395. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  82396. * @param view defines the view matrix to use
  82397. * @param projection defines the projection matrix to use
  82398. * @returns the new Vector3
  82399. */
  82400. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  82401. /**
  82402. * Unproject from screen space to object space
  82403. * @param source defines the screen space Vector3 to use
  82404. * @param viewportWidth defines the current width of the viewport
  82405. * @param viewportHeight defines the current height of the viewport
  82406. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  82407. * @param view defines the view matrix to use
  82408. * @param projection defines the projection matrix to use
  82409. * @param result defines the Vector3 where to store the result
  82410. */
  82411. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  82412. /**
  82413. * Unproject from screen space to object space
  82414. * @param sourceX defines the screen space x coordinate to use
  82415. * @param sourceY defines the screen space y coordinate to use
  82416. * @param sourceZ defines the screen space z coordinate to use
  82417. * @param viewportWidth defines the current width of the viewport
  82418. * @param viewportHeight defines the current height of the viewport
  82419. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  82420. * @param view defines the view matrix to use
  82421. * @param projection defines the projection matrix to use
  82422. * @param result defines the Vector3 where to store the result
  82423. */
  82424. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  82425. /**
  82426. * Gets the minimal coordinate values between two Vector3
  82427. * @param left defines the first operand
  82428. * @param right defines the second operand
  82429. * @returns the new Vector3
  82430. */
  82431. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  82432. /**
  82433. * Gets the maximal coordinate values between two Vector3
  82434. * @param left defines the first operand
  82435. * @param right defines the second operand
  82436. * @returns the new Vector3
  82437. */
  82438. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  82439. /**
  82440. * Returns the distance between the vectors "value1" and "value2"
  82441. * @param value1 defines the first operand
  82442. * @param value2 defines the second operand
  82443. * @returns the distance
  82444. */
  82445. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  82446. /**
  82447. * Returns the squared distance between the vectors "value1" and "value2"
  82448. * @param value1 defines the first operand
  82449. * @param value2 defines the second operand
  82450. * @returns the squared distance
  82451. */
  82452. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  82453. /**
  82454. * Returns a new Vector3 located at the center between "value1" and "value2"
  82455. * @param value1 defines the first operand
  82456. * @param value2 defines the second operand
  82457. * @returns the new Vector3
  82458. */
  82459. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  82460. /**
  82461. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  82462. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  82463. * to something in order to rotate it from its local system to the given target system
  82464. * Note: axis1, axis2 and axis3 are normalized during this operation
  82465. * @param axis1 defines the first axis
  82466. * @param axis2 defines the second axis
  82467. * @param axis3 defines the third axis
  82468. * @returns a new Vector3
  82469. */
  82470. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  82471. /**
  82472. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  82473. * @param axis1 defines the first axis
  82474. * @param axis2 defines the second axis
  82475. * @param axis3 defines the third axis
  82476. * @param ref defines the Vector3 where to store the result
  82477. */
  82478. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  82479. }
  82480. /**
  82481. * Vector4 class created for EulerAngle class conversion to Quaternion
  82482. */
  82483. export class Vector4 {
  82484. /** x value of the vector */
  82485. x: number;
  82486. /** y value of the vector */
  82487. y: number;
  82488. /** z value of the vector */
  82489. z: number;
  82490. /** w value of the vector */
  82491. w: number;
  82492. /**
  82493. * Creates a Vector4 object from the given floats.
  82494. * @param x x value of the vector
  82495. * @param y y value of the vector
  82496. * @param z z value of the vector
  82497. * @param w w value of the vector
  82498. */
  82499. constructor(
  82500. /** x value of the vector */
  82501. x: number,
  82502. /** y value of the vector */
  82503. y: number,
  82504. /** z value of the vector */
  82505. z: number,
  82506. /** w value of the vector */
  82507. w: number);
  82508. /**
  82509. * Returns the string with the Vector4 coordinates.
  82510. * @returns a string containing all the vector values
  82511. */
  82512. toString(): string;
  82513. /**
  82514. * Returns the string "Vector4".
  82515. * @returns "Vector4"
  82516. */
  82517. getClassName(): string;
  82518. /**
  82519. * Returns the Vector4 hash code.
  82520. * @returns a unique hash code
  82521. */
  82522. getHashCode(): number;
  82523. /**
  82524. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  82525. * @returns the resulting array
  82526. */
  82527. asArray(): number[];
  82528. /**
  82529. * Populates the given array from the given index with the Vector4 coordinates.
  82530. * @param array array to populate
  82531. * @param index index of the array to start at (default: 0)
  82532. * @returns the Vector4.
  82533. */
  82534. toArray(array: FloatArray, index?: number): Vector4;
  82535. /**
  82536. * Update the current vector from an array
  82537. * @param array defines the destination array
  82538. * @param index defines the offset in the destination array
  82539. * @returns the current Vector3
  82540. */
  82541. fromArray(array: FloatArray, index?: number): Vector4;
  82542. /**
  82543. * Adds the given vector to the current Vector4.
  82544. * @param otherVector the vector to add
  82545. * @returns the updated Vector4.
  82546. */
  82547. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  82548. /**
  82549. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  82550. * @param otherVector the vector to add
  82551. * @returns the resulting vector
  82552. */
  82553. add(otherVector: DeepImmutable<Vector4>): Vector4;
  82554. /**
  82555. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  82556. * @param otherVector the vector to add
  82557. * @param result the vector to store the result
  82558. * @returns the current Vector4.
  82559. */
  82560. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  82561. /**
  82562. * Subtract in place the given vector from the current Vector4.
  82563. * @param otherVector the vector to subtract
  82564. * @returns the updated Vector4.
  82565. */
  82566. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  82567. /**
  82568. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  82569. * @param otherVector the vector to add
  82570. * @returns the new vector with the result
  82571. */
  82572. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  82573. /**
  82574. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  82575. * @param otherVector the vector to subtract
  82576. * @param result the vector to store the result
  82577. * @returns the current Vector4.
  82578. */
  82579. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  82580. /**
  82581. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  82582. */
  82583. /**
  82584. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  82585. * @param x value to subtract
  82586. * @param y value to subtract
  82587. * @param z value to subtract
  82588. * @param w value to subtract
  82589. * @returns new vector containing the result
  82590. */
  82591. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  82592. /**
  82593. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  82594. * @param x value to subtract
  82595. * @param y value to subtract
  82596. * @param z value to subtract
  82597. * @param w value to subtract
  82598. * @param result the vector to store the result in
  82599. * @returns the current Vector4.
  82600. */
  82601. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  82602. /**
  82603. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  82604. * @returns a new vector with the negated values
  82605. */
  82606. negate(): Vector4;
  82607. /**
  82608. * Negate this vector in place
  82609. * @returns this
  82610. */
  82611. negateInPlace(): Vector4;
  82612. /**
  82613. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  82614. * @param result defines the Vector3 object where to store the result
  82615. * @returns the current Vector4
  82616. */
  82617. negateToRef(result: Vector4): Vector4;
  82618. /**
  82619. * Multiplies the current Vector4 coordinates by scale (float).
  82620. * @param scale the number to scale with
  82621. * @returns the updated Vector4.
  82622. */
  82623. scaleInPlace(scale: number): Vector4;
  82624. /**
  82625. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  82626. * @param scale the number to scale with
  82627. * @returns a new vector with the result
  82628. */
  82629. scale(scale: number): Vector4;
  82630. /**
  82631. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  82632. * @param scale the number to scale with
  82633. * @param result a vector to store the result in
  82634. * @returns the current Vector4.
  82635. */
  82636. scaleToRef(scale: number, result: Vector4): Vector4;
  82637. /**
  82638. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  82639. * @param scale defines the scale factor
  82640. * @param result defines the Vector4 object where to store the result
  82641. * @returns the unmodified current Vector4
  82642. */
  82643. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  82644. /**
  82645. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  82646. * @param otherVector the vector to compare against
  82647. * @returns true if they are equal
  82648. */
  82649. equals(otherVector: DeepImmutable<Vector4>): boolean;
  82650. /**
  82651. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  82652. * @param otherVector vector to compare against
  82653. * @param epsilon (Default: very small number)
  82654. * @returns true if they are equal
  82655. */
  82656. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  82657. /**
  82658. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  82659. * @param x x value to compare against
  82660. * @param y y value to compare against
  82661. * @param z z value to compare against
  82662. * @param w w value to compare against
  82663. * @returns true if equal
  82664. */
  82665. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  82666. /**
  82667. * Multiplies in place the current Vector4 by the given one.
  82668. * @param otherVector vector to multiple with
  82669. * @returns the updated Vector4.
  82670. */
  82671. multiplyInPlace(otherVector: Vector4): Vector4;
  82672. /**
  82673. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  82674. * @param otherVector vector to multiple with
  82675. * @returns resulting new vector
  82676. */
  82677. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  82678. /**
  82679. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  82680. * @param otherVector vector to multiple with
  82681. * @param result vector to store the result
  82682. * @returns the current Vector4.
  82683. */
  82684. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  82685. /**
  82686. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  82687. * @param x x value multiply with
  82688. * @param y y value multiply with
  82689. * @param z z value multiply with
  82690. * @param w w value multiply with
  82691. * @returns resulting new vector
  82692. */
  82693. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  82694. /**
  82695. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  82696. * @param otherVector vector to devide with
  82697. * @returns resulting new vector
  82698. */
  82699. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  82700. /**
  82701. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  82702. * @param otherVector vector to devide with
  82703. * @param result vector to store the result
  82704. * @returns the current Vector4.
  82705. */
  82706. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  82707. /**
  82708. * Divides the current Vector3 coordinates by the given ones.
  82709. * @param otherVector vector to devide with
  82710. * @returns the updated Vector3.
  82711. */
  82712. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  82713. /**
  82714. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  82715. * @param other defines the second operand
  82716. * @returns the current updated Vector4
  82717. */
  82718. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  82719. /**
  82720. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  82721. * @param other defines the second operand
  82722. * @returns the current updated Vector4
  82723. */
  82724. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  82725. /**
  82726. * Gets a new Vector4 from current Vector4 floored values
  82727. * @returns a new Vector4
  82728. */
  82729. floor(): Vector4;
  82730. /**
  82731. * Gets a new Vector4 from current Vector3 floored values
  82732. * @returns a new Vector4
  82733. */
  82734. fract(): Vector4;
  82735. /**
  82736. * Returns the Vector4 length (float).
  82737. * @returns the length
  82738. */
  82739. length(): number;
  82740. /**
  82741. * Returns the Vector4 squared length (float).
  82742. * @returns the length squared
  82743. */
  82744. lengthSquared(): number;
  82745. /**
  82746. * Normalizes in place the Vector4.
  82747. * @returns the updated Vector4.
  82748. */
  82749. normalize(): Vector4;
  82750. /**
  82751. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  82752. * @returns this converted to a new vector3
  82753. */
  82754. toVector3(): Vector3;
  82755. /**
  82756. * Returns a new Vector4 copied from the current one.
  82757. * @returns the new cloned vector
  82758. */
  82759. clone(): Vector4;
  82760. /**
  82761. * Updates the current Vector4 with the given one coordinates.
  82762. * @param source the source vector to copy from
  82763. * @returns the updated Vector4.
  82764. */
  82765. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  82766. /**
  82767. * Updates the current Vector4 coordinates with the given floats.
  82768. * @param x float to copy from
  82769. * @param y float to copy from
  82770. * @param z float to copy from
  82771. * @param w float to copy from
  82772. * @returns the updated Vector4.
  82773. */
  82774. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  82775. /**
  82776. * Updates the current Vector4 coordinates with the given floats.
  82777. * @param x float to set from
  82778. * @param y float to set from
  82779. * @param z float to set from
  82780. * @param w float to set from
  82781. * @returns the updated Vector4.
  82782. */
  82783. set(x: number, y: number, z: number, w: number): Vector4;
  82784. /**
  82785. * Copies the given float to the current Vector3 coordinates
  82786. * @param v defines the x, y, z and w coordinates of the operand
  82787. * @returns the current updated Vector3
  82788. */
  82789. setAll(v: number): Vector4;
  82790. /**
  82791. * Returns a new Vector4 set from the starting index of the given array.
  82792. * @param array the array to pull values from
  82793. * @param offset the offset into the array to start at
  82794. * @returns the new vector
  82795. */
  82796. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  82797. /**
  82798. * Updates the given vector "result" from the starting index of the given array.
  82799. * @param array the array to pull values from
  82800. * @param offset the offset into the array to start at
  82801. * @param result the vector to store the result in
  82802. */
  82803. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  82804. /**
  82805. * Updates the given vector "result" from the starting index of the given Float32Array.
  82806. * @param array the array to pull values from
  82807. * @param offset the offset into the array to start at
  82808. * @param result the vector to store the result in
  82809. */
  82810. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  82811. /**
  82812. * Updates the given vector "result" coordinates from the given floats.
  82813. * @param x float to set from
  82814. * @param y float to set from
  82815. * @param z float to set from
  82816. * @param w float to set from
  82817. * @param result the vector to the floats in
  82818. */
  82819. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  82820. /**
  82821. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  82822. * @returns the new vector
  82823. */
  82824. static Zero(): Vector4;
  82825. /**
  82826. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  82827. * @returns the new vector
  82828. */
  82829. static One(): Vector4;
  82830. /**
  82831. * Returns a new normalized Vector4 from the given one.
  82832. * @param vector the vector to normalize
  82833. * @returns the vector
  82834. */
  82835. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  82836. /**
  82837. * Updates the given vector "result" from the normalization of the given one.
  82838. * @param vector the vector to normalize
  82839. * @param result the vector to store the result in
  82840. */
  82841. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  82842. /**
  82843. * Returns a vector with the minimum values from the left and right vectors
  82844. * @param left left vector to minimize
  82845. * @param right right vector to minimize
  82846. * @returns a new vector with the minimum of the left and right vector values
  82847. */
  82848. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  82849. /**
  82850. * Returns a vector with the maximum values from the left and right vectors
  82851. * @param left left vector to maximize
  82852. * @param right right vector to maximize
  82853. * @returns a new vector with the maximum of the left and right vector values
  82854. */
  82855. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  82856. /**
  82857. * Returns the distance (float) between the vectors "value1" and "value2".
  82858. * @param value1 value to calulate the distance between
  82859. * @param value2 value to calulate the distance between
  82860. * @return the distance between the two vectors
  82861. */
  82862. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  82863. /**
  82864. * Returns the squared distance (float) between the vectors "value1" and "value2".
  82865. * @param value1 value to calulate the distance between
  82866. * @param value2 value to calulate the distance between
  82867. * @return the distance between the two vectors squared
  82868. */
  82869. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  82870. /**
  82871. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  82872. * @param value1 value to calulate the center between
  82873. * @param value2 value to calulate the center between
  82874. * @return the center between the two vectors
  82875. */
  82876. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  82877. /**
  82878. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  82879. * This methods computes transformed normalized direction vectors only.
  82880. * @param vector the vector to transform
  82881. * @param transformation the transformation matrix to apply
  82882. * @returns the new vector
  82883. */
  82884. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  82885. /**
  82886. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  82887. * This methods computes transformed normalized direction vectors only.
  82888. * @param vector the vector to transform
  82889. * @param transformation the transformation matrix to apply
  82890. * @param result the vector to store the result in
  82891. */
  82892. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  82893. /**
  82894. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  82895. * This methods computes transformed normalized direction vectors only.
  82896. * @param x value to transform
  82897. * @param y value to transform
  82898. * @param z value to transform
  82899. * @param w value to transform
  82900. * @param transformation the transformation matrix to apply
  82901. * @param result the vector to store the results in
  82902. */
  82903. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  82904. /**
  82905. * Creates a new Vector4 from a Vector3
  82906. * @param source defines the source data
  82907. * @param w defines the 4th component (default is 0)
  82908. * @returns a new Vector4
  82909. */
  82910. static FromVector3(source: Vector3, w?: number): Vector4;
  82911. }
  82912. /**
  82913. * Class used to store quaternion data
  82914. * @see https://en.wikipedia.org/wiki/Quaternion
  82915. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  82916. */
  82917. export class Quaternion {
  82918. /** @hidden */
  82919. _x: number;
  82920. /** @hidden */
  82921. _y: number;
  82922. /** @hidden */
  82923. _z: number;
  82924. /** @hidden */
  82925. _w: number;
  82926. /** @hidden */
  82927. _isDirty: boolean;
  82928. /** Gets or sets the x coordinate */
  82929. get x(): number;
  82930. set x(value: number);
  82931. /** Gets or sets the y coordinate */
  82932. get y(): number;
  82933. set y(value: number);
  82934. /** Gets or sets the z coordinate */
  82935. get z(): number;
  82936. set z(value: number);
  82937. /** Gets or sets the w coordinate */
  82938. get w(): number;
  82939. set w(value: number);
  82940. /**
  82941. * Creates a new Quaternion from the given floats
  82942. * @param x defines the first component (0 by default)
  82943. * @param y defines the second component (0 by default)
  82944. * @param z defines the third component (0 by default)
  82945. * @param w defines the fourth component (1.0 by default)
  82946. */
  82947. constructor(x?: number, y?: number, z?: number, w?: number);
  82948. /**
  82949. * Gets a string representation for the current quaternion
  82950. * @returns a string with the Quaternion coordinates
  82951. */
  82952. toString(): string;
  82953. /**
  82954. * Gets the class name of the quaternion
  82955. * @returns the string "Quaternion"
  82956. */
  82957. getClassName(): string;
  82958. /**
  82959. * Gets a hash code for this quaternion
  82960. * @returns the quaternion hash code
  82961. */
  82962. getHashCode(): number;
  82963. /**
  82964. * Copy the quaternion to an array
  82965. * @returns a new array populated with 4 elements from the quaternion coordinates
  82966. */
  82967. asArray(): number[];
  82968. /**
  82969. * Check if two quaternions are equals
  82970. * @param otherQuaternion defines the second operand
  82971. * @return true if the current quaternion and the given one coordinates are strictly equals
  82972. */
  82973. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  82974. /**
  82975. * Gets a boolean if two quaternions are equals (using an epsilon value)
  82976. * @param otherQuaternion defines the other quaternion
  82977. * @param epsilon defines the minimal distance to consider equality
  82978. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  82979. */
  82980. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  82981. /**
  82982. * Clone the current quaternion
  82983. * @returns a new quaternion copied from the current one
  82984. */
  82985. clone(): Quaternion;
  82986. /**
  82987. * Copy a quaternion to the current one
  82988. * @param other defines the other quaternion
  82989. * @returns the updated current quaternion
  82990. */
  82991. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  82992. /**
  82993. * Updates the current quaternion with the given float coordinates
  82994. * @param x defines the x coordinate
  82995. * @param y defines the y coordinate
  82996. * @param z defines the z coordinate
  82997. * @param w defines the w coordinate
  82998. * @returns the updated current quaternion
  82999. */
  83000. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  83001. /**
  83002. * Updates the current quaternion from the given float coordinates
  83003. * @param x defines the x coordinate
  83004. * @param y defines the y coordinate
  83005. * @param z defines the z coordinate
  83006. * @param w defines the w coordinate
  83007. * @returns the updated current quaternion
  83008. */
  83009. set(x: number, y: number, z: number, w: number): Quaternion;
  83010. /**
  83011. * Adds two quaternions
  83012. * @param other defines the second operand
  83013. * @returns a new quaternion as the addition result of the given one and the current quaternion
  83014. */
  83015. add(other: DeepImmutable<Quaternion>): Quaternion;
  83016. /**
  83017. * Add a quaternion to the current one
  83018. * @param other defines the quaternion to add
  83019. * @returns the current quaternion
  83020. */
  83021. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  83022. /**
  83023. * Subtract two quaternions
  83024. * @param other defines the second operand
  83025. * @returns a new quaternion as the subtraction result of the given one from the current one
  83026. */
  83027. subtract(other: Quaternion): Quaternion;
  83028. /**
  83029. * Multiplies the current quaternion by a scale factor
  83030. * @param value defines the scale factor
  83031. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  83032. */
  83033. scale(value: number): Quaternion;
  83034. /**
  83035. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  83036. * @param scale defines the scale factor
  83037. * @param result defines the Quaternion object where to store the result
  83038. * @returns the unmodified current quaternion
  83039. */
  83040. scaleToRef(scale: number, result: Quaternion): Quaternion;
  83041. /**
  83042. * Multiplies in place the current quaternion by a scale factor
  83043. * @param value defines the scale factor
  83044. * @returns the current modified quaternion
  83045. */
  83046. scaleInPlace(value: number): Quaternion;
  83047. /**
  83048. * Scale the current quaternion values by a factor and add the result to a given quaternion
  83049. * @param scale defines the scale factor
  83050. * @param result defines the Quaternion object where to store the result
  83051. * @returns the unmodified current quaternion
  83052. */
  83053. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  83054. /**
  83055. * Multiplies two quaternions
  83056. * @param q1 defines the second operand
  83057. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  83058. */
  83059. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  83060. /**
  83061. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  83062. * @param q1 defines the second operand
  83063. * @param result defines the target quaternion
  83064. * @returns the current quaternion
  83065. */
  83066. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  83067. /**
  83068. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  83069. * @param q1 defines the second operand
  83070. * @returns the currentupdated quaternion
  83071. */
  83072. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  83073. /**
  83074. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  83075. * @param ref defines the target quaternion
  83076. * @returns the current quaternion
  83077. */
  83078. conjugateToRef(ref: Quaternion): Quaternion;
  83079. /**
  83080. * Conjugates in place (1-q) the current quaternion
  83081. * @returns the current updated quaternion
  83082. */
  83083. conjugateInPlace(): Quaternion;
  83084. /**
  83085. * Conjugates in place (1-q) the current quaternion
  83086. * @returns a new quaternion
  83087. */
  83088. conjugate(): Quaternion;
  83089. /**
  83090. * Gets length of current quaternion
  83091. * @returns the quaternion length (float)
  83092. */
  83093. length(): number;
  83094. /**
  83095. * Normalize in place the current quaternion
  83096. * @returns the current updated quaternion
  83097. */
  83098. normalize(): Quaternion;
  83099. /**
  83100. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  83101. * @param order is a reserved parameter and is ignore for now
  83102. * @returns a new Vector3 containing the Euler angles
  83103. */
  83104. toEulerAngles(order?: string): Vector3;
  83105. /**
  83106. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  83107. * @param result defines the vector which will be filled with the Euler angles
  83108. * @param order is a reserved parameter and is ignore for now
  83109. * @returns the current unchanged quaternion
  83110. */
  83111. toEulerAnglesToRef(result: Vector3): Quaternion;
  83112. /**
  83113. * Updates the given rotation matrix with the current quaternion values
  83114. * @param result defines the target matrix
  83115. * @returns the current unchanged quaternion
  83116. */
  83117. toRotationMatrix(result: Matrix): Quaternion;
  83118. /**
  83119. * Updates the current quaternion from the given rotation matrix values
  83120. * @param matrix defines the source matrix
  83121. * @returns the current updated quaternion
  83122. */
  83123. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  83124. /**
  83125. * Creates a new quaternion from a rotation matrix
  83126. * @param matrix defines the source matrix
  83127. * @returns a new quaternion created from the given rotation matrix values
  83128. */
  83129. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  83130. /**
  83131. * Updates the given quaternion with the given rotation matrix values
  83132. * @param matrix defines the source matrix
  83133. * @param result defines the target quaternion
  83134. */
  83135. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  83136. /**
  83137. * Returns the dot product (float) between the quaternions "left" and "right"
  83138. * @param left defines the left operand
  83139. * @param right defines the right operand
  83140. * @returns the dot product
  83141. */
  83142. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  83143. /**
  83144. * Checks if the two quaternions are close to each other
  83145. * @param quat0 defines the first quaternion to check
  83146. * @param quat1 defines the second quaternion to check
  83147. * @returns true if the two quaternions are close to each other
  83148. */
  83149. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  83150. /**
  83151. * Creates an empty quaternion
  83152. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  83153. */
  83154. static Zero(): Quaternion;
  83155. /**
  83156. * Inverse a given quaternion
  83157. * @param q defines the source quaternion
  83158. * @returns a new quaternion as the inverted current quaternion
  83159. */
  83160. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  83161. /**
  83162. * Inverse a given quaternion
  83163. * @param q defines the source quaternion
  83164. * @param result the quaternion the result will be stored in
  83165. * @returns the result quaternion
  83166. */
  83167. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  83168. /**
  83169. * Creates an identity quaternion
  83170. * @returns the identity quaternion
  83171. */
  83172. static Identity(): Quaternion;
  83173. /**
  83174. * Gets a boolean indicating if the given quaternion is identity
  83175. * @param quaternion defines the quaternion to check
  83176. * @returns true if the quaternion is identity
  83177. */
  83178. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  83179. /**
  83180. * Creates a quaternion from a rotation around an axis
  83181. * @param axis defines the axis to use
  83182. * @param angle defines the angle to use
  83183. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  83184. */
  83185. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  83186. /**
  83187. * Creates a rotation around an axis and stores it into the given quaternion
  83188. * @param axis defines the axis to use
  83189. * @param angle defines the angle to use
  83190. * @param result defines the target quaternion
  83191. * @returns the target quaternion
  83192. */
  83193. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  83194. /**
  83195. * Creates a new quaternion from data stored into an array
  83196. * @param array defines the data source
  83197. * @param offset defines the offset in the source array where the data starts
  83198. * @returns a new quaternion
  83199. */
  83200. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  83201. /**
  83202. * Updates the given quaternion "result" from the starting index of the given array.
  83203. * @param array the array to pull values from
  83204. * @param offset the offset into the array to start at
  83205. * @param result the quaternion to store the result in
  83206. */
  83207. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  83208. /**
  83209. * Create a quaternion from Euler rotation angles
  83210. * @param x Pitch
  83211. * @param y Yaw
  83212. * @param z Roll
  83213. * @returns the new Quaternion
  83214. */
  83215. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  83216. /**
  83217. * Updates a quaternion from Euler rotation angles
  83218. * @param x Pitch
  83219. * @param y Yaw
  83220. * @param z Roll
  83221. * @param result the quaternion to store the result
  83222. * @returns the updated quaternion
  83223. */
  83224. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  83225. /**
  83226. * Create a quaternion from Euler rotation vector
  83227. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  83228. * @returns the new Quaternion
  83229. */
  83230. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  83231. /**
  83232. * Updates a quaternion from Euler rotation vector
  83233. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  83234. * @param result the quaternion to store the result
  83235. * @returns the updated quaternion
  83236. */
  83237. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  83238. /**
  83239. * Creates a new quaternion from the given Euler float angles (y, x, z)
  83240. * @param yaw defines the rotation around Y axis
  83241. * @param pitch defines the rotation around X axis
  83242. * @param roll defines the rotation around Z axis
  83243. * @returns the new quaternion
  83244. */
  83245. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  83246. /**
  83247. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  83248. * @param yaw defines the rotation around Y axis
  83249. * @param pitch defines the rotation around X axis
  83250. * @param roll defines the rotation around Z axis
  83251. * @param result defines the target quaternion
  83252. */
  83253. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  83254. /**
  83255. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  83256. * @param alpha defines the rotation around first axis
  83257. * @param beta defines the rotation around second axis
  83258. * @param gamma defines the rotation around third axis
  83259. * @returns the new quaternion
  83260. */
  83261. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  83262. /**
  83263. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  83264. * @param alpha defines the rotation around first axis
  83265. * @param beta defines the rotation around second axis
  83266. * @param gamma defines the rotation around third axis
  83267. * @param result defines the target quaternion
  83268. */
  83269. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  83270. /**
  83271. * 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)
  83272. * @param axis1 defines the first axis
  83273. * @param axis2 defines the second axis
  83274. * @param axis3 defines the third axis
  83275. * @returns the new quaternion
  83276. */
  83277. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  83278. /**
  83279. * 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
  83280. * @param axis1 defines the first axis
  83281. * @param axis2 defines the second axis
  83282. * @param axis3 defines the third axis
  83283. * @param ref defines the target quaternion
  83284. */
  83285. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  83286. /**
  83287. * Interpolates between two quaternions
  83288. * @param left defines first quaternion
  83289. * @param right defines second quaternion
  83290. * @param amount defines the gradient to use
  83291. * @returns the new interpolated quaternion
  83292. */
  83293. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  83294. /**
  83295. * Interpolates between two quaternions and stores it into a target quaternion
  83296. * @param left defines first quaternion
  83297. * @param right defines second quaternion
  83298. * @param amount defines the gradient to use
  83299. * @param result defines the target quaternion
  83300. */
  83301. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  83302. /**
  83303. * Interpolate between two quaternions using Hermite interpolation
  83304. * @param value1 defines first quaternion
  83305. * @param tangent1 defines the incoming tangent
  83306. * @param value2 defines second quaternion
  83307. * @param tangent2 defines the outgoing tangent
  83308. * @param amount defines the target quaternion
  83309. * @returns the new interpolated quaternion
  83310. */
  83311. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  83312. }
  83313. /**
  83314. * Class used to store matrix data (4x4)
  83315. */
  83316. export class Matrix {
  83317. /**
  83318. * Gets the precision of matrix computations
  83319. */
  83320. static get Use64Bits(): boolean;
  83321. private static _updateFlagSeed;
  83322. private static _identityReadOnly;
  83323. private _isIdentity;
  83324. private _isIdentityDirty;
  83325. private _isIdentity3x2;
  83326. private _isIdentity3x2Dirty;
  83327. /**
  83328. * Gets the update flag of the matrix which is an unique number for the matrix.
  83329. * It will be incremented every time the matrix data change.
  83330. * You can use it to speed the comparison between two versions of the same matrix.
  83331. */
  83332. updateFlag: number;
  83333. private readonly _m;
  83334. /**
  83335. * Gets the internal data of the matrix
  83336. */
  83337. get m(): DeepImmutable<Float32Array | Array<number>>;
  83338. /** @hidden */
  83339. _markAsUpdated(): void;
  83340. /** @hidden */
  83341. private _updateIdentityStatus;
  83342. /**
  83343. * Creates an empty matrix (filled with zeros)
  83344. */
  83345. constructor();
  83346. /**
  83347. * Check if the current matrix is identity
  83348. * @returns true is the matrix is the identity matrix
  83349. */
  83350. isIdentity(): boolean;
  83351. /**
  83352. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  83353. * @returns true is the matrix is the identity matrix
  83354. */
  83355. isIdentityAs3x2(): boolean;
  83356. /**
  83357. * Gets the determinant of the matrix
  83358. * @returns the matrix determinant
  83359. */
  83360. determinant(): number;
  83361. /**
  83362. * Returns the matrix as a Float32Array or Array<number>
  83363. * @returns the matrix underlying array
  83364. */
  83365. toArray(): DeepImmutable<Float32Array | Array<number>>;
  83366. /**
  83367. * Returns the matrix as a Float32Array or Array<number>
  83368. * @returns the matrix underlying array.
  83369. */
  83370. asArray(): DeepImmutable<Float32Array | Array<number>>;
  83371. /**
  83372. * Inverts the current matrix in place
  83373. * @returns the current inverted matrix
  83374. */
  83375. invert(): Matrix;
  83376. /**
  83377. * Sets all the matrix elements to zero
  83378. * @returns the current matrix
  83379. */
  83380. reset(): Matrix;
  83381. /**
  83382. * Adds the current matrix with a second one
  83383. * @param other defines the matrix to add
  83384. * @returns a new matrix as the addition of the current matrix and the given one
  83385. */
  83386. add(other: DeepImmutable<Matrix>): Matrix;
  83387. /**
  83388. * Sets the given matrix "result" to the addition of the current matrix and the given one
  83389. * @param other defines the matrix to add
  83390. * @param result defines the target matrix
  83391. * @returns the current matrix
  83392. */
  83393. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  83394. /**
  83395. * Adds in place the given matrix to the current matrix
  83396. * @param other defines the second operand
  83397. * @returns the current updated matrix
  83398. */
  83399. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  83400. /**
  83401. * Sets the given matrix to the current inverted Matrix
  83402. * @param other defines the target matrix
  83403. * @returns the unmodified current matrix
  83404. */
  83405. invertToRef(other: Matrix): Matrix;
  83406. /**
  83407. * add a value at the specified position in the current Matrix
  83408. * @param index the index of the value within the matrix. between 0 and 15.
  83409. * @param value the value to be added
  83410. * @returns the current updated matrix
  83411. */
  83412. addAtIndex(index: number, value: number): Matrix;
  83413. /**
  83414. * mutiply the specified position in the current Matrix by a value
  83415. * @param index the index of the value within the matrix. between 0 and 15.
  83416. * @param value the value to be added
  83417. * @returns the current updated matrix
  83418. */
  83419. multiplyAtIndex(index: number, value: number): Matrix;
  83420. /**
  83421. * Inserts the translation vector (using 3 floats) in the current matrix
  83422. * @param x defines the 1st component of the translation
  83423. * @param y defines the 2nd component of the translation
  83424. * @param z defines the 3rd component of the translation
  83425. * @returns the current updated matrix
  83426. */
  83427. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  83428. /**
  83429. * Adds the translation vector (using 3 floats) in the current matrix
  83430. * @param x defines the 1st component of the translation
  83431. * @param y defines the 2nd component of the translation
  83432. * @param z defines the 3rd component of the translation
  83433. * @returns the current updated matrix
  83434. */
  83435. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  83436. /**
  83437. * Inserts the translation vector in the current matrix
  83438. * @param vector3 defines the translation to insert
  83439. * @returns the current updated matrix
  83440. */
  83441. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  83442. /**
  83443. * Gets the translation value of the current matrix
  83444. * @returns a new Vector3 as the extracted translation from the matrix
  83445. */
  83446. getTranslation(): Vector3;
  83447. /**
  83448. * Fill a Vector3 with the extracted translation from the matrix
  83449. * @param result defines the Vector3 where to store the translation
  83450. * @returns the current matrix
  83451. */
  83452. getTranslationToRef(result: Vector3): Matrix;
  83453. /**
  83454. * Remove rotation and scaling part from the matrix
  83455. * @returns the updated matrix
  83456. */
  83457. removeRotationAndScaling(): Matrix;
  83458. /**
  83459. * Multiply two matrices
  83460. * @param other defines the second operand
  83461. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  83462. */
  83463. multiply(other: DeepImmutable<Matrix>): Matrix;
  83464. /**
  83465. * Copy the current matrix from the given one
  83466. * @param other defines the source matrix
  83467. * @returns the current updated matrix
  83468. */
  83469. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  83470. /**
  83471. * Populates the given array from the starting index with the current matrix values
  83472. * @param array defines the target array
  83473. * @param offset defines the offset in the target array where to start storing values
  83474. * @returns the current matrix
  83475. */
  83476. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  83477. /**
  83478. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  83479. * @param other defines the second operand
  83480. * @param result defines the matrix where to store the multiplication
  83481. * @returns the current matrix
  83482. */
  83483. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  83484. /**
  83485. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  83486. * @param other defines the second operand
  83487. * @param result defines the array where to store the multiplication
  83488. * @param offset defines the offset in the target array where to start storing values
  83489. * @returns the current matrix
  83490. */
  83491. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  83492. /**
  83493. * Check equality between this matrix and a second one
  83494. * @param value defines the second matrix to compare
  83495. * @returns true is the current matrix and the given one values are strictly equal
  83496. */
  83497. equals(value: DeepImmutable<Matrix>): boolean;
  83498. /**
  83499. * Clone the current matrix
  83500. * @returns a new matrix from the current matrix
  83501. */
  83502. clone(): Matrix;
  83503. /**
  83504. * Returns the name of the current matrix class
  83505. * @returns the string "Matrix"
  83506. */
  83507. getClassName(): string;
  83508. /**
  83509. * Gets the hash code of the current matrix
  83510. * @returns the hash code
  83511. */
  83512. getHashCode(): number;
  83513. /**
  83514. * Decomposes the current Matrix into a translation, rotation and scaling components
  83515. * @param scale defines the scale vector3 given as a reference to update
  83516. * @param rotation defines the rotation quaternion given as a reference to update
  83517. * @param translation defines the translation vector3 given as a reference to update
  83518. * @returns true if operation was successful
  83519. */
  83520. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  83521. /**
  83522. * Gets specific row of the matrix
  83523. * @param index defines the number of the row to get
  83524. * @returns the index-th row of the current matrix as a new Vector4
  83525. */
  83526. getRow(index: number): Nullable<Vector4>;
  83527. /**
  83528. * Sets the index-th row of the current matrix to the vector4 values
  83529. * @param index defines the number of the row to set
  83530. * @param row defines the target vector4
  83531. * @returns the updated current matrix
  83532. */
  83533. setRow(index: number, row: Vector4): Matrix;
  83534. /**
  83535. * Compute the transpose of the matrix
  83536. * @returns the new transposed matrix
  83537. */
  83538. transpose(): Matrix;
  83539. /**
  83540. * Compute the transpose of the matrix and store it in a given matrix
  83541. * @param result defines the target matrix
  83542. * @returns the current matrix
  83543. */
  83544. transposeToRef(result: Matrix): Matrix;
  83545. /**
  83546. * Sets the index-th row of the current matrix with the given 4 x float values
  83547. * @param index defines the row index
  83548. * @param x defines the x component to set
  83549. * @param y defines the y component to set
  83550. * @param z defines the z component to set
  83551. * @param w defines the w component to set
  83552. * @returns the updated current matrix
  83553. */
  83554. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  83555. /**
  83556. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  83557. * @param scale defines the scale factor
  83558. * @returns a new matrix
  83559. */
  83560. scale(scale: number): Matrix;
  83561. /**
  83562. * Scale the current matrix values by a factor to a given result matrix
  83563. * @param scale defines the scale factor
  83564. * @param result defines the matrix to store the result
  83565. * @returns the current matrix
  83566. */
  83567. scaleToRef(scale: number, result: Matrix): Matrix;
  83568. /**
  83569. * Scale the current matrix values by a factor and add the result to a given matrix
  83570. * @param scale defines the scale factor
  83571. * @param result defines the Matrix to store the result
  83572. * @returns the current matrix
  83573. */
  83574. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  83575. /**
  83576. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  83577. * @param ref matrix to store the result
  83578. */
  83579. toNormalMatrix(ref: Matrix): void;
  83580. /**
  83581. * Gets only rotation part of the current matrix
  83582. * @returns a new matrix sets to the extracted rotation matrix from the current one
  83583. */
  83584. getRotationMatrix(): Matrix;
  83585. /**
  83586. * Extracts the rotation matrix from the current one and sets it as the given "result"
  83587. * @param result defines the target matrix to store data to
  83588. * @returns the current matrix
  83589. */
  83590. getRotationMatrixToRef(result: Matrix): Matrix;
  83591. /**
  83592. * Toggles model matrix from being right handed to left handed in place and vice versa
  83593. */
  83594. toggleModelMatrixHandInPlace(): void;
  83595. /**
  83596. * Toggles projection matrix from being right handed to left handed in place and vice versa
  83597. */
  83598. toggleProjectionMatrixHandInPlace(): void;
  83599. /**
  83600. * Creates a matrix from an array
  83601. * @param array defines the source array
  83602. * @param offset defines an offset in the source array
  83603. * @returns a new Matrix set from the starting index of the given array
  83604. */
  83605. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  83606. /**
  83607. * Copy the content of an array into a given matrix
  83608. * @param array defines the source array
  83609. * @param offset defines an offset in the source array
  83610. * @param result defines the target matrix
  83611. */
  83612. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  83613. /**
  83614. * Stores an array into a matrix after having multiplied each component by a given factor
  83615. * @param array defines the source array
  83616. * @param offset defines the offset in the source array
  83617. * @param scale defines the scaling factor
  83618. * @param result defines the target matrix
  83619. */
  83620. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  83621. /**
  83622. * Gets an identity matrix that must not be updated
  83623. */
  83624. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  83625. /**
  83626. * Stores a list of values (16) inside a given matrix
  83627. * @param initialM11 defines 1st value of 1st row
  83628. * @param initialM12 defines 2nd value of 1st row
  83629. * @param initialM13 defines 3rd value of 1st row
  83630. * @param initialM14 defines 4th value of 1st row
  83631. * @param initialM21 defines 1st value of 2nd row
  83632. * @param initialM22 defines 2nd value of 2nd row
  83633. * @param initialM23 defines 3rd value of 2nd row
  83634. * @param initialM24 defines 4th value of 2nd row
  83635. * @param initialM31 defines 1st value of 3rd row
  83636. * @param initialM32 defines 2nd value of 3rd row
  83637. * @param initialM33 defines 3rd value of 3rd row
  83638. * @param initialM34 defines 4th value of 3rd row
  83639. * @param initialM41 defines 1st value of 4th row
  83640. * @param initialM42 defines 2nd value of 4th row
  83641. * @param initialM43 defines 3rd value of 4th row
  83642. * @param initialM44 defines 4th value of 4th row
  83643. * @param result defines the target matrix
  83644. */
  83645. 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;
  83646. /**
  83647. * Creates new matrix from a list of values (16)
  83648. * @param initialM11 defines 1st value of 1st row
  83649. * @param initialM12 defines 2nd value of 1st row
  83650. * @param initialM13 defines 3rd value of 1st row
  83651. * @param initialM14 defines 4th value of 1st row
  83652. * @param initialM21 defines 1st value of 2nd row
  83653. * @param initialM22 defines 2nd value of 2nd row
  83654. * @param initialM23 defines 3rd value of 2nd row
  83655. * @param initialM24 defines 4th value of 2nd row
  83656. * @param initialM31 defines 1st value of 3rd row
  83657. * @param initialM32 defines 2nd value of 3rd row
  83658. * @param initialM33 defines 3rd value of 3rd row
  83659. * @param initialM34 defines 4th value of 3rd row
  83660. * @param initialM41 defines 1st value of 4th row
  83661. * @param initialM42 defines 2nd value of 4th row
  83662. * @param initialM43 defines 3rd value of 4th row
  83663. * @param initialM44 defines 4th value of 4th row
  83664. * @returns the new matrix
  83665. */
  83666. 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;
  83667. /**
  83668. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  83669. * @param scale defines the scale vector3
  83670. * @param rotation defines the rotation quaternion
  83671. * @param translation defines the translation vector3
  83672. * @returns a new matrix
  83673. */
  83674. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  83675. /**
  83676. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  83677. * @param scale defines the scale vector3
  83678. * @param rotation defines the rotation quaternion
  83679. * @param translation defines the translation vector3
  83680. * @param result defines the target matrix
  83681. */
  83682. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  83683. /**
  83684. * Creates a new identity matrix
  83685. * @returns a new identity matrix
  83686. */
  83687. static Identity(): Matrix;
  83688. /**
  83689. * Creates a new identity matrix and stores the result in a given matrix
  83690. * @param result defines the target matrix
  83691. */
  83692. static IdentityToRef(result: Matrix): void;
  83693. /**
  83694. * Creates a new zero matrix
  83695. * @returns a new zero matrix
  83696. */
  83697. static Zero(): Matrix;
  83698. /**
  83699. * Creates a new rotation matrix for "angle" radians around the X axis
  83700. * @param angle defines the angle (in radians) to use
  83701. * @return the new matrix
  83702. */
  83703. static RotationX(angle: number): Matrix;
  83704. /**
  83705. * Creates a new matrix as the invert of a given matrix
  83706. * @param source defines the source matrix
  83707. * @returns the new matrix
  83708. */
  83709. static Invert(source: DeepImmutable<Matrix>): Matrix;
  83710. /**
  83711. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  83712. * @param angle defines the angle (in radians) to use
  83713. * @param result defines the target matrix
  83714. */
  83715. static RotationXToRef(angle: number, result: Matrix): void;
  83716. /**
  83717. * Creates a new rotation matrix for "angle" radians around the Y axis
  83718. * @param angle defines the angle (in radians) to use
  83719. * @return the new matrix
  83720. */
  83721. static RotationY(angle: number): Matrix;
  83722. /**
  83723. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  83724. * @param angle defines the angle (in radians) to use
  83725. * @param result defines the target matrix
  83726. */
  83727. static RotationYToRef(angle: number, result: Matrix): void;
  83728. /**
  83729. * Creates a new rotation matrix for "angle" radians around the Z axis
  83730. * @param angle defines the angle (in radians) to use
  83731. * @return the new matrix
  83732. */
  83733. static RotationZ(angle: number): Matrix;
  83734. /**
  83735. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  83736. * @param angle defines the angle (in radians) to use
  83737. * @param result defines the target matrix
  83738. */
  83739. static RotationZToRef(angle: number, result: Matrix): void;
  83740. /**
  83741. * Creates a new rotation matrix for "angle" radians around the given axis
  83742. * @param axis defines the axis to use
  83743. * @param angle defines the angle (in radians) to use
  83744. * @return the new matrix
  83745. */
  83746. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  83747. /**
  83748. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  83749. * @param axis defines the axis to use
  83750. * @param angle defines the angle (in radians) to use
  83751. * @param result defines the target matrix
  83752. */
  83753. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  83754. /**
  83755. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  83756. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  83757. * @param from defines the vector to align
  83758. * @param to defines the vector to align to
  83759. * @param result defines the target matrix
  83760. */
  83761. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  83762. /**
  83763. * Creates a rotation matrix
  83764. * @param yaw defines the yaw angle in radians (Y axis)
  83765. * @param pitch defines the pitch angle in radians (X axis)
  83766. * @param roll defines the roll angle in radians (Z axis)
  83767. * @returns the new rotation matrix
  83768. */
  83769. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  83770. /**
  83771. * Creates a rotation matrix and stores it in a given matrix
  83772. * @param yaw defines the yaw angle in radians (Y axis)
  83773. * @param pitch defines the pitch angle in radians (X axis)
  83774. * @param roll defines the roll angle in radians (Z axis)
  83775. * @param result defines the target matrix
  83776. */
  83777. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  83778. /**
  83779. * Creates a scaling matrix
  83780. * @param x defines the scale factor on X axis
  83781. * @param y defines the scale factor on Y axis
  83782. * @param z defines the scale factor on Z axis
  83783. * @returns the new matrix
  83784. */
  83785. static Scaling(x: number, y: number, z: number): Matrix;
  83786. /**
  83787. * Creates a scaling matrix and stores it in a given matrix
  83788. * @param x defines the scale factor on X axis
  83789. * @param y defines the scale factor on Y axis
  83790. * @param z defines the scale factor on Z axis
  83791. * @param result defines the target matrix
  83792. */
  83793. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  83794. /**
  83795. * Creates a translation matrix
  83796. * @param x defines the translation on X axis
  83797. * @param y defines the translation on Y axis
  83798. * @param z defines the translationon Z axis
  83799. * @returns the new matrix
  83800. */
  83801. static Translation(x: number, y: number, z: number): Matrix;
  83802. /**
  83803. * Creates a translation matrix and stores it in a given matrix
  83804. * @param x defines the translation on X axis
  83805. * @param y defines the translation on Y axis
  83806. * @param z defines the translationon Z axis
  83807. * @param result defines the target matrix
  83808. */
  83809. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  83810. /**
  83811. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  83812. * @param startValue defines the start value
  83813. * @param endValue defines the end value
  83814. * @param gradient defines the gradient factor
  83815. * @returns the new matrix
  83816. */
  83817. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  83818. /**
  83819. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  83820. * @param startValue defines the start value
  83821. * @param endValue defines the end value
  83822. * @param gradient defines the gradient factor
  83823. * @param result defines the Matrix object where to store data
  83824. */
  83825. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  83826. /**
  83827. * Builds a new matrix whose values are computed by:
  83828. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  83829. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  83830. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  83831. * @param startValue defines the first matrix
  83832. * @param endValue defines the second matrix
  83833. * @param gradient defines the gradient between the two matrices
  83834. * @returns the new matrix
  83835. */
  83836. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  83837. /**
  83838. * Update a matrix to values which are computed by:
  83839. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  83840. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  83841. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  83842. * @param startValue defines the first matrix
  83843. * @param endValue defines the second matrix
  83844. * @param gradient defines the gradient between the two matrices
  83845. * @param result defines the target matrix
  83846. */
  83847. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  83848. /**
  83849. * 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"
  83850. * This function works in left handed mode
  83851. * @param eye defines the final position of the entity
  83852. * @param target defines where the entity should look at
  83853. * @param up defines the up vector for the entity
  83854. * @returns the new matrix
  83855. */
  83856. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  83857. /**
  83858. * 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".
  83859. * This function works in left handed mode
  83860. * @param eye defines the final position of the entity
  83861. * @param target defines where the entity should look at
  83862. * @param up defines the up vector for the entity
  83863. * @param result defines the target matrix
  83864. */
  83865. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  83866. /**
  83867. * 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"
  83868. * This function works in right handed mode
  83869. * @param eye defines the final position of the entity
  83870. * @param target defines where the entity should look at
  83871. * @param up defines the up vector for the entity
  83872. * @returns the new matrix
  83873. */
  83874. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  83875. /**
  83876. * 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".
  83877. * This function works in right handed mode
  83878. * @param eye defines the final position of the entity
  83879. * @param target defines where the entity should look at
  83880. * @param up defines the up vector for the entity
  83881. * @param result defines the target matrix
  83882. */
  83883. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  83884. /**
  83885. * Create a left-handed orthographic projection matrix
  83886. * @param width defines the viewport width
  83887. * @param height defines the viewport height
  83888. * @param znear defines the near clip plane
  83889. * @param zfar defines the far clip plane
  83890. * @returns a new matrix as a left-handed orthographic projection matrix
  83891. */
  83892. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  83893. /**
  83894. * Store a left-handed orthographic projection to a given matrix
  83895. * @param width defines the viewport width
  83896. * @param height defines the viewport height
  83897. * @param znear defines the near clip plane
  83898. * @param zfar defines the far clip plane
  83899. * @param result defines the target matrix
  83900. */
  83901. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  83902. /**
  83903. * Create a left-handed orthographic projection matrix
  83904. * @param left defines the viewport left coordinate
  83905. * @param right defines the viewport right coordinate
  83906. * @param bottom defines the viewport bottom coordinate
  83907. * @param top defines the viewport top coordinate
  83908. * @param znear defines the near clip plane
  83909. * @param zfar defines the far clip plane
  83910. * @returns a new matrix as a left-handed orthographic projection matrix
  83911. */
  83912. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  83913. /**
  83914. * Stores a left-handed orthographic projection into a given matrix
  83915. * @param left defines the viewport left coordinate
  83916. * @param right defines the viewport right coordinate
  83917. * @param bottom defines the viewport bottom coordinate
  83918. * @param top defines the viewport top coordinate
  83919. * @param znear defines the near clip plane
  83920. * @param zfar defines the far clip plane
  83921. * @param result defines the target matrix
  83922. */
  83923. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  83924. /**
  83925. * Creates a right-handed orthographic projection matrix
  83926. * @param left defines the viewport left coordinate
  83927. * @param right defines the viewport right coordinate
  83928. * @param bottom defines the viewport bottom coordinate
  83929. * @param top defines the viewport top coordinate
  83930. * @param znear defines the near clip plane
  83931. * @param zfar defines the far clip plane
  83932. * @returns a new matrix as a right-handed orthographic projection matrix
  83933. */
  83934. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  83935. /**
  83936. * Stores a right-handed orthographic projection into a given matrix
  83937. * @param left defines the viewport left coordinate
  83938. * @param right defines the viewport right coordinate
  83939. * @param bottom defines the viewport bottom coordinate
  83940. * @param top defines the viewport top coordinate
  83941. * @param znear defines the near clip plane
  83942. * @param zfar defines the far clip plane
  83943. * @param result defines the target matrix
  83944. */
  83945. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  83946. /**
  83947. * Creates a left-handed perspective projection matrix
  83948. * @param width defines the viewport width
  83949. * @param height defines the viewport height
  83950. * @param znear defines the near clip plane
  83951. * @param zfar defines the far clip plane
  83952. * @returns a new matrix as a left-handed perspective projection matrix
  83953. */
  83954. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  83955. /**
  83956. * Creates a left-handed perspective projection matrix
  83957. * @param fov defines the horizontal field of view
  83958. * @param aspect defines the aspect ratio
  83959. * @param znear defines the near clip plane
  83960. * @param zfar defines the far clip plane
  83961. * @returns a new matrix as a left-handed perspective projection matrix
  83962. */
  83963. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  83964. /**
  83965. * Stores a left-handed perspective projection into a given matrix
  83966. * @param fov defines the horizontal field of view
  83967. * @param aspect defines the aspect ratio
  83968. * @param znear defines the near clip plane
  83969. * @param zfar defines the far clip plane
  83970. * @param result defines the target matrix
  83971. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  83972. */
  83973. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  83974. /**
  83975. * Stores a left-handed perspective projection into a given matrix with depth reversed
  83976. * @param fov defines the horizontal field of view
  83977. * @param aspect defines the aspect ratio
  83978. * @param znear defines the near clip plane
  83979. * @param zfar not used as infinity is used as far clip
  83980. * @param result defines the target matrix
  83981. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  83982. */
  83983. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  83984. /**
  83985. * Creates a right-handed perspective projection matrix
  83986. * @param fov defines the horizontal field of view
  83987. * @param aspect defines the aspect ratio
  83988. * @param znear defines the near clip plane
  83989. * @param zfar defines the far clip plane
  83990. * @returns a new matrix as a right-handed perspective projection matrix
  83991. */
  83992. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  83993. /**
  83994. * Stores a right-handed perspective projection into a given matrix
  83995. * @param fov defines the horizontal field of view
  83996. * @param aspect defines the aspect ratio
  83997. * @param znear defines the near clip plane
  83998. * @param zfar defines the far clip plane
  83999. * @param result defines the target matrix
  84000. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  84001. */
  84002. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  84003. /**
  84004. * Stores a right-handed perspective projection into a given matrix
  84005. * @param fov defines the horizontal field of view
  84006. * @param aspect defines the aspect ratio
  84007. * @param znear defines the near clip plane
  84008. * @param zfar not used as infinity is used as far clip
  84009. * @param result defines the target matrix
  84010. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  84011. */
  84012. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  84013. /**
  84014. * Stores a perspective projection for WebVR info a given matrix
  84015. * @param fov defines the field of view
  84016. * @param znear defines the near clip plane
  84017. * @param zfar defines the far clip plane
  84018. * @param result defines the target matrix
  84019. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  84020. */
  84021. static PerspectiveFovWebVRToRef(fov: {
  84022. upDegrees: number;
  84023. downDegrees: number;
  84024. leftDegrees: number;
  84025. rightDegrees: number;
  84026. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  84027. /**
  84028. * Computes a complete transformation matrix
  84029. * @param viewport defines the viewport to use
  84030. * @param world defines the world matrix
  84031. * @param view defines the view matrix
  84032. * @param projection defines the projection matrix
  84033. * @param zmin defines the near clip plane
  84034. * @param zmax defines the far clip plane
  84035. * @returns the transformation matrix
  84036. */
  84037. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  84038. /**
  84039. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  84040. * @param matrix defines the matrix to use
  84041. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  84042. */
  84043. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  84044. /**
  84045. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  84046. * @param matrix defines the matrix to use
  84047. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  84048. */
  84049. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  84050. /**
  84051. * Compute the transpose of a given matrix
  84052. * @param matrix defines the matrix to transpose
  84053. * @returns the new matrix
  84054. */
  84055. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  84056. /**
  84057. * Compute the transpose of a matrix and store it in a target matrix
  84058. * @param matrix defines the matrix to transpose
  84059. * @param result defines the target matrix
  84060. */
  84061. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  84062. /**
  84063. * Computes a reflection matrix from a plane
  84064. * @param plane defines the reflection plane
  84065. * @returns a new matrix
  84066. */
  84067. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  84068. /**
  84069. * Computes a reflection matrix from a plane
  84070. * @param plane defines the reflection plane
  84071. * @param result defines the target matrix
  84072. */
  84073. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  84074. /**
  84075. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  84076. * @param xaxis defines the value of the 1st axis
  84077. * @param yaxis defines the value of the 2nd axis
  84078. * @param zaxis defines the value of the 3rd axis
  84079. * @param result defines the target matrix
  84080. */
  84081. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  84082. /**
  84083. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  84084. * @param quat defines the quaternion to use
  84085. * @param result defines the target matrix
  84086. */
  84087. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  84088. }
  84089. /**
  84090. * @hidden
  84091. */
  84092. export class TmpVectors {
  84093. static Vector2: Vector2[];
  84094. static Vector3: Vector3[];
  84095. static Vector4: Vector4[];
  84096. static Quaternion: Quaternion[];
  84097. static Matrix: Matrix[];
  84098. }
  84099. }
  84100. declare module BABYLON {
  84101. /**
  84102. * Defines potential orientation for back face culling
  84103. */
  84104. export enum Orientation {
  84105. /**
  84106. * Clockwise
  84107. */
  84108. CW = 0,
  84109. /** Counter clockwise */
  84110. CCW = 1
  84111. }
  84112. /** Class used to represent a Bezier curve */
  84113. export class BezierCurve {
  84114. /**
  84115. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  84116. * @param t defines the time
  84117. * @param x1 defines the left coordinate on X axis
  84118. * @param y1 defines the left coordinate on Y axis
  84119. * @param x2 defines the right coordinate on X axis
  84120. * @param y2 defines the right coordinate on Y axis
  84121. * @returns the interpolated value
  84122. */
  84123. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  84124. }
  84125. /**
  84126. * Defines angle representation
  84127. */
  84128. export class Angle {
  84129. private _radians;
  84130. /**
  84131. * Creates an Angle object of "radians" radians (float).
  84132. * @param radians the angle in radians
  84133. */
  84134. constructor(radians: number);
  84135. /**
  84136. * Get value in degrees
  84137. * @returns the Angle value in degrees (float)
  84138. */
  84139. degrees(): number;
  84140. /**
  84141. * Get value in radians
  84142. * @returns the Angle value in radians (float)
  84143. */
  84144. radians(): number;
  84145. /**
  84146. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  84147. * @param a defines first point as the origin
  84148. * @param b defines point
  84149. * @returns a new Angle
  84150. */
  84151. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  84152. /**
  84153. * Gets a new Angle object from the given float in radians
  84154. * @param radians defines the angle value in radians
  84155. * @returns a new Angle
  84156. */
  84157. static FromRadians(radians: number): Angle;
  84158. /**
  84159. * Gets a new Angle object from the given float in degrees
  84160. * @param degrees defines the angle value in degrees
  84161. * @returns a new Angle
  84162. */
  84163. static FromDegrees(degrees: number): Angle;
  84164. }
  84165. /**
  84166. * This represents an arc in a 2d space.
  84167. */
  84168. export class Arc2 {
  84169. /** Defines the start point of the arc */
  84170. startPoint: Vector2;
  84171. /** Defines the mid point of the arc */
  84172. midPoint: Vector2;
  84173. /** Defines the end point of the arc */
  84174. endPoint: Vector2;
  84175. /**
  84176. * Defines the center point of the arc.
  84177. */
  84178. centerPoint: Vector2;
  84179. /**
  84180. * Defines the radius of the arc.
  84181. */
  84182. radius: number;
  84183. /**
  84184. * Defines the angle of the arc (from mid point to end point).
  84185. */
  84186. angle: Angle;
  84187. /**
  84188. * Defines the start angle of the arc (from start point to middle point).
  84189. */
  84190. startAngle: Angle;
  84191. /**
  84192. * Defines the orientation of the arc (clock wise/counter clock wise).
  84193. */
  84194. orientation: Orientation;
  84195. /**
  84196. * Creates an Arc object from the three given points : start, middle and end.
  84197. * @param startPoint Defines the start point of the arc
  84198. * @param midPoint Defines the midlle point of the arc
  84199. * @param endPoint Defines the end point of the arc
  84200. */
  84201. constructor(
  84202. /** Defines the start point of the arc */
  84203. startPoint: Vector2,
  84204. /** Defines the mid point of the arc */
  84205. midPoint: Vector2,
  84206. /** Defines the end point of the arc */
  84207. endPoint: Vector2);
  84208. }
  84209. /**
  84210. * Represents a 2D path made up of multiple 2D points
  84211. */
  84212. export class Path2 {
  84213. private _points;
  84214. private _length;
  84215. /**
  84216. * If the path start and end point are the same
  84217. */
  84218. closed: boolean;
  84219. /**
  84220. * Creates a Path2 object from the starting 2D coordinates x and y.
  84221. * @param x the starting points x value
  84222. * @param y the starting points y value
  84223. */
  84224. constructor(x: number, y: number);
  84225. /**
  84226. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  84227. * @param x the added points x value
  84228. * @param y the added points y value
  84229. * @returns the updated Path2.
  84230. */
  84231. addLineTo(x: number, y: number): Path2;
  84232. /**
  84233. * 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.
  84234. * @param midX middle point x value
  84235. * @param midY middle point y value
  84236. * @param endX end point x value
  84237. * @param endY end point y value
  84238. * @param numberOfSegments (default: 36)
  84239. * @returns the updated Path2.
  84240. */
  84241. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  84242. /**
  84243. * Closes the Path2.
  84244. * @returns the Path2.
  84245. */
  84246. close(): Path2;
  84247. /**
  84248. * Gets the sum of the distance between each sequential point in the path
  84249. * @returns the Path2 total length (float).
  84250. */
  84251. length(): number;
  84252. /**
  84253. * Gets the points which construct the path
  84254. * @returns the Path2 internal array of points.
  84255. */
  84256. getPoints(): Vector2[];
  84257. /**
  84258. * Retreives the point at the distance aways from the starting point
  84259. * @param normalizedLengthPosition the length along the path to retreive the point from
  84260. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  84261. */
  84262. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  84263. /**
  84264. * Creates a new path starting from an x and y position
  84265. * @param x starting x value
  84266. * @param y starting y value
  84267. * @returns a new Path2 starting at the coordinates (x, y).
  84268. */
  84269. static StartingAt(x: number, y: number): Path2;
  84270. }
  84271. /**
  84272. * Represents a 3D path made up of multiple 3D points
  84273. */
  84274. export class Path3D {
  84275. /**
  84276. * an array of Vector3, the curve axis of the Path3D
  84277. */
  84278. path: Vector3[];
  84279. private _curve;
  84280. private _distances;
  84281. private _tangents;
  84282. private _normals;
  84283. private _binormals;
  84284. private _raw;
  84285. private _alignTangentsWithPath;
  84286. private readonly _pointAtData;
  84287. /**
  84288. * new Path3D(path, normal, raw)
  84289. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  84290. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  84291. * @param path an array of Vector3, the curve axis of the Path3D
  84292. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  84293. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  84294. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  84295. */
  84296. constructor(
  84297. /**
  84298. * an array of Vector3, the curve axis of the Path3D
  84299. */
  84300. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  84301. /**
  84302. * Returns the Path3D array of successive Vector3 designing its curve.
  84303. * @returns the Path3D array of successive Vector3 designing its curve.
  84304. */
  84305. getCurve(): Vector3[];
  84306. /**
  84307. * Returns the Path3D array of successive Vector3 designing its curve.
  84308. * @returns the Path3D array of successive Vector3 designing its curve.
  84309. */
  84310. getPoints(): Vector3[];
  84311. /**
  84312. * @returns the computed length (float) of the path.
  84313. */
  84314. length(): number;
  84315. /**
  84316. * Returns an array populated with tangent vectors on each Path3D curve point.
  84317. * @returns an array populated with tangent vectors on each Path3D curve point.
  84318. */
  84319. getTangents(): Vector3[];
  84320. /**
  84321. * Returns an array populated with normal vectors on each Path3D curve point.
  84322. * @returns an array populated with normal vectors on each Path3D curve point.
  84323. */
  84324. getNormals(): Vector3[];
  84325. /**
  84326. * Returns an array populated with binormal vectors on each Path3D curve point.
  84327. * @returns an array populated with binormal vectors on each Path3D curve point.
  84328. */
  84329. getBinormals(): Vector3[];
  84330. /**
  84331. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  84332. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  84333. */
  84334. getDistances(): number[];
  84335. /**
  84336. * Returns an interpolated point along this path
  84337. * @param position the position of the point along this path, from 0.0 to 1.0
  84338. * @returns a new Vector3 as the point
  84339. */
  84340. getPointAt(position: number): Vector3;
  84341. /**
  84342. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  84343. * @param position the position of the point along this path, from 0.0 to 1.0
  84344. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  84345. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  84346. */
  84347. getTangentAt(position: number, interpolated?: boolean): Vector3;
  84348. /**
  84349. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  84350. * @param position the position of the point along this path, from 0.0 to 1.0
  84351. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  84352. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  84353. */
  84354. getNormalAt(position: number, interpolated?: boolean): Vector3;
  84355. /**
  84356. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  84357. * @param position the position of the point along this path, from 0.0 to 1.0
  84358. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  84359. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  84360. */
  84361. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  84362. /**
  84363. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  84364. * @param position the position of the point along this path, from 0.0 to 1.0
  84365. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  84366. */
  84367. getDistanceAt(position: number): number;
  84368. /**
  84369. * Returns the array index of the previous point of an interpolated point along this path
  84370. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  84371. * @returns the array index
  84372. */
  84373. getPreviousPointIndexAt(position: number): number;
  84374. /**
  84375. * 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)
  84376. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  84377. * @returns the sub position
  84378. */
  84379. getSubPositionAt(position: number): number;
  84380. /**
  84381. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  84382. * @param target the vector of which to get the closest position to
  84383. * @returns the position of the closest virtual point on this path to the target vector
  84384. */
  84385. getClosestPositionTo(target: Vector3): number;
  84386. /**
  84387. * Returns a sub path (slice) of this path
  84388. * @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
  84389. * @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
  84390. * @returns a sub path (slice) of this path
  84391. */
  84392. slice(start?: number, end?: number): Path3D;
  84393. /**
  84394. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  84395. * @param path path which all values are copied into the curves points
  84396. * @param firstNormal which should be projected onto the curve
  84397. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  84398. * @returns the same object updated.
  84399. */
  84400. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  84401. private _compute;
  84402. private _getFirstNonNullVector;
  84403. private _getLastNonNullVector;
  84404. private _normalVector;
  84405. /**
  84406. * Updates the point at data for an interpolated point along this curve
  84407. * @param position the position of the point along this curve, from 0.0 to 1.0
  84408. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  84409. * @returns the (updated) point at data
  84410. */
  84411. private _updatePointAtData;
  84412. /**
  84413. * Updates the point at data from the specified parameters
  84414. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  84415. * @param point the interpolated point
  84416. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  84417. */
  84418. private _setPointAtData;
  84419. /**
  84420. * Updates the point at interpolation matrix for the tangents, normals and binormals
  84421. */
  84422. private _updateInterpolationMatrix;
  84423. }
  84424. /**
  84425. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  84426. * A Curve3 is designed from a series of successive Vector3.
  84427. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  84428. */
  84429. export class Curve3 {
  84430. private _points;
  84431. private _length;
  84432. /**
  84433. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  84434. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  84435. * @param v1 (Vector3) the control point
  84436. * @param v2 (Vector3) the end point of the Quadratic Bezier
  84437. * @param nbPoints (integer) the wanted number of points in the curve
  84438. * @returns the created Curve3
  84439. */
  84440. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  84441. /**
  84442. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  84443. * @param v0 (Vector3) the origin point of the Cubic Bezier
  84444. * @param v1 (Vector3) the first control point
  84445. * @param v2 (Vector3) the second control point
  84446. * @param v3 (Vector3) the end point of the Cubic Bezier
  84447. * @param nbPoints (integer) the wanted number of points in the curve
  84448. * @returns the created Curve3
  84449. */
  84450. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  84451. /**
  84452. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  84453. * @param p1 (Vector3) the origin point of the Hermite Spline
  84454. * @param t1 (Vector3) the tangent vector at the origin point
  84455. * @param p2 (Vector3) the end point of the Hermite Spline
  84456. * @param t2 (Vector3) the tangent vector at the end point
  84457. * @param nbPoints (integer) the wanted number of points in the curve
  84458. * @returns the created Curve3
  84459. */
  84460. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  84461. /**
  84462. * Returns a Curve3 object along a CatmullRom Spline curve :
  84463. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  84464. * @param nbPoints (integer) the wanted number of points between each curve control points
  84465. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  84466. * @returns the created Curve3
  84467. */
  84468. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  84469. /**
  84470. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  84471. * A Curve3 is designed from a series of successive Vector3.
  84472. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  84473. * @param points points which make up the curve
  84474. */
  84475. constructor(points: Vector3[]);
  84476. /**
  84477. * @returns the Curve3 stored array of successive Vector3
  84478. */
  84479. getPoints(): Vector3[];
  84480. /**
  84481. * @returns the computed length (float) of the curve.
  84482. */
  84483. length(): number;
  84484. /**
  84485. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  84486. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  84487. * curveA and curveB keep unchanged.
  84488. * @param curve the curve to continue from this curve
  84489. * @returns the newly constructed curve
  84490. */
  84491. continue(curve: DeepImmutable<Curve3>): Curve3;
  84492. private _computeLength;
  84493. }
  84494. }
  84495. declare module BABYLON {
  84496. /**
  84497. * This represents the main contract an easing function should follow.
  84498. * Easing functions are used throughout the animation system.
  84499. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84500. */
  84501. export interface IEasingFunction {
  84502. /**
  84503. * Given an input gradient between 0 and 1, this returns the corrseponding value
  84504. * of the easing function.
  84505. * The link below provides some of the most common examples of easing functions.
  84506. * @see https://easings.net/
  84507. * @param gradient Defines the value between 0 and 1 we want the easing value for
  84508. * @returns the corresponding value on the curve defined by the easing function
  84509. */
  84510. ease(gradient: number): number;
  84511. }
  84512. /**
  84513. * Base class used for every default easing function.
  84514. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84515. */
  84516. export class EasingFunction implements IEasingFunction {
  84517. /**
  84518. * Interpolation follows the mathematical formula associated with the easing function.
  84519. */
  84520. static readonly EASINGMODE_EASEIN: number;
  84521. /**
  84522. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  84523. */
  84524. static readonly EASINGMODE_EASEOUT: number;
  84525. /**
  84526. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  84527. */
  84528. static readonly EASINGMODE_EASEINOUT: number;
  84529. private _easingMode;
  84530. /**
  84531. * Sets the easing mode of the current function.
  84532. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  84533. */
  84534. setEasingMode(easingMode: number): void;
  84535. /**
  84536. * Gets the current easing mode.
  84537. * @returns the easing mode
  84538. */
  84539. getEasingMode(): number;
  84540. /**
  84541. * @hidden
  84542. */
  84543. easeInCore(gradient: number): number;
  84544. /**
  84545. * Given an input gradient between 0 and 1, this returns the corresponding value
  84546. * of the easing function.
  84547. * @param gradient Defines the value between 0 and 1 we want the easing value for
  84548. * @returns the corresponding value on the curve defined by the easing function
  84549. */
  84550. ease(gradient: number): number;
  84551. }
  84552. /**
  84553. * Easing function with a circle shape (see link below).
  84554. * @see https://easings.net/#easeInCirc
  84555. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84556. */
  84557. export class CircleEase extends EasingFunction implements IEasingFunction {
  84558. /** @hidden */
  84559. easeInCore(gradient: number): number;
  84560. }
  84561. /**
  84562. * Easing function with a ease back shape (see link below).
  84563. * @see https://easings.net/#easeInBack
  84564. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84565. */
  84566. export class BackEase extends EasingFunction implements IEasingFunction {
  84567. /** Defines the amplitude of the function */
  84568. amplitude: number;
  84569. /**
  84570. * Instantiates a back ease easing
  84571. * @see https://easings.net/#easeInBack
  84572. * @param amplitude Defines the amplitude of the function
  84573. */
  84574. constructor(
  84575. /** Defines the amplitude of the function */
  84576. amplitude?: number);
  84577. /** @hidden */
  84578. easeInCore(gradient: number): number;
  84579. }
  84580. /**
  84581. * Easing function with a bouncing shape (see link below).
  84582. * @see https://easings.net/#easeInBounce
  84583. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84584. */
  84585. export class BounceEase extends EasingFunction implements IEasingFunction {
  84586. /** Defines the number of bounces */
  84587. bounces: number;
  84588. /** Defines the amplitude of the bounce */
  84589. bounciness: number;
  84590. /**
  84591. * Instantiates a bounce easing
  84592. * @see https://easings.net/#easeInBounce
  84593. * @param bounces Defines the number of bounces
  84594. * @param bounciness Defines the amplitude of the bounce
  84595. */
  84596. constructor(
  84597. /** Defines the number of bounces */
  84598. bounces?: number,
  84599. /** Defines the amplitude of the bounce */
  84600. bounciness?: number);
  84601. /** @hidden */
  84602. easeInCore(gradient: number): number;
  84603. }
  84604. /**
  84605. * Easing function with a power of 3 shape (see link below).
  84606. * @see https://easings.net/#easeInCubic
  84607. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84608. */
  84609. export class CubicEase extends EasingFunction implements IEasingFunction {
  84610. /** @hidden */
  84611. easeInCore(gradient: number): number;
  84612. }
  84613. /**
  84614. * Easing function with an elastic shape (see link below).
  84615. * @see https://easings.net/#easeInElastic
  84616. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84617. */
  84618. export class ElasticEase extends EasingFunction implements IEasingFunction {
  84619. /** Defines the number of oscillations*/
  84620. oscillations: number;
  84621. /** Defines the amplitude of the oscillations*/
  84622. springiness: number;
  84623. /**
  84624. * Instantiates an elastic easing function
  84625. * @see https://easings.net/#easeInElastic
  84626. * @param oscillations Defines the number of oscillations
  84627. * @param springiness Defines the amplitude of the oscillations
  84628. */
  84629. constructor(
  84630. /** Defines the number of oscillations*/
  84631. oscillations?: number,
  84632. /** Defines the amplitude of the oscillations*/
  84633. springiness?: number);
  84634. /** @hidden */
  84635. easeInCore(gradient: number): number;
  84636. }
  84637. /**
  84638. * Easing function with an exponential shape (see link below).
  84639. * @see https://easings.net/#easeInExpo
  84640. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84641. */
  84642. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  84643. /** Defines the exponent of the function */
  84644. exponent: number;
  84645. /**
  84646. * Instantiates an exponential easing function
  84647. * @see https://easings.net/#easeInExpo
  84648. * @param exponent Defines the exponent of the function
  84649. */
  84650. constructor(
  84651. /** Defines the exponent of the function */
  84652. exponent?: number);
  84653. /** @hidden */
  84654. easeInCore(gradient: number): number;
  84655. }
  84656. /**
  84657. * Easing function with a power shape (see link below).
  84658. * @see https://easings.net/#easeInQuad
  84659. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84660. */
  84661. export class PowerEase extends EasingFunction implements IEasingFunction {
  84662. /** Defines the power of the function */
  84663. power: number;
  84664. /**
  84665. * Instantiates an power base easing function
  84666. * @see https://easings.net/#easeInQuad
  84667. * @param power Defines the power of the function
  84668. */
  84669. constructor(
  84670. /** Defines the power of the function */
  84671. power?: number);
  84672. /** @hidden */
  84673. easeInCore(gradient: number): number;
  84674. }
  84675. /**
  84676. * Easing function with a power of 2 shape (see link below).
  84677. * @see https://easings.net/#easeInQuad
  84678. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84679. */
  84680. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  84681. /** @hidden */
  84682. easeInCore(gradient: number): number;
  84683. }
  84684. /**
  84685. * Easing function with a power of 4 shape (see link below).
  84686. * @see https://easings.net/#easeInQuart
  84687. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84688. */
  84689. export class QuarticEase extends EasingFunction implements IEasingFunction {
  84690. /** @hidden */
  84691. easeInCore(gradient: number): number;
  84692. }
  84693. /**
  84694. * Easing function with a power of 5 shape (see link below).
  84695. * @see https://easings.net/#easeInQuint
  84696. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84697. */
  84698. export class QuinticEase extends EasingFunction implements IEasingFunction {
  84699. /** @hidden */
  84700. easeInCore(gradient: number): number;
  84701. }
  84702. /**
  84703. * Easing function with a sin shape (see link below).
  84704. * @see https://easings.net/#easeInSine
  84705. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84706. */
  84707. export class SineEase extends EasingFunction implements IEasingFunction {
  84708. /** @hidden */
  84709. easeInCore(gradient: number): number;
  84710. }
  84711. /**
  84712. * Easing function with a bezier shape (see link below).
  84713. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  84714. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84715. */
  84716. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  84717. /** Defines the x component of the start tangent in the bezier curve */
  84718. x1: number;
  84719. /** Defines the y component of the start tangent in the bezier curve */
  84720. y1: number;
  84721. /** Defines the x component of the end tangent in the bezier curve */
  84722. x2: number;
  84723. /** Defines the y component of the end tangent in the bezier curve */
  84724. y2: number;
  84725. /**
  84726. * Instantiates a bezier function
  84727. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  84728. * @param x1 Defines the x component of the start tangent in the bezier curve
  84729. * @param y1 Defines the y component of the start tangent in the bezier curve
  84730. * @param x2 Defines the x component of the end tangent in the bezier curve
  84731. * @param y2 Defines the y component of the end tangent in the bezier curve
  84732. */
  84733. constructor(
  84734. /** Defines the x component of the start tangent in the bezier curve */
  84735. x1?: number,
  84736. /** Defines the y component of the start tangent in the bezier curve */
  84737. y1?: number,
  84738. /** Defines the x component of the end tangent in the bezier curve */
  84739. x2?: number,
  84740. /** Defines the y component of the end tangent in the bezier curve */
  84741. y2?: number);
  84742. /** @hidden */
  84743. easeInCore(gradient: number): number;
  84744. }
  84745. }
  84746. declare module BABYLON {
  84747. /**
  84748. * Class used to hold a RBG color
  84749. */
  84750. export class Color3 {
  84751. /**
  84752. * Defines the red component (between 0 and 1, default is 0)
  84753. */
  84754. r: number;
  84755. /**
  84756. * Defines the green component (between 0 and 1, default is 0)
  84757. */
  84758. g: number;
  84759. /**
  84760. * Defines the blue component (between 0 and 1, default is 0)
  84761. */
  84762. b: number;
  84763. /**
  84764. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  84765. * @param r defines the red component (between 0 and 1, default is 0)
  84766. * @param g defines the green component (between 0 and 1, default is 0)
  84767. * @param b defines the blue component (between 0 and 1, default is 0)
  84768. */
  84769. constructor(
  84770. /**
  84771. * Defines the red component (between 0 and 1, default is 0)
  84772. */
  84773. r?: number,
  84774. /**
  84775. * Defines the green component (between 0 and 1, default is 0)
  84776. */
  84777. g?: number,
  84778. /**
  84779. * Defines the blue component (between 0 and 1, default is 0)
  84780. */
  84781. b?: number);
  84782. /**
  84783. * Creates a string with the Color3 current values
  84784. * @returns the string representation of the Color3 object
  84785. */
  84786. toString(): string;
  84787. /**
  84788. * Returns the string "Color3"
  84789. * @returns "Color3"
  84790. */
  84791. getClassName(): string;
  84792. /**
  84793. * Compute the Color3 hash code
  84794. * @returns an unique number that can be used to hash Color3 objects
  84795. */
  84796. getHashCode(): number;
  84797. /**
  84798. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  84799. * @param array defines the array where to store the r,g,b components
  84800. * @param index defines an optional index in the target array to define where to start storing values
  84801. * @returns the current Color3 object
  84802. */
  84803. toArray(array: FloatArray, index?: number): Color3;
  84804. /**
  84805. * Update the current color with values stored in an array from the starting index of the given array
  84806. * @param array defines the source array
  84807. * @param offset defines an offset in the source array
  84808. * @returns the current Color3 object
  84809. */
  84810. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  84811. /**
  84812. * Returns a new Color4 object from the current Color3 and the given alpha
  84813. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  84814. * @returns a new Color4 object
  84815. */
  84816. toColor4(alpha?: number): Color4;
  84817. /**
  84818. * Returns a new array populated with 3 numeric elements : red, green and blue values
  84819. * @returns the new array
  84820. */
  84821. asArray(): number[];
  84822. /**
  84823. * Returns the luminance value
  84824. * @returns a float value
  84825. */
  84826. toLuminance(): number;
  84827. /**
  84828. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  84829. * @param otherColor defines the second operand
  84830. * @returns the new Color3 object
  84831. */
  84832. multiply(otherColor: DeepImmutable<Color3>): Color3;
  84833. /**
  84834. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  84835. * @param otherColor defines the second operand
  84836. * @param result defines the Color3 object where to store the result
  84837. * @returns the current Color3
  84838. */
  84839. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  84840. /**
  84841. * Determines equality between Color3 objects
  84842. * @param otherColor defines the second operand
  84843. * @returns true if the rgb values are equal to the given ones
  84844. */
  84845. equals(otherColor: DeepImmutable<Color3>): boolean;
  84846. /**
  84847. * Determines equality between the current Color3 object and a set of r,b,g values
  84848. * @param r defines the red component to check
  84849. * @param g defines the green component to check
  84850. * @param b defines the blue component to check
  84851. * @returns true if the rgb values are equal to the given ones
  84852. */
  84853. equalsFloats(r: number, g: number, b: number): boolean;
  84854. /**
  84855. * Multiplies in place each rgb value by scale
  84856. * @param scale defines the scaling factor
  84857. * @returns the updated Color3
  84858. */
  84859. scale(scale: number): Color3;
  84860. /**
  84861. * Multiplies the rgb values by scale and stores the result into "result"
  84862. * @param scale defines the scaling factor
  84863. * @param result defines the Color3 object where to store the result
  84864. * @returns the unmodified current Color3
  84865. */
  84866. scaleToRef(scale: number, result: Color3): Color3;
  84867. /**
  84868. * Scale the current Color3 values by a factor and add the result to a given Color3
  84869. * @param scale defines the scale factor
  84870. * @param result defines color to store the result into
  84871. * @returns the unmodified current Color3
  84872. */
  84873. scaleAndAddToRef(scale: number, result: Color3): Color3;
  84874. /**
  84875. * Clamps the rgb values by the min and max values and stores the result into "result"
  84876. * @param min defines minimum clamping value (default is 0)
  84877. * @param max defines maximum clamping value (default is 1)
  84878. * @param result defines color to store the result into
  84879. * @returns the original Color3
  84880. */
  84881. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  84882. /**
  84883. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  84884. * @param otherColor defines the second operand
  84885. * @returns the new Color3
  84886. */
  84887. add(otherColor: DeepImmutable<Color3>): Color3;
  84888. /**
  84889. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  84890. * @param otherColor defines the second operand
  84891. * @param result defines Color3 object to store the result into
  84892. * @returns the unmodified current Color3
  84893. */
  84894. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  84895. /**
  84896. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  84897. * @param otherColor defines the second operand
  84898. * @returns the new Color3
  84899. */
  84900. subtract(otherColor: DeepImmutable<Color3>): Color3;
  84901. /**
  84902. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  84903. * @param otherColor defines the second operand
  84904. * @param result defines Color3 object to store the result into
  84905. * @returns the unmodified current Color3
  84906. */
  84907. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  84908. /**
  84909. * Copy the current object
  84910. * @returns a new Color3 copied the current one
  84911. */
  84912. clone(): Color3;
  84913. /**
  84914. * Copies the rgb values from the source in the current Color3
  84915. * @param source defines the source Color3 object
  84916. * @returns the updated Color3 object
  84917. */
  84918. copyFrom(source: DeepImmutable<Color3>): Color3;
  84919. /**
  84920. * Updates the Color3 rgb values from the given floats
  84921. * @param r defines the red component to read from
  84922. * @param g defines the green component to read from
  84923. * @param b defines the blue component to read from
  84924. * @returns the current Color3 object
  84925. */
  84926. copyFromFloats(r: number, g: number, b: number): Color3;
  84927. /**
  84928. * Updates the Color3 rgb values from the given floats
  84929. * @param r defines the red component to read from
  84930. * @param g defines the green component to read from
  84931. * @param b defines the blue component to read from
  84932. * @returns the current Color3 object
  84933. */
  84934. set(r: number, g: number, b: number): Color3;
  84935. /**
  84936. * Compute the Color3 hexadecimal code as a string
  84937. * @returns a string containing the hexadecimal representation of the Color3 object
  84938. */
  84939. toHexString(): string;
  84940. /**
  84941. * Computes a new Color3 converted from the current one to linear space
  84942. * @returns a new Color3 object
  84943. */
  84944. toLinearSpace(): Color3;
  84945. /**
  84946. * Converts current color in rgb space to HSV values
  84947. * @returns a new color3 representing the HSV values
  84948. */
  84949. toHSV(): Color3;
  84950. /**
  84951. * Converts current color in rgb space to HSV values
  84952. * @param result defines the Color3 where to store the HSV values
  84953. */
  84954. toHSVToRef(result: Color3): void;
  84955. /**
  84956. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  84957. * @param convertedColor defines the Color3 object where to store the linear space version
  84958. * @returns the unmodified Color3
  84959. */
  84960. toLinearSpaceToRef(convertedColor: Color3): Color3;
  84961. /**
  84962. * Computes a new Color3 converted from the current one to gamma space
  84963. * @returns a new Color3 object
  84964. */
  84965. toGammaSpace(): Color3;
  84966. /**
  84967. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  84968. * @param convertedColor defines the Color3 object where to store the gamma space version
  84969. * @returns the unmodified Color3
  84970. */
  84971. toGammaSpaceToRef(convertedColor: Color3): Color3;
  84972. private static _BlackReadOnly;
  84973. /**
  84974. * Convert Hue, saturation and value to a Color3 (RGB)
  84975. * @param hue defines the hue
  84976. * @param saturation defines the saturation
  84977. * @param value defines the value
  84978. * @param result defines the Color3 where to store the RGB values
  84979. */
  84980. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  84981. /**
  84982. * Creates a new Color3 from the string containing valid hexadecimal values
  84983. * @param hex defines a string containing valid hexadecimal values
  84984. * @returns a new Color3 object
  84985. */
  84986. static FromHexString(hex: string): Color3;
  84987. /**
  84988. * Creates a new Color3 from the starting index of the given array
  84989. * @param array defines the source array
  84990. * @param offset defines an offset in the source array
  84991. * @returns a new Color3 object
  84992. */
  84993. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  84994. /**
  84995. * Creates a new Color3 from the starting index element of the given array
  84996. * @param array defines the source array to read from
  84997. * @param offset defines the offset in the source array
  84998. * @param result defines the target Color3 object
  84999. */
  85000. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  85001. /**
  85002. * Creates a new Color3 from integer values (< 256)
  85003. * @param r defines the red component to read from (value between 0 and 255)
  85004. * @param g defines the green component to read from (value between 0 and 255)
  85005. * @param b defines the blue component to read from (value between 0 and 255)
  85006. * @returns a new Color3 object
  85007. */
  85008. static FromInts(r: number, g: number, b: number): Color3;
  85009. /**
  85010. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  85011. * @param start defines the start Color3 value
  85012. * @param end defines the end Color3 value
  85013. * @param amount defines the gradient value between start and end
  85014. * @returns a new Color3 object
  85015. */
  85016. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  85017. /**
  85018. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  85019. * @param left defines the start value
  85020. * @param right defines the end value
  85021. * @param amount defines the gradient factor
  85022. * @param result defines the Color3 object where to store the result
  85023. */
  85024. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  85025. /**
  85026. * Returns a Color3 value containing a red color
  85027. * @returns a new Color3 object
  85028. */
  85029. static Red(): Color3;
  85030. /**
  85031. * Returns a Color3 value containing a green color
  85032. * @returns a new Color3 object
  85033. */
  85034. static Green(): Color3;
  85035. /**
  85036. * Returns a Color3 value containing a blue color
  85037. * @returns a new Color3 object
  85038. */
  85039. static Blue(): Color3;
  85040. /**
  85041. * Returns a Color3 value containing a black color
  85042. * @returns a new Color3 object
  85043. */
  85044. static Black(): Color3;
  85045. /**
  85046. * Gets a Color3 value containing a black color that must not be updated
  85047. */
  85048. static get BlackReadOnly(): DeepImmutable<Color3>;
  85049. /**
  85050. * Returns a Color3 value containing a white color
  85051. * @returns a new Color3 object
  85052. */
  85053. static White(): Color3;
  85054. /**
  85055. * Returns a Color3 value containing a purple color
  85056. * @returns a new Color3 object
  85057. */
  85058. static Purple(): Color3;
  85059. /**
  85060. * Returns a Color3 value containing a magenta color
  85061. * @returns a new Color3 object
  85062. */
  85063. static Magenta(): Color3;
  85064. /**
  85065. * Returns a Color3 value containing a yellow color
  85066. * @returns a new Color3 object
  85067. */
  85068. static Yellow(): Color3;
  85069. /**
  85070. * Returns a Color3 value containing a gray color
  85071. * @returns a new Color3 object
  85072. */
  85073. static Gray(): Color3;
  85074. /**
  85075. * Returns a Color3 value containing a teal color
  85076. * @returns a new Color3 object
  85077. */
  85078. static Teal(): Color3;
  85079. /**
  85080. * Returns a Color3 value containing a random color
  85081. * @returns a new Color3 object
  85082. */
  85083. static Random(): Color3;
  85084. }
  85085. /**
  85086. * Class used to hold a RBGA color
  85087. */
  85088. export class Color4 {
  85089. /**
  85090. * Defines the red component (between 0 and 1, default is 0)
  85091. */
  85092. r: number;
  85093. /**
  85094. * Defines the green component (between 0 and 1, default is 0)
  85095. */
  85096. g: number;
  85097. /**
  85098. * Defines the blue component (between 0 and 1, default is 0)
  85099. */
  85100. b: number;
  85101. /**
  85102. * Defines the alpha component (between 0 and 1, default is 1)
  85103. */
  85104. a: number;
  85105. /**
  85106. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  85107. * @param r defines the red component (between 0 and 1, default is 0)
  85108. * @param g defines the green component (between 0 and 1, default is 0)
  85109. * @param b defines the blue component (between 0 and 1, default is 0)
  85110. * @param a defines the alpha component (between 0 and 1, default is 1)
  85111. */
  85112. constructor(
  85113. /**
  85114. * Defines the red component (between 0 and 1, default is 0)
  85115. */
  85116. r?: number,
  85117. /**
  85118. * Defines the green component (between 0 and 1, default is 0)
  85119. */
  85120. g?: number,
  85121. /**
  85122. * Defines the blue component (between 0 and 1, default is 0)
  85123. */
  85124. b?: number,
  85125. /**
  85126. * Defines the alpha component (between 0 and 1, default is 1)
  85127. */
  85128. a?: number);
  85129. /**
  85130. * Adds in place the given Color4 values to the current Color4 object
  85131. * @param right defines the second operand
  85132. * @returns the current updated Color4 object
  85133. */
  85134. addInPlace(right: DeepImmutable<Color4>): Color4;
  85135. /**
  85136. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  85137. * @returns the new array
  85138. */
  85139. asArray(): number[];
  85140. /**
  85141. * Stores from the starting index in the given array the Color4 successive values
  85142. * @param array defines the array where to store the r,g,b components
  85143. * @param index defines an optional index in the target array to define where to start storing values
  85144. * @returns the current Color4 object
  85145. */
  85146. toArray(array: number[], index?: number): Color4;
  85147. /**
  85148. * Update the current color with values stored in an array from the starting index of the given array
  85149. * @param array defines the source array
  85150. * @param offset defines an offset in the source array
  85151. * @returns the current Color4 object
  85152. */
  85153. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  85154. /**
  85155. * Determines equality between Color4 objects
  85156. * @param otherColor defines the second operand
  85157. * @returns true if the rgba values are equal to the given ones
  85158. */
  85159. equals(otherColor: DeepImmutable<Color4>): boolean;
  85160. /**
  85161. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  85162. * @param right defines the second operand
  85163. * @returns a new Color4 object
  85164. */
  85165. add(right: DeepImmutable<Color4>): Color4;
  85166. /**
  85167. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  85168. * @param right defines the second operand
  85169. * @returns a new Color4 object
  85170. */
  85171. subtract(right: DeepImmutable<Color4>): Color4;
  85172. /**
  85173. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  85174. * @param right defines the second operand
  85175. * @param result defines the Color4 object where to store the result
  85176. * @returns the current Color4 object
  85177. */
  85178. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  85179. /**
  85180. * Creates a new Color4 with the current Color4 values multiplied by scale
  85181. * @param scale defines the scaling factor to apply
  85182. * @returns a new Color4 object
  85183. */
  85184. scale(scale: number): Color4;
  85185. /**
  85186. * Multiplies the current Color4 values by scale and stores the result in "result"
  85187. * @param scale defines the scaling factor to apply
  85188. * @param result defines the Color4 object where to store the result
  85189. * @returns the current unmodified Color4
  85190. */
  85191. scaleToRef(scale: number, result: Color4): Color4;
  85192. /**
  85193. * Scale the current Color4 values by a factor and add the result to a given Color4
  85194. * @param scale defines the scale factor
  85195. * @param result defines the Color4 object where to store the result
  85196. * @returns the unmodified current Color4
  85197. */
  85198. scaleAndAddToRef(scale: number, result: Color4): Color4;
  85199. /**
  85200. * Clamps the rgb values by the min and max values and stores the result into "result"
  85201. * @param min defines minimum clamping value (default is 0)
  85202. * @param max defines maximum clamping value (default is 1)
  85203. * @param result defines color to store the result into.
  85204. * @returns the cuurent Color4
  85205. */
  85206. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  85207. /**
  85208. * Multipy an Color4 value by another and return a new Color4 object
  85209. * @param color defines the Color4 value to multiply by
  85210. * @returns a new Color4 object
  85211. */
  85212. multiply(color: Color4): Color4;
  85213. /**
  85214. * Multipy a Color4 value by another and push the result in a reference value
  85215. * @param color defines the Color4 value to multiply by
  85216. * @param result defines the Color4 to fill the result in
  85217. * @returns the result Color4
  85218. */
  85219. multiplyToRef(color: Color4, result: Color4): Color4;
  85220. /**
  85221. * Creates a string with the Color4 current values
  85222. * @returns the string representation of the Color4 object
  85223. */
  85224. toString(): string;
  85225. /**
  85226. * Returns the string "Color4"
  85227. * @returns "Color4"
  85228. */
  85229. getClassName(): string;
  85230. /**
  85231. * Compute the Color4 hash code
  85232. * @returns an unique number that can be used to hash Color4 objects
  85233. */
  85234. getHashCode(): number;
  85235. /**
  85236. * Creates a new Color4 copied from the current one
  85237. * @returns a new Color4 object
  85238. */
  85239. clone(): Color4;
  85240. /**
  85241. * Copies the given Color4 values into the current one
  85242. * @param source defines the source Color4 object
  85243. * @returns the current updated Color4 object
  85244. */
  85245. copyFrom(source: Color4): Color4;
  85246. /**
  85247. * Copies the given float values into the current one
  85248. * @param r defines the red component to read from
  85249. * @param g defines the green component to read from
  85250. * @param b defines the blue component to read from
  85251. * @param a defines the alpha component to read from
  85252. * @returns the current updated Color4 object
  85253. */
  85254. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  85255. /**
  85256. * Copies the given float values into the current one
  85257. * @param r defines the red component to read from
  85258. * @param g defines the green component to read from
  85259. * @param b defines the blue component to read from
  85260. * @param a defines the alpha component to read from
  85261. * @returns the current updated Color4 object
  85262. */
  85263. set(r: number, g: number, b: number, a: number): Color4;
  85264. /**
  85265. * Compute the Color4 hexadecimal code as a string
  85266. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  85267. * @returns a string containing the hexadecimal representation of the Color4 object
  85268. */
  85269. toHexString(returnAsColor3?: boolean): string;
  85270. /**
  85271. * Computes a new Color4 converted from the current one to linear space
  85272. * @returns a new Color4 object
  85273. */
  85274. toLinearSpace(): Color4;
  85275. /**
  85276. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  85277. * @param convertedColor defines the Color4 object where to store the linear space version
  85278. * @returns the unmodified Color4
  85279. */
  85280. toLinearSpaceToRef(convertedColor: Color4): Color4;
  85281. /**
  85282. * Computes a new Color4 converted from the current one to gamma space
  85283. * @returns a new Color4 object
  85284. */
  85285. toGammaSpace(): Color4;
  85286. /**
  85287. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  85288. * @param convertedColor defines the Color4 object where to store the gamma space version
  85289. * @returns the unmodified Color4
  85290. */
  85291. toGammaSpaceToRef(convertedColor: Color4): Color4;
  85292. /**
  85293. * Creates a new Color4 from the string containing valid hexadecimal values
  85294. * @param hex defines a string containing valid hexadecimal values
  85295. * @returns a new Color4 object
  85296. */
  85297. static FromHexString(hex: string): Color4;
  85298. /**
  85299. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  85300. * @param left defines the start value
  85301. * @param right defines the end value
  85302. * @param amount defines the gradient factor
  85303. * @returns a new Color4 object
  85304. */
  85305. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  85306. /**
  85307. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  85308. * @param left defines the start value
  85309. * @param right defines the end value
  85310. * @param amount defines the gradient factor
  85311. * @param result defines the Color4 object where to store data
  85312. */
  85313. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  85314. /**
  85315. * Creates a new Color4 from a Color3 and an alpha value
  85316. * @param color3 defines the source Color3 to read from
  85317. * @param alpha defines the alpha component (1.0 by default)
  85318. * @returns a new Color4 object
  85319. */
  85320. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  85321. /**
  85322. * Creates a new Color4 from the starting index element of the given array
  85323. * @param array defines the source array to read from
  85324. * @param offset defines the offset in the source array
  85325. * @returns a new Color4 object
  85326. */
  85327. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  85328. /**
  85329. * Creates a new Color4 from the starting index element of the given array
  85330. * @param array defines the source array to read from
  85331. * @param offset defines the offset in the source array
  85332. * @param result defines the target Color4 object
  85333. */
  85334. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  85335. /**
  85336. * Creates a new Color3 from integer values (< 256)
  85337. * @param r defines the red component to read from (value between 0 and 255)
  85338. * @param g defines the green component to read from (value between 0 and 255)
  85339. * @param b defines the blue component to read from (value between 0 and 255)
  85340. * @param a defines the alpha component to read from (value between 0 and 255)
  85341. * @returns a new Color3 object
  85342. */
  85343. static FromInts(r: number, g: number, b: number, a: number): Color4;
  85344. /**
  85345. * Check the content of a given array and convert it to an array containing RGBA data
  85346. * If the original array was already containing count * 4 values then it is returned directly
  85347. * @param colors defines the array to check
  85348. * @param count defines the number of RGBA data to expect
  85349. * @returns an array containing count * 4 values (RGBA)
  85350. */
  85351. static CheckColors4(colors: number[], count: number): number[];
  85352. }
  85353. /**
  85354. * @hidden
  85355. */
  85356. export class TmpColors {
  85357. static Color3: Color3[];
  85358. static Color4: Color4[];
  85359. }
  85360. }
  85361. declare module BABYLON {
  85362. /**
  85363. * Defines an interface which represents an animation key frame
  85364. */
  85365. export interface IAnimationKey {
  85366. /**
  85367. * Frame of the key frame
  85368. */
  85369. frame: number;
  85370. /**
  85371. * Value at the specifies key frame
  85372. */
  85373. value: any;
  85374. /**
  85375. * The input tangent for the cubic hermite spline
  85376. */
  85377. inTangent?: any;
  85378. /**
  85379. * The output tangent for the cubic hermite spline
  85380. */
  85381. outTangent?: any;
  85382. /**
  85383. * The animation interpolation type
  85384. */
  85385. interpolation?: AnimationKeyInterpolation;
  85386. }
  85387. /**
  85388. * Enum for the animation key frame interpolation type
  85389. */
  85390. export enum AnimationKeyInterpolation {
  85391. /**
  85392. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  85393. */
  85394. STEP = 1
  85395. }
  85396. }
  85397. declare module BABYLON {
  85398. /**
  85399. * Represents the range of an animation
  85400. */
  85401. export class AnimationRange {
  85402. /**The name of the animation range**/
  85403. name: string;
  85404. /**The starting frame of the animation */
  85405. from: number;
  85406. /**The ending frame of the animation*/
  85407. to: number;
  85408. /**
  85409. * Initializes the range of an animation
  85410. * @param name The name of the animation range
  85411. * @param from The starting frame of the animation
  85412. * @param to The ending frame of the animation
  85413. */
  85414. constructor(
  85415. /**The name of the animation range**/
  85416. name: string,
  85417. /**The starting frame of the animation */
  85418. from: number,
  85419. /**The ending frame of the animation*/
  85420. to: number);
  85421. /**
  85422. * Makes a copy of the animation range
  85423. * @returns A copy of the animation range
  85424. */
  85425. clone(): AnimationRange;
  85426. }
  85427. }
  85428. declare module BABYLON {
  85429. /**
  85430. * Composed of a frame, and an action function
  85431. */
  85432. export class AnimationEvent {
  85433. /** The frame for which the event is triggered **/
  85434. frame: number;
  85435. /** The event to perform when triggered **/
  85436. action: (currentFrame: number) => void;
  85437. /** Specifies if the event should be triggered only once**/
  85438. onlyOnce?: boolean | undefined;
  85439. /**
  85440. * Specifies if the animation event is done
  85441. */
  85442. isDone: boolean;
  85443. /**
  85444. * Initializes the animation event
  85445. * @param frame The frame for which the event is triggered
  85446. * @param action The event to perform when triggered
  85447. * @param onlyOnce Specifies if the event should be triggered only once
  85448. */
  85449. constructor(
  85450. /** The frame for which the event is triggered **/
  85451. frame: number,
  85452. /** The event to perform when triggered **/
  85453. action: (currentFrame: number) => void,
  85454. /** Specifies if the event should be triggered only once**/
  85455. onlyOnce?: boolean | undefined);
  85456. /** @hidden */
  85457. _clone(): AnimationEvent;
  85458. }
  85459. }
  85460. declare module BABYLON {
  85461. /**
  85462. * Interface used to define a behavior
  85463. */
  85464. export interface Behavior<T> {
  85465. /** gets or sets behavior's name */
  85466. name: string;
  85467. /**
  85468. * Function called when the behavior needs to be initialized (after attaching it to a target)
  85469. */
  85470. init(): void;
  85471. /**
  85472. * Called when the behavior is attached to a target
  85473. * @param target defines the target where the behavior is attached to
  85474. */
  85475. attach(target: T): void;
  85476. /**
  85477. * Called when the behavior is detached from its target
  85478. */
  85479. detach(): void;
  85480. }
  85481. /**
  85482. * Interface implemented by classes supporting behaviors
  85483. */
  85484. export interface IBehaviorAware<T> {
  85485. /**
  85486. * Attach a behavior
  85487. * @param behavior defines the behavior to attach
  85488. * @returns the current host
  85489. */
  85490. addBehavior(behavior: Behavior<T>): T;
  85491. /**
  85492. * Remove a behavior from the current object
  85493. * @param behavior defines the behavior to detach
  85494. * @returns the current host
  85495. */
  85496. removeBehavior(behavior: Behavior<T>): T;
  85497. /**
  85498. * Gets a behavior using its name to search
  85499. * @param name defines the name to search
  85500. * @returns the behavior or null if not found
  85501. */
  85502. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  85503. }
  85504. }
  85505. declare module BABYLON {
  85506. /**
  85507. * Defines an array and its length.
  85508. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  85509. */
  85510. export interface ISmartArrayLike<T> {
  85511. /**
  85512. * The data of the array.
  85513. */
  85514. data: Array<T>;
  85515. /**
  85516. * The active length of the array.
  85517. */
  85518. length: number;
  85519. }
  85520. /**
  85521. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  85522. */
  85523. export class SmartArray<T> implements ISmartArrayLike<T> {
  85524. /**
  85525. * The full set of data from the array.
  85526. */
  85527. data: Array<T>;
  85528. /**
  85529. * The active length of the array.
  85530. */
  85531. length: number;
  85532. protected _id: number;
  85533. /**
  85534. * Instantiates a Smart Array.
  85535. * @param capacity defines the default capacity of the array.
  85536. */
  85537. constructor(capacity: number);
  85538. /**
  85539. * Pushes a value at the end of the active data.
  85540. * @param value defines the object to push in the array.
  85541. */
  85542. push(value: T): void;
  85543. /**
  85544. * Iterates over the active data and apply the lambda to them.
  85545. * @param func defines the action to apply on each value.
  85546. */
  85547. forEach(func: (content: T) => void): void;
  85548. /**
  85549. * Sorts the full sets of data.
  85550. * @param compareFn defines the comparison function to apply.
  85551. */
  85552. sort(compareFn: (a: T, b: T) => number): void;
  85553. /**
  85554. * Resets the active data to an empty array.
  85555. */
  85556. reset(): void;
  85557. /**
  85558. * Releases all the data from the array as well as the array.
  85559. */
  85560. dispose(): void;
  85561. /**
  85562. * Concats the active data with a given array.
  85563. * @param array defines the data to concatenate with.
  85564. */
  85565. concat(array: any): void;
  85566. /**
  85567. * Returns the position of a value in the active data.
  85568. * @param value defines the value to find the index for
  85569. * @returns the index if found in the active data otherwise -1
  85570. */
  85571. indexOf(value: T): number;
  85572. /**
  85573. * Returns whether an element is part of the active data.
  85574. * @param value defines the value to look for
  85575. * @returns true if found in the active data otherwise false
  85576. */
  85577. contains(value: T): boolean;
  85578. private static _GlobalId;
  85579. }
  85580. /**
  85581. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  85582. * The data in this array can only be present once
  85583. */
  85584. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  85585. private _duplicateId;
  85586. /**
  85587. * Pushes a value at the end of the active data.
  85588. * THIS DOES NOT PREVENT DUPPLICATE DATA
  85589. * @param value defines the object to push in the array.
  85590. */
  85591. push(value: T): void;
  85592. /**
  85593. * Pushes a value at the end of the active data.
  85594. * If the data is already present, it won t be added again
  85595. * @param value defines the object to push in the array.
  85596. * @returns true if added false if it was already present
  85597. */
  85598. pushNoDuplicate(value: T): boolean;
  85599. /**
  85600. * Resets the active data to an empty array.
  85601. */
  85602. reset(): void;
  85603. /**
  85604. * Concats the active data with a given array.
  85605. * This ensures no dupplicate will be present in the result.
  85606. * @param array defines the data to concatenate with.
  85607. */
  85608. concatWithNoDuplicate(array: any): void;
  85609. }
  85610. }
  85611. declare module BABYLON {
  85612. /**
  85613. * @ignore
  85614. * This is a list of all the different input types that are available in the application.
  85615. * Fo instance: ArcRotateCameraGamepadInput...
  85616. */
  85617. export var CameraInputTypes: {};
  85618. /**
  85619. * This is the contract to implement in order to create a new input class.
  85620. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  85621. */
  85622. export interface ICameraInput<TCamera extends Camera> {
  85623. /**
  85624. * Defines the camera the input is attached to.
  85625. */
  85626. camera: Nullable<TCamera>;
  85627. /**
  85628. * Gets the class name of the current intput.
  85629. * @returns the class name
  85630. */
  85631. getClassName(): string;
  85632. /**
  85633. * Get the friendly name associated with the input class.
  85634. * @returns the input friendly name
  85635. */
  85636. getSimpleName(): string;
  85637. /**
  85638. * Attach the input controls to a specific dom element to get the input from.
  85639. * @param element Defines the element the controls should be listened from
  85640. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  85641. */
  85642. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  85643. /**
  85644. * Detach the current controls from the specified dom element.
  85645. * @param element Defines the element to stop listening the inputs from
  85646. */
  85647. detachControl(element: Nullable<HTMLElement>): void;
  85648. /**
  85649. * Update the current camera state depending on the inputs that have been used this frame.
  85650. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  85651. */
  85652. checkInputs?: () => void;
  85653. }
  85654. /**
  85655. * Represents a map of input types to input instance or input index to input instance.
  85656. */
  85657. export interface CameraInputsMap<TCamera extends Camera> {
  85658. /**
  85659. * Accessor to the input by input type.
  85660. */
  85661. [name: string]: ICameraInput<TCamera>;
  85662. /**
  85663. * Accessor to the input by input index.
  85664. */
  85665. [idx: number]: ICameraInput<TCamera>;
  85666. }
  85667. /**
  85668. * This represents the input manager used within a camera.
  85669. * It helps dealing with all the different kind of input attached to a camera.
  85670. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  85671. */
  85672. export class CameraInputsManager<TCamera extends Camera> {
  85673. /**
  85674. * Defines the list of inputs attahed to the camera.
  85675. */
  85676. attached: CameraInputsMap<TCamera>;
  85677. /**
  85678. * Defines the dom element the camera is collecting inputs from.
  85679. * This is null if the controls have not been attached.
  85680. */
  85681. attachedElement: Nullable<HTMLElement>;
  85682. /**
  85683. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  85684. */
  85685. noPreventDefault: boolean;
  85686. /**
  85687. * Defined the camera the input manager belongs to.
  85688. */
  85689. camera: TCamera;
  85690. /**
  85691. * Update the current camera state depending on the inputs that have been used this frame.
  85692. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  85693. */
  85694. checkInputs: () => void;
  85695. /**
  85696. * Instantiate a new Camera Input Manager.
  85697. * @param camera Defines the camera the input manager blongs to
  85698. */
  85699. constructor(camera: TCamera);
  85700. /**
  85701. * Add an input method to a camera
  85702. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  85703. * @param input camera input method
  85704. */
  85705. add(input: ICameraInput<TCamera>): void;
  85706. /**
  85707. * Remove a specific input method from a camera
  85708. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  85709. * @param inputToRemove camera input method
  85710. */
  85711. remove(inputToRemove: ICameraInput<TCamera>): void;
  85712. /**
  85713. * Remove a specific input type from a camera
  85714. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  85715. * @param inputType the type of the input to remove
  85716. */
  85717. removeByType(inputType: string): void;
  85718. private _addCheckInputs;
  85719. /**
  85720. * Attach the input controls to the currently attached dom element to listen the events from.
  85721. * @param input Defines the input to attach
  85722. */
  85723. attachInput(input: ICameraInput<TCamera>): void;
  85724. /**
  85725. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  85726. * @param element Defines the dom element to collect the events from
  85727. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  85728. */
  85729. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  85730. /**
  85731. * Detach the current manager inputs controls from a specific dom element.
  85732. * @param element Defines the dom element to collect the events from
  85733. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  85734. */
  85735. detachElement(element: HTMLElement, disconnect?: boolean): void;
  85736. /**
  85737. * Rebuild the dynamic inputCheck function from the current list of
  85738. * defined inputs in the manager.
  85739. */
  85740. rebuildInputCheck(): void;
  85741. /**
  85742. * Remove all attached input methods from a camera
  85743. */
  85744. clear(): void;
  85745. /**
  85746. * Serialize the current input manager attached to a camera.
  85747. * This ensures than once parsed,
  85748. * the input associated to the camera will be identical to the current ones
  85749. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  85750. */
  85751. serialize(serializedCamera: any): void;
  85752. /**
  85753. * Parses an input manager serialized JSON to restore the previous list of inputs
  85754. * and states associated to a camera.
  85755. * @param parsedCamera Defines the JSON to parse
  85756. */
  85757. parse(parsedCamera: any): void;
  85758. }
  85759. }
  85760. declare module BABYLON {
  85761. /**
  85762. * Class used to store data that will be store in GPU memory
  85763. */
  85764. export class Buffer {
  85765. private _engine;
  85766. private _buffer;
  85767. /** @hidden */
  85768. _data: Nullable<DataArray>;
  85769. private _updatable;
  85770. private _instanced;
  85771. private _divisor;
  85772. /**
  85773. * Gets the byte stride.
  85774. */
  85775. readonly byteStride: number;
  85776. /**
  85777. * Constructor
  85778. * @param engine the engine
  85779. * @param data the data to use for this buffer
  85780. * @param updatable whether the data is updatable
  85781. * @param stride the stride (optional)
  85782. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  85783. * @param instanced whether the buffer is instanced (optional)
  85784. * @param useBytes set to true if the stride in in bytes (optional)
  85785. * @param divisor sets an optional divisor for instances (1 by default)
  85786. */
  85787. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  85788. /**
  85789. * Create a new VertexBuffer based on the current buffer
  85790. * @param kind defines the vertex buffer kind (position, normal, etc.)
  85791. * @param offset defines offset in the buffer (0 by default)
  85792. * @param size defines the size in floats of attributes (position is 3 for instance)
  85793. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  85794. * @param instanced defines if the vertex buffer contains indexed data
  85795. * @param useBytes defines if the offset and stride are in bytes *
  85796. * @param divisor sets an optional divisor for instances (1 by default)
  85797. * @returns the new vertex buffer
  85798. */
  85799. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  85800. /**
  85801. * Gets a boolean indicating if the Buffer is updatable?
  85802. * @returns true if the buffer is updatable
  85803. */
  85804. isUpdatable(): boolean;
  85805. /**
  85806. * Gets current buffer's data
  85807. * @returns a DataArray or null
  85808. */
  85809. getData(): Nullable<DataArray>;
  85810. /**
  85811. * Gets underlying native buffer
  85812. * @returns underlying native buffer
  85813. */
  85814. getBuffer(): Nullable<DataBuffer>;
  85815. /**
  85816. * Gets the stride in float32 units (i.e. byte stride / 4).
  85817. * May not be an integer if the byte stride is not divisible by 4.
  85818. * @returns the stride in float32 units
  85819. * @deprecated Please use byteStride instead.
  85820. */
  85821. getStrideSize(): number;
  85822. /**
  85823. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  85824. * @param data defines the data to store
  85825. */
  85826. create(data?: Nullable<DataArray>): void;
  85827. /** @hidden */
  85828. _rebuild(): void;
  85829. /**
  85830. * Update current buffer data
  85831. * @param data defines the data to store
  85832. */
  85833. update(data: DataArray): void;
  85834. /**
  85835. * Updates the data directly.
  85836. * @param data the new data
  85837. * @param offset the new offset
  85838. * @param vertexCount the vertex count (optional)
  85839. * @param useBytes set to true if the offset is in bytes
  85840. */
  85841. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  85842. /**
  85843. * Release all resources
  85844. */
  85845. dispose(): void;
  85846. }
  85847. /**
  85848. * Specialized buffer used to store vertex data
  85849. */
  85850. export class VertexBuffer {
  85851. /** @hidden */
  85852. _buffer: Buffer;
  85853. private _kind;
  85854. private _size;
  85855. private _ownsBuffer;
  85856. private _instanced;
  85857. private _instanceDivisor;
  85858. /**
  85859. * The byte type.
  85860. */
  85861. static readonly BYTE: number;
  85862. /**
  85863. * The unsigned byte type.
  85864. */
  85865. static readonly UNSIGNED_BYTE: number;
  85866. /**
  85867. * The short type.
  85868. */
  85869. static readonly SHORT: number;
  85870. /**
  85871. * The unsigned short type.
  85872. */
  85873. static readonly UNSIGNED_SHORT: number;
  85874. /**
  85875. * The integer type.
  85876. */
  85877. static readonly INT: number;
  85878. /**
  85879. * The unsigned integer type.
  85880. */
  85881. static readonly UNSIGNED_INT: number;
  85882. /**
  85883. * The float type.
  85884. */
  85885. static readonly FLOAT: number;
  85886. /**
  85887. * Gets or sets the instance divisor when in instanced mode
  85888. */
  85889. get instanceDivisor(): number;
  85890. set instanceDivisor(value: number);
  85891. /**
  85892. * Gets the byte stride.
  85893. */
  85894. readonly byteStride: number;
  85895. /**
  85896. * Gets the byte offset.
  85897. */
  85898. readonly byteOffset: number;
  85899. /**
  85900. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  85901. */
  85902. readonly normalized: boolean;
  85903. /**
  85904. * Gets the data type of each component in the array.
  85905. */
  85906. readonly type: number;
  85907. /**
  85908. * Constructor
  85909. * @param engine the engine
  85910. * @param data the data to use for this vertex buffer
  85911. * @param kind the vertex buffer kind
  85912. * @param updatable whether the data is updatable
  85913. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  85914. * @param stride the stride (optional)
  85915. * @param instanced whether the buffer is instanced (optional)
  85916. * @param offset the offset of the data (optional)
  85917. * @param size the number of components (optional)
  85918. * @param type the type of the component (optional)
  85919. * @param normalized whether the data contains normalized data (optional)
  85920. * @param useBytes set to true if stride and offset are in bytes (optional)
  85921. * @param divisor defines the instance divisor to use (1 by default)
  85922. */
  85923. 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);
  85924. /** @hidden */
  85925. _rebuild(): void;
  85926. /**
  85927. * Returns the kind of the VertexBuffer (string)
  85928. * @returns a string
  85929. */
  85930. getKind(): string;
  85931. /**
  85932. * Gets a boolean indicating if the VertexBuffer is updatable?
  85933. * @returns true if the buffer is updatable
  85934. */
  85935. isUpdatable(): boolean;
  85936. /**
  85937. * Gets current buffer's data
  85938. * @returns a DataArray or null
  85939. */
  85940. getData(): Nullable<DataArray>;
  85941. /**
  85942. * Gets underlying native buffer
  85943. * @returns underlying native buffer
  85944. */
  85945. getBuffer(): Nullable<DataBuffer>;
  85946. /**
  85947. * Gets the stride in float32 units (i.e. byte stride / 4).
  85948. * May not be an integer if the byte stride is not divisible by 4.
  85949. * @returns the stride in float32 units
  85950. * @deprecated Please use byteStride instead.
  85951. */
  85952. getStrideSize(): number;
  85953. /**
  85954. * Returns the offset as a multiple of the type byte length.
  85955. * @returns the offset in bytes
  85956. * @deprecated Please use byteOffset instead.
  85957. */
  85958. getOffset(): number;
  85959. /**
  85960. * Returns the number of components per vertex attribute (integer)
  85961. * @returns the size in float
  85962. */
  85963. getSize(): number;
  85964. /**
  85965. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  85966. * @returns true if this buffer is instanced
  85967. */
  85968. getIsInstanced(): boolean;
  85969. /**
  85970. * Returns the instancing divisor, zero for non-instanced (integer).
  85971. * @returns a number
  85972. */
  85973. getInstanceDivisor(): number;
  85974. /**
  85975. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  85976. * @param data defines the data to store
  85977. */
  85978. create(data?: DataArray): void;
  85979. /**
  85980. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  85981. * This function will create a new buffer if the current one is not updatable
  85982. * @param data defines the data to store
  85983. */
  85984. update(data: DataArray): void;
  85985. /**
  85986. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  85987. * Returns the directly updated WebGLBuffer.
  85988. * @param data the new data
  85989. * @param offset the new offset
  85990. * @param useBytes set to true if the offset is in bytes
  85991. */
  85992. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  85993. /**
  85994. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  85995. */
  85996. dispose(): void;
  85997. /**
  85998. * Enumerates each value of this vertex buffer as numbers.
  85999. * @param count the number of values to enumerate
  86000. * @param callback the callback function called for each value
  86001. */
  86002. forEach(count: number, callback: (value: number, index: number) => void): void;
  86003. /**
  86004. * Positions
  86005. */
  86006. static readonly PositionKind: string;
  86007. /**
  86008. * Normals
  86009. */
  86010. static readonly NormalKind: string;
  86011. /**
  86012. * Tangents
  86013. */
  86014. static readonly TangentKind: string;
  86015. /**
  86016. * Texture coordinates
  86017. */
  86018. static readonly UVKind: string;
  86019. /**
  86020. * Texture coordinates 2
  86021. */
  86022. static readonly UV2Kind: string;
  86023. /**
  86024. * Texture coordinates 3
  86025. */
  86026. static readonly UV3Kind: string;
  86027. /**
  86028. * Texture coordinates 4
  86029. */
  86030. static readonly UV4Kind: string;
  86031. /**
  86032. * Texture coordinates 5
  86033. */
  86034. static readonly UV5Kind: string;
  86035. /**
  86036. * Texture coordinates 6
  86037. */
  86038. static readonly UV6Kind: string;
  86039. /**
  86040. * Colors
  86041. */
  86042. static readonly ColorKind: string;
  86043. /**
  86044. * Matrix indices (for bones)
  86045. */
  86046. static readonly MatricesIndicesKind: string;
  86047. /**
  86048. * Matrix weights (for bones)
  86049. */
  86050. static readonly MatricesWeightsKind: string;
  86051. /**
  86052. * Additional matrix indices (for bones)
  86053. */
  86054. static readonly MatricesIndicesExtraKind: string;
  86055. /**
  86056. * Additional matrix weights (for bones)
  86057. */
  86058. static readonly MatricesWeightsExtraKind: string;
  86059. /**
  86060. * Deduces the stride given a kind.
  86061. * @param kind The kind string to deduce
  86062. * @returns The deduced stride
  86063. */
  86064. static DeduceStride(kind: string): number;
  86065. /**
  86066. * Gets the byte length of the given type.
  86067. * @param type the type
  86068. * @returns the number of bytes
  86069. */
  86070. static GetTypeByteLength(type: number): number;
  86071. /**
  86072. * Enumerates each value of the given parameters as numbers.
  86073. * @param data the data to enumerate
  86074. * @param byteOffset the byte offset of the data
  86075. * @param byteStride the byte stride of the data
  86076. * @param componentCount the number of components per element
  86077. * @param componentType the type of the component
  86078. * @param count the number of values to enumerate
  86079. * @param normalized whether the data is normalized
  86080. * @param callback the callback function called for each value
  86081. */
  86082. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  86083. private static _GetFloatValue;
  86084. }
  86085. }
  86086. declare module BABYLON {
  86087. /**
  86088. * @hidden
  86089. */
  86090. export class IntersectionInfo {
  86091. bu: Nullable<number>;
  86092. bv: Nullable<number>;
  86093. distance: number;
  86094. faceId: number;
  86095. subMeshId: number;
  86096. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  86097. }
  86098. }
  86099. declare module BABYLON {
  86100. /**
  86101. * Class used to store bounding sphere information
  86102. */
  86103. export class BoundingSphere {
  86104. /**
  86105. * Gets the center of the bounding sphere in local space
  86106. */
  86107. readonly center: Vector3;
  86108. /**
  86109. * Radius of the bounding sphere in local space
  86110. */
  86111. radius: number;
  86112. /**
  86113. * Gets the center of the bounding sphere in world space
  86114. */
  86115. readonly centerWorld: Vector3;
  86116. /**
  86117. * Radius of the bounding sphere in world space
  86118. */
  86119. radiusWorld: number;
  86120. /**
  86121. * Gets the minimum vector in local space
  86122. */
  86123. readonly minimum: Vector3;
  86124. /**
  86125. * Gets the maximum vector in local space
  86126. */
  86127. readonly maximum: Vector3;
  86128. private _worldMatrix;
  86129. private static readonly TmpVector3;
  86130. /**
  86131. * Creates a new bounding sphere
  86132. * @param min defines the minimum vector (in local space)
  86133. * @param max defines the maximum vector (in local space)
  86134. * @param worldMatrix defines the new world matrix
  86135. */
  86136. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  86137. /**
  86138. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  86139. * @param min defines the new minimum vector (in local space)
  86140. * @param max defines the new maximum vector (in local space)
  86141. * @param worldMatrix defines the new world matrix
  86142. */
  86143. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  86144. /**
  86145. * Scale the current bounding sphere by applying a scale factor
  86146. * @param factor defines the scale factor to apply
  86147. * @returns the current bounding box
  86148. */
  86149. scale(factor: number): BoundingSphere;
  86150. /**
  86151. * Gets the world matrix of the bounding box
  86152. * @returns a matrix
  86153. */
  86154. getWorldMatrix(): DeepImmutable<Matrix>;
  86155. /** @hidden */
  86156. _update(worldMatrix: DeepImmutable<Matrix>): void;
  86157. /**
  86158. * Tests if the bounding sphere is intersecting the frustum planes
  86159. * @param frustumPlanes defines the frustum planes to test
  86160. * @returns true if there is an intersection
  86161. */
  86162. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  86163. /**
  86164. * Tests if the bounding sphere center is in between the frustum planes.
  86165. * Used for optimistic fast inclusion.
  86166. * @param frustumPlanes defines the frustum planes to test
  86167. * @returns true if the sphere center is in between the frustum planes
  86168. */
  86169. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  86170. /**
  86171. * Tests if a point is inside the bounding sphere
  86172. * @param point defines the point to test
  86173. * @returns true if the point is inside the bounding sphere
  86174. */
  86175. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  86176. /**
  86177. * Checks if two sphere intersct
  86178. * @param sphere0 sphere 0
  86179. * @param sphere1 sphere 1
  86180. * @returns true if the speres intersect
  86181. */
  86182. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  86183. }
  86184. }
  86185. declare module BABYLON {
  86186. /**
  86187. * Class used to store bounding box information
  86188. */
  86189. export class BoundingBox implements ICullable {
  86190. /**
  86191. * Gets the 8 vectors representing the bounding box in local space
  86192. */
  86193. readonly vectors: Vector3[];
  86194. /**
  86195. * Gets the center of the bounding box in local space
  86196. */
  86197. readonly center: Vector3;
  86198. /**
  86199. * Gets the center of the bounding box in world space
  86200. */
  86201. readonly centerWorld: Vector3;
  86202. /**
  86203. * Gets the extend size in local space
  86204. */
  86205. readonly extendSize: Vector3;
  86206. /**
  86207. * Gets the extend size in world space
  86208. */
  86209. readonly extendSizeWorld: Vector3;
  86210. /**
  86211. * Gets the OBB (object bounding box) directions
  86212. */
  86213. readonly directions: Vector3[];
  86214. /**
  86215. * Gets the 8 vectors representing the bounding box in world space
  86216. */
  86217. readonly vectorsWorld: Vector3[];
  86218. /**
  86219. * Gets the minimum vector in world space
  86220. */
  86221. readonly minimumWorld: Vector3;
  86222. /**
  86223. * Gets the maximum vector in world space
  86224. */
  86225. readonly maximumWorld: Vector3;
  86226. /**
  86227. * Gets the minimum vector in local space
  86228. */
  86229. readonly minimum: Vector3;
  86230. /**
  86231. * Gets the maximum vector in local space
  86232. */
  86233. readonly maximum: Vector3;
  86234. private _worldMatrix;
  86235. private static readonly TmpVector3;
  86236. /**
  86237. * @hidden
  86238. */
  86239. _tag: number;
  86240. /**
  86241. * Creates a new bounding box
  86242. * @param min defines the minimum vector (in local space)
  86243. * @param max defines the maximum vector (in local space)
  86244. * @param worldMatrix defines the new world matrix
  86245. */
  86246. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  86247. /**
  86248. * Recreates the entire bounding box from scratch as if we call the constructor in place
  86249. * @param min defines the new minimum vector (in local space)
  86250. * @param max defines the new maximum vector (in local space)
  86251. * @param worldMatrix defines the new world matrix
  86252. */
  86253. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  86254. /**
  86255. * Scale the current bounding box by applying a scale factor
  86256. * @param factor defines the scale factor to apply
  86257. * @returns the current bounding box
  86258. */
  86259. scale(factor: number): BoundingBox;
  86260. /**
  86261. * Gets the world matrix of the bounding box
  86262. * @returns a matrix
  86263. */
  86264. getWorldMatrix(): DeepImmutable<Matrix>;
  86265. /** @hidden */
  86266. _update(world: DeepImmutable<Matrix>): void;
  86267. /**
  86268. * Tests if the bounding box is intersecting the frustum planes
  86269. * @param frustumPlanes defines the frustum planes to test
  86270. * @returns true if there is an intersection
  86271. */
  86272. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  86273. /**
  86274. * Tests if the bounding box is entirely inside the frustum planes
  86275. * @param frustumPlanes defines the frustum planes to test
  86276. * @returns true if there is an inclusion
  86277. */
  86278. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  86279. /**
  86280. * Tests if a point is inside the bounding box
  86281. * @param point defines the point to test
  86282. * @returns true if the point is inside the bounding box
  86283. */
  86284. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  86285. /**
  86286. * Tests if the bounding box intersects with a bounding sphere
  86287. * @param sphere defines the sphere to test
  86288. * @returns true if there is an intersection
  86289. */
  86290. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  86291. /**
  86292. * Tests if the bounding box intersects with a box defined by a min and max vectors
  86293. * @param min defines the min vector to use
  86294. * @param max defines the max vector to use
  86295. * @returns true if there is an intersection
  86296. */
  86297. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  86298. /**
  86299. * Tests if two bounding boxes are intersections
  86300. * @param box0 defines the first box to test
  86301. * @param box1 defines the second box to test
  86302. * @returns true if there is an intersection
  86303. */
  86304. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  86305. /**
  86306. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  86307. * @param minPoint defines the minimum vector of the bounding box
  86308. * @param maxPoint defines the maximum vector of the bounding box
  86309. * @param sphereCenter defines the sphere center
  86310. * @param sphereRadius defines the sphere radius
  86311. * @returns true if there is an intersection
  86312. */
  86313. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  86314. /**
  86315. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  86316. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  86317. * @param frustumPlanes defines the frustum planes to test
  86318. * @return true if there is an inclusion
  86319. */
  86320. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  86321. /**
  86322. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  86323. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  86324. * @param frustumPlanes defines the frustum planes to test
  86325. * @return true if there is an intersection
  86326. */
  86327. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  86328. }
  86329. }
  86330. declare module BABYLON {
  86331. /** @hidden */
  86332. export class Collider {
  86333. /** Define if a collision was found */
  86334. collisionFound: boolean;
  86335. /**
  86336. * Define last intersection point in local space
  86337. */
  86338. intersectionPoint: Vector3;
  86339. /**
  86340. * Define last collided mesh
  86341. */
  86342. collidedMesh: Nullable<AbstractMesh>;
  86343. private _collisionPoint;
  86344. private _planeIntersectionPoint;
  86345. private _tempVector;
  86346. private _tempVector2;
  86347. private _tempVector3;
  86348. private _tempVector4;
  86349. private _edge;
  86350. private _baseToVertex;
  86351. private _destinationPoint;
  86352. private _slidePlaneNormal;
  86353. private _displacementVector;
  86354. /** @hidden */
  86355. _radius: Vector3;
  86356. /** @hidden */
  86357. _retry: number;
  86358. private _velocity;
  86359. private _basePoint;
  86360. private _epsilon;
  86361. /** @hidden */
  86362. _velocityWorldLength: number;
  86363. /** @hidden */
  86364. _basePointWorld: Vector3;
  86365. private _velocityWorld;
  86366. private _normalizedVelocity;
  86367. /** @hidden */
  86368. _initialVelocity: Vector3;
  86369. /** @hidden */
  86370. _initialPosition: Vector3;
  86371. private _nearestDistance;
  86372. private _collisionMask;
  86373. get collisionMask(): number;
  86374. set collisionMask(mask: number);
  86375. /**
  86376. * Gets the plane normal used to compute the sliding response (in local space)
  86377. */
  86378. get slidePlaneNormal(): Vector3;
  86379. /** @hidden */
  86380. _initialize(source: Vector3, dir: Vector3, e: number): void;
  86381. /** @hidden */
  86382. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  86383. /** @hidden */
  86384. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  86385. /** @hidden */
  86386. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  86387. /** @hidden */
  86388. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  86389. /** @hidden */
  86390. _getResponse(pos: Vector3, vel: Vector3): void;
  86391. }
  86392. }
  86393. declare module BABYLON {
  86394. /**
  86395. * Interface for cullable objects
  86396. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  86397. */
  86398. export interface ICullable {
  86399. /**
  86400. * Checks if the object or part of the object is in the frustum
  86401. * @param frustumPlanes Camera near/planes
  86402. * @returns true if the object is in frustum otherwise false
  86403. */
  86404. isInFrustum(frustumPlanes: Plane[]): boolean;
  86405. /**
  86406. * Checks if a cullable object (mesh...) is in the camera frustum
  86407. * Unlike isInFrustum this cheks the full bounding box
  86408. * @param frustumPlanes Camera near/planes
  86409. * @returns true if the object is in frustum otherwise false
  86410. */
  86411. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  86412. }
  86413. /**
  86414. * Info for a bounding data of a mesh
  86415. */
  86416. export class BoundingInfo implements ICullable {
  86417. /**
  86418. * Bounding box for the mesh
  86419. */
  86420. readonly boundingBox: BoundingBox;
  86421. /**
  86422. * Bounding sphere for the mesh
  86423. */
  86424. readonly boundingSphere: BoundingSphere;
  86425. private _isLocked;
  86426. private static readonly TmpVector3;
  86427. /**
  86428. * Constructs bounding info
  86429. * @param minimum min vector of the bounding box/sphere
  86430. * @param maximum max vector of the bounding box/sphere
  86431. * @param worldMatrix defines the new world matrix
  86432. */
  86433. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  86434. /**
  86435. * Recreates the entire bounding info from scratch as if we call the constructor in place
  86436. * @param min defines the new minimum vector (in local space)
  86437. * @param max defines the new maximum vector (in local space)
  86438. * @param worldMatrix defines the new world matrix
  86439. */
  86440. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  86441. /**
  86442. * min vector of the bounding box/sphere
  86443. */
  86444. get minimum(): Vector3;
  86445. /**
  86446. * max vector of the bounding box/sphere
  86447. */
  86448. get maximum(): Vector3;
  86449. /**
  86450. * If the info is locked and won't be updated to avoid perf overhead
  86451. */
  86452. get isLocked(): boolean;
  86453. set isLocked(value: boolean);
  86454. /**
  86455. * Updates the bounding sphere and box
  86456. * @param world world matrix to be used to update
  86457. */
  86458. update(world: DeepImmutable<Matrix>): void;
  86459. /**
  86460. * Recreate the bounding info to be centered around a specific point given a specific extend.
  86461. * @param center New center of the bounding info
  86462. * @param extend New extend of the bounding info
  86463. * @returns the current bounding info
  86464. */
  86465. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  86466. /**
  86467. * Scale the current bounding info by applying a scale factor
  86468. * @param factor defines the scale factor to apply
  86469. * @returns the current bounding info
  86470. */
  86471. scale(factor: number): BoundingInfo;
  86472. /**
  86473. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  86474. * @param frustumPlanes defines the frustum to test
  86475. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  86476. * @returns true if the bounding info is in the frustum planes
  86477. */
  86478. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  86479. /**
  86480. * Gets the world distance between the min and max points of the bounding box
  86481. */
  86482. get diagonalLength(): number;
  86483. /**
  86484. * Checks if a cullable object (mesh...) is in the camera frustum
  86485. * Unlike isInFrustum this cheks the full bounding box
  86486. * @param frustumPlanes Camera near/planes
  86487. * @returns true if the object is in frustum otherwise false
  86488. */
  86489. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  86490. /** @hidden */
  86491. _checkCollision(collider: Collider): boolean;
  86492. /**
  86493. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  86494. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  86495. * @param point the point to check intersection with
  86496. * @returns if the point intersects
  86497. */
  86498. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  86499. /**
  86500. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  86501. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  86502. * @param boundingInfo the bounding info to check intersection with
  86503. * @param precise if the intersection should be done using OBB
  86504. * @returns if the bounding info intersects
  86505. */
  86506. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  86507. }
  86508. }
  86509. declare module BABYLON {
  86510. /**
  86511. * Extracts minimum and maximum values from a list of indexed positions
  86512. * @param positions defines the positions to use
  86513. * @param indices defines the indices to the positions
  86514. * @param indexStart defines the start index
  86515. * @param indexCount defines the end index
  86516. * @param bias defines bias value to add to the result
  86517. * @return minimum and maximum values
  86518. */
  86519. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  86520. minimum: Vector3;
  86521. maximum: Vector3;
  86522. };
  86523. /**
  86524. * Extracts minimum and maximum values from a list of positions
  86525. * @param positions defines the positions to use
  86526. * @param start defines the start index in the positions array
  86527. * @param count defines the number of positions to handle
  86528. * @param bias defines bias value to add to the result
  86529. * @param stride defines the stride size to use (distance between two positions in the positions array)
  86530. * @return minimum and maximum values
  86531. */
  86532. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  86533. minimum: Vector3;
  86534. maximum: Vector3;
  86535. };
  86536. }
  86537. declare module BABYLON {
  86538. /** @hidden */
  86539. export class WebGLDataBuffer extends DataBuffer {
  86540. private _buffer;
  86541. constructor(resource: WebGLBuffer);
  86542. get underlyingResource(): any;
  86543. }
  86544. }
  86545. declare module BABYLON {
  86546. /** @hidden */
  86547. export class WebGLPipelineContext implements IPipelineContext {
  86548. engine: ThinEngine;
  86549. program: Nullable<WebGLProgram>;
  86550. context?: WebGLRenderingContext;
  86551. vertexShader?: WebGLShader;
  86552. fragmentShader?: WebGLShader;
  86553. isParallelCompiled: boolean;
  86554. onCompiled?: () => void;
  86555. transformFeedback?: WebGLTransformFeedback | null;
  86556. vertexCompilationError: Nullable<string>;
  86557. fragmentCompilationError: Nullable<string>;
  86558. programLinkError: Nullable<string>;
  86559. programValidationError: Nullable<string>;
  86560. get isAsync(): boolean;
  86561. get isReady(): boolean;
  86562. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  86563. _getVertexShaderCode(): string | null;
  86564. _getFragmentShaderCode(): string | null;
  86565. }
  86566. }
  86567. declare module BABYLON {
  86568. interface ThinEngine {
  86569. /**
  86570. * Create an uniform buffer
  86571. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  86572. * @param elements defines the content of the uniform buffer
  86573. * @returns the webGL uniform buffer
  86574. */
  86575. createUniformBuffer(elements: FloatArray): DataBuffer;
  86576. /**
  86577. * Create a dynamic uniform buffer
  86578. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  86579. * @param elements defines the content of the uniform buffer
  86580. * @returns the webGL uniform buffer
  86581. */
  86582. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  86583. /**
  86584. * Update an existing uniform buffer
  86585. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  86586. * @param uniformBuffer defines the target uniform buffer
  86587. * @param elements defines the content to update
  86588. * @param offset defines the offset in the uniform buffer where update should start
  86589. * @param count defines the size of the data to update
  86590. */
  86591. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  86592. /**
  86593. * Bind an uniform buffer to the current webGL context
  86594. * @param buffer defines the buffer to bind
  86595. */
  86596. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  86597. /**
  86598. * Bind a buffer to the current webGL context at a given location
  86599. * @param buffer defines the buffer to bind
  86600. * @param location defines the index where to bind the buffer
  86601. */
  86602. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  86603. /**
  86604. * Bind a specific block at a given index in a specific shader program
  86605. * @param pipelineContext defines the pipeline context to use
  86606. * @param blockName defines the block name
  86607. * @param index defines the index where to bind the block
  86608. */
  86609. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  86610. }
  86611. }
  86612. declare module BABYLON {
  86613. /**
  86614. * Uniform buffer objects.
  86615. *
  86616. * Handles blocks of uniform on the GPU.
  86617. *
  86618. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  86619. *
  86620. * For more information, please refer to :
  86621. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  86622. */
  86623. export class UniformBuffer {
  86624. private _engine;
  86625. private _buffer;
  86626. private _data;
  86627. private _bufferData;
  86628. private _dynamic?;
  86629. private _uniformLocations;
  86630. private _uniformSizes;
  86631. private _uniformLocationPointer;
  86632. private _needSync;
  86633. private _noUBO;
  86634. private _currentEffect;
  86635. /** @hidden */
  86636. _alreadyBound: boolean;
  86637. private static _MAX_UNIFORM_SIZE;
  86638. private static _tempBuffer;
  86639. /**
  86640. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  86641. * This is dynamic to allow compat with webgl 1 and 2.
  86642. * You will need to pass the name of the uniform as well as the value.
  86643. */
  86644. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  86645. /**
  86646. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  86647. * This is dynamic to allow compat with webgl 1 and 2.
  86648. * You will need to pass the name of the uniform as well as the value.
  86649. */
  86650. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  86651. /**
  86652. * Lambda to Update a single float in a uniform buffer.
  86653. * This is dynamic to allow compat with webgl 1 and 2.
  86654. * You will need to pass the name of the uniform as well as the value.
  86655. */
  86656. updateFloat: (name: string, x: number) => void;
  86657. /**
  86658. * Lambda to Update a vec2 of float in a uniform buffer.
  86659. * This is dynamic to allow compat with webgl 1 and 2.
  86660. * You will need to pass the name of the uniform as well as the value.
  86661. */
  86662. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  86663. /**
  86664. * Lambda to Update a vec3 of float in a uniform buffer.
  86665. * This is dynamic to allow compat with webgl 1 and 2.
  86666. * You will need to pass the name of the uniform as well as the value.
  86667. */
  86668. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  86669. /**
  86670. * Lambda to Update a vec4 of float in a uniform buffer.
  86671. * This is dynamic to allow compat with webgl 1 and 2.
  86672. * You will need to pass the name of the uniform as well as the value.
  86673. */
  86674. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  86675. /**
  86676. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  86677. * This is dynamic to allow compat with webgl 1 and 2.
  86678. * You will need to pass the name of the uniform as well as the value.
  86679. */
  86680. updateMatrix: (name: string, mat: Matrix) => void;
  86681. /**
  86682. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  86683. * This is dynamic to allow compat with webgl 1 and 2.
  86684. * You will need to pass the name of the uniform as well as the value.
  86685. */
  86686. updateVector3: (name: string, vector: Vector3) => void;
  86687. /**
  86688. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  86689. * This is dynamic to allow compat with webgl 1 and 2.
  86690. * You will need to pass the name of the uniform as well as the value.
  86691. */
  86692. updateVector4: (name: string, vector: Vector4) => void;
  86693. /**
  86694. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  86695. * This is dynamic to allow compat with webgl 1 and 2.
  86696. * You will need to pass the name of the uniform as well as the value.
  86697. */
  86698. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  86699. /**
  86700. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  86701. * This is dynamic to allow compat with webgl 1 and 2.
  86702. * You will need to pass the name of the uniform as well as the value.
  86703. */
  86704. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  86705. /**
  86706. * Instantiates a new Uniform buffer objects.
  86707. *
  86708. * Handles blocks of uniform on the GPU.
  86709. *
  86710. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  86711. *
  86712. * For more information, please refer to :
  86713. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  86714. * @param engine Define the engine the buffer is associated with
  86715. * @param data Define the data contained in the buffer
  86716. * @param dynamic Define if the buffer is updatable
  86717. */
  86718. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  86719. /**
  86720. * Indicates if the buffer is using the WebGL2 UBO implementation,
  86721. * or just falling back on setUniformXXX calls.
  86722. */
  86723. get useUbo(): boolean;
  86724. /**
  86725. * Indicates if the WebGL underlying uniform buffer is in sync
  86726. * with the javascript cache data.
  86727. */
  86728. get isSync(): boolean;
  86729. /**
  86730. * Indicates if the WebGL underlying uniform buffer is dynamic.
  86731. * Also, a dynamic UniformBuffer will disable cache verification and always
  86732. * update the underlying WebGL uniform buffer to the GPU.
  86733. * @returns if Dynamic, otherwise false
  86734. */
  86735. isDynamic(): boolean;
  86736. /**
  86737. * The data cache on JS side.
  86738. * @returns the underlying data as a float array
  86739. */
  86740. getData(): Float32Array;
  86741. /**
  86742. * The underlying WebGL Uniform buffer.
  86743. * @returns the webgl buffer
  86744. */
  86745. getBuffer(): Nullable<DataBuffer>;
  86746. /**
  86747. * std140 layout specifies how to align data within an UBO structure.
  86748. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  86749. * for specs.
  86750. */
  86751. private _fillAlignment;
  86752. /**
  86753. * Adds an uniform in the buffer.
  86754. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  86755. * for the layout to be correct !
  86756. * @param name Name of the uniform, as used in the uniform block in the shader.
  86757. * @param size Data size, or data directly.
  86758. */
  86759. addUniform(name: string, size: number | number[]): void;
  86760. /**
  86761. * Adds a Matrix 4x4 to the uniform buffer.
  86762. * @param name Name of the uniform, as used in the uniform block in the shader.
  86763. * @param mat A 4x4 matrix.
  86764. */
  86765. addMatrix(name: string, mat: Matrix): void;
  86766. /**
  86767. * Adds a vec2 to the uniform buffer.
  86768. * @param name Name of the uniform, as used in the uniform block in the shader.
  86769. * @param x Define the x component value of the vec2
  86770. * @param y Define the y component value of the vec2
  86771. */
  86772. addFloat2(name: string, x: number, y: number): void;
  86773. /**
  86774. * Adds a vec3 to the uniform buffer.
  86775. * @param name Name of the uniform, as used in the uniform block in the shader.
  86776. * @param x Define the x component value of the vec3
  86777. * @param y Define the y component value of the vec3
  86778. * @param z Define the z component value of the vec3
  86779. */
  86780. addFloat3(name: string, x: number, y: number, z: number): void;
  86781. /**
  86782. * Adds a vec3 to the uniform buffer.
  86783. * @param name Name of the uniform, as used in the uniform block in the shader.
  86784. * @param color Define the vec3 from a Color
  86785. */
  86786. addColor3(name: string, color: Color3): void;
  86787. /**
  86788. * Adds a vec4 to the uniform buffer.
  86789. * @param name Name of the uniform, as used in the uniform block in the shader.
  86790. * @param color Define the rgb components from a Color
  86791. * @param alpha Define the a component of the vec4
  86792. */
  86793. addColor4(name: string, color: Color3, alpha: number): void;
  86794. /**
  86795. * Adds a vec3 to the uniform buffer.
  86796. * @param name Name of the uniform, as used in the uniform block in the shader.
  86797. * @param vector Define the vec3 components from a Vector
  86798. */
  86799. addVector3(name: string, vector: Vector3): void;
  86800. /**
  86801. * Adds a Matrix 3x3 to the uniform buffer.
  86802. * @param name Name of the uniform, as used in the uniform block in the shader.
  86803. */
  86804. addMatrix3x3(name: string): void;
  86805. /**
  86806. * Adds a Matrix 2x2 to the uniform buffer.
  86807. * @param name Name of the uniform, as used in the uniform block in the shader.
  86808. */
  86809. addMatrix2x2(name: string): void;
  86810. /**
  86811. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  86812. */
  86813. create(): void;
  86814. /** @hidden */
  86815. _rebuild(): void;
  86816. /**
  86817. * Updates the WebGL Uniform Buffer on the GPU.
  86818. * If the `dynamic` flag is set to true, no cache comparison is done.
  86819. * Otherwise, the buffer will be updated only if the cache differs.
  86820. */
  86821. update(): void;
  86822. /**
  86823. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  86824. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  86825. * @param data Define the flattened data
  86826. * @param size Define the size of the data.
  86827. */
  86828. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  86829. private _valueCache;
  86830. private _cacheMatrix;
  86831. private _updateMatrix3x3ForUniform;
  86832. private _updateMatrix3x3ForEffect;
  86833. private _updateMatrix2x2ForEffect;
  86834. private _updateMatrix2x2ForUniform;
  86835. private _updateFloatForEffect;
  86836. private _updateFloatForUniform;
  86837. private _updateFloat2ForEffect;
  86838. private _updateFloat2ForUniform;
  86839. private _updateFloat3ForEffect;
  86840. private _updateFloat3ForUniform;
  86841. private _updateFloat4ForEffect;
  86842. private _updateFloat4ForUniform;
  86843. private _updateMatrixForEffect;
  86844. private _updateMatrixForUniform;
  86845. private _updateVector3ForEffect;
  86846. private _updateVector3ForUniform;
  86847. private _updateVector4ForEffect;
  86848. private _updateVector4ForUniform;
  86849. private _updateColor3ForEffect;
  86850. private _updateColor3ForUniform;
  86851. private _updateColor4ForEffect;
  86852. private _updateColor4ForUniform;
  86853. /**
  86854. * Sets a sampler uniform on the effect.
  86855. * @param name Define the name of the sampler.
  86856. * @param texture Define the texture to set in the sampler
  86857. */
  86858. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  86859. /**
  86860. * Directly updates the value of the uniform in the cache AND on the GPU.
  86861. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  86862. * @param data Define the flattened data
  86863. */
  86864. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  86865. /**
  86866. * Binds this uniform buffer to an effect.
  86867. * @param effect Define the effect to bind the buffer to
  86868. * @param name Name of the uniform block in the shader.
  86869. */
  86870. bindToEffect(effect: Effect, name: string): void;
  86871. /**
  86872. * Disposes the uniform buffer.
  86873. */
  86874. dispose(): void;
  86875. }
  86876. }
  86877. declare module BABYLON {
  86878. /**
  86879. * Enum that determines the text-wrapping mode to use.
  86880. */
  86881. export enum InspectableType {
  86882. /**
  86883. * Checkbox for booleans
  86884. */
  86885. Checkbox = 0,
  86886. /**
  86887. * Sliders for numbers
  86888. */
  86889. Slider = 1,
  86890. /**
  86891. * Vector3
  86892. */
  86893. Vector3 = 2,
  86894. /**
  86895. * Quaternions
  86896. */
  86897. Quaternion = 3,
  86898. /**
  86899. * Color3
  86900. */
  86901. Color3 = 4,
  86902. /**
  86903. * String
  86904. */
  86905. String = 5
  86906. }
  86907. /**
  86908. * Interface used to define custom inspectable properties.
  86909. * This interface is used by the inspector to display custom property grids
  86910. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  86911. */
  86912. export interface IInspectable {
  86913. /**
  86914. * Gets the label to display
  86915. */
  86916. label: string;
  86917. /**
  86918. * Gets the name of the property to edit
  86919. */
  86920. propertyName: string;
  86921. /**
  86922. * Gets the type of the editor to use
  86923. */
  86924. type: InspectableType;
  86925. /**
  86926. * Gets the minimum value of the property when using in "slider" mode
  86927. */
  86928. min?: number;
  86929. /**
  86930. * Gets the maximum value of the property when using in "slider" mode
  86931. */
  86932. max?: number;
  86933. /**
  86934. * Gets the setp to use when using in "slider" mode
  86935. */
  86936. step?: number;
  86937. }
  86938. }
  86939. declare module BABYLON {
  86940. /**
  86941. * Class used to provide helper for timing
  86942. */
  86943. export class TimingTools {
  86944. /**
  86945. * Polyfill for setImmediate
  86946. * @param action defines the action to execute after the current execution block
  86947. */
  86948. static SetImmediate(action: () => void): void;
  86949. }
  86950. }
  86951. declare module BABYLON {
  86952. /**
  86953. * Class used to enable instatition of objects by class name
  86954. */
  86955. export class InstantiationTools {
  86956. /**
  86957. * Use this object to register external classes like custom textures or material
  86958. * to allow the laoders to instantiate them
  86959. */
  86960. static RegisteredExternalClasses: {
  86961. [key: string]: Object;
  86962. };
  86963. /**
  86964. * Tries to instantiate a new object from a given class name
  86965. * @param className defines the class name to instantiate
  86966. * @returns the new object or null if the system was not able to do the instantiation
  86967. */
  86968. static Instantiate(className: string): any;
  86969. }
  86970. }
  86971. declare module BABYLON {
  86972. /**
  86973. * Define options used to create a depth texture
  86974. */
  86975. export class DepthTextureCreationOptions {
  86976. /** Specifies whether or not a stencil should be allocated in the texture */
  86977. generateStencil?: boolean;
  86978. /** Specifies whether or not bilinear filtering is enable on the texture */
  86979. bilinearFiltering?: boolean;
  86980. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  86981. comparisonFunction?: number;
  86982. /** Specifies if the created texture is a cube texture */
  86983. isCube?: boolean;
  86984. }
  86985. }
  86986. declare module BABYLON {
  86987. interface ThinEngine {
  86988. /**
  86989. * Creates a depth stencil cube texture.
  86990. * This is only available in WebGL 2.
  86991. * @param size The size of face edge in the cube texture.
  86992. * @param options The options defining the cube texture.
  86993. * @returns The cube texture
  86994. */
  86995. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  86996. /**
  86997. * Creates a cube texture
  86998. * @param rootUrl defines the url where the files to load is located
  86999. * @param scene defines the current scene
  87000. * @param files defines the list of files to load (1 per face)
  87001. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  87002. * @param onLoad defines an optional callback raised when the texture is loaded
  87003. * @param onError defines an optional callback raised if there is an issue to load the texture
  87004. * @param format defines the format of the data
  87005. * @param forcedExtension defines the extension to use to pick the right loader
  87006. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  87007. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  87008. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  87009. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  87010. * @returns the cube texture as an InternalTexture
  87011. */
  87012. 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;
  87013. /**
  87014. * Creates a cube texture
  87015. * @param rootUrl defines the url where the files to load is located
  87016. * @param scene defines the current scene
  87017. * @param files defines the list of files to load (1 per face)
  87018. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  87019. * @param onLoad defines an optional callback raised when the texture is loaded
  87020. * @param onError defines an optional callback raised if there is an issue to load the texture
  87021. * @param format defines the format of the data
  87022. * @param forcedExtension defines the extension to use to pick the right loader
  87023. * @returns the cube texture as an InternalTexture
  87024. */
  87025. 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;
  87026. /**
  87027. * Creates a cube texture
  87028. * @param rootUrl defines the url where the files to load is located
  87029. * @param scene defines the current scene
  87030. * @param files defines the list of files to load (1 per face)
  87031. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  87032. * @param onLoad defines an optional callback raised when the texture is loaded
  87033. * @param onError defines an optional callback raised if there is an issue to load the texture
  87034. * @param format defines the format of the data
  87035. * @param forcedExtension defines the extension to use to pick the right loader
  87036. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  87037. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  87038. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  87039. * @returns the cube texture as an InternalTexture
  87040. */
  87041. 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;
  87042. /** @hidden */
  87043. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  87044. /** @hidden */
  87045. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  87046. /** @hidden */
  87047. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  87048. /** @hidden */
  87049. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  87050. /**
  87051. * @hidden
  87052. */
  87053. _setCubeMapTextureParams(loadMipmap: boolean): void;
  87054. }
  87055. }
  87056. declare module BABYLON {
  87057. /**
  87058. * Class for creating a cube texture
  87059. */
  87060. export class CubeTexture extends BaseTexture {
  87061. private _delayedOnLoad;
  87062. /**
  87063. * Observable triggered once the texture has been loaded.
  87064. */
  87065. onLoadObservable: Observable<CubeTexture>;
  87066. /**
  87067. * The url of the texture
  87068. */
  87069. url: string;
  87070. /**
  87071. * Gets or sets the center of the bounding box associated with the cube texture.
  87072. * It must define where the camera used to render the texture was set
  87073. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  87074. */
  87075. boundingBoxPosition: Vector3;
  87076. private _boundingBoxSize;
  87077. /**
  87078. * Gets or sets the size of the bounding box associated with the cube texture
  87079. * When defined, the cubemap will switch to local mode
  87080. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  87081. * @example https://www.babylonjs-playground.com/#RNASML
  87082. */
  87083. set boundingBoxSize(value: Vector3);
  87084. /**
  87085. * Returns the bounding box size
  87086. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  87087. */
  87088. get boundingBoxSize(): Vector3;
  87089. protected _rotationY: number;
  87090. /**
  87091. * Sets texture matrix rotation angle around Y axis in radians.
  87092. */
  87093. set rotationY(value: number);
  87094. /**
  87095. * Gets texture matrix rotation angle around Y axis radians.
  87096. */
  87097. get rotationY(): number;
  87098. /**
  87099. * Are mip maps generated for this texture or not.
  87100. */
  87101. get noMipmap(): boolean;
  87102. private _noMipmap;
  87103. private _files;
  87104. protected _forcedExtension: Nullable<string>;
  87105. private _extensions;
  87106. private _textureMatrix;
  87107. private _format;
  87108. private _createPolynomials;
  87109. /**
  87110. * Creates a cube texture from an array of image urls
  87111. * @param files defines an array of image urls
  87112. * @param scene defines the hosting scene
  87113. * @param noMipmap specifies if mip maps are not used
  87114. * @returns a cube texture
  87115. */
  87116. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  87117. /**
  87118. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  87119. * @param url defines the url of the prefiltered texture
  87120. * @param scene defines the scene the texture is attached to
  87121. * @param forcedExtension defines the extension of the file if different from the url
  87122. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  87123. * @return the prefiltered texture
  87124. */
  87125. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  87126. /**
  87127. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  87128. * as prefiltered data.
  87129. * @param rootUrl defines the url of the texture or the root name of the six images
  87130. * @param null defines the scene or engine the texture is attached to
  87131. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  87132. * @param noMipmap defines if mipmaps should be created or not
  87133. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  87134. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  87135. * @param onError defines a callback triggered in case of error during load
  87136. * @param format defines the internal format to use for the texture once loaded
  87137. * @param prefiltered defines whether or not the texture is created from prefiltered data
  87138. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  87139. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  87140. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  87141. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  87142. * @return the cube texture
  87143. */
  87144. 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);
  87145. /**
  87146. * Get the current class name of the texture useful for serialization or dynamic coding.
  87147. * @returns "CubeTexture"
  87148. */
  87149. getClassName(): string;
  87150. /**
  87151. * Update the url (and optional buffer) of this texture if url was null during construction.
  87152. * @param url the url of the texture
  87153. * @param forcedExtension defines the extension to use
  87154. * @param onLoad callback called when the texture is loaded (defaults to null)
  87155. * @param prefiltered Defines whether the updated texture is prefiltered or not
  87156. */
  87157. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  87158. /**
  87159. * Delays loading of the cube texture
  87160. * @param forcedExtension defines the extension to use
  87161. */
  87162. delayLoad(forcedExtension?: string): void;
  87163. /**
  87164. * Returns the reflection texture matrix
  87165. * @returns the reflection texture matrix
  87166. */
  87167. getReflectionTextureMatrix(): Matrix;
  87168. /**
  87169. * Sets the reflection texture matrix
  87170. * @param value Reflection texture matrix
  87171. */
  87172. setReflectionTextureMatrix(value: Matrix): void;
  87173. /**
  87174. * Parses text to create a cube texture
  87175. * @param parsedTexture define the serialized text to read from
  87176. * @param scene defines the hosting scene
  87177. * @param rootUrl defines the root url of the cube texture
  87178. * @returns a cube texture
  87179. */
  87180. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  87181. /**
  87182. * Makes a clone, or deep copy, of the cube texture
  87183. * @returns a new cube texture
  87184. */
  87185. clone(): CubeTexture;
  87186. }
  87187. }
  87188. declare module BABYLON {
  87189. /**
  87190. * Manages the defines for the Material
  87191. */
  87192. export class MaterialDefines {
  87193. /** @hidden */
  87194. protected _keys: string[];
  87195. private _isDirty;
  87196. /** @hidden */
  87197. _renderId: number;
  87198. /** @hidden */
  87199. _areLightsDirty: boolean;
  87200. /** @hidden */
  87201. _areLightsDisposed: boolean;
  87202. /** @hidden */
  87203. _areAttributesDirty: boolean;
  87204. /** @hidden */
  87205. _areTexturesDirty: boolean;
  87206. /** @hidden */
  87207. _areFresnelDirty: boolean;
  87208. /** @hidden */
  87209. _areMiscDirty: boolean;
  87210. /** @hidden */
  87211. _areImageProcessingDirty: boolean;
  87212. /** @hidden */
  87213. _normals: boolean;
  87214. /** @hidden */
  87215. _uvs: boolean;
  87216. /** @hidden */
  87217. _needNormals: boolean;
  87218. /** @hidden */
  87219. _needUVs: boolean;
  87220. [id: string]: any;
  87221. /**
  87222. * Specifies if the material needs to be re-calculated
  87223. */
  87224. get isDirty(): boolean;
  87225. /**
  87226. * Marks the material to indicate that it has been re-calculated
  87227. */
  87228. markAsProcessed(): void;
  87229. /**
  87230. * Marks the material to indicate that it needs to be re-calculated
  87231. */
  87232. markAsUnprocessed(): void;
  87233. /**
  87234. * Marks the material to indicate all of its defines need to be re-calculated
  87235. */
  87236. markAllAsDirty(): void;
  87237. /**
  87238. * Marks the material to indicate that image processing needs to be re-calculated
  87239. */
  87240. markAsImageProcessingDirty(): void;
  87241. /**
  87242. * Marks the material to indicate the lights need to be re-calculated
  87243. * @param disposed Defines whether the light is dirty due to dispose or not
  87244. */
  87245. markAsLightDirty(disposed?: boolean): void;
  87246. /**
  87247. * Marks the attribute state as changed
  87248. */
  87249. markAsAttributesDirty(): void;
  87250. /**
  87251. * Marks the texture state as changed
  87252. */
  87253. markAsTexturesDirty(): void;
  87254. /**
  87255. * Marks the fresnel state as changed
  87256. */
  87257. markAsFresnelDirty(): void;
  87258. /**
  87259. * Marks the misc state as changed
  87260. */
  87261. markAsMiscDirty(): void;
  87262. /**
  87263. * Rebuilds the material defines
  87264. */
  87265. rebuild(): void;
  87266. /**
  87267. * Specifies if two material defines are equal
  87268. * @param other - A material define instance to compare to
  87269. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  87270. */
  87271. isEqual(other: MaterialDefines): boolean;
  87272. /**
  87273. * Clones this instance's defines to another instance
  87274. * @param other - material defines to clone values to
  87275. */
  87276. cloneTo(other: MaterialDefines): void;
  87277. /**
  87278. * Resets the material define values
  87279. */
  87280. reset(): void;
  87281. /**
  87282. * Converts the material define values to a string
  87283. * @returns - String of material define information
  87284. */
  87285. toString(): string;
  87286. }
  87287. }
  87288. declare module BABYLON {
  87289. /**
  87290. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  87291. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  87292. * 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;
  87293. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  87294. */
  87295. export class ColorCurves {
  87296. private _dirty;
  87297. private _tempColor;
  87298. private _globalCurve;
  87299. private _highlightsCurve;
  87300. private _midtonesCurve;
  87301. private _shadowsCurve;
  87302. private _positiveCurve;
  87303. private _negativeCurve;
  87304. private _globalHue;
  87305. private _globalDensity;
  87306. private _globalSaturation;
  87307. private _globalExposure;
  87308. /**
  87309. * Gets the global Hue value.
  87310. * 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).
  87311. */
  87312. get globalHue(): number;
  87313. /**
  87314. * Sets the global Hue value.
  87315. * 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).
  87316. */
  87317. set globalHue(value: number);
  87318. /**
  87319. * Gets the global Density value.
  87320. * 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.
  87321. * Values less than zero provide a filter of opposite hue.
  87322. */
  87323. get globalDensity(): number;
  87324. /**
  87325. * Sets the global Density value.
  87326. * 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.
  87327. * Values less than zero provide a filter of opposite hue.
  87328. */
  87329. set globalDensity(value: number);
  87330. /**
  87331. * Gets the global Saturation value.
  87332. * 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.
  87333. */
  87334. get globalSaturation(): number;
  87335. /**
  87336. * Sets the global Saturation value.
  87337. * 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.
  87338. */
  87339. set globalSaturation(value: number);
  87340. /**
  87341. * Gets the global Exposure value.
  87342. * 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.
  87343. */
  87344. get globalExposure(): number;
  87345. /**
  87346. * Sets the global Exposure value.
  87347. * 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.
  87348. */
  87349. set globalExposure(value: number);
  87350. private _highlightsHue;
  87351. private _highlightsDensity;
  87352. private _highlightsSaturation;
  87353. private _highlightsExposure;
  87354. /**
  87355. * Gets the highlights Hue value.
  87356. * 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).
  87357. */
  87358. get highlightsHue(): number;
  87359. /**
  87360. * Sets the highlights Hue value.
  87361. * 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).
  87362. */
  87363. set highlightsHue(value: number);
  87364. /**
  87365. * Gets the highlights Density value.
  87366. * 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.
  87367. * Values less than zero provide a filter of opposite hue.
  87368. */
  87369. get highlightsDensity(): number;
  87370. /**
  87371. * Sets the highlights Density value.
  87372. * 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.
  87373. * Values less than zero provide a filter of opposite hue.
  87374. */
  87375. set highlightsDensity(value: number);
  87376. /**
  87377. * Gets the highlights Saturation value.
  87378. * 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.
  87379. */
  87380. get highlightsSaturation(): number;
  87381. /**
  87382. * Sets the highlights Saturation value.
  87383. * 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.
  87384. */
  87385. set highlightsSaturation(value: number);
  87386. /**
  87387. * Gets the highlights Exposure value.
  87388. * 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.
  87389. */
  87390. get highlightsExposure(): number;
  87391. /**
  87392. * Sets the highlights Exposure value.
  87393. * 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.
  87394. */
  87395. set highlightsExposure(value: number);
  87396. private _midtonesHue;
  87397. private _midtonesDensity;
  87398. private _midtonesSaturation;
  87399. private _midtonesExposure;
  87400. /**
  87401. * Gets the midtones Hue value.
  87402. * 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).
  87403. */
  87404. get midtonesHue(): number;
  87405. /**
  87406. * Sets the midtones Hue value.
  87407. * 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).
  87408. */
  87409. set midtonesHue(value: number);
  87410. /**
  87411. * Gets the midtones Density value.
  87412. * 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.
  87413. * Values less than zero provide a filter of opposite hue.
  87414. */
  87415. get midtonesDensity(): number;
  87416. /**
  87417. * Sets the midtones Density value.
  87418. * 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.
  87419. * Values less than zero provide a filter of opposite hue.
  87420. */
  87421. set midtonesDensity(value: number);
  87422. /**
  87423. * Gets the midtones Saturation value.
  87424. * 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.
  87425. */
  87426. get midtonesSaturation(): number;
  87427. /**
  87428. * Sets the midtones Saturation value.
  87429. * 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.
  87430. */
  87431. set midtonesSaturation(value: number);
  87432. /**
  87433. * Gets the midtones Exposure value.
  87434. * 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.
  87435. */
  87436. get midtonesExposure(): number;
  87437. /**
  87438. * Sets the midtones Exposure value.
  87439. * 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.
  87440. */
  87441. set midtonesExposure(value: number);
  87442. private _shadowsHue;
  87443. private _shadowsDensity;
  87444. private _shadowsSaturation;
  87445. private _shadowsExposure;
  87446. /**
  87447. * Gets the shadows Hue value.
  87448. * 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).
  87449. */
  87450. get shadowsHue(): number;
  87451. /**
  87452. * Sets the shadows Hue value.
  87453. * 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).
  87454. */
  87455. set shadowsHue(value: number);
  87456. /**
  87457. * Gets the shadows Density value.
  87458. * 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.
  87459. * Values less than zero provide a filter of opposite hue.
  87460. */
  87461. get shadowsDensity(): number;
  87462. /**
  87463. * Sets the shadows Density value.
  87464. * 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.
  87465. * Values less than zero provide a filter of opposite hue.
  87466. */
  87467. set shadowsDensity(value: number);
  87468. /**
  87469. * Gets the shadows Saturation value.
  87470. * 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.
  87471. */
  87472. get shadowsSaturation(): number;
  87473. /**
  87474. * Sets the shadows Saturation value.
  87475. * 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.
  87476. */
  87477. set shadowsSaturation(value: number);
  87478. /**
  87479. * Gets the shadows Exposure value.
  87480. * 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.
  87481. */
  87482. get shadowsExposure(): number;
  87483. /**
  87484. * Sets the shadows Exposure value.
  87485. * 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.
  87486. */
  87487. set shadowsExposure(value: number);
  87488. /**
  87489. * Returns the class name
  87490. * @returns The class name
  87491. */
  87492. getClassName(): string;
  87493. /**
  87494. * Binds the color curves to the shader.
  87495. * @param colorCurves The color curve to bind
  87496. * @param effect The effect to bind to
  87497. * @param positiveUniform The positive uniform shader parameter
  87498. * @param neutralUniform The neutral uniform shader parameter
  87499. * @param negativeUniform The negative uniform shader parameter
  87500. */
  87501. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  87502. /**
  87503. * Prepare the list of uniforms associated with the ColorCurves effects.
  87504. * @param uniformsList The list of uniforms used in the effect
  87505. */
  87506. static PrepareUniforms(uniformsList: string[]): void;
  87507. /**
  87508. * Returns color grading data based on a hue, density, saturation and exposure value.
  87509. * @param filterHue The hue of the color filter.
  87510. * @param filterDensity The density of the color filter.
  87511. * @param saturation The saturation.
  87512. * @param exposure The exposure.
  87513. * @param result The result data container.
  87514. */
  87515. private getColorGradingDataToRef;
  87516. /**
  87517. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  87518. * @param value The input slider value in range [-100,100].
  87519. * @returns Adjusted value.
  87520. */
  87521. private static applyColorGradingSliderNonlinear;
  87522. /**
  87523. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  87524. * @param hue The hue (H) input.
  87525. * @param saturation The saturation (S) input.
  87526. * @param brightness The brightness (B) input.
  87527. * @result An RGBA color represented as Vector4.
  87528. */
  87529. private static fromHSBToRef;
  87530. /**
  87531. * Returns a value clamped between min and max
  87532. * @param value The value to clamp
  87533. * @param min The minimum of value
  87534. * @param max The maximum of value
  87535. * @returns The clamped value.
  87536. */
  87537. private static clamp;
  87538. /**
  87539. * Clones the current color curve instance.
  87540. * @return The cloned curves
  87541. */
  87542. clone(): ColorCurves;
  87543. /**
  87544. * Serializes the current color curve instance to a json representation.
  87545. * @return a JSON representation
  87546. */
  87547. serialize(): any;
  87548. /**
  87549. * Parses the color curve from a json representation.
  87550. * @param source the JSON source to parse
  87551. * @return The parsed curves
  87552. */
  87553. static Parse(source: any): ColorCurves;
  87554. }
  87555. }
  87556. declare module BABYLON {
  87557. /**
  87558. * Interface to follow in your material defines to integrate easily the
  87559. * Image proccessing functions.
  87560. * @hidden
  87561. */
  87562. export interface IImageProcessingConfigurationDefines {
  87563. IMAGEPROCESSING: boolean;
  87564. VIGNETTE: boolean;
  87565. VIGNETTEBLENDMODEMULTIPLY: boolean;
  87566. VIGNETTEBLENDMODEOPAQUE: boolean;
  87567. TONEMAPPING: boolean;
  87568. TONEMAPPING_ACES: boolean;
  87569. CONTRAST: boolean;
  87570. EXPOSURE: boolean;
  87571. COLORCURVES: boolean;
  87572. COLORGRADING: boolean;
  87573. COLORGRADING3D: boolean;
  87574. SAMPLER3DGREENDEPTH: boolean;
  87575. SAMPLER3DBGRMAP: boolean;
  87576. IMAGEPROCESSINGPOSTPROCESS: boolean;
  87577. }
  87578. /**
  87579. * @hidden
  87580. */
  87581. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  87582. IMAGEPROCESSING: boolean;
  87583. VIGNETTE: boolean;
  87584. VIGNETTEBLENDMODEMULTIPLY: boolean;
  87585. VIGNETTEBLENDMODEOPAQUE: boolean;
  87586. TONEMAPPING: boolean;
  87587. TONEMAPPING_ACES: boolean;
  87588. CONTRAST: boolean;
  87589. COLORCURVES: boolean;
  87590. COLORGRADING: boolean;
  87591. COLORGRADING3D: boolean;
  87592. SAMPLER3DGREENDEPTH: boolean;
  87593. SAMPLER3DBGRMAP: boolean;
  87594. IMAGEPROCESSINGPOSTPROCESS: boolean;
  87595. EXPOSURE: boolean;
  87596. constructor();
  87597. }
  87598. /**
  87599. * This groups together the common properties used for image processing either in direct forward pass
  87600. * or through post processing effect depending on the use of the image processing pipeline in your scene
  87601. * or not.
  87602. */
  87603. export class ImageProcessingConfiguration {
  87604. /**
  87605. * Default tone mapping applied in BabylonJS.
  87606. */
  87607. static readonly TONEMAPPING_STANDARD: number;
  87608. /**
  87609. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  87610. * to other engines rendering to increase portability.
  87611. */
  87612. static readonly TONEMAPPING_ACES: number;
  87613. /**
  87614. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  87615. */
  87616. colorCurves: Nullable<ColorCurves>;
  87617. private _colorCurvesEnabled;
  87618. /**
  87619. * Gets wether the color curves effect is enabled.
  87620. */
  87621. get colorCurvesEnabled(): boolean;
  87622. /**
  87623. * Sets wether the color curves effect is enabled.
  87624. */
  87625. set colorCurvesEnabled(value: boolean);
  87626. private _colorGradingTexture;
  87627. /**
  87628. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  87629. */
  87630. get colorGradingTexture(): Nullable<BaseTexture>;
  87631. /**
  87632. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  87633. */
  87634. set colorGradingTexture(value: Nullable<BaseTexture>);
  87635. private _colorGradingEnabled;
  87636. /**
  87637. * Gets wether the color grading effect is enabled.
  87638. */
  87639. get colorGradingEnabled(): boolean;
  87640. /**
  87641. * Sets wether the color grading effect is enabled.
  87642. */
  87643. set colorGradingEnabled(value: boolean);
  87644. private _colorGradingWithGreenDepth;
  87645. /**
  87646. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  87647. */
  87648. get colorGradingWithGreenDepth(): boolean;
  87649. /**
  87650. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  87651. */
  87652. set colorGradingWithGreenDepth(value: boolean);
  87653. private _colorGradingBGR;
  87654. /**
  87655. * Gets wether the color grading texture contains BGR values.
  87656. */
  87657. get colorGradingBGR(): boolean;
  87658. /**
  87659. * Sets wether the color grading texture contains BGR values.
  87660. */
  87661. set colorGradingBGR(value: boolean);
  87662. /** @hidden */
  87663. _exposure: number;
  87664. /**
  87665. * Gets the Exposure used in the effect.
  87666. */
  87667. get exposure(): number;
  87668. /**
  87669. * Sets the Exposure used in the effect.
  87670. */
  87671. set exposure(value: number);
  87672. private _toneMappingEnabled;
  87673. /**
  87674. * Gets wether the tone mapping effect is enabled.
  87675. */
  87676. get toneMappingEnabled(): boolean;
  87677. /**
  87678. * Sets wether the tone mapping effect is enabled.
  87679. */
  87680. set toneMappingEnabled(value: boolean);
  87681. private _toneMappingType;
  87682. /**
  87683. * Gets the type of tone mapping effect.
  87684. */
  87685. get toneMappingType(): number;
  87686. /**
  87687. * Sets the type of tone mapping effect used in BabylonJS.
  87688. */
  87689. set toneMappingType(value: number);
  87690. protected _contrast: number;
  87691. /**
  87692. * Gets the contrast used in the effect.
  87693. */
  87694. get contrast(): number;
  87695. /**
  87696. * Sets the contrast used in the effect.
  87697. */
  87698. set contrast(value: number);
  87699. /**
  87700. * Vignette stretch size.
  87701. */
  87702. vignetteStretch: number;
  87703. /**
  87704. * Vignette centre X Offset.
  87705. */
  87706. vignetteCentreX: number;
  87707. /**
  87708. * Vignette centre Y Offset.
  87709. */
  87710. vignetteCentreY: number;
  87711. /**
  87712. * Vignette weight or intensity of the vignette effect.
  87713. */
  87714. vignetteWeight: number;
  87715. /**
  87716. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  87717. * if vignetteEnabled is set to true.
  87718. */
  87719. vignetteColor: Color4;
  87720. /**
  87721. * Camera field of view used by the Vignette effect.
  87722. */
  87723. vignetteCameraFov: number;
  87724. private _vignetteBlendMode;
  87725. /**
  87726. * Gets the vignette blend mode allowing different kind of effect.
  87727. */
  87728. get vignetteBlendMode(): number;
  87729. /**
  87730. * Sets the vignette blend mode allowing different kind of effect.
  87731. */
  87732. set vignetteBlendMode(value: number);
  87733. private _vignetteEnabled;
  87734. /**
  87735. * Gets wether the vignette effect is enabled.
  87736. */
  87737. get vignetteEnabled(): boolean;
  87738. /**
  87739. * Sets wether the vignette effect is enabled.
  87740. */
  87741. set vignetteEnabled(value: boolean);
  87742. private _applyByPostProcess;
  87743. /**
  87744. * Gets wether the image processing is applied through a post process or not.
  87745. */
  87746. get applyByPostProcess(): boolean;
  87747. /**
  87748. * Sets wether the image processing is applied through a post process or not.
  87749. */
  87750. set applyByPostProcess(value: boolean);
  87751. private _isEnabled;
  87752. /**
  87753. * Gets wether the image processing is enabled or not.
  87754. */
  87755. get isEnabled(): boolean;
  87756. /**
  87757. * Sets wether the image processing is enabled or not.
  87758. */
  87759. set isEnabled(value: boolean);
  87760. /**
  87761. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  87762. */
  87763. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  87764. /**
  87765. * Method called each time the image processing information changes requires to recompile the effect.
  87766. */
  87767. protected _updateParameters(): void;
  87768. /**
  87769. * Gets the current class name.
  87770. * @return "ImageProcessingConfiguration"
  87771. */
  87772. getClassName(): string;
  87773. /**
  87774. * Prepare the list of uniforms associated with the Image Processing effects.
  87775. * @param uniforms The list of uniforms used in the effect
  87776. * @param defines the list of defines currently in use
  87777. */
  87778. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  87779. /**
  87780. * Prepare the list of samplers associated with the Image Processing effects.
  87781. * @param samplersList The list of uniforms used in the effect
  87782. * @param defines the list of defines currently in use
  87783. */
  87784. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  87785. /**
  87786. * Prepare the list of defines associated to the shader.
  87787. * @param defines the list of defines to complete
  87788. * @param forPostProcess Define if we are currently in post process mode or not
  87789. */
  87790. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  87791. /**
  87792. * Returns true if all the image processing information are ready.
  87793. * @returns True if ready, otherwise, false
  87794. */
  87795. isReady(): boolean;
  87796. /**
  87797. * Binds the image processing to the shader.
  87798. * @param effect The effect to bind to
  87799. * @param overrideAspectRatio Override the aspect ratio of the effect
  87800. */
  87801. bind(effect: Effect, overrideAspectRatio?: number): void;
  87802. /**
  87803. * Clones the current image processing instance.
  87804. * @return The cloned image processing
  87805. */
  87806. clone(): ImageProcessingConfiguration;
  87807. /**
  87808. * Serializes the current image processing instance to a json representation.
  87809. * @return a JSON representation
  87810. */
  87811. serialize(): any;
  87812. /**
  87813. * Parses the image processing from a json representation.
  87814. * @param source the JSON source to parse
  87815. * @return The parsed image processing
  87816. */
  87817. static Parse(source: any): ImageProcessingConfiguration;
  87818. private static _VIGNETTEMODE_MULTIPLY;
  87819. private static _VIGNETTEMODE_OPAQUE;
  87820. /**
  87821. * Used to apply the vignette as a mix with the pixel color.
  87822. */
  87823. static get VIGNETTEMODE_MULTIPLY(): number;
  87824. /**
  87825. * Used to apply the vignette as a replacement of the pixel color.
  87826. */
  87827. static get VIGNETTEMODE_OPAQUE(): number;
  87828. }
  87829. }
  87830. declare module BABYLON {
  87831. /** @hidden */
  87832. export var postprocessVertexShader: {
  87833. name: string;
  87834. shader: string;
  87835. };
  87836. }
  87837. declare module BABYLON {
  87838. interface ThinEngine {
  87839. /**
  87840. * Creates a new render target texture
  87841. * @param size defines the size of the texture
  87842. * @param options defines the options used to create the texture
  87843. * @returns a new render target texture stored in an InternalTexture
  87844. */
  87845. createRenderTargetTexture(size: number | {
  87846. width: number;
  87847. height: number;
  87848. layers?: number;
  87849. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  87850. /**
  87851. * Creates a depth stencil texture.
  87852. * This is only available in WebGL 2 or with the depth texture extension available.
  87853. * @param size The size of face edge in the texture.
  87854. * @param options The options defining the texture.
  87855. * @returns The texture
  87856. */
  87857. createDepthStencilTexture(size: number | {
  87858. width: number;
  87859. height: number;
  87860. layers?: number;
  87861. }, options: DepthTextureCreationOptions): InternalTexture;
  87862. /** @hidden */
  87863. _createDepthStencilTexture(size: number | {
  87864. width: number;
  87865. height: number;
  87866. layers?: number;
  87867. }, options: DepthTextureCreationOptions): InternalTexture;
  87868. }
  87869. }
  87870. declare module BABYLON {
  87871. /**
  87872. * Defines the kind of connection point for node based material
  87873. */
  87874. export enum NodeMaterialBlockConnectionPointTypes {
  87875. /** Float */
  87876. Float = 1,
  87877. /** Int */
  87878. Int = 2,
  87879. /** Vector2 */
  87880. Vector2 = 4,
  87881. /** Vector3 */
  87882. Vector3 = 8,
  87883. /** Vector4 */
  87884. Vector4 = 16,
  87885. /** Color3 */
  87886. Color3 = 32,
  87887. /** Color4 */
  87888. Color4 = 64,
  87889. /** Matrix */
  87890. Matrix = 128,
  87891. /** Custom object */
  87892. Object = 256,
  87893. /** Detect type based on connection */
  87894. AutoDetect = 1024,
  87895. /** Output type that will be defined by input type */
  87896. BasedOnInput = 2048
  87897. }
  87898. }
  87899. declare module BABYLON {
  87900. /**
  87901. * Enum used to define the target of a block
  87902. */
  87903. export enum NodeMaterialBlockTargets {
  87904. /** Vertex shader */
  87905. Vertex = 1,
  87906. /** Fragment shader */
  87907. Fragment = 2,
  87908. /** Neutral */
  87909. Neutral = 4,
  87910. /** Vertex and Fragment */
  87911. VertexAndFragment = 3
  87912. }
  87913. }
  87914. declare module BABYLON {
  87915. /**
  87916. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  87917. */
  87918. export enum NodeMaterialBlockConnectionPointMode {
  87919. /** Value is an uniform */
  87920. Uniform = 0,
  87921. /** Value is a mesh attribute */
  87922. Attribute = 1,
  87923. /** Value is a varying between vertex and fragment shaders */
  87924. Varying = 2,
  87925. /** Mode is undefined */
  87926. Undefined = 3
  87927. }
  87928. }
  87929. declare module BABYLON {
  87930. /**
  87931. * Enum used to define system values e.g. values automatically provided by the system
  87932. */
  87933. export enum NodeMaterialSystemValues {
  87934. /** World */
  87935. World = 1,
  87936. /** View */
  87937. View = 2,
  87938. /** Projection */
  87939. Projection = 3,
  87940. /** ViewProjection */
  87941. ViewProjection = 4,
  87942. /** WorldView */
  87943. WorldView = 5,
  87944. /** WorldViewProjection */
  87945. WorldViewProjection = 6,
  87946. /** CameraPosition */
  87947. CameraPosition = 7,
  87948. /** Fog Color */
  87949. FogColor = 8,
  87950. /** Delta time */
  87951. DeltaTime = 9
  87952. }
  87953. }
  87954. declare module BABYLON {
  87955. /** Defines supported spaces */
  87956. export enum Space {
  87957. /** Local (object) space */
  87958. LOCAL = 0,
  87959. /** World space */
  87960. WORLD = 1,
  87961. /** Bone space */
  87962. BONE = 2
  87963. }
  87964. /** Defines the 3 main axes */
  87965. export class Axis {
  87966. /** X axis */
  87967. static X: Vector3;
  87968. /** Y axis */
  87969. static Y: Vector3;
  87970. /** Z axis */
  87971. static Z: Vector3;
  87972. }
  87973. }
  87974. declare module BABYLON {
  87975. /**
  87976. * Represents a camera frustum
  87977. */
  87978. export class Frustum {
  87979. /**
  87980. * Gets the planes representing the frustum
  87981. * @param transform matrix to be applied to the returned planes
  87982. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  87983. */
  87984. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  87985. /**
  87986. * Gets the near frustum plane transformed by the transform matrix
  87987. * @param transform transformation matrix to be applied to the resulting frustum plane
  87988. * @param frustumPlane the resuling frustum plane
  87989. */
  87990. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87991. /**
  87992. * Gets the far frustum plane transformed by the transform matrix
  87993. * @param transform transformation matrix to be applied to the resulting frustum plane
  87994. * @param frustumPlane the resuling frustum plane
  87995. */
  87996. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87997. /**
  87998. * Gets the left frustum plane transformed by the transform matrix
  87999. * @param transform transformation matrix to be applied to the resulting frustum plane
  88000. * @param frustumPlane the resuling frustum plane
  88001. */
  88002. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  88003. /**
  88004. * Gets the right frustum plane transformed by the transform matrix
  88005. * @param transform transformation matrix to be applied to the resulting frustum plane
  88006. * @param frustumPlane the resuling frustum plane
  88007. */
  88008. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  88009. /**
  88010. * Gets the top frustum plane transformed by the transform matrix
  88011. * @param transform transformation matrix to be applied to the resulting frustum plane
  88012. * @param frustumPlane the resuling frustum plane
  88013. */
  88014. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  88015. /**
  88016. * Gets the bottom frustum plane transformed by the transform matrix
  88017. * @param transform transformation matrix to be applied to the resulting frustum plane
  88018. * @param frustumPlane the resuling frustum plane
  88019. */
  88020. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  88021. /**
  88022. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  88023. * @param transform transformation matrix to be applied to the resulting frustum planes
  88024. * @param frustumPlanes the resuling frustum planes
  88025. */
  88026. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  88027. }
  88028. }
  88029. declare module BABYLON {
  88030. /**
  88031. * Interface for the size containing width and height
  88032. */
  88033. export interface ISize {
  88034. /**
  88035. * Width
  88036. */
  88037. width: number;
  88038. /**
  88039. * Heighht
  88040. */
  88041. height: number;
  88042. }
  88043. /**
  88044. * Size containing widht and height
  88045. */
  88046. export class Size implements ISize {
  88047. /**
  88048. * Width
  88049. */
  88050. width: number;
  88051. /**
  88052. * Height
  88053. */
  88054. height: number;
  88055. /**
  88056. * Creates a Size object from the given width and height (floats).
  88057. * @param width width of the new size
  88058. * @param height height of the new size
  88059. */
  88060. constructor(width: number, height: number);
  88061. /**
  88062. * Returns a string with the Size width and height
  88063. * @returns a string with the Size width and height
  88064. */
  88065. toString(): string;
  88066. /**
  88067. * "Size"
  88068. * @returns the string "Size"
  88069. */
  88070. getClassName(): string;
  88071. /**
  88072. * Returns the Size hash code.
  88073. * @returns a hash code for a unique width and height
  88074. */
  88075. getHashCode(): number;
  88076. /**
  88077. * Updates the current size from the given one.
  88078. * @param src the given size
  88079. */
  88080. copyFrom(src: Size): void;
  88081. /**
  88082. * Updates in place the current Size from the given floats.
  88083. * @param width width of the new size
  88084. * @param height height of the new size
  88085. * @returns the updated Size.
  88086. */
  88087. copyFromFloats(width: number, height: number): Size;
  88088. /**
  88089. * Updates in place the current Size from the given floats.
  88090. * @param width width to set
  88091. * @param height height to set
  88092. * @returns the updated Size.
  88093. */
  88094. set(width: number, height: number): Size;
  88095. /**
  88096. * Multiplies the width and height by numbers
  88097. * @param w factor to multiple the width by
  88098. * @param h factor to multiple the height by
  88099. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  88100. */
  88101. multiplyByFloats(w: number, h: number): Size;
  88102. /**
  88103. * Clones the size
  88104. * @returns a new Size copied from the given one.
  88105. */
  88106. clone(): Size;
  88107. /**
  88108. * True if the current Size and the given one width and height are strictly equal.
  88109. * @param other the other size to compare against
  88110. * @returns True if the current Size and the given one width and height are strictly equal.
  88111. */
  88112. equals(other: Size): boolean;
  88113. /**
  88114. * The surface of the Size : width * height (float).
  88115. */
  88116. get surface(): number;
  88117. /**
  88118. * Create a new size of zero
  88119. * @returns a new Size set to (0.0, 0.0)
  88120. */
  88121. static Zero(): Size;
  88122. /**
  88123. * Sums the width and height of two sizes
  88124. * @param otherSize size to add to this size
  88125. * @returns a new Size set as the addition result of the current Size and the given one.
  88126. */
  88127. add(otherSize: Size): Size;
  88128. /**
  88129. * Subtracts the width and height of two
  88130. * @param otherSize size to subtract to this size
  88131. * @returns a new Size set as the subtraction result of the given one from the current Size.
  88132. */
  88133. subtract(otherSize: Size): Size;
  88134. /**
  88135. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  88136. * @param start starting size to lerp between
  88137. * @param end end size to lerp between
  88138. * @param amount amount to lerp between the start and end values
  88139. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  88140. */
  88141. static Lerp(start: Size, end: Size, amount: number): Size;
  88142. }
  88143. }
  88144. declare module BABYLON {
  88145. /**
  88146. * Contains position and normal vectors for a vertex
  88147. */
  88148. export class PositionNormalVertex {
  88149. /** the position of the vertex (defaut: 0,0,0) */
  88150. position: Vector3;
  88151. /** the normal of the vertex (defaut: 0,1,0) */
  88152. normal: Vector3;
  88153. /**
  88154. * Creates a PositionNormalVertex
  88155. * @param position the position of the vertex (defaut: 0,0,0)
  88156. * @param normal the normal of the vertex (defaut: 0,1,0)
  88157. */
  88158. constructor(
  88159. /** the position of the vertex (defaut: 0,0,0) */
  88160. position?: Vector3,
  88161. /** the normal of the vertex (defaut: 0,1,0) */
  88162. normal?: Vector3);
  88163. /**
  88164. * Clones the PositionNormalVertex
  88165. * @returns the cloned PositionNormalVertex
  88166. */
  88167. clone(): PositionNormalVertex;
  88168. }
  88169. /**
  88170. * Contains position, normal and uv vectors for a vertex
  88171. */
  88172. export class PositionNormalTextureVertex {
  88173. /** the position of the vertex (defaut: 0,0,0) */
  88174. position: Vector3;
  88175. /** the normal of the vertex (defaut: 0,1,0) */
  88176. normal: Vector3;
  88177. /** the uv of the vertex (default: 0,0) */
  88178. uv: Vector2;
  88179. /**
  88180. * Creates a PositionNormalTextureVertex
  88181. * @param position the position of the vertex (defaut: 0,0,0)
  88182. * @param normal the normal of the vertex (defaut: 0,1,0)
  88183. * @param uv the uv of the vertex (default: 0,0)
  88184. */
  88185. constructor(
  88186. /** the position of the vertex (defaut: 0,0,0) */
  88187. position?: Vector3,
  88188. /** the normal of the vertex (defaut: 0,1,0) */
  88189. normal?: Vector3,
  88190. /** the uv of the vertex (default: 0,0) */
  88191. uv?: Vector2);
  88192. /**
  88193. * Clones the PositionNormalTextureVertex
  88194. * @returns the cloned PositionNormalTextureVertex
  88195. */
  88196. clone(): PositionNormalTextureVertex;
  88197. }
  88198. }
  88199. declare module BABYLON {
  88200. /**
  88201. * Enum defining the type of animations supported by InputBlock
  88202. */
  88203. export enum AnimatedInputBlockTypes {
  88204. /** No animation */
  88205. None = 0,
  88206. /** Time based animation. Will only work for floats */
  88207. Time = 1
  88208. }
  88209. }
  88210. declare module BABYLON {
  88211. /**
  88212. * Interface describing all the common properties and methods a shadow light needs to implement.
  88213. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  88214. * as well as binding the different shadow properties to the effects.
  88215. */
  88216. export interface IShadowLight extends Light {
  88217. /**
  88218. * The light id in the scene (used in scene.findLighById for instance)
  88219. */
  88220. id: string;
  88221. /**
  88222. * The position the shdow will be casted from.
  88223. */
  88224. position: Vector3;
  88225. /**
  88226. * In 2d mode (needCube being false), the direction used to cast the shadow.
  88227. */
  88228. direction: Vector3;
  88229. /**
  88230. * The transformed position. Position of the light in world space taking parenting in account.
  88231. */
  88232. transformedPosition: Vector3;
  88233. /**
  88234. * The transformed direction. Direction of the light in world space taking parenting in account.
  88235. */
  88236. transformedDirection: Vector3;
  88237. /**
  88238. * The friendly name of the light in the scene.
  88239. */
  88240. name: string;
  88241. /**
  88242. * Defines the shadow projection clipping minimum z value.
  88243. */
  88244. shadowMinZ: number;
  88245. /**
  88246. * Defines the shadow projection clipping maximum z value.
  88247. */
  88248. shadowMaxZ: number;
  88249. /**
  88250. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  88251. * @returns true if the information has been computed, false if it does not need to (no parenting)
  88252. */
  88253. computeTransformedInformation(): boolean;
  88254. /**
  88255. * Gets the scene the light belongs to.
  88256. * @returns The scene
  88257. */
  88258. getScene(): Scene;
  88259. /**
  88260. * Callback defining a custom Projection Matrix Builder.
  88261. * This can be used to override the default projection matrix computation.
  88262. */
  88263. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  88264. /**
  88265. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  88266. * @param matrix The materix to updated with the projection information
  88267. * @param viewMatrix The transform matrix of the light
  88268. * @param renderList The list of mesh to render in the map
  88269. * @returns The current light
  88270. */
  88271. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  88272. /**
  88273. * Gets the current depth scale used in ESM.
  88274. * @returns The scale
  88275. */
  88276. getDepthScale(): number;
  88277. /**
  88278. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  88279. * @returns true if a cube texture needs to be use
  88280. */
  88281. needCube(): boolean;
  88282. /**
  88283. * Detects if the projection matrix requires to be recomputed this frame.
  88284. * @returns true if it requires to be recomputed otherwise, false.
  88285. */
  88286. needProjectionMatrixCompute(): boolean;
  88287. /**
  88288. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  88289. */
  88290. forceProjectionMatrixCompute(): void;
  88291. /**
  88292. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  88293. * @param faceIndex The index of the face we are computed the direction to generate shadow
  88294. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  88295. */
  88296. getShadowDirection(faceIndex?: number): Vector3;
  88297. /**
  88298. * Gets the minZ used for shadow according to both the scene and the light.
  88299. * @param activeCamera The camera we are returning the min for
  88300. * @returns the depth min z
  88301. */
  88302. getDepthMinZ(activeCamera: Camera): number;
  88303. /**
  88304. * Gets the maxZ used for shadow according to both the scene and the light.
  88305. * @param activeCamera The camera we are returning the max for
  88306. * @returns the depth max z
  88307. */
  88308. getDepthMaxZ(activeCamera: Camera): number;
  88309. }
  88310. /**
  88311. * Base implementation IShadowLight
  88312. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  88313. */
  88314. export abstract class ShadowLight extends Light implements IShadowLight {
  88315. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  88316. protected _position: Vector3;
  88317. protected _setPosition(value: Vector3): void;
  88318. /**
  88319. * Sets the position the shadow will be casted from. Also use as the light position for both
  88320. * point and spot lights.
  88321. */
  88322. get position(): Vector3;
  88323. /**
  88324. * Sets the position the shadow will be casted from. Also use as the light position for both
  88325. * point and spot lights.
  88326. */
  88327. set position(value: Vector3);
  88328. protected _direction: Vector3;
  88329. protected _setDirection(value: Vector3): void;
  88330. /**
  88331. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  88332. * Also use as the light direction on spot and directional lights.
  88333. */
  88334. get direction(): Vector3;
  88335. /**
  88336. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  88337. * Also use as the light direction on spot and directional lights.
  88338. */
  88339. set direction(value: Vector3);
  88340. protected _shadowMinZ: number;
  88341. /**
  88342. * Gets the shadow projection clipping minimum z value.
  88343. */
  88344. get shadowMinZ(): number;
  88345. /**
  88346. * Sets the shadow projection clipping minimum z value.
  88347. */
  88348. set shadowMinZ(value: number);
  88349. protected _shadowMaxZ: number;
  88350. /**
  88351. * Sets the shadow projection clipping maximum z value.
  88352. */
  88353. get shadowMaxZ(): number;
  88354. /**
  88355. * Gets the shadow projection clipping maximum z value.
  88356. */
  88357. set shadowMaxZ(value: number);
  88358. /**
  88359. * Callback defining a custom Projection Matrix Builder.
  88360. * This can be used to override the default projection matrix computation.
  88361. */
  88362. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  88363. /**
  88364. * The transformed position. Position of the light in world space taking parenting in account.
  88365. */
  88366. transformedPosition: Vector3;
  88367. /**
  88368. * The transformed direction. Direction of the light in world space taking parenting in account.
  88369. */
  88370. transformedDirection: Vector3;
  88371. private _needProjectionMatrixCompute;
  88372. /**
  88373. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  88374. * @returns true if the information has been computed, false if it does not need to (no parenting)
  88375. */
  88376. computeTransformedInformation(): boolean;
  88377. /**
  88378. * Return the depth scale used for the shadow map.
  88379. * @returns the depth scale.
  88380. */
  88381. getDepthScale(): number;
  88382. /**
  88383. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  88384. * @param faceIndex The index of the face we are computed the direction to generate shadow
  88385. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  88386. */
  88387. getShadowDirection(faceIndex?: number): Vector3;
  88388. /**
  88389. * Returns the ShadowLight absolute position in the World.
  88390. * @returns the position vector in world space
  88391. */
  88392. getAbsolutePosition(): Vector3;
  88393. /**
  88394. * Sets the ShadowLight direction toward the passed target.
  88395. * @param target The point to target in local space
  88396. * @returns the updated ShadowLight direction
  88397. */
  88398. setDirectionToTarget(target: Vector3): Vector3;
  88399. /**
  88400. * Returns the light rotation in euler definition.
  88401. * @returns the x y z rotation in local space.
  88402. */
  88403. getRotation(): Vector3;
  88404. /**
  88405. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  88406. * @returns true if a cube texture needs to be use
  88407. */
  88408. needCube(): boolean;
  88409. /**
  88410. * Detects if the projection matrix requires to be recomputed this frame.
  88411. * @returns true if it requires to be recomputed otherwise, false.
  88412. */
  88413. needProjectionMatrixCompute(): boolean;
  88414. /**
  88415. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  88416. */
  88417. forceProjectionMatrixCompute(): void;
  88418. /** @hidden */
  88419. _initCache(): void;
  88420. /** @hidden */
  88421. _isSynchronized(): boolean;
  88422. /**
  88423. * Computes the world matrix of the node
  88424. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  88425. * @returns the world matrix
  88426. */
  88427. computeWorldMatrix(force?: boolean): Matrix;
  88428. /**
  88429. * Gets the minZ used for shadow according to both the scene and the light.
  88430. * @param activeCamera The camera we are returning the min for
  88431. * @returns the depth min z
  88432. */
  88433. getDepthMinZ(activeCamera: Camera): number;
  88434. /**
  88435. * Gets the maxZ used for shadow according to both the scene and the light.
  88436. * @param activeCamera The camera we are returning the max for
  88437. * @returns the depth max z
  88438. */
  88439. getDepthMaxZ(activeCamera: Camera): number;
  88440. /**
  88441. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  88442. * @param matrix The materix to updated with the projection information
  88443. * @param viewMatrix The transform matrix of the light
  88444. * @param renderList The list of mesh to render in the map
  88445. * @returns The current light
  88446. */
  88447. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  88448. }
  88449. }
  88450. declare module BABYLON {
  88451. /** @hidden */
  88452. export var packingFunctions: {
  88453. name: string;
  88454. shader: string;
  88455. };
  88456. }
  88457. declare module BABYLON {
  88458. /** @hidden */
  88459. export var bayerDitherFunctions: {
  88460. name: string;
  88461. shader: string;
  88462. };
  88463. }
  88464. declare module BABYLON {
  88465. /** @hidden */
  88466. export var shadowMapFragmentDeclaration: {
  88467. name: string;
  88468. shader: string;
  88469. };
  88470. }
  88471. declare module BABYLON {
  88472. /** @hidden */
  88473. export var clipPlaneFragmentDeclaration: {
  88474. name: string;
  88475. shader: string;
  88476. };
  88477. }
  88478. declare module BABYLON {
  88479. /** @hidden */
  88480. export var clipPlaneFragment: {
  88481. name: string;
  88482. shader: string;
  88483. };
  88484. }
  88485. declare module BABYLON {
  88486. /** @hidden */
  88487. export var shadowMapFragment: {
  88488. name: string;
  88489. shader: string;
  88490. };
  88491. }
  88492. declare module BABYLON {
  88493. /** @hidden */
  88494. export var shadowMapPixelShader: {
  88495. name: string;
  88496. shader: string;
  88497. };
  88498. }
  88499. declare module BABYLON {
  88500. /** @hidden */
  88501. export var bonesDeclaration: {
  88502. name: string;
  88503. shader: string;
  88504. };
  88505. }
  88506. declare module BABYLON {
  88507. /** @hidden */
  88508. export var morphTargetsVertexGlobalDeclaration: {
  88509. name: string;
  88510. shader: string;
  88511. };
  88512. }
  88513. declare module BABYLON {
  88514. /** @hidden */
  88515. export var morphTargetsVertexDeclaration: {
  88516. name: string;
  88517. shader: string;
  88518. };
  88519. }
  88520. declare module BABYLON {
  88521. /** @hidden */
  88522. export var instancesDeclaration: {
  88523. name: string;
  88524. shader: string;
  88525. };
  88526. }
  88527. declare module BABYLON {
  88528. /** @hidden */
  88529. export var helperFunctions: {
  88530. name: string;
  88531. shader: string;
  88532. };
  88533. }
  88534. declare module BABYLON {
  88535. /** @hidden */
  88536. export var shadowMapVertexDeclaration: {
  88537. name: string;
  88538. shader: string;
  88539. };
  88540. }
  88541. declare module BABYLON {
  88542. /** @hidden */
  88543. export var clipPlaneVertexDeclaration: {
  88544. name: string;
  88545. shader: string;
  88546. };
  88547. }
  88548. declare module BABYLON {
  88549. /** @hidden */
  88550. export var morphTargetsVertex: {
  88551. name: string;
  88552. shader: string;
  88553. };
  88554. }
  88555. declare module BABYLON {
  88556. /** @hidden */
  88557. export var instancesVertex: {
  88558. name: string;
  88559. shader: string;
  88560. };
  88561. }
  88562. declare module BABYLON {
  88563. /** @hidden */
  88564. export var bonesVertex: {
  88565. name: string;
  88566. shader: string;
  88567. };
  88568. }
  88569. declare module BABYLON {
  88570. /** @hidden */
  88571. export var shadowMapVertexNormalBias: {
  88572. name: string;
  88573. shader: string;
  88574. };
  88575. }
  88576. declare module BABYLON {
  88577. /** @hidden */
  88578. export var shadowMapVertexMetric: {
  88579. name: string;
  88580. shader: string;
  88581. };
  88582. }
  88583. declare module BABYLON {
  88584. /** @hidden */
  88585. export var clipPlaneVertex: {
  88586. name: string;
  88587. shader: string;
  88588. };
  88589. }
  88590. declare module BABYLON {
  88591. /** @hidden */
  88592. export var shadowMapVertexShader: {
  88593. name: string;
  88594. shader: string;
  88595. };
  88596. }
  88597. declare module BABYLON {
  88598. /** @hidden */
  88599. export var depthBoxBlurPixelShader: {
  88600. name: string;
  88601. shader: string;
  88602. };
  88603. }
  88604. declare module BABYLON {
  88605. /** @hidden */
  88606. export var shadowMapFragmentSoftTransparentShadow: {
  88607. name: string;
  88608. shader: string;
  88609. };
  88610. }
  88611. declare module BABYLON {
  88612. /**
  88613. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  88614. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  88615. */
  88616. export class EffectFallbacks implements IEffectFallbacks {
  88617. private _defines;
  88618. private _currentRank;
  88619. private _maxRank;
  88620. private _mesh;
  88621. /**
  88622. * Removes the fallback from the bound mesh.
  88623. */
  88624. unBindMesh(): void;
  88625. /**
  88626. * Adds a fallback on the specified property.
  88627. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  88628. * @param define The name of the define in the shader
  88629. */
  88630. addFallback(rank: number, define: string): void;
  88631. /**
  88632. * Sets the mesh to use CPU skinning when needing to fallback.
  88633. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  88634. * @param mesh The mesh to use the fallbacks.
  88635. */
  88636. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  88637. /**
  88638. * Checks to see if more fallbacks are still availible.
  88639. */
  88640. get hasMoreFallbacks(): boolean;
  88641. /**
  88642. * Removes the defines that should be removed when falling back.
  88643. * @param currentDefines defines the current define statements for the shader.
  88644. * @param effect defines the current effect we try to compile
  88645. * @returns The resulting defines with defines of the current rank removed.
  88646. */
  88647. reduce(currentDefines: string, effect: Effect): string;
  88648. }
  88649. }
  88650. declare module BABYLON {
  88651. /**
  88652. * Interface used to define Action
  88653. */
  88654. export interface IAction {
  88655. /**
  88656. * Trigger for the action
  88657. */
  88658. trigger: number;
  88659. /** Options of the trigger */
  88660. triggerOptions: any;
  88661. /**
  88662. * Gets the trigger parameters
  88663. * @returns the trigger parameters
  88664. */
  88665. getTriggerParameter(): any;
  88666. /**
  88667. * Internal only - executes current action event
  88668. * @hidden
  88669. */
  88670. _executeCurrent(evt?: ActionEvent): void;
  88671. /**
  88672. * Serialize placeholder for child classes
  88673. * @param parent of child
  88674. * @returns the serialized object
  88675. */
  88676. serialize(parent: any): any;
  88677. /**
  88678. * Internal only
  88679. * @hidden
  88680. */
  88681. _prepare(): void;
  88682. /**
  88683. * Internal only - manager for action
  88684. * @hidden
  88685. */
  88686. _actionManager: AbstractActionManager;
  88687. /**
  88688. * Adds action to chain of actions, may be a DoNothingAction
  88689. * @param action defines the next action to execute
  88690. * @returns The action passed in
  88691. * @see https://www.babylonjs-playground.com/#1T30HR#0
  88692. */
  88693. then(action: IAction): IAction;
  88694. }
  88695. /**
  88696. * The action to be carried out following a trigger
  88697. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  88698. */
  88699. export class Action implements IAction {
  88700. /** the trigger, with or without parameters, for the action */
  88701. triggerOptions: any;
  88702. /**
  88703. * Trigger for the action
  88704. */
  88705. trigger: number;
  88706. /**
  88707. * Internal only - manager for action
  88708. * @hidden
  88709. */
  88710. _actionManager: ActionManager;
  88711. private _nextActiveAction;
  88712. private _child;
  88713. private _condition?;
  88714. private _triggerParameter;
  88715. /**
  88716. * An event triggered prior to action being executed.
  88717. */
  88718. onBeforeExecuteObservable: Observable<Action>;
  88719. /**
  88720. * Creates a new Action
  88721. * @param triggerOptions the trigger, with or without parameters, for the action
  88722. * @param condition an optional determinant of action
  88723. */
  88724. constructor(
  88725. /** the trigger, with or without parameters, for the action */
  88726. triggerOptions: any, condition?: Condition);
  88727. /**
  88728. * Internal only
  88729. * @hidden
  88730. */
  88731. _prepare(): void;
  88732. /**
  88733. * Gets the trigger parameters
  88734. * @returns the trigger parameters
  88735. */
  88736. getTriggerParameter(): any;
  88737. /**
  88738. * Internal only - executes current action event
  88739. * @hidden
  88740. */
  88741. _executeCurrent(evt?: ActionEvent): void;
  88742. /**
  88743. * Execute placeholder for child classes
  88744. * @param evt optional action event
  88745. */
  88746. execute(evt?: ActionEvent): void;
  88747. /**
  88748. * Skips to next active action
  88749. */
  88750. skipToNextActiveAction(): void;
  88751. /**
  88752. * Adds action to chain of actions, may be a DoNothingAction
  88753. * @param action defines the next action to execute
  88754. * @returns The action passed in
  88755. * @see https://www.babylonjs-playground.com/#1T30HR#0
  88756. */
  88757. then(action: Action): Action;
  88758. /**
  88759. * Internal only
  88760. * @hidden
  88761. */
  88762. _getProperty(propertyPath: string): string;
  88763. /**
  88764. * Internal only
  88765. * @hidden
  88766. */
  88767. _getEffectiveTarget(target: any, propertyPath: string): any;
  88768. /**
  88769. * Serialize placeholder for child classes
  88770. * @param parent of child
  88771. * @returns the serialized object
  88772. */
  88773. serialize(parent: any): any;
  88774. /**
  88775. * Internal only called by serialize
  88776. * @hidden
  88777. */
  88778. protected _serialize(serializedAction: any, parent?: any): any;
  88779. /**
  88780. * Internal only
  88781. * @hidden
  88782. */
  88783. static _SerializeValueAsString: (value: any) => string;
  88784. /**
  88785. * Internal only
  88786. * @hidden
  88787. */
  88788. static _GetTargetProperty: (target: Scene | Node) => {
  88789. name: string;
  88790. targetType: string;
  88791. value: string;
  88792. };
  88793. }
  88794. }
  88795. declare module BABYLON {
  88796. /**
  88797. * A Condition applied to an Action
  88798. */
  88799. export class Condition {
  88800. /**
  88801. * Internal only - manager for action
  88802. * @hidden
  88803. */
  88804. _actionManager: ActionManager;
  88805. /**
  88806. * Internal only
  88807. * @hidden
  88808. */
  88809. _evaluationId: number;
  88810. /**
  88811. * Internal only
  88812. * @hidden
  88813. */
  88814. _currentResult: boolean;
  88815. /**
  88816. * Creates a new Condition
  88817. * @param actionManager the manager of the action the condition is applied to
  88818. */
  88819. constructor(actionManager: ActionManager);
  88820. /**
  88821. * Check if the current condition is valid
  88822. * @returns a boolean
  88823. */
  88824. isValid(): boolean;
  88825. /**
  88826. * Internal only
  88827. * @hidden
  88828. */
  88829. _getProperty(propertyPath: string): string;
  88830. /**
  88831. * Internal only
  88832. * @hidden
  88833. */
  88834. _getEffectiveTarget(target: any, propertyPath: string): any;
  88835. /**
  88836. * Serialize placeholder for child classes
  88837. * @returns the serialized object
  88838. */
  88839. serialize(): any;
  88840. /**
  88841. * Internal only
  88842. * @hidden
  88843. */
  88844. protected _serialize(serializedCondition: any): any;
  88845. }
  88846. /**
  88847. * Defines specific conditional operators as extensions of Condition
  88848. */
  88849. export class ValueCondition extends Condition {
  88850. /** path to specify the property of the target the conditional operator uses */
  88851. propertyPath: string;
  88852. /** the value compared by the conditional operator against the current value of the property */
  88853. value: any;
  88854. /** the conditional operator, default ValueCondition.IsEqual */
  88855. operator: number;
  88856. /**
  88857. * Internal only
  88858. * @hidden
  88859. */
  88860. private static _IsEqual;
  88861. /**
  88862. * Internal only
  88863. * @hidden
  88864. */
  88865. private static _IsDifferent;
  88866. /**
  88867. * Internal only
  88868. * @hidden
  88869. */
  88870. private static _IsGreater;
  88871. /**
  88872. * Internal only
  88873. * @hidden
  88874. */
  88875. private static _IsLesser;
  88876. /**
  88877. * returns the number for IsEqual
  88878. */
  88879. static get IsEqual(): number;
  88880. /**
  88881. * Returns the number for IsDifferent
  88882. */
  88883. static get IsDifferent(): number;
  88884. /**
  88885. * Returns the number for IsGreater
  88886. */
  88887. static get IsGreater(): number;
  88888. /**
  88889. * Returns the number for IsLesser
  88890. */
  88891. static get IsLesser(): number;
  88892. /**
  88893. * Internal only The action manager for the condition
  88894. * @hidden
  88895. */
  88896. _actionManager: ActionManager;
  88897. /**
  88898. * Internal only
  88899. * @hidden
  88900. */
  88901. private _target;
  88902. /**
  88903. * Internal only
  88904. * @hidden
  88905. */
  88906. private _effectiveTarget;
  88907. /**
  88908. * Internal only
  88909. * @hidden
  88910. */
  88911. private _property;
  88912. /**
  88913. * Creates a new ValueCondition
  88914. * @param actionManager manager for the action the condition applies to
  88915. * @param target for the action
  88916. * @param propertyPath path to specify the property of the target the conditional operator uses
  88917. * @param value the value compared by the conditional operator against the current value of the property
  88918. * @param operator the conditional operator, default ValueCondition.IsEqual
  88919. */
  88920. constructor(actionManager: ActionManager, target: any,
  88921. /** path to specify the property of the target the conditional operator uses */
  88922. propertyPath: string,
  88923. /** the value compared by the conditional operator against the current value of the property */
  88924. value: any,
  88925. /** the conditional operator, default ValueCondition.IsEqual */
  88926. operator?: number);
  88927. /**
  88928. * Compares the given value with the property value for the specified conditional operator
  88929. * @returns the result of the comparison
  88930. */
  88931. isValid(): boolean;
  88932. /**
  88933. * Serialize the ValueCondition into a JSON compatible object
  88934. * @returns serialization object
  88935. */
  88936. serialize(): any;
  88937. /**
  88938. * Gets the name of the conditional operator for the ValueCondition
  88939. * @param operator the conditional operator
  88940. * @returns the name
  88941. */
  88942. static GetOperatorName(operator: number): string;
  88943. }
  88944. /**
  88945. * Defines a predicate condition as an extension of Condition
  88946. */
  88947. export class PredicateCondition extends Condition {
  88948. /** defines the predicate function used to validate the condition */
  88949. predicate: () => boolean;
  88950. /**
  88951. * Internal only - manager for action
  88952. * @hidden
  88953. */
  88954. _actionManager: ActionManager;
  88955. /**
  88956. * Creates a new PredicateCondition
  88957. * @param actionManager manager for the action the condition applies to
  88958. * @param predicate defines the predicate function used to validate the condition
  88959. */
  88960. constructor(actionManager: ActionManager,
  88961. /** defines the predicate function used to validate the condition */
  88962. predicate: () => boolean);
  88963. /**
  88964. * @returns the validity of the predicate condition
  88965. */
  88966. isValid(): boolean;
  88967. }
  88968. /**
  88969. * Defines a state condition as an extension of Condition
  88970. */
  88971. export class StateCondition extends Condition {
  88972. /** Value to compare with target state */
  88973. value: string;
  88974. /**
  88975. * Internal only - manager for action
  88976. * @hidden
  88977. */
  88978. _actionManager: ActionManager;
  88979. /**
  88980. * Internal only
  88981. * @hidden
  88982. */
  88983. private _target;
  88984. /**
  88985. * Creates a new StateCondition
  88986. * @param actionManager manager for the action the condition applies to
  88987. * @param target of the condition
  88988. * @param value to compare with target state
  88989. */
  88990. constructor(actionManager: ActionManager, target: any,
  88991. /** Value to compare with target state */
  88992. value: string);
  88993. /**
  88994. * Gets a boolean indicating if the current condition is met
  88995. * @returns the validity of the state
  88996. */
  88997. isValid(): boolean;
  88998. /**
  88999. * Serialize the StateCondition into a JSON compatible object
  89000. * @returns serialization object
  89001. */
  89002. serialize(): any;
  89003. }
  89004. }
  89005. declare module BABYLON {
  89006. /**
  89007. * This defines an action responsible to toggle a boolean once triggered.
  89008. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89009. */
  89010. export class SwitchBooleanAction extends Action {
  89011. /**
  89012. * The path to the boolean property in the target object
  89013. */
  89014. propertyPath: string;
  89015. private _target;
  89016. private _effectiveTarget;
  89017. private _property;
  89018. /**
  89019. * Instantiate the action
  89020. * @param triggerOptions defines the trigger options
  89021. * @param target defines the object containing the boolean
  89022. * @param propertyPath defines the path to the boolean property in the target object
  89023. * @param condition defines the trigger related conditions
  89024. */
  89025. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  89026. /** @hidden */
  89027. _prepare(): void;
  89028. /**
  89029. * Execute the action toggle the boolean value.
  89030. */
  89031. execute(): void;
  89032. /**
  89033. * Serializes the actions and its related information.
  89034. * @param parent defines the object to serialize in
  89035. * @returns the serialized object
  89036. */
  89037. serialize(parent: any): any;
  89038. }
  89039. /**
  89040. * This defines an action responsible to set a the state field of the target
  89041. * to a desired value once triggered.
  89042. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89043. */
  89044. export class SetStateAction extends Action {
  89045. /**
  89046. * The value to store in the state field.
  89047. */
  89048. value: string;
  89049. private _target;
  89050. /**
  89051. * Instantiate the action
  89052. * @param triggerOptions defines the trigger options
  89053. * @param target defines the object containing the state property
  89054. * @param value defines the value to store in the state field
  89055. * @param condition defines the trigger related conditions
  89056. */
  89057. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  89058. /**
  89059. * Execute the action and store the value on the target state property.
  89060. */
  89061. execute(): void;
  89062. /**
  89063. * Serializes the actions and its related information.
  89064. * @param parent defines the object to serialize in
  89065. * @returns the serialized object
  89066. */
  89067. serialize(parent: any): any;
  89068. }
  89069. /**
  89070. * This defines an action responsible to set a property of the target
  89071. * to a desired value once triggered.
  89072. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89073. */
  89074. export class SetValueAction extends Action {
  89075. /**
  89076. * The path of the property to set in the target.
  89077. */
  89078. propertyPath: string;
  89079. /**
  89080. * The value to set in the property
  89081. */
  89082. value: any;
  89083. private _target;
  89084. private _effectiveTarget;
  89085. private _property;
  89086. /**
  89087. * Instantiate the action
  89088. * @param triggerOptions defines the trigger options
  89089. * @param target defines the object containing the property
  89090. * @param propertyPath defines the path of the property to set in the target
  89091. * @param value defines the value to set in the property
  89092. * @param condition defines the trigger related conditions
  89093. */
  89094. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  89095. /** @hidden */
  89096. _prepare(): void;
  89097. /**
  89098. * Execute the action and set the targetted property to the desired value.
  89099. */
  89100. execute(): void;
  89101. /**
  89102. * Serializes the actions and its related information.
  89103. * @param parent defines the object to serialize in
  89104. * @returns the serialized object
  89105. */
  89106. serialize(parent: any): any;
  89107. }
  89108. /**
  89109. * This defines an action responsible to increment the target value
  89110. * to a desired value once triggered.
  89111. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89112. */
  89113. export class IncrementValueAction extends Action {
  89114. /**
  89115. * The path of the property to increment in the target.
  89116. */
  89117. propertyPath: string;
  89118. /**
  89119. * The value we should increment the property by.
  89120. */
  89121. value: any;
  89122. private _target;
  89123. private _effectiveTarget;
  89124. private _property;
  89125. /**
  89126. * Instantiate the action
  89127. * @param triggerOptions defines the trigger options
  89128. * @param target defines the object containing the property
  89129. * @param propertyPath defines the path of the property to increment in the target
  89130. * @param value defines the value value we should increment the property by
  89131. * @param condition defines the trigger related conditions
  89132. */
  89133. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  89134. /** @hidden */
  89135. _prepare(): void;
  89136. /**
  89137. * Execute the action and increment the target of the value amount.
  89138. */
  89139. execute(): void;
  89140. /**
  89141. * Serializes the actions and its related information.
  89142. * @param parent defines the object to serialize in
  89143. * @returns the serialized object
  89144. */
  89145. serialize(parent: any): any;
  89146. }
  89147. /**
  89148. * This defines an action responsible to start an animation once triggered.
  89149. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89150. */
  89151. export class PlayAnimationAction extends Action {
  89152. /**
  89153. * Where the animation should start (animation frame)
  89154. */
  89155. from: number;
  89156. /**
  89157. * Where the animation should stop (animation frame)
  89158. */
  89159. to: number;
  89160. /**
  89161. * Define if the animation should loop or stop after the first play.
  89162. */
  89163. loop?: boolean;
  89164. private _target;
  89165. /**
  89166. * Instantiate the action
  89167. * @param triggerOptions defines the trigger options
  89168. * @param target defines the target animation or animation name
  89169. * @param from defines from where the animation should start (animation frame)
  89170. * @param end defines where the animation should stop (animation frame)
  89171. * @param loop defines if the animation should loop or stop after the first play
  89172. * @param condition defines the trigger related conditions
  89173. */
  89174. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  89175. /** @hidden */
  89176. _prepare(): void;
  89177. /**
  89178. * Execute the action and play the animation.
  89179. */
  89180. execute(): void;
  89181. /**
  89182. * Serializes the actions and its related information.
  89183. * @param parent defines the object to serialize in
  89184. * @returns the serialized object
  89185. */
  89186. serialize(parent: any): any;
  89187. }
  89188. /**
  89189. * This defines an action responsible to stop an animation once triggered.
  89190. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89191. */
  89192. export class StopAnimationAction extends Action {
  89193. private _target;
  89194. /**
  89195. * Instantiate the action
  89196. * @param triggerOptions defines the trigger options
  89197. * @param target defines the target animation or animation name
  89198. * @param condition defines the trigger related conditions
  89199. */
  89200. constructor(triggerOptions: any, target: any, condition?: Condition);
  89201. /** @hidden */
  89202. _prepare(): void;
  89203. /**
  89204. * Execute the action and stop the animation.
  89205. */
  89206. execute(): void;
  89207. /**
  89208. * Serializes the actions and its related information.
  89209. * @param parent defines the object to serialize in
  89210. * @returns the serialized object
  89211. */
  89212. serialize(parent: any): any;
  89213. }
  89214. /**
  89215. * This defines an action responsible that does nothing once triggered.
  89216. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89217. */
  89218. export class DoNothingAction extends Action {
  89219. /**
  89220. * Instantiate the action
  89221. * @param triggerOptions defines the trigger options
  89222. * @param condition defines the trigger related conditions
  89223. */
  89224. constructor(triggerOptions?: any, condition?: Condition);
  89225. /**
  89226. * Execute the action and do nothing.
  89227. */
  89228. execute(): void;
  89229. /**
  89230. * Serializes the actions and its related information.
  89231. * @param parent defines the object to serialize in
  89232. * @returns the serialized object
  89233. */
  89234. serialize(parent: any): any;
  89235. }
  89236. /**
  89237. * This defines an action responsible to trigger several actions once triggered.
  89238. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89239. */
  89240. export class CombineAction extends Action {
  89241. /**
  89242. * The list of aggregated animations to run.
  89243. */
  89244. children: Action[];
  89245. /**
  89246. * Instantiate the action
  89247. * @param triggerOptions defines the trigger options
  89248. * @param children defines the list of aggregated animations to run
  89249. * @param condition defines the trigger related conditions
  89250. */
  89251. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  89252. /** @hidden */
  89253. _prepare(): void;
  89254. /**
  89255. * Execute the action and executes all the aggregated actions.
  89256. */
  89257. execute(evt: ActionEvent): void;
  89258. /**
  89259. * Serializes the actions and its related information.
  89260. * @param parent defines the object to serialize in
  89261. * @returns the serialized object
  89262. */
  89263. serialize(parent: any): any;
  89264. }
  89265. /**
  89266. * This defines an action responsible to run code (external event) once triggered.
  89267. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89268. */
  89269. export class ExecuteCodeAction extends Action {
  89270. /**
  89271. * The callback function to run.
  89272. */
  89273. func: (evt: ActionEvent) => void;
  89274. /**
  89275. * Instantiate the action
  89276. * @param triggerOptions defines the trigger options
  89277. * @param func defines the callback function to run
  89278. * @param condition defines the trigger related conditions
  89279. */
  89280. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  89281. /**
  89282. * Execute the action and run the attached code.
  89283. */
  89284. execute(evt: ActionEvent): void;
  89285. }
  89286. /**
  89287. * This defines an action responsible to set the parent property of the target once triggered.
  89288. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89289. */
  89290. export class SetParentAction extends Action {
  89291. private _parent;
  89292. private _target;
  89293. /**
  89294. * Instantiate the action
  89295. * @param triggerOptions defines the trigger options
  89296. * @param target defines the target containing the parent property
  89297. * @param parent defines from where the animation should start (animation frame)
  89298. * @param condition defines the trigger related conditions
  89299. */
  89300. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  89301. /** @hidden */
  89302. _prepare(): void;
  89303. /**
  89304. * Execute the action and set the parent property.
  89305. */
  89306. execute(): void;
  89307. /**
  89308. * Serializes the actions and its related information.
  89309. * @param parent defines the object to serialize in
  89310. * @returns the serialized object
  89311. */
  89312. serialize(parent: any): any;
  89313. }
  89314. }
  89315. declare module BABYLON {
  89316. /**
  89317. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  89318. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  89319. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89320. */
  89321. export class ActionManager extends AbstractActionManager {
  89322. /**
  89323. * Nothing
  89324. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89325. */
  89326. static readonly NothingTrigger: number;
  89327. /**
  89328. * On pick
  89329. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89330. */
  89331. static readonly OnPickTrigger: number;
  89332. /**
  89333. * On left pick
  89334. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89335. */
  89336. static readonly OnLeftPickTrigger: number;
  89337. /**
  89338. * On right pick
  89339. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89340. */
  89341. static readonly OnRightPickTrigger: number;
  89342. /**
  89343. * On center pick
  89344. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89345. */
  89346. static readonly OnCenterPickTrigger: number;
  89347. /**
  89348. * On pick down
  89349. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89350. */
  89351. static readonly OnPickDownTrigger: number;
  89352. /**
  89353. * On double pick
  89354. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89355. */
  89356. static readonly OnDoublePickTrigger: number;
  89357. /**
  89358. * On pick up
  89359. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89360. */
  89361. static readonly OnPickUpTrigger: number;
  89362. /**
  89363. * On pick out.
  89364. * This trigger will only be raised if you also declared a OnPickDown
  89365. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89366. */
  89367. static readonly OnPickOutTrigger: number;
  89368. /**
  89369. * On long press
  89370. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89371. */
  89372. static readonly OnLongPressTrigger: number;
  89373. /**
  89374. * On pointer over
  89375. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89376. */
  89377. static readonly OnPointerOverTrigger: number;
  89378. /**
  89379. * On pointer out
  89380. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89381. */
  89382. static readonly OnPointerOutTrigger: number;
  89383. /**
  89384. * On every frame
  89385. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89386. */
  89387. static readonly OnEveryFrameTrigger: number;
  89388. /**
  89389. * On intersection enter
  89390. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89391. */
  89392. static readonly OnIntersectionEnterTrigger: number;
  89393. /**
  89394. * On intersection exit
  89395. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89396. */
  89397. static readonly OnIntersectionExitTrigger: number;
  89398. /**
  89399. * On key down
  89400. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89401. */
  89402. static readonly OnKeyDownTrigger: number;
  89403. /**
  89404. * On key up
  89405. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89406. */
  89407. static readonly OnKeyUpTrigger: number;
  89408. private _scene;
  89409. /**
  89410. * Creates a new action manager
  89411. * @param scene defines the hosting scene
  89412. */
  89413. constructor(scene: Scene);
  89414. /**
  89415. * Releases all associated resources
  89416. */
  89417. dispose(): void;
  89418. /**
  89419. * Gets hosting scene
  89420. * @returns the hosting scene
  89421. */
  89422. getScene(): Scene;
  89423. /**
  89424. * Does this action manager handles actions of any of the given triggers
  89425. * @param triggers defines the triggers to be tested
  89426. * @return a boolean indicating whether one (or more) of the triggers is handled
  89427. */
  89428. hasSpecificTriggers(triggers: number[]): boolean;
  89429. /**
  89430. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  89431. * speed.
  89432. * @param triggerA defines the trigger to be tested
  89433. * @param triggerB defines the trigger to be tested
  89434. * @return a boolean indicating whether one (or more) of the triggers is handled
  89435. */
  89436. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  89437. /**
  89438. * Does this action manager handles actions of a given trigger
  89439. * @param trigger defines the trigger to be tested
  89440. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  89441. * @return whether the trigger is handled
  89442. */
  89443. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  89444. /**
  89445. * Does this action manager has pointer triggers
  89446. */
  89447. get hasPointerTriggers(): boolean;
  89448. /**
  89449. * Does this action manager has pick triggers
  89450. */
  89451. get hasPickTriggers(): boolean;
  89452. /**
  89453. * Registers an action to this action manager
  89454. * @param action defines the action to be registered
  89455. * @return the action amended (prepared) after registration
  89456. */
  89457. registerAction(action: IAction): Nullable<IAction>;
  89458. /**
  89459. * Unregisters an action to this action manager
  89460. * @param action defines the action to be unregistered
  89461. * @return a boolean indicating whether the action has been unregistered
  89462. */
  89463. unregisterAction(action: IAction): Boolean;
  89464. /**
  89465. * Process a specific trigger
  89466. * @param trigger defines the trigger to process
  89467. * @param evt defines the event details to be processed
  89468. */
  89469. processTrigger(trigger: number, evt?: IActionEvent): void;
  89470. /** @hidden */
  89471. _getEffectiveTarget(target: any, propertyPath: string): any;
  89472. /** @hidden */
  89473. _getProperty(propertyPath: string): string;
  89474. /**
  89475. * Serialize this manager to a JSON object
  89476. * @param name defines the property name to store this manager
  89477. * @returns a JSON representation of this manager
  89478. */
  89479. serialize(name: string): any;
  89480. /**
  89481. * Creates a new ActionManager from a JSON data
  89482. * @param parsedActions defines the JSON data to read from
  89483. * @param object defines the hosting mesh
  89484. * @param scene defines the hosting scene
  89485. */
  89486. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  89487. /**
  89488. * Get a trigger name by index
  89489. * @param trigger defines the trigger index
  89490. * @returns a trigger name
  89491. */
  89492. static GetTriggerName(trigger: number): string;
  89493. }
  89494. }
  89495. declare module BABYLON {
  89496. /**
  89497. * Class used to represent a sprite
  89498. * @see https://doc.babylonjs.com/babylon101/sprites
  89499. */
  89500. export class Sprite implements IAnimatable {
  89501. /** defines the name */
  89502. name: string;
  89503. /** Gets or sets the current world position */
  89504. position: Vector3;
  89505. /** Gets or sets the main color */
  89506. color: Color4;
  89507. /** Gets or sets the width */
  89508. width: number;
  89509. /** Gets or sets the height */
  89510. height: number;
  89511. /** Gets or sets rotation angle */
  89512. angle: number;
  89513. /** Gets or sets the cell index in the sprite sheet */
  89514. cellIndex: number;
  89515. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  89516. cellRef: string;
  89517. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  89518. invertU: boolean;
  89519. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  89520. invertV: boolean;
  89521. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  89522. disposeWhenFinishedAnimating: boolean;
  89523. /** Gets the list of attached animations */
  89524. animations: Nullable<Array<Animation>>;
  89525. /** Gets or sets a boolean indicating if the sprite can be picked */
  89526. isPickable: boolean;
  89527. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  89528. useAlphaForPicking: boolean;
  89529. /** @hidden */
  89530. _xOffset: number;
  89531. /** @hidden */
  89532. _yOffset: number;
  89533. /** @hidden */
  89534. _xSize: number;
  89535. /** @hidden */
  89536. _ySize: number;
  89537. /**
  89538. * Gets or sets the associated action manager
  89539. */
  89540. actionManager: Nullable<ActionManager>;
  89541. /**
  89542. * An event triggered when the control has been disposed
  89543. */
  89544. onDisposeObservable: Observable<Sprite>;
  89545. private _animationStarted;
  89546. private _loopAnimation;
  89547. private _fromIndex;
  89548. private _toIndex;
  89549. private _delay;
  89550. private _direction;
  89551. private _manager;
  89552. private _time;
  89553. private _onAnimationEnd;
  89554. /**
  89555. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  89556. */
  89557. isVisible: boolean;
  89558. /**
  89559. * Gets or sets the sprite size
  89560. */
  89561. get size(): number;
  89562. set size(value: number);
  89563. /**
  89564. * Returns a boolean indicating if the animation is started
  89565. */
  89566. get animationStarted(): boolean;
  89567. /**
  89568. * Gets or sets the unique id of the sprite
  89569. */
  89570. uniqueId: number;
  89571. /**
  89572. * Gets the manager of this sprite
  89573. */
  89574. get manager(): ISpriteManager;
  89575. /**
  89576. * Creates a new Sprite
  89577. * @param name defines the name
  89578. * @param manager defines the manager
  89579. */
  89580. constructor(
  89581. /** defines the name */
  89582. name: string, manager: ISpriteManager);
  89583. /**
  89584. * Returns the string "Sprite"
  89585. * @returns "Sprite"
  89586. */
  89587. getClassName(): string;
  89588. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  89589. get fromIndex(): number;
  89590. set fromIndex(value: number);
  89591. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  89592. get toIndex(): number;
  89593. set toIndex(value: number);
  89594. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  89595. get loopAnimation(): boolean;
  89596. set loopAnimation(value: boolean);
  89597. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  89598. get delay(): number;
  89599. set delay(value: number);
  89600. /**
  89601. * Starts an animation
  89602. * @param from defines the initial key
  89603. * @param to defines the end key
  89604. * @param loop defines if the animation must loop
  89605. * @param delay defines the start delay (in ms)
  89606. * @param onAnimationEnd defines a callback to call when animation ends
  89607. */
  89608. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  89609. /** Stops current animation (if any) */
  89610. stopAnimation(): void;
  89611. /** @hidden */
  89612. _animate(deltaTime: number): void;
  89613. /** Release associated resources */
  89614. dispose(): void;
  89615. /**
  89616. * Serializes the sprite to a JSON object
  89617. * @returns the JSON object
  89618. */
  89619. serialize(): any;
  89620. /**
  89621. * Parses a JSON object to create a new sprite
  89622. * @param parsedSprite The JSON object to parse
  89623. * @param manager defines the hosting manager
  89624. * @returns the new sprite
  89625. */
  89626. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  89627. }
  89628. }
  89629. declare module BABYLON {
  89630. /**
  89631. * Information about the result of picking within a scene
  89632. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  89633. */
  89634. export class PickingInfo {
  89635. /** @hidden */
  89636. _pickingUnavailable: boolean;
  89637. /**
  89638. * If the pick collided with an object
  89639. */
  89640. hit: boolean;
  89641. /**
  89642. * Distance away where the pick collided
  89643. */
  89644. distance: number;
  89645. /**
  89646. * The location of pick collision
  89647. */
  89648. pickedPoint: Nullable<Vector3>;
  89649. /**
  89650. * The mesh corresponding the the pick collision
  89651. */
  89652. pickedMesh: Nullable<AbstractMesh>;
  89653. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  89654. bu: number;
  89655. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  89656. bv: number;
  89657. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  89658. faceId: number;
  89659. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  89660. subMeshFaceId: number;
  89661. /** Id of the the submesh that was picked */
  89662. subMeshId: number;
  89663. /** If a sprite was picked, this will be the sprite the pick collided with */
  89664. pickedSprite: Nullable<Sprite>;
  89665. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  89666. thinInstanceIndex: number;
  89667. /**
  89668. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  89669. */
  89670. originMesh: Nullable<AbstractMesh>;
  89671. /**
  89672. * The ray that was used to perform the picking.
  89673. */
  89674. ray: Nullable<Ray>;
  89675. /**
  89676. * Gets the normal correspodning to the face the pick collided with
  89677. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  89678. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  89679. * @returns The normal correspodning to the face the pick collided with
  89680. */
  89681. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  89682. /**
  89683. * Gets the texture coordinates of where the pick occured
  89684. * @returns the vector containing the coordnates of the texture
  89685. */
  89686. getTextureCoordinates(): Nullable<Vector2>;
  89687. }
  89688. }
  89689. declare module BABYLON {
  89690. /**
  89691. * Class representing a ray with position and direction
  89692. */
  89693. export class Ray {
  89694. /** origin point */
  89695. origin: Vector3;
  89696. /** direction */
  89697. direction: Vector3;
  89698. /** length of the ray */
  89699. length: number;
  89700. private static readonly _TmpVector3;
  89701. private _tmpRay;
  89702. /**
  89703. * Creates a new ray
  89704. * @param origin origin point
  89705. * @param direction direction
  89706. * @param length length of the ray
  89707. */
  89708. constructor(
  89709. /** origin point */
  89710. origin: Vector3,
  89711. /** direction */
  89712. direction: Vector3,
  89713. /** length of the ray */
  89714. length?: number);
  89715. /**
  89716. * Checks if the ray intersects a box
  89717. * This does not account for the ray lenght by design to improve perfs.
  89718. * @param minimum bound of the box
  89719. * @param maximum bound of the box
  89720. * @param intersectionTreshold extra extend to be added to the box in all direction
  89721. * @returns if the box was hit
  89722. */
  89723. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  89724. /**
  89725. * Checks if the ray intersects a box
  89726. * This does not account for the ray lenght by design to improve perfs.
  89727. * @param box the bounding box to check
  89728. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  89729. * @returns if the box was hit
  89730. */
  89731. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  89732. /**
  89733. * If the ray hits a sphere
  89734. * @param sphere the bounding sphere to check
  89735. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  89736. * @returns true if it hits the sphere
  89737. */
  89738. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  89739. /**
  89740. * If the ray hits a triange
  89741. * @param vertex0 triangle vertex
  89742. * @param vertex1 triangle vertex
  89743. * @param vertex2 triangle vertex
  89744. * @returns intersection information if hit
  89745. */
  89746. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  89747. /**
  89748. * Checks if ray intersects a plane
  89749. * @param plane the plane to check
  89750. * @returns the distance away it was hit
  89751. */
  89752. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  89753. /**
  89754. * Calculate the intercept of a ray on a given axis
  89755. * @param axis to check 'x' | 'y' | 'z'
  89756. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  89757. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  89758. */
  89759. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  89760. /**
  89761. * Checks if ray intersects a mesh
  89762. * @param mesh the mesh to check
  89763. * @param fastCheck defines if the first intersection will be used (and not the closest)
  89764. * @returns picking info of the intersecton
  89765. */
  89766. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  89767. /**
  89768. * Checks if ray intersects a mesh
  89769. * @param meshes the meshes to check
  89770. * @param fastCheck defines if the first intersection will be used (and not the closest)
  89771. * @param results array to store result in
  89772. * @returns Array of picking infos
  89773. */
  89774. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  89775. private _comparePickingInfo;
  89776. private static smallnum;
  89777. private static rayl;
  89778. /**
  89779. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  89780. * @param sega the first point of the segment to test the intersection against
  89781. * @param segb the second point of the segment to test the intersection against
  89782. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  89783. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  89784. */
  89785. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  89786. /**
  89787. * Update the ray from viewport position
  89788. * @param x position
  89789. * @param y y position
  89790. * @param viewportWidth viewport width
  89791. * @param viewportHeight viewport height
  89792. * @param world world matrix
  89793. * @param view view matrix
  89794. * @param projection projection matrix
  89795. * @returns this ray updated
  89796. */
  89797. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  89798. /**
  89799. * Creates a ray with origin and direction of 0,0,0
  89800. * @returns the new ray
  89801. */
  89802. static Zero(): Ray;
  89803. /**
  89804. * Creates a new ray from screen space and viewport
  89805. * @param x position
  89806. * @param y y position
  89807. * @param viewportWidth viewport width
  89808. * @param viewportHeight viewport height
  89809. * @param world world matrix
  89810. * @param view view matrix
  89811. * @param projection projection matrix
  89812. * @returns new ray
  89813. */
  89814. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  89815. /**
  89816. * 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
  89817. * transformed to the given world matrix.
  89818. * @param origin The origin point
  89819. * @param end The end point
  89820. * @param world a matrix to transform the ray to. Default is the identity matrix.
  89821. * @returns the new ray
  89822. */
  89823. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  89824. /**
  89825. * Transforms a ray by a matrix
  89826. * @param ray ray to transform
  89827. * @param matrix matrix to apply
  89828. * @returns the resulting new ray
  89829. */
  89830. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  89831. /**
  89832. * Transforms a ray by a matrix
  89833. * @param ray ray to transform
  89834. * @param matrix matrix to apply
  89835. * @param result ray to store result in
  89836. */
  89837. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  89838. /**
  89839. * Unproject a ray from screen space to object space
  89840. * @param sourceX defines the screen space x coordinate to use
  89841. * @param sourceY defines the screen space y coordinate to use
  89842. * @param viewportWidth defines the current width of the viewport
  89843. * @param viewportHeight defines the current height of the viewport
  89844. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  89845. * @param view defines the view matrix to use
  89846. * @param projection defines the projection matrix to use
  89847. */
  89848. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  89849. }
  89850. /**
  89851. * Type used to define predicate used to select faces when a mesh intersection is detected
  89852. */
  89853. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  89854. interface Scene {
  89855. /** @hidden */
  89856. _tempPickingRay: Nullable<Ray>;
  89857. /** @hidden */
  89858. _cachedRayForTransform: Ray;
  89859. /** @hidden */
  89860. _pickWithRayInverseMatrix: Matrix;
  89861. /** @hidden */
  89862. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  89863. /** @hidden */
  89864. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  89865. /** @hidden */
  89866. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  89867. }
  89868. }
  89869. declare module BABYLON {
  89870. /**
  89871. * Groups all the scene component constants in one place to ease maintenance.
  89872. * @hidden
  89873. */
  89874. export class SceneComponentConstants {
  89875. static readonly NAME_EFFECTLAYER: string;
  89876. static readonly NAME_LAYER: string;
  89877. static readonly NAME_LENSFLARESYSTEM: string;
  89878. static readonly NAME_BOUNDINGBOXRENDERER: string;
  89879. static readonly NAME_PARTICLESYSTEM: string;
  89880. static readonly NAME_GAMEPAD: string;
  89881. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  89882. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  89883. static readonly NAME_PREPASSRENDERER: string;
  89884. static readonly NAME_DEPTHRENDERER: string;
  89885. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  89886. static readonly NAME_SPRITE: string;
  89887. static readonly NAME_OUTLINERENDERER: string;
  89888. static readonly NAME_PROCEDURALTEXTURE: string;
  89889. static readonly NAME_SHADOWGENERATOR: string;
  89890. static readonly NAME_OCTREE: string;
  89891. static readonly NAME_PHYSICSENGINE: string;
  89892. static readonly NAME_AUDIO: string;
  89893. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  89894. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  89895. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  89896. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  89897. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  89898. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  89899. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  89900. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  89901. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  89902. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  89903. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  89904. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  89905. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  89906. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  89907. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  89908. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  89909. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  89910. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  89911. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  89912. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  89913. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  89914. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  89915. static readonly STEP_AFTERRENDER_AUDIO: number;
  89916. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  89917. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  89918. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  89919. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  89920. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  89921. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  89922. static readonly STEP_POINTERMOVE_SPRITE: number;
  89923. static readonly STEP_POINTERDOWN_SPRITE: number;
  89924. static readonly STEP_POINTERUP_SPRITE: number;
  89925. }
  89926. /**
  89927. * This represents a scene component.
  89928. *
  89929. * This is used to decouple the dependency the scene is having on the different workloads like
  89930. * layers, post processes...
  89931. */
  89932. export interface ISceneComponent {
  89933. /**
  89934. * The name of the component. Each component must have a unique name.
  89935. */
  89936. name: string;
  89937. /**
  89938. * The scene the component belongs to.
  89939. */
  89940. scene: Scene;
  89941. /**
  89942. * Register the component to one instance of a scene.
  89943. */
  89944. register(): void;
  89945. /**
  89946. * Rebuilds the elements related to this component in case of
  89947. * context lost for instance.
  89948. */
  89949. rebuild(): void;
  89950. /**
  89951. * Disposes the component and the associated ressources.
  89952. */
  89953. dispose(): void;
  89954. }
  89955. /**
  89956. * This represents a SERIALIZABLE scene component.
  89957. *
  89958. * This extends Scene Component to add Serialization methods on top.
  89959. */
  89960. export interface ISceneSerializableComponent extends ISceneComponent {
  89961. /**
  89962. * Adds all the elements from the container to the scene
  89963. * @param container the container holding the elements
  89964. */
  89965. addFromContainer(container: AbstractScene): void;
  89966. /**
  89967. * Removes all the elements in the container from the scene
  89968. * @param container contains the elements to remove
  89969. * @param dispose if the removed element should be disposed (default: false)
  89970. */
  89971. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  89972. /**
  89973. * Serializes the component data to the specified json object
  89974. * @param serializationObject The object to serialize to
  89975. */
  89976. serialize(serializationObject: any): void;
  89977. }
  89978. /**
  89979. * Strong typing of a Mesh related stage step action
  89980. */
  89981. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  89982. /**
  89983. * Strong typing of a Evaluate Sub Mesh related stage step action
  89984. */
  89985. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  89986. /**
  89987. * Strong typing of a Active Mesh related stage step action
  89988. */
  89989. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  89990. /**
  89991. * Strong typing of a Camera related stage step action
  89992. */
  89993. export type CameraStageAction = (camera: Camera) => void;
  89994. /**
  89995. * Strong typing of a Camera Frame buffer related stage step action
  89996. */
  89997. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  89998. /**
  89999. * Strong typing of a Render Target related stage step action
  90000. */
  90001. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  90002. /**
  90003. * Strong typing of a RenderingGroup related stage step action
  90004. */
  90005. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  90006. /**
  90007. * Strong typing of a Mesh Render related stage step action
  90008. */
  90009. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  90010. /**
  90011. * Strong typing of a simple stage step action
  90012. */
  90013. export type SimpleStageAction = () => void;
  90014. /**
  90015. * Strong typing of a render target action.
  90016. */
  90017. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  90018. /**
  90019. * Strong typing of a pointer move action.
  90020. */
  90021. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  90022. /**
  90023. * Strong typing of a pointer up/down action.
  90024. */
  90025. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  90026. /**
  90027. * Representation of a stage in the scene (Basically a list of ordered steps)
  90028. * @hidden
  90029. */
  90030. export class Stage<T extends Function> extends Array<{
  90031. index: number;
  90032. component: ISceneComponent;
  90033. action: T;
  90034. }> {
  90035. /**
  90036. * Hide ctor from the rest of the world.
  90037. * @param items The items to add.
  90038. */
  90039. private constructor();
  90040. /**
  90041. * Creates a new Stage.
  90042. * @returns A new instance of a Stage
  90043. */
  90044. static Create<T extends Function>(): Stage<T>;
  90045. /**
  90046. * Registers a step in an ordered way in the targeted stage.
  90047. * @param index Defines the position to register the step in
  90048. * @param component Defines the component attached to the step
  90049. * @param action Defines the action to launch during the step
  90050. */
  90051. registerStep(index: number, component: ISceneComponent, action: T): void;
  90052. /**
  90053. * Clears all the steps from the stage.
  90054. */
  90055. clear(): void;
  90056. }
  90057. }
  90058. declare module BABYLON {
  90059. interface Scene {
  90060. /** @hidden */
  90061. _pointerOverSprite: Nullable<Sprite>;
  90062. /** @hidden */
  90063. _pickedDownSprite: Nullable<Sprite>;
  90064. /** @hidden */
  90065. _tempSpritePickingRay: Nullable<Ray>;
  90066. /**
  90067. * All of the sprite managers added to this scene
  90068. * @see https://doc.babylonjs.com/babylon101/sprites
  90069. */
  90070. spriteManagers: Array<ISpriteManager>;
  90071. /**
  90072. * An event triggered when sprites rendering is about to start
  90073. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  90074. */
  90075. onBeforeSpritesRenderingObservable: Observable<Scene>;
  90076. /**
  90077. * An event triggered when sprites rendering is done
  90078. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  90079. */
  90080. onAfterSpritesRenderingObservable: Observable<Scene>;
  90081. /** @hidden */
  90082. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  90083. /** Launch a ray to try to pick a sprite in the scene
  90084. * @param x position on screen
  90085. * @param y position on screen
  90086. * @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
  90087. * @param fastCheck defines if the first intersection will be used (and not the closest)
  90088. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  90089. * @returns a PickingInfo
  90090. */
  90091. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  90092. /** Use the given ray to pick a sprite in the scene
  90093. * @param ray The ray (in world space) to use to pick meshes
  90094. * @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
  90095. * @param fastCheck defines if the first intersection will be used (and not the closest)
  90096. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  90097. * @returns a PickingInfo
  90098. */
  90099. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  90100. /** @hidden */
  90101. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  90102. /** Launch a ray to try to pick sprites in the scene
  90103. * @param x position on screen
  90104. * @param y position on screen
  90105. * @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
  90106. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  90107. * @returns a PickingInfo array
  90108. */
  90109. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  90110. /** Use the given ray to pick sprites in the scene
  90111. * @param ray The ray (in world space) to use to pick meshes
  90112. * @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
  90113. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  90114. * @returns a PickingInfo array
  90115. */
  90116. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  90117. /**
  90118. * Force the sprite under the pointer
  90119. * @param sprite defines the sprite to use
  90120. */
  90121. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  90122. /**
  90123. * Gets the sprite under the pointer
  90124. * @returns a Sprite or null if no sprite is under the pointer
  90125. */
  90126. getPointerOverSprite(): Nullable<Sprite>;
  90127. }
  90128. /**
  90129. * Defines the sprite scene component responsible to manage sprites
  90130. * in a given scene.
  90131. */
  90132. export class SpriteSceneComponent implements ISceneComponent {
  90133. /**
  90134. * The component name helpfull to identify the component in the list of scene components.
  90135. */
  90136. readonly name: string;
  90137. /**
  90138. * The scene the component belongs to.
  90139. */
  90140. scene: Scene;
  90141. /** @hidden */
  90142. private _spritePredicate;
  90143. /**
  90144. * Creates a new instance of the component for the given scene
  90145. * @param scene Defines the scene to register the component in
  90146. */
  90147. constructor(scene: Scene);
  90148. /**
  90149. * Registers the component in a given scene
  90150. */
  90151. register(): void;
  90152. /**
  90153. * Rebuilds the elements related to this component in case of
  90154. * context lost for instance.
  90155. */
  90156. rebuild(): void;
  90157. /**
  90158. * Disposes the component and the associated ressources.
  90159. */
  90160. dispose(): void;
  90161. private _pickSpriteButKeepRay;
  90162. private _pointerMove;
  90163. private _pointerDown;
  90164. private _pointerUp;
  90165. }
  90166. }
  90167. declare module BABYLON {
  90168. /** @hidden */
  90169. export var fogFragmentDeclaration: {
  90170. name: string;
  90171. shader: string;
  90172. };
  90173. }
  90174. declare module BABYLON {
  90175. /** @hidden */
  90176. export var fogFragment: {
  90177. name: string;
  90178. shader: string;
  90179. };
  90180. }
  90181. declare module BABYLON {
  90182. /** @hidden */
  90183. export var spritesPixelShader: {
  90184. name: string;
  90185. shader: string;
  90186. };
  90187. }
  90188. declare module BABYLON {
  90189. /** @hidden */
  90190. export var fogVertexDeclaration: {
  90191. name: string;
  90192. shader: string;
  90193. };
  90194. }
  90195. declare module BABYLON {
  90196. /** @hidden */
  90197. export var spritesVertexShader: {
  90198. name: string;
  90199. shader: string;
  90200. };
  90201. }
  90202. declare module BABYLON {
  90203. /**
  90204. * Defines the minimum interface to fullfil in order to be a sprite manager.
  90205. */
  90206. export interface ISpriteManager extends IDisposable {
  90207. /**
  90208. * Gets manager's name
  90209. */
  90210. name: string;
  90211. /**
  90212. * Restricts the camera to viewing objects with the same layerMask.
  90213. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  90214. */
  90215. layerMask: number;
  90216. /**
  90217. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  90218. */
  90219. isPickable: boolean;
  90220. /**
  90221. * Gets the hosting scene
  90222. */
  90223. scene: Scene;
  90224. /**
  90225. * Specifies the rendering group id for this mesh (0 by default)
  90226. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  90227. */
  90228. renderingGroupId: number;
  90229. /**
  90230. * Defines the list of sprites managed by the manager.
  90231. */
  90232. sprites: Array<Sprite>;
  90233. /**
  90234. * Gets or sets the spritesheet texture
  90235. */
  90236. texture: Texture;
  90237. /** Defines the default width of a cell in the spritesheet */
  90238. cellWidth: number;
  90239. /** Defines the default height of a cell in the spritesheet */
  90240. cellHeight: number;
  90241. /**
  90242. * Tests the intersection of a sprite with a specific ray.
  90243. * @param ray The ray we are sending to test the collision
  90244. * @param camera The camera space we are sending rays in
  90245. * @param predicate A predicate allowing excluding sprites from the list of object to test
  90246. * @param fastCheck defines if the first intersection will be used (and not the closest)
  90247. * @returns picking info or null.
  90248. */
  90249. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  90250. /**
  90251. * Intersects the sprites with a ray
  90252. * @param ray defines the ray to intersect with
  90253. * @param camera defines the current active camera
  90254. * @param predicate defines a predicate used to select candidate sprites
  90255. * @returns null if no hit or a PickingInfo array
  90256. */
  90257. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  90258. /**
  90259. * Renders the list of sprites on screen.
  90260. */
  90261. render(): void;
  90262. }
  90263. /**
  90264. * Class used to manage multiple sprites on the same spritesheet
  90265. * @see https://doc.babylonjs.com/babylon101/sprites
  90266. */
  90267. export class SpriteManager implements ISpriteManager {
  90268. /** defines the manager's name */
  90269. name: string;
  90270. /** Define the Url to load snippets */
  90271. static SnippetUrl: string;
  90272. /** Snippet ID if the manager was created from the snippet server */
  90273. snippetId: string;
  90274. /** Gets the list of sprites */
  90275. sprites: Sprite[];
  90276. /** Gets or sets the rendering group id (0 by default) */
  90277. renderingGroupId: number;
  90278. /** Gets or sets camera layer mask */
  90279. layerMask: number;
  90280. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  90281. fogEnabled: boolean;
  90282. /** Gets or sets a boolean indicating if the sprites are pickable */
  90283. isPickable: boolean;
  90284. /** Defines the default width of a cell in the spritesheet */
  90285. cellWidth: number;
  90286. /** Defines the default height of a cell in the spritesheet */
  90287. cellHeight: number;
  90288. /** Associative array from JSON sprite data file */
  90289. private _cellData;
  90290. /** Array of sprite names from JSON sprite data file */
  90291. private _spriteMap;
  90292. /** True when packed cell data from JSON file is ready*/
  90293. private _packedAndReady;
  90294. private _textureContent;
  90295. private _useInstancing;
  90296. /**
  90297. * An event triggered when the manager is disposed.
  90298. */
  90299. onDisposeObservable: Observable<SpriteManager>;
  90300. private _onDisposeObserver;
  90301. /**
  90302. * Callback called when the manager is disposed
  90303. */
  90304. set onDispose(callback: () => void);
  90305. private _capacity;
  90306. private _fromPacked;
  90307. private _spriteTexture;
  90308. private _epsilon;
  90309. private _scene;
  90310. private _vertexData;
  90311. private _buffer;
  90312. private _vertexBuffers;
  90313. private _spriteBuffer;
  90314. private _indexBuffer;
  90315. private _effectBase;
  90316. private _effectFog;
  90317. private _vertexBufferSize;
  90318. /**
  90319. * Gets or sets the unique id of the sprite
  90320. */
  90321. uniqueId: number;
  90322. /**
  90323. * Gets the array of sprites
  90324. */
  90325. get children(): Sprite[];
  90326. /**
  90327. * Gets the hosting scene
  90328. */
  90329. get scene(): Scene;
  90330. /**
  90331. * Gets the capacity of the manager
  90332. */
  90333. get capacity(): number;
  90334. /**
  90335. * Gets or sets the spritesheet texture
  90336. */
  90337. get texture(): Texture;
  90338. set texture(value: Texture);
  90339. private _blendMode;
  90340. /**
  90341. * Blend mode use to render the particle, it can be any of
  90342. * the static Constants.ALPHA_x properties provided in this class.
  90343. * Default value is Constants.ALPHA_COMBINE
  90344. */
  90345. get blendMode(): number;
  90346. set blendMode(blendMode: number);
  90347. /** Disables writing to the depth buffer when rendering the sprites.
  90348. * It can be handy to disable depth writing when using textures without alpha channel
  90349. * and setting some specific blend modes.
  90350. */
  90351. disableDepthWrite: boolean;
  90352. /**
  90353. * Creates a new sprite manager
  90354. * @param name defines the manager's name
  90355. * @param imgUrl defines the sprite sheet url
  90356. * @param capacity defines the maximum allowed number of sprites
  90357. * @param cellSize defines the size of a sprite cell
  90358. * @param scene defines the hosting scene
  90359. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  90360. * @param samplingMode defines the smapling mode to use with spritesheet
  90361. * @param fromPacked set to false; do not alter
  90362. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  90363. */
  90364. constructor(
  90365. /** defines the manager's name */
  90366. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  90367. /**
  90368. * Returns the string "SpriteManager"
  90369. * @returns "SpriteManager"
  90370. */
  90371. getClassName(): string;
  90372. private _makePacked;
  90373. private _appendSpriteVertex;
  90374. private _checkTextureAlpha;
  90375. /**
  90376. * Intersects the sprites with a ray
  90377. * @param ray defines the ray to intersect with
  90378. * @param camera defines the current active camera
  90379. * @param predicate defines a predicate used to select candidate sprites
  90380. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  90381. * @returns null if no hit or a PickingInfo
  90382. */
  90383. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  90384. /**
  90385. * Intersects the sprites with a ray
  90386. * @param ray defines the ray to intersect with
  90387. * @param camera defines the current active camera
  90388. * @param predicate defines a predicate used to select candidate sprites
  90389. * @returns null if no hit or a PickingInfo array
  90390. */
  90391. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  90392. /**
  90393. * Render all child sprites
  90394. */
  90395. render(): void;
  90396. /**
  90397. * Release associated resources
  90398. */
  90399. dispose(): void;
  90400. /**
  90401. * Serializes the sprite manager to a JSON object
  90402. * @param serializeTexture defines if the texture must be serialized as well
  90403. * @returns the JSON object
  90404. */
  90405. serialize(serializeTexture?: boolean): any;
  90406. /**
  90407. * Parses a JSON object to create a new sprite manager.
  90408. * @param parsedManager The JSON object to parse
  90409. * @param scene The scene to create the sprite managerin
  90410. * @param rootUrl The root url to use to load external dependencies like texture
  90411. * @returns the new sprite manager
  90412. */
  90413. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  90414. /**
  90415. * Creates a sprite manager from a snippet saved in a remote file
  90416. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  90417. * @param url defines the url to load from
  90418. * @param scene defines the hosting scene
  90419. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  90420. * @returns a promise that will resolve to the new sprite manager
  90421. */
  90422. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  90423. /**
  90424. * Creates a sprite manager from a snippet saved by the sprite editor
  90425. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  90426. * @param scene defines the hosting scene
  90427. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  90428. * @returns a promise that will resolve to the new sprite manager
  90429. */
  90430. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  90431. }
  90432. }
  90433. declare module BABYLON {
  90434. /** Interface used by value gradients (color, factor, ...) */
  90435. export interface IValueGradient {
  90436. /**
  90437. * Gets or sets the gradient value (between 0 and 1)
  90438. */
  90439. gradient: number;
  90440. }
  90441. /** Class used to store color4 gradient */
  90442. export class ColorGradient implements IValueGradient {
  90443. /**
  90444. * Gets or sets the gradient value (between 0 and 1)
  90445. */
  90446. gradient: number;
  90447. /**
  90448. * Gets or sets first associated color
  90449. */
  90450. color1: Color4;
  90451. /**
  90452. * Gets or sets second associated color
  90453. */
  90454. color2?: Color4 | undefined;
  90455. /**
  90456. * Creates a new color4 gradient
  90457. * @param gradient gets or sets the gradient value (between 0 and 1)
  90458. * @param color1 gets or sets first associated color
  90459. * @param color2 gets or sets first second color
  90460. */
  90461. constructor(
  90462. /**
  90463. * Gets or sets the gradient value (between 0 and 1)
  90464. */
  90465. gradient: number,
  90466. /**
  90467. * Gets or sets first associated color
  90468. */
  90469. color1: Color4,
  90470. /**
  90471. * Gets or sets second associated color
  90472. */
  90473. color2?: Color4 | undefined);
  90474. /**
  90475. * Will get a color picked randomly between color1 and color2.
  90476. * If color2 is undefined then color1 will be used
  90477. * @param result defines the target Color4 to store the result in
  90478. */
  90479. getColorToRef(result: Color4): void;
  90480. }
  90481. /** Class used to store color 3 gradient */
  90482. export class Color3Gradient implements IValueGradient {
  90483. /**
  90484. * Gets or sets the gradient value (between 0 and 1)
  90485. */
  90486. gradient: number;
  90487. /**
  90488. * Gets or sets the associated color
  90489. */
  90490. color: Color3;
  90491. /**
  90492. * Creates a new color3 gradient
  90493. * @param gradient gets or sets the gradient value (between 0 and 1)
  90494. * @param color gets or sets associated color
  90495. */
  90496. constructor(
  90497. /**
  90498. * Gets or sets the gradient value (between 0 and 1)
  90499. */
  90500. gradient: number,
  90501. /**
  90502. * Gets or sets the associated color
  90503. */
  90504. color: Color3);
  90505. }
  90506. /** Class used to store factor gradient */
  90507. export class FactorGradient implements IValueGradient {
  90508. /**
  90509. * Gets or sets the gradient value (between 0 and 1)
  90510. */
  90511. gradient: number;
  90512. /**
  90513. * Gets or sets first associated factor
  90514. */
  90515. factor1: number;
  90516. /**
  90517. * Gets or sets second associated factor
  90518. */
  90519. factor2?: number | undefined;
  90520. /**
  90521. * Creates a new factor gradient
  90522. * @param gradient gets or sets the gradient value (between 0 and 1)
  90523. * @param factor1 gets or sets first associated factor
  90524. * @param factor2 gets or sets second associated factor
  90525. */
  90526. constructor(
  90527. /**
  90528. * Gets or sets the gradient value (between 0 and 1)
  90529. */
  90530. gradient: number,
  90531. /**
  90532. * Gets or sets first associated factor
  90533. */
  90534. factor1: number,
  90535. /**
  90536. * Gets or sets second associated factor
  90537. */
  90538. factor2?: number | undefined);
  90539. /**
  90540. * Will get a number picked randomly between factor1 and factor2.
  90541. * If factor2 is undefined then factor1 will be used
  90542. * @returns the picked number
  90543. */
  90544. getFactor(): number;
  90545. }
  90546. /**
  90547. * Helper used to simplify some generic gradient tasks
  90548. */
  90549. export class GradientHelper {
  90550. /**
  90551. * Gets the current gradient from an array of IValueGradient
  90552. * @param ratio defines the current ratio to get
  90553. * @param gradients defines the array of IValueGradient
  90554. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  90555. */
  90556. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  90557. }
  90558. }
  90559. declare module BABYLON {
  90560. interface ThinEngine {
  90561. /**
  90562. * Creates a raw texture
  90563. * @param data defines the data to store in the texture
  90564. * @param width defines the width of the texture
  90565. * @param height defines the height of the texture
  90566. * @param format defines the format of the data
  90567. * @param generateMipMaps defines if the engine should generate the mip levels
  90568. * @param invertY defines if data must be stored with Y axis inverted
  90569. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  90570. * @param compression defines the compression used (null by default)
  90571. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  90572. * @returns the raw texture inside an InternalTexture
  90573. */
  90574. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  90575. /**
  90576. * Update a raw texture
  90577. * @param texture defines the texture to update
  90578. * @param data defines the data to store in the texture
  90579. * @param format defines the format of the data
  90580. * @param invertY defines if data must be stored with Y axis inverted
  90581. */
  90582. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  90583. /**
  90584. * Update a raw texture
  90585. * @param texture defines the texture to update
  90586. * @param data defines the data to store in the texture
  90587. * @param format defines the format of the data
  90588. * @param invertY defines if data must be stored with Y axis inverted
  90589. * @param compression defines the compression used (null by default)
  90590. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  90591. */
  90592. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  90593. /**
  90594. * Creates a new raw cube texture
  90595. * @param data defines the array of data to use to create each face
  90596. * @param size defines the size of the textures
  90597. * @param format defines the format of the data
  90598. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  90599. * @param generateMipMaps defines if the engine should generate the mip levels
  90600. * @param invertY defines if data must be stored with Y axis inverted
  90601. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  90602. * @param compression defines the compression used (null by default)
  90603. * @returns the cube texture as an InternalTexture
  90604. */
  90605. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  90606. /**
  90607. * Update a raw cube texture
  90608. * @param texture defines the texture to udpdate
  90609. * @param data defines the data to store
  90610. * @param format defines the data format
  90611. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  90612. * @param invertY defines if data must be stored with Y axis inverted
  90613. */
  90614. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  90615. /**
  90616. * Update a raw cube texture
  90617. * @param texture defines the texture to udpdate
  90618. * @param data defines the data to store
  90619. * @param format defines the data format
  90620. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  90621. * @param invertY defines if data must be stored with Y axis inverted
  90622. * @param compression defines the compression used (null by default)
  90623. */
  90624. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  90625. /**
  90626. * Update a raw cube texture
  90627. * @param texture defines the texture to udpdate
  90628. * @param data defines the data to store
  90629. * @param format defines the data format
  90630. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  90631. * @param invertY defines if data must be stored with Y axis inverted
  90632. * @param compression defines the compression used (null by default)
  90633. * @param level defines which level of the texture to update
  90634. */
  90635. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  90636. /**
  90637. * Creates a new raw cube texture from a specified url
  90638. * @param url defines the url where the data is located
  90639. * @param scene defines the current scene
  90640. * @param size defines the size of the textures
  90641. * @param format defines the format of the data
  90642. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  90643. * @param noMipmap defines if the engine should avoid generating the mip levels
  90644. * @param callback defines a callback used to extract texture data from loaded data
  90645. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  90646. * @param onLoad defines a callback called when texture is loaded
  90647. * @param onError defines a callback called if there is an error
  90648. * @returns the cube texture as an InternalTexture
  90649. */
  90650. 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;
  90651. /**
  90652. * Creates a new raw cube texture from a specified url
  90653. * @param url defines the url where the data is located
  90654. * @param scene defines the current scene
  90655. * @param size defines the size of the textures
  90656. * @param format defines the format of the data
  90657. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  90658. * @param noMipmap defines if the engine should avoid generating the mip levels
  90659. * @param callback defines a callback used to extract texture data from loaded data
  90660. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  90661. * @param onLoad defines a callback called when texture is loaded
  90662. * @param onError defines a callback called if there is an error
  90663. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  90664. * @param invertY defines if data must be stored with Y axis inverted
  90665. * @returns the cube texture as an InternalTexture
  90666. */
  90667. 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;
  90668. /**
  90669. * Creates a new raw 3D texture
  90670. * @param data defines the data used to create the texture
  90671. * @param width defines the width of the texture
  90672. * @param height defines the height of the texture
  90673. * @param depth defines the depth of the texture
  90674. * @param format defines the format of the texture
  90675. * @param generateMipMaps defines if the engine must generate mip levels
  90676. * @param invertY defines if data must be stored with Y axis inverted
  90677. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  90678. * @param compression defines the compressed used (can be null)
  90679. * @param textureType defines the compressed used (can be null)
  90680. * @returns a new raw 3D texture (stored in an InternalTexture)
  90681. */
  90682. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  90683. /**
  90684. * Update a raw 3D texture
  90685. * @param texture defines the texture to update
  90686. * @param data defines the data to store
  90687. * @param format defines the data format
  90688. * @param invertY defines if data must be stored with Y axis inverted
  90689. */
  90690. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  90691. /**
  90692. * Update a raw 3D texture
  90693. * @param texture defines the texture to update
  90694. * @param data defines the data to store
  90695. * @param format defines the data format
  90696. * @param invertY defines if data must be stored with Y axis inverted
  90697. * @param compression defines the used compression (can be null)
  90698. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  90699. */
  90700. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  90701. /**
  90702. * Creates a new raw 2D array texture
  90703. * @param data defines the data used to create the texture
  90704. * @param width defines the width of the texture
  90705. * @param height defines the height of the texture
  90706. * @param depth defines the number of layers of the texture
  90707. * @param format defines the format of the texture
  90708. * @param generateMipMaps defines if the engine must generate mip levels
  90709. * @param invertY defines if data must be stored with Y axis inverted
  90710. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  90711. * @param compression defines the compressed used (can be null)
  90712. * @param textureType defines the compressed used (can be null)
  90713. * @returns a new raw 2D array texture (stored in an InternalTexture)
  90714. */
  90715. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  90716. /**
  90717. * Update a raw 2D array texture
  90718. * @param texture defines the texture to update
  90719. * @param data defines the data to store
  90720. * @param format defines the data format
  90721. * @param invertY defines if data must be stored with Y axis inverted
  90722. */
  90723. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  90724. /**
  90725. * Update a raw 2D array texture
  90726. * @param texture defines the texture to update
  90727. * @param data defines the data to store
  90728. * @param format defines the data format
  90729. * @param invertY defines if data must be stored with Y axis inverted
  90730. * @param compression defines the used compression (can be null)
  90731. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  90732. */
  90733. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  90734. }
  90735. }
  90736. declare module BABYLON {
  90737. /**
  90738. * Raw texture can help creating a texture directly from an array of data.
  90739. * This can be super useful if you either get the data from an uncompressed source or
  90740. * if you wish to create your texture pixel by pixel.
  90741. */
  90742. export class RawTexture extends Texture {
  90743. /**
  90744. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  90745. */
  90746. format: number;
  90747. /**
  90748. * Instantiates a new RawTexture.
  90749. * Raw texture can help creating a texture directly from an array of data.
  90750. * This can be super useful if you either get the data from an uncompressed source or
  90751. * if you wish to create your texture pixel by pixel.
  90752. * @param data define the array of data to use to create the texture
  90753. * @param width define the width of the texture
  90754. * @param height define the height of the texture
  90755. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  90756. * @param sceneOrEngine defines the scene or engine the texture will belong to
  90757. * @param generateMipMaps define whether mip maps should be generated or not
  90758. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  90759. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  90760. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  90761. */
  90762. constructor(data: ArrayBufferView, width: number, height: number,
  90763. /**
  90764. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  90765. */
  90766. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  90767. /**
  90768. * Updates the texture underlying data.
  90769. * @param data Define the new data of the texture
  90770. */
  90771. update(data: ArrayBufferView): void;
  90772. /**
  90773. * Creates a luminance texture from some data.
  90774. * @param data Define the texture data
  90775. * @param width Define the width of the texture
  90776. * @param height Define the height of the texture
  90777. * @param sceneOrEngine defines the scene or engine the texture will belong to
  90778. * @param generateMipMaps Define whether or not to create mip maps for the texture
  90779. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  90780. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  90781. * @returns the luminance texture
  90782. */
  90783. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  90784. /**
  90785. * Creates a luminance alpha texture from some data.
  90786. * @param data Define the texture data
  90787. * @param width Define the width of the texture
  90788. * @param height Define the height of the texture
  90789. * @param sceneOrEngine defines the scene or engine the texture will belong to
  90790. * @param generateMipMaps Define whether or not to create mip maps for the texture
  90791. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  90792. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  90793. * @returns the luminance alpha texture
  90794. */
  90795. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  90796. /**
  90797. * Creates an alpha texture from some data.
  90798. * @param data Define the texture data
  90799. * @param width Define the width of the texture
  90800. * @param height Define the height of the texture
  90801. * @param sceneOrEngine defines the scene or engine the texture will belong to
  90802. * @param generateMipMaps Define whether or not to create mip maps for the texture
  90803. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  90804. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  90805. * @returns the alpha texture
  90806. */
  90807. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  90808. /**
  90809. * Creates a RGB texture from some data.
  90810. * @param data Define the texture data
  90811. * @param width Define the width of the texture
  90812. * @param height Define the height of the texture
  90813. * @param sceneOrEngine defines the scene or engine the texture will belong to
  90814. * @param generateMipMaps Define whether or not to create mip maps for the texture
  90815. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  90816. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  90817. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  90818. * @returns the RGB alpha texture
  90819. */
  90820. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  90821. /**
  90822. * Creates a RGBA texture from some data.
  90823. * @param data Define the texture data
  90824. * @param width Define the width of the texture
  90825. * @param height Define the height of the texture
  90826. * @param sceneOrEngine defines the scene or engine the texture will belong to
  90827. * @param generateMipMaps Define whether or not to create mip maps for the texture
  90828. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  90829. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  90830. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  90831. * @returns the RGBA texture
  90832. */
  90833. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  90834. /**
  90835. * Creates a R texture from some data.
  90836. * @param data Define the texture data
  90837. * @param width Define the width of the texture
  90838. * @param height Define the height of the texture
  90839. * @param sceneOrEngine defines the scene or engine the texture will belong to
  90840. * @param generateMipMaps Define whether or not to create mip maps for the texture
  90841. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  90842. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  90843. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  90844. * @returns the R texture
  90845. */
  90846. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  90847. }
  90848. }
  90849. declare module BABYLON {
  90850. interface ThinEngine {
  90851. /**
  90852. * Update a dynamic index buffer
  90853. * @param indexBuffer defines the target index buffer
  90854. * @param indices defines the data to update
  90855. * @param offset defines the offset in the target index buffer where update should start
  90856. */
  90857. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  90858. /**
  90859. * Updates a dynamic vertex buffer.
  90860. * @param vertexBuffer the vertex buffer to update
  90861. * @param data the data used to update the vertex buffer
  90862. * @param byteOffset the byte offset of the data
  90863. * @param byteLength the byte length of the data
  90864. */
  90865. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  90866. }
  90867. }
  90868. declare module BABYLON {
  90869. interface AbstractScene {
  90870. /**
  90871. * The list of procedural textures added to the scene
  90872. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  90873. */
  90874. proceduralTextures: Array<ProceduralTexture>;
  90875. }
  90876. /**
  90877. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  90878. * in a given scene.
  90879. */
  90880. export class ProceduralTextureSceneComponent implements ISceneComponent {
  90881. /**
  90882. * The component name helpfull to identify the component in the list of scene components.
  90883. */
  90884. readonly name: string;
  90885. /**
  90886. * The scene the component belongs to.
  90887. */
  90888. scene: Scene;
  90889. /**
  90890. * Creates a new instance of the component for the given scene
  90891. * @param scene Defines the scene to register the component in
  90892. */
  90893. constructor(scene: Scene);
  90894. /**
  90895. * Registers the component in a given scene
  90896. */
  90897. register(): void;
  90898. /**
  90899. * Rebuilds the elements related to this component in case of
  90900. * context lost for instance.
  90901. */
  90902. rebuild(): void;
  90903. /**
  90904. * Disposes the component and the associated ressources.
  90905. */
  90906. dispose(): void;
  90907. private _beforeClear;
  90908. }
  90909. }
  90910. declare module BABYLON {
  90911. interface ThinEngine {
  90912. /**
  90913. * Creates a new render target cube texture
  90914. * @param size defines the size of the texture
  90915. * @param options defines the options used to create the texture
  90916. * @returns a new render target cube texture stored in an InternalTexture
  90917. */
  90918. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  90919. }
  90920. }
  90921. declare module BABYLON {
  90922. /** @hidden */
  90923. export var proceduralVertexShader: {
  90924. name: string;
  90925. shader: string;
  90926. };
  90927. }
  90928. declare module BABYLON {
  90929. /**
  90930. * 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.
  90931. * This is the base class of any Procedural texture and contains most of the shareable code.
  90932. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  90933. */
  90934. export class ProceduralTexture extends Texture {
  90935. isCube: boolean;
  90936. /**
  90937. * Define if the texture is enabled or not (disabled texture will not render)
  90938. */
  90939. isEnabled: boolean;
  90940. /**
  90941. * Define if the texture must be cleared before rendering (default is true)
  90942. */
  90943. autoClear: boolean;
  90944. /**
  90945. * Callback called when the texture is generated
  90946. */
  90947. onGenerated: () => void;
  90948. /**
  90949. * Event raised when the texture is generated
  90950. */
  90951. onGeneratedObservable: Observable<ProceduralTexture>;
  90952. /** @hidden */
  90953. _generateMipMaps: boolean;
  90954. /** @hidden **/
  90955. _effect: Effect;
  90956. /** @hidden */
  90957. _textures: {
  90958. [key: string]: Texture;
  90959. };
  90960. /** @hidden */
  90961. protected _fallbackTexture: Nullable<Texture>;
  90962. private _size;
  90963. private _currentRefreshId;
  90964. private _frameId;
  90965. private _refreshRate;
  90966. private _vertexBuffers;
  90967. private _indexBuffer;
  90968. private _uniforms;
  90969. private _samplers;
  90970. private _fragment;
  90971. private _floats;
  90972. private _ints;
  90973. private _floatsArrays;
  90974. private _colors3;
  90975. private _colors4;
  90976. private _vectors2;
  90977. private _vectors3;
  90978. private _matrices;
  90979. private _fallbackTextureUsed;
  90980. private _fullEngine;
  90981. private _cachedDefines;
  90982. private _contentUpdateId;
  90983. private _contentData;
  90984. /**
  90985. * Instantiates a new procedural texture.
  90986. * 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.
  90987. * This is the base class of any Procedural texture and contains most of the shareable code.
  90988. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  90989. * @param name Define the name of the texture
  90990. * @param size Define the size of the texture to create
  90991. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  90992. * @param scene Define the scene the texture belongs to
  90993. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  90994. * @param generateMipMaps Define if the texture should creates mip maps or not
  90995. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  90996. */
  90997. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  90998. /**
  90999. * The effect that is created when initializing the post process.
  91000. * @returns The created effect corresponding the the postprocess.
  91001. */
  91002. getEffect(): Effect;
  91003. /**
  91004. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  91005. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  91006. */
  91007. getContent(): Nullable<ArrayBufferView>;
  91008. private _createIndexBuffer;
  91009. /** @hidden */
  91010. _rebuild(): void;
  91011. /**
  91012. * Resets the texture in order to recreate its associated resources.
  91013. * This can be called in case of context loss
  91014. */
  91015. reset(): void;
  91016. protected _getDefines(): string;
  91017. /**
  91018. * Is the texture ready to be used ? (rendered at least once)
  91019. * @returns true if ready, otherwise, false.
  91020. */
  91021. isReady(): boolean;
  91022. /**
  91023. * Resets the refresh counter of the texture and start bak from scratch.
  91024. * Could be useful to regenerate the texture if it is setup to render only once.
  91025. */
  91026. resetRefreshCounter(): void;
  91027. /**
  91028. * Set the fragment shader to use in order to render the texture.
  91029. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  91030. */
  91031. setFragment(fragment: any): void;
  91032. /**
  91033. * Define the refresh rate of the texture or the rendering frequency.
  91034. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  91035. */
  91036. get refreshRate(): number;
  91037. set refreshRate(value: number);
  91038. /** @hidden */
  91039. _shouldRender(): boolean;
  91040. /**
  91041. * Get the size the texture is rendering at.
  91042. * @returns the size (texture is always squared)
  91043. */
  91044. getRenderSize(): number;
  91045. /**
  91046. * Resize the texture to new value.
  91047. * @param size Define the new size the texture should have
  91048. * @param generateMipMaps Define whether the new texture should create mip maps
  91049. */
  91050. resize(size: number, generateMipMaps: boolean): void;
  91051. private _checkUniform;
  91052. /**
  91053. * Set a texture in the shader program used to render.
  91054. * @param name Define the name of the uniform samplers as defined in the shader
  91055. * @param texture Define the texture to bind to this sampler
  91056. * @return the texture itself allowing "fluent" like uniform updates
  91057. */
  91058. setTexture(name: string, texture: Texture): ProceduralTexture;
  91059. /**
  91060. * Set a float in the shader.
  91061. * @param name Define the name of the uniform as defined in the shader
  91062. * @param value Define the value to give to the uniform
  91063. * @return the texture itself allowing "fluent" like uniform updates
  91064. */
  91065. setFloat(name: string, value: number): ProceduralTexture;
  91066. /**
  91067. * Set a int in the shader.
  91068. * @param name Define the name of the uniform as defined in the shader
  91069. * @param value Define the value to give to the uniform
  91070. * @return the texture itself allowing "fluent" like uniform updates
  91071. */
  91072. setInt(name: string, value: number): ProceduralTexture;
  91073. /**
  91074. * Set an array of floats in the shader.
  91075. * @param name Define the name of the uniform as defined in the shader
  91076. * @param value Define the value to give to the uniform
  91077. * @return the texture itself allowing "fluent" like uniform updates
  91078. */
  91079. setFloats(name: string, value: number[]): ProceduralTexture;
  91080. /**
  91081. * Set a vec3 in the shader from a Color3.
  91082. * @param name Define the name of the uniform as defined in the shader
  91083. * @param value Define the value to give to the uniform
  91084. * @return the texture itself allowing "fluent" like uniform updates
  91085. */
  91086. setColor3(name: string, value: Color3): ProceduralTexture;
  91087. /**
  91088. * Set a vec4 in the shader from a Color4.
  91089. * @param name Define the name of the uniform as defined in the shader
  91090. * @param value Define the value to give to the uniform
  91091. * @return the texture itself allowing "fluent" like uniform updates
  91092. */
  91093. setColor4(name: string, value: Color4): ProceduralTexture;
  91094. /**
  91095. * Set a vec2 in the shader from a Vector2.
  91096. * @param name Define the name of the uniform as defined in the shader
  91097. * @param value Define the value to give to the uniform
  91098. * @return the texture itself allowing "fluent" like uniform updates
  91099. */
  91100. setVector2(name: string, value: Vector2): ProceduralTexture;
  91101. /**
  91102. * Set a vec3 in the shader from a Vector3.
  91103. * @param name Define the name of the uniform as defined in the shader
  91104. * @param value Define the value to give to the uniform
  91105. * @return the texture itself allowing "fluent" like uniform updates
  91106. */
  91107. setVector3(name: string, value: Vector3): ProceduralTexture;
  91108. /**
  91109. * Set a mat4 in the shader from a MAtrix.
  91110. * @param name Define the name of the uniform as defined in the shader
  91111. * @param value Define the value to give to the uniform
  91112. * @return the texture itself allowing "fluent" like uniform updates
  91113. */
  91114. setMatrix(name: string, value: Matrix): ProceduralTexture;
  91115. /**
  91116. * Render the texture to its associated render target.
  91117. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  91118. */
  91119. render(useCameraPostProcess?: boolean): void;
  91120. /**
  91121. * Clone the texture.
  91122. * @returns the cloned texture
  91123. */
  91124. clone(): ProceduralTexture;
  91125. /**
  91126. * Dispose the texture and release its asoociated resources.
  91127. */
  91128. dispose(): void;
  91129. }
  91130. }
  91131. declare module BABYLON {
  91132. /**
  91133. * This represents the base class for particle system in Babylon.
  91134. * 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.
  91135. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  91136. * @example https://doc.babylonjs.com/babylon101/particles
  91137. */
  91138. export class BaseParticleSystem {
  91139. /**
  91140. * Source color is added to the destination color without alpha affecting the result
  91141. */
  91142. static BLENDMODE_ONEONE: number;
  91143. /**
  91144. * Blend current color and particle color using particle’s alpha
  91145. */
  91146. static BLENDMODE_STANDARD: number;
  91147. /**
  91148. * Add current color and particle color multiplied by particle’s alpha
  91149. */
  91150. static BLENDMODE_ADD: number;
  91151. /**
  91152. * Multiply current color with particle color
  91153. */
  91154. static BLENDMODE_MULTIPLY: number;
  91155. /**
  91156. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  91157. */
  91158. static BLENDMODE_MULTIPLYADD: number;
  91159. /**
  91160. * List of animations used by the particle system.
  91161. */
  91162. animations: Animation[];
  91163. /**
  91164. * Gets or sets the unique id of the particle system
  91165. */
  91166. uniqueId: number;
  91167. /**
  91168. * The id of the Particle system.
  91169. */
  91170. id: string;
  91171. /**
  91172. * The friendly name of the Particle system.
  91173. */
  91174. name: string;
  91175. /**
  91176. * Snippet ID if the particle system was created from the snippet server
  91177. */
  91178. snippetId: string;
  91179. /**
  91180. * The rendering group used by the Particle system to chose when to render.
  91181. */
  91182. renderingGroupId: number;
  91183. /**
  91184. * The emitter represents the Mesh or position we are attaching the particle system to.
  91185. */
  91186. emitter: Nullable<AbstractMesh | Vector3>;
  91187. /**
  91188. * The maximum number of particles to emit per frame
  91189. */
  91190. emitRate: number;
  91191. /**
  91192. * If you want to launch only a few particles at once, that can be done, as well.
  91193. */
  91194. manualEmitCount: number;
  91195. /**
  91196. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  91197. */
  91198. updateSpeed: number;
  91199. /**
  91200. * The amount of time the particle system is running (depends of the overall update speed).
  91201. */
  91202. targetStopDuration: number;
  91203. /**
  91204. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  91205. */
  91206. disposeOnStop: boolean;
  91207. /**
  91208. * Minimum power of emitting particles.
  91209. */
  91210. minEmitPower: number;
  91211. /**
  91212. * Maximum power of emitting particles.
  91213. */
  91214. maxEmitPower: number;
  91215. /**
  91216. * Minimum life time of emitting particles.
  91217. */
  91218. minLifeTime: number;
  91219. /**
  91220. * Maximum life time of emitting particles.
  91221. */
  91222. maxLifeTime: number;
  91223. /**
  91224. * Minimum Size of emitting particles.
  91225. */
  91226. minSize: number;
  91227. /**
  91228. * Maximum Size of emitting particles.
  91229. */
  91230. maxSize: number;
  91231. /**
  91232. * Minimum scale of emitting particles on X axis.
  91233. */
  91234. minScaleX: number;
  91235. /**
  91236. * Maximum scale of emitting particles on X axis.
  91237. */
  91238. maxScaleX: number;
  91239. /**
  91240. * Minimum scale of emitting particles on Y axis.
  91241. */
  91242. minScaleY: number;
  91243. /**
  91244. * Maximum scale of emitting particles on Y axis.
  91245. */
  91246. maxScaleY: number;
  91247. /**
  91248. * Gets or sets the minimal initial rotation in radians.
  91249. */
  91250. minInitialRotation: number;
  91251. /**
  91252. * Gets or sets the maximal initial rotation in radians.
  91253. */
  91254. maxInitialRotation: number;
  91255. /**
  91256. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  91257. */
  91258. minAngularSpeed: number;
  91259. /**
  91260. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  91261. */
  91262. maxAngularSpeed: number;
  91263. /**
  91264. * The texture used to render each particle. (this can be a spritesheet)
  91265. */
  91266. particleTexture: Nullable<BaseTexture>;
  91267. /**
  91268. * The layer mask we are rendering the particles through.
  91269. */
  91270. layerMask: number;
  91271. /**
  91272. * This can help using your own shader to render the particle system.
  91273. * The according effect will be created
  91274. */
  91275. customShader: any;
  91276. /**
  91277. * By default particle system starts as soon as they are created. This prevents the
  91278. * automatic start to happen and let you decide when to start emitting particles.
  91279. */
  91280. preventAutoStart: boolean;
  91281. private _noiseTexture;
  91282. /**
  91283. * Gets or sets a texture used to add random noise to particle positions
  91284. */
  91285. get noiseTexture(): Nullable<ProceduralTexture>;
  91286. set noiseTexture(value: Nullable<ProceduralTexture>);
  91287. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  91288. noiseStrength: Vector3;
  91289. /**
  91290. * Callback triggered when the particle animation is ending.
  91291. */
  91292. onAnimationEnd: Nullable<() => void>;
  91293. /**
  91294. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  91295. */
  91296. blendMode: number;
  91297. /**
  91298. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  91299. * to override the particles.
  91300. */
  91301. forceDepthWrite: boolean;
  91302. /** 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 */
  91303. preWarmCycles: number;
  91304. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  91305. preWarmStepOffset: number;
  91306. /**
  91307. * 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)
  91308. */
  91309. spriteCellChangeSpeed: number;
  91310. /**
  91311. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  91312. */
  91313. startSpriteCellID: number;
  91314. /**
  91315. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  91316. */
  91317. endSpriteCellID: number;
  91318. /**
  91319. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  91320. */
  91321. spriteCellWidth: number;
  91322. /**
  91323. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  91324. */
  91325. spriteCellHeight: number;
  91326. /**
  91327. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  91328. */
  91329. spriteRandomStartCell: boolean;
  91330. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  91331. translationPivot: Vector2;
  91332. /** @hidden */
  91333. protected _isAnimationSheetEnabled: boolean;
  91334. /**
  91335. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  91336. */
  91337. beginAnimationOnStart: boolean;
  91338. /**
  91339. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  91340. */
  91341. beginAnimationFrom: number;
  91342. /**
  91343. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  91344. */
  91345. beginAnimationTo: number;
  91346. /**
  91347. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  91348. */
  91349. beginAnimationLoop: boolean;
  91350. /**
  91351. * Gets or sets a world offset applied to all particles
  91352. */
  91353. worldOffset: Vector3;
  91354. /**
  91355. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  91356. */
  91357. get isAnimationSheetEnabled(): boolean;
  91358. set isAnimationSheetEnabled(value: boolean);
  91359. /**
  91360. * Get hosting scene
  91361. * @returns the scene
  91362. */
  91363. getScene(): Nullable<Scene>;
  91364. /**
  91365. * You can use gravity if you want to give an orientation to your particles.
  91366. */
  91367. gravity: Vector3;
  91368. protected _colorGradients: Nullable<Array<ColorGradient>>;
  91369. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  91370. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  91371. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  91372. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  91373. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  91374. protected _dragGradients: Nullable<Array<FactorGradient>>;
  91375. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  91376. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  91377. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  91378. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  91379. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  91380. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  91381. /**
  91382. * Defines the delay in milliseconds before starting the system (0 by default)
  91383. */
  91384. startDelay: number;
  91385. /**
  91386. * Gets the current list of drag gradients.
  91387. * You must use addDragGradient and removeDragGradient to udpate this list
  91388. * @returns the list of drag gradients
  91389. */
  91390. getDragGradients(): Nullable<Array<FactorGradient>>;
  91391. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  91392. limitVelocityDamping: number;
  91393. /**
  91394. * Gets the current list of limit velocity gradients.
  91395. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  91396. * @returns the list of limit velocity gradients
  91397. */
  91398. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  91399. /**
  91400. * Gets the current list of color gradients.
  91401. * You must use addColorGradient and removeColorGradient to udpate this list
  91402. * @returns the list of color gradients
  91403. */
  91404. getColorGradients(): Nullable<Array<ColorGradient>>;
  91405. /**
  91406. * Gets the current list of size gradients.
  91407. * You must use addSizeGradient and removeSizeGradient to udpate this list
  91408. * @returns the list of size gradients
  91409. */
  91410. getSizeGradients(): Nullable<Array<FactorGradient>>;
  91411. /**
  91412. * Gets the current list of color remap gradients.
  91413. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  91414. * @returns the list of color remap gradients
  91415. */
  91416. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  91417. /**
  91418. * Gets the current list of alpha remap gradients.
  91419. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  91420. * @returns the list of alpha remap gradients
  91421. */
  91422. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  91423. /**
  91424. * Gets the current list of life time gradients.
  91425. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  91426. * @returns the list of life time gradients
  91427. */
  91428. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  91429. /**
  91430. * Gets the current list of angular speed gradients.
  91431. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  91432. * @returns the list of angular speed gradients
  91433. */
  91434. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  91435. /**
  91436. * Gets the current list of velocity gradients.
  91437. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  91438. * @returns the list of velocity gradients
  91439. */
  91440. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  91441. /**
  91442. * Gets the current list of start size gradients.
  91443. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  91444. * @returns the list of start size gradients
  91445. */
  91446. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  91447. /**
  91448. * Gets the current list of emit rate gradients.
  91449. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  91450. * @returns the list of emit rate gradients
  91451. */
  91452. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  91453. /**
  91454. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91455. * This only works when particleEmitterTyps is a BoxParticleEmitter
  91456. */
  91457. get direction1(): Vector3;
  91458. set direction1(value: Vector3);
  91459. /**
  91460. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91461. * This only works when particleEmitterTyps is a BoxParticleEmitter
  91462. */
  91463. get direction2(): Vector3;
  91464. set direction2(value: Vector3);
  91465. /**
  91466. * 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.
  91467. * This only works when particleEmitterTyps is a BoxParticleEmitter
  91468. */
  91469. get minEmitBox(): Vector3;
  91470. set minEmitBox(value: Vector3);
  91471. /**
  91472. * 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.
  91473. * This only works when particleEmitterTyps is a BoxParticleEmitter
  91474. */
  91475. get maxEmitBox(): Vector3;
  91476. set maxEmitBox(value: Vector3);
  91477. /**
  91478. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  91479. */
  91480. color1: Color4;
  91481. /**
  91482. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  91483. */
  91484. color2: Color4;
  91485. /**
  91486. * Color the particle will have at the end of its lifetime
  91487. */
  91488. colorDead: Color4;
  91489. /**
  91490. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  91491. */
  91492. textureMask: Color4;
  91493. /**
  91494. * The particle emitter type defines the emitter used by the particle system.
  91495. * It can be for example box, sphere, or cone...
  91496. */
  91497. particleEmitterType: IParticleEmitterType;
  91498. /** @hidden */
  91499. _isSubEmitter: boolean;
  91500. /**
  91501. * Gets or sets the billboard mode to use when isBillboardBased = true.
  91502. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  91503. */
  91504. billboardMode: number;
  91505. protected _isBillboardBased: boolean;
  91506. /**
  91507. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  91508. */
  91509. get isBillboardBased(): boolean;
  91510. set isBillboardBased(value: boolean);
  91511. /**
  91512. * The scene the particle system belongs to.
  91513. */
  91514. protected _scene: Nullable<Scene>;
  91515. /**
  91516. * The engine the particle system belongs to.
  91517. */
  91518. protected _engine: ThinEngine;
  91519. /**
  91520. * Local cache of defines for image processing.
  91521. */
  91522. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  91523. /**
  91524. * Default configuration related to image processing available in the standard Material.
  91525. */
  91526. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  91527. /**
  91528. * Gets the image processing configuration used either in this material.
  91529. */
  91530. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  91531. /**
  91532. * Sets the Default image processing configuration used either in the this material.
  91533. *
  91534. * If sets to null, the scene one is in use.
  91535. */
  91536. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  91537. /**
  91538. * Attaches a new image processing configuration to the Standard Material.
  91539. * @param configuration
  91540. */
  91541. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  91542. /** @hidden */
  91543. protected _reset(): void;
  91544. /** @hidden */
  91545. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  91546. /**
  91547. * Instantiates a particle system.
  91548. * 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.
  91549. * @param name The name of the particle system
  91550. */
  91551. constructor(name: string);
  91552. /**
  91553. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  91554. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  91555. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  91556. * @returns the emitter
  91557. */
  91558. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  91559. /**
  91560. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  91561. * @param radius The radius of the hemisphere to emit from
  91562. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  91563. * @returns the emitter
  91564. */
  91565. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  91566. /**
  91567. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  91568. * @param radius The radius of the sphere to emit from
  91569. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  91570. * @returns the emitter
  91571. */
  91572. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  91573. /**
  91574. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  91575. * @param radius The radius of the sphere to emit from
  91576. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  91577. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  91578. * @returns the emitter
  91579. */
  91580. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  91581. /**
  91582. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  91583. * @param radius The radius of the emission cylinder
  91584. * @param height The height of the emission cylinder
  91585. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  91586. * @param directionRandomizer How much to randomize the particle direction [0-1]
  91587. * @returns the emitter
  91588. */
  91589. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  91590. /**
  91591. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  91592. * @param radius The radius of the cylinder to emit from
  91593. * @param height The height of the emission cylinder
  91594. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91595. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  91596. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  91597. * @returns the emitter
  91598. */
  91599. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  91600. /**
  91601. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  91602. * @param radius The radius of the cone to emit from
  91603. * @param angle The base angle of the cone
  91604. * @returns the emitter
  91605. */
  91606. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  91607. /**
  91608. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  91609. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  91610. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  91611. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  91612. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  91613. * @returns the emitter
  91614. */
  91615. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  91616. }
  91617. }
  91618. declare module BABYLON {
  91619. /**
  91620. * Type of sub emitter
  91621. */
  91622. export enum SubEmitterType {
  91623. /**
  91624. * Attached to the particle over it's lifetime
  91625. */
  91626. ATTACHED = 0,
  91627. /**
  91628. * Created when the particle dies
  91629. */
  91630. END = 1
  91631. }
  91632. /**
  91633. * Sub emitter class used to emit particles from an existing particle
  91634. */
  91635. export class SubEmitter {
  91636. /**
  91637. * the particle system to be used by the sub emitter
  91638. */
  91639. particleSystem: ParticleSystem;
  91640. /**
  91641. * Type of the submitter (Default: END)
  91642. */
  91643. type: SubEmitterType;
  91644. /**
  91645. * 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)
  91646. * Note: This only is supported when using an emitter of type Mesh
  91647. */
  91648. inheritDirection: boolean;
  91649. /**
  91650. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  91651. */
  91652. inheritedVelocityAmount: number;
  91653. /**
  91654. * Creates a sub emitter
  91655. * @param particleSystem the particle system to be used by the sub emitter
  91656. */
  91657. constructor(
  91658. /**
  91659. * the particle system to be used by the sub emitter
  91660. */
  91661. particleSystem: ParticleSystem);
  91662. /**
  91663. * Clones the sub emitter
  91664. * @returns the cloned sub emitter
  91665. */
  91666. clone(): SubEmitter;
  91667. /**
  91668. * Serialize current object to a JSON object
  91669. * @returns the serialized object
  91670. */
  91671. serialize(): any;
  91672. /** @hidden */
  91673. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  91674. /**
  91675. * Creates a new SubEmitter from a serialized JSON version
  91676. * @param serializationObject defines the JSON object to read from
  91677. * @param sceneOrEngine defines the hosting scene or the hosting engine
  91678. * @param rootUrl defines the rootUrl for data loading
  91679. * @returns a new SubEmitter
  91680. */
  91681. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  91682. /** Release associated resources */
  91683. dispose(): void;
  91684. }
  91685. }
  91686. declare module BABYLON {
  91687. /** @hidden */
  91688. export var imageProcessingDeclaration: {
  91689. name: string;
  91690. shader: string;
  91691. };
  91692. }
  91693. declare module BABYLON {
  91694. /** @hidden */
  91695. export var imageProcessingFunctions: {
  91696. name: string;
  91697. shader: string;
  91698. };
  91699. }
  91700. declare module BABYLON {
  91701. /** @hidden */
  91702. export var particlesPixelShader: {
  91703. name: string;
  91704. shader: string;
  91705. };
  91706. }
  91707. declare module BABYLON {
  91708. /** @hidden */
  91709. export var particlesVertexShader: {
  91710. name: string;
  91711. shader: string;
  91712. };
  91713. }
  91714. declare module BABYLON {
  91715. /**
  91716. * Interface used to define entities containing multiple clip planes
  91717. */
  91718. export interface IClipPlanesHolder {
  91719. /**
  91720. * Gets or sets the active clipplane 1
  91721. */
  91722. clipPlane: Nullable<Plane>;
  91723. /**
  91724. * Gets or sets the active clipplane 2
  91725. */
  91726. clipPlane2: Nullable<Plane>;
  91727. /**
  91728. * Gets or sets the active clipplane 3
  91729. */
  91730. clipPlane3: Nullable<Plane>;
  91731. /**
  91732. * Gets or sets the active clipplane 4
  91733. */
  91734. clipPlane4: Nullable<Plane>;
  91735. /**
  91736. * Gets or sets the active clipplane 5
  91737. */
  91738. clipPlane5: Nullable<Plane>;
  91739. /**
  91740. * Gets or sets the active clipplane 6
  91741. */
  91742. clipPlane6: Nullable<Plane>;
  91743. }
  91744. }
  91745. declare module BABYLON {
  91746. /**
  91747. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  91748. *
  91749. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  91750. *
  91751. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  91752. */
  91753. export class ThinMaterialHelper {
  91754. /**
  91755. * Binds the clip plane information from the holder to the effect.
  91756. * @param effect The effect we are binding the data to
  91757. * @param holder The entity containing the clip plane information
  91758. */
  91759. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  91760. }
  91761. }
  91762. declare module BABYLON {
  91763. interface ThinEngine {
  91764. /**
  91765. * Sets alpha constants used by some alpha blending modes
  91766. * @param r defines the red component
  91767. * @param g defines the green component
  91768. * @param b defines the blue component
  91769. * @param a defines the alpha component
  91770. */
  91771. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  91772. /**
  91773. * Sets the current alpha mode
  91774. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  91775. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  91776. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  91777. */
  91778. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  91779. /**
  91780. * Gets the current alpha mode
  91781. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  91782. * @returns the current alpha mode
  91783. */
  91784. getAlphaMode(): number;
  91785. /**
  91786. * Sets the current alpha equation
  91787. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  91788. */
  91789. setAlphaEquation(equation: number): void;
  91790. /**
  91791. * Gets the current alpha equation.
  91792. * @returns the current alpha equation
  91793. */
  91794. getAlphaEquation(): number;
  91795. }
  91796. }
  91797. declare module BABYLON {
  91798. /**
  91799. * This represents a particle system in Babylon.
  91800. * 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.
  91801. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  91802. * @example https://doc.babylonjs.com/babylon101/particles
  91803. */
  91804. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  91805. /**
  91806. * Billboard mode will only apply to Y axis
  91807. */
  91808. static readonly BILLBOARDMODE_Y: number;
  91809. /**
  91810. * Billboard mode will apply to all axes
  91811. */
  91812. static readonly BILLBOARDMODE_ALL: number;
  91813. /**
  91814. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  91815. */
  91816. static readonly BILLBOARDMODE_STRETCHED: number;
  91817. /**
  91818. * This function can be defined to provide custom update for active particles.
  91819. * This function will be called instead of regular update (age, position, color, etc.).
  91820. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  91821. */
  91822. updateFunction: (particles: Particle[]) => void;
  91823. private _emitterWorldMatrix;
  91824. /**
  91825. * This function can be defined to specify initial direction for every new particle.
  91826. * It by default use the emitterType defined function
  91827. */
  91828. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  91829. /**
  91830. * This function can be defined to specify initial position for every new particle.
  91831. * It by default use the emitterType defined function
  91832. */
  91833. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  91834. /**
  91835. * @hidden
  91836. */
  91837. _inheritedVelocityOffset: Vector3;
  91838. /**
  91839. * An event triggered when the system is disposed
  91840. */
  91841. onDisposeObservable: Observable<IParticleSystem>;
  91842. private _onDisposeObserver;
  91843. /**
  91844. * Sets a callback that will be triggered when the system is disposed
  91845. */
  91846. set onDispose(callback: () => void);
  91847. private _particles;
  91848. private _epsilon;
  91849. private _capacity;
  91850. private _stockParticles;
  91851. private _newPartsExcess;
  91852. private _vertexData;
  91853. private _vertexBuffer;
  91854. private _vertexBuffers;
  91855. private _spriteBuffer;
  91856. private _indexBuffer;
  91857. private _effect;
  91858. private _customEffect;
  91859. private _cachedDefines;
  91860. private _scaledColorStep;
  91861. private _colorDiff;
  91862. private _scaledDirection;
  91863. private _scaledGravity;
  91864. private _currentRenderId;
  91865. private _alive;
  91866. private _useInstancing;
  91867. private _started;
  91868. private _stopped;
  91869. private _actualFrame;
  91870. private _scaledUpdateSpeed;
  91871. private _vertexBufferSize;
  91872. /** @hidden */
  91873. _currentEmitRateGradient: Nullable<FactorGradient>;
  91874. /** @hidden */
  91875. _currentEmitRate1: number;
  91876. /** @hidden */
  91877. _currentEmitRate2: number;
  91878. /** @hidden */
  91879. _currentStartSizeGradient: Nullable<FactorGradient>;
  91880. /** @hidden */
  91881. _currentStartSize1: number;
  91882. /** @hidden */
  91883. _currentStartSize2: number;
  91884. private readonly _rawTextureWidth;
  91885. private _rampGradientsTexture;
  91886. private _useRampGradients;
  91887. /** Gets or sets a matrix to use to compute projection */
  91888. defaultProjectionMatrix: Matrix;
  91889. /** Gets or sets a matrix to use to compute view */
  91890. defaultViewMatrix: Matrix;
  91891. /** Gets or sets a boolean indicating that ramp gradients must be used
  91892. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  91893. */
  91894. get useRampGradients(): boolean;
  91895. set useRampGradients(value: boolean);
  91896. /**
  91897. * 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.
  91898. * 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: [])
  91899. */
  91900. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  91901. private _subEmitters;
  91902. /**
  91903. * @hidden
  91904. * If the particle systems emitter should be disposed when the particle system is disposed
  91905. */
  91906. _disposeEmitterOnDispose: boolean;
  91907. /**
  91908. * The current active Sub-systems, this property is used by the root particle system only.
  91909. */
  91910. activeSubSystems: Array<ParticleSystem>;
  91911. /**
  91912. * Specifies if the particles are updated in emitter local space or world space
  91913. */
  91914. isLocal: boolean;
  91915. private _rootParticleSystem;
  91916. /**
  91917. * Gets the current list of active particles
  91918. */
  91919. get particles(): Particle[];
  91920. /**
  91921. * Gets the number of particles active at the same time.
  91922. * @returns The number of active particles.
  91923. */
  91924. getActiveCount(): number;
  91925. /**
  91926. * Returns the string "ParticleSystem"
  91927. * @returns a string containing the class name
  91928. */
  91929. getClassName(): string;
  91930. /**
  91931. * Gets a boolean indicating that the system is stopping
  91932. * @returns true if the system is currently stopping
  91933. */
  91934. isStopping(): boolean;
  91935. /**
  91936. * Gets the custom effect used to render the particles
  91937. * @param blendMode Blend mode for which the effect should be retrieved
  91938. * @returns The effect
  91939. */
  91940. getCustomEffect(blendMode?: number): Nullable<Effect>;
  91941. /**
  91942. * Sets the custom effect used to render the particles
  91943. * @param effect The effect to set
  91944. * @param blendMode Blend mode for which the effect should be set
  91945. */
  91946. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  91947. /** @hidden */
  91948. private _onBeforeDrawParticlesObservable;
  91949. /**
  91950. * Observable that will be called just before the particles are drawn
  91951. */
  91952. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  91953. /**
  91954. * Gets the name of the particle vertex shader
  91955. */
  91956. get vertexShaderName(): string;
  91957. /**
  91958. * Instantiates a particle system.
  91959. * 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.
  91960. * @param name The name of the particle system
  91961. * @param capacity The max number of particles alive at the same time
  91962. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  91963. * @param customEffect a custom effect used to change the way particles are rendered by default
  91964. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  91965. * @param epsilon Offset used to render the particles
  91966. */
  91967. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  91968. private _addFactorGradient;
  91969. private _removeFactorGradient;
  91970. /**
  91971. * Adds a new life time gradient
  91972. * @param gradient defines the gradient to use (between 0 and 1)
  91973. * @param factor defines the life time factor to affect to the specified gradient
  91974. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91975. * @returns the current particle system
  91976. */
  91977. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91978. /**
  91979. * Remove a specific life time gradient
  91980. * @param gradient defines the gradient to remove
  91981. * @returns the current particle system
  91982. */
  91983. removeLifeTimeGradient(gradient: number): IParticleSystem;
  91984. /**
  91985. * Adds a new size gradient
  91986. * @param gradient defines the gradient to use (between 0 and 1)
  91987. * @param factor defines the size factor to affect to the specified gradient
  91988. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91989. * @returns the current particle system
  91990. */
  91991. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91992. /**
  91993. * Remove a specific size gradient
  91994. * @param gradient defines the gradient to remove
  91995. * @returns the current particle system
  91996. */
  91997. removeSizeGradient(gradient: number): IParticleSystem;
  91998. /**
  91999. * Adds a new color remap gradient
  92000. * @param gradient defines the gradient to use (between 0 and 1)
  92001. * @param min defines the color remap minimal range
  92002. * @param max defines the color remap maximal range
  92003. * @returns the current particle system
  92004. */
  92005. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  92006. /**
  92007. * Remove a specific color remap gradient
  92008. * @param gradient defines the gradient to remove
  92009. * @returns the current particle system
  92010. */
  92011. removeColorRemapGradient(gradient: number): IParticleSystem;
  92012. /**
  92013. * Adds a new alpha remap gradient
  92014. * @param gradient defines the gradient to use (between 0 and 1)
  92015. * @param min defines the alpha remap minimal range
  92016. * @param max defines the alpha remap maximal range
  92017. * @returns the current particle system
  92018. */
  92019. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  92020. /**
  92021. * Remove a specific alpha remap gradient
  92022. * @param gradient defines the gradient to remove
  92023. * @returns the current particle system
  92024. */
  92025. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  92026. /**
  92027. * Adds a new angular speed gradient
  92028. * @param gradient defines the gradient to use (between 0 and 1)
  92029. * @param factor defines the angular speed to affect to the specified gradient
  92030. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92031. * @returns the current particle system
  92032. */
  92033. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92034. /**
  92035. * Remove a specific angular speed gradient
  92036. * @param gradient defines the gradient to remove
  92037. * @returns the current particle system
  92038. */
  92039. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  92040. /**
  92041. * Adds a new velocity gradient
  92042. * @param gradient defines the gradient to use (between 0 and 1)
  92043. * @param factor defines the velocity to affect to the specified gradient
  92044. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92045. * @returns the current particle system
  92046. */
  92047. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92048. /**
  92049. * Remove a specific velocity gradient
  92050. * @param gradient defines the gradient to remove
  92051. * @returns the current particle system
  92052. */
  92053. removeVelocityGradient(gradient: number): IParticleSystem;
  92054. /**
  92055. * Adds a new limit velocity gradient
  92056. * @param gradient defines the gradient to use (between 0 and 1)
  92057. * @param factor defines the limit velocity value to affect to the specified gradient
  92058. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92059. * @returns the current particle system
  92060. */
  92061. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92062. /**
  92063. * Remove a specific limit velocity gradient
  92064. * @param gradient defines the gradient to remove
  92065. * @returns the current particle system
  92066. */
  92067. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  92068. /**
  92069. * Adds a new drag gradient
  92070. * @param gradient defines the gradient to use (between 0 and 1)
  92071. * @param factor defines the drag value to affect to the specified gradient
  92072. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92073. * @returns the current particle system
  92074. */
  92075. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92076. /**
  92077. * Remove a specific drag gradient
  92078. * @param gradient defines the gradient to remove
  92079. * @returns the current particle system
  92080. */
  92081. removeDragGradient(gradient: number): IParticleSystem;
  92082. /**
  92083. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  92084. * @param gradient defines the gradient to use (between 0 and 1)
  92085. * @param factor defines the emit rate value to affect to the specified gradient
  92086. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92087. * @returns the current particle system
  92088. */
  92089. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92090. /**
  92091. * Remove a specific emit rate gradient
  92092. * @param gradient defines the gradient to remove
  92093. * @returns the current particle system
  92094. */
  92095. removeEmitRateGradient(gradient: number): IParticleSystem;
  92096. /**
  92097. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  92098. * @param gradient defines the gradient to use (between 0 and 1)
  92099. * @param factor defines the start size value to affect to the specified gradient
  92100. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92101. * @returns the current particle system
  92102. */
  92103. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92104. /**
  92105. * Remove a specific start size gradient
  92106. * @param gradient defines the gradient to remove
  92107. * @returns the current particle system
  92108. */
  92109. removeStartSizeGradient(gradient: number): IParticleSystem;
  92110. private _createRampGradientTexture;
  92111. /**
  92112. * Gets the current list of ramp gradients.
  92113. * You must use addRampGradient and removeRampGradient to udpate this list
  92114. * @returns the list of ramp gradients
  92115. */
  92116. getRampGradients(): Nullable<Array<Color3Gradient>>;
  92117. /** Force the system to rebuild all gradients that need to be resync */
  92118. forceRefreshGradients(): void;
  92119. private _syncRampGradientTexture;
  92120. /**
  92121. * Adds a new ramp gradient used to remap particle colors
  92122. * @param gradient defines the gradient to use (between 0 and 1)
  92123. * @param color defines the color to affect to the specified gradient
  92124. * @returns the current particle system
  92125. */
  92126. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  92127. /**
  92128. * Remove a specific ramp gradient
  92129. * @param gradient defines the gradient to remove
  92130. * @returns the current particle system
  92131. */
  92132. removeRampGradient(gradient: number): ParticleSystem;
  92133. /**
  92134. * Adds a new color gradient
  92135. * @param gradient defines the gradient to use (between 0 and 1)
  92136. * @param color1 defines the color to affect to the specified gradient
  92137. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  92138. * @returns this particle system
  92139. */
  92140. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  92141. /**
  92142. * Remove a specific color gradient
  92143. * @param gradient defines the gradient to remove
  92144. * @returns this particle system
  92145. */
  92146. removeColorGradient(gradient: number): IParticleSystem;
  92147. private _fetchR;
  92148. protected _reset(): void;
  92149. private _resetEffect;
  92150. private _createVertexBuffers;
  92151. private _createIndexBuffer;
  92152. /**
  92153. * Gets the maximum number of particles active at the same time.
  92154. * @returns The max number of active particles.
  92155. */
  92156. getCapacity(): number;
  92157. /**
  92158. * Gets whether there are still active particles in the system.
  92159. * @returns True if it is alive, otherwise false.
  92160. */
  92161. isAlive(): boolean;
  92162. /**
  92163. * Gets if the system has been started. (Note: this will still be true after stop is called)
  92164. * @returns True if it has been started, otherwise false.
  92165. */
  92166. isStarted(): boolean;
  92167. private _prepareSubEmitterInternalArray;
  92168. /**
  92169. * Starts the particle system and begins to emit
  92170. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  92171. */
  92172. start(delay?: number): void;
  92173. /**
  92174. * Stops the particle system.
  92175. * @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.
  92176. */
  92177. stop(stopSubEmitters?: boolean): void;
  92178. /**
  92179. * Remove all active particles
  92180. */
  92181. reset(): void;
  92182. /**
  92183. * @hidden (for internal use only)
  92184. */
  92185. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  92186. /**
  92187. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  92188. * Its lifetime will start back at 0.
  92189. */
  92190. recycleParticle: (particle: Particle) => void;
  92191. private _stopSubEmitters;
  92192. private _createParticle;
  92193. private _removeFromRoot;
  92194. private _emitFromParticle;
  92195. private _update;
  92196. /** @hidden */
  92197. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  92198. /** @hidden */
  92199. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  92200. /**
  92201. * Fill the defines array according to the current settings of the particle system
  92202. * @param defines Array to be updated
  92203. * @param blendMode blend mode to take into account when updating the array
  92204. */
  92205. fillDefines(defines: Array<string>, blendMode: number): void;
  92206. /**
  92207. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  92208. * @param uniforms Uniforms array to fill
  92209. * @param attributes Attributes array to fill
  92210. * @param samplers Samplers array to fill
  92211. */
  92212. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  92213. /** @hidden */
  92214. private _getEffect;
  92215. /**
  92216. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  92217. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  92218. */
  92219. animate(preWarmOnly?: boolean): void;
  92220. private _appendParticleVertices;
  92221. /**
  92222. * Rebuilds the particle system.
  92223. */
  92224. rebuild(): void;
  92225. /**
  92226. * Is this system ready to be used/rendered
  92227. * @return true if the system is ready
  92228. */
  92229. isReady(): boolean;
  92230. private _render;
  92231. /**
  92232. * Renders the particle system in its current state.
  92233. * @returns the current number of particles
  92234. */
  92235. render(): number;
  92236. /**
  92237. * Disposes the particle system and free the associated resources
  92238. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  92239. */
  92240. dispose(disposeTexture?: boolean): void;
  92241. /**
  92242. * Clones the particle system.
  92243. * @param name The name of the cloned object
  92244. * @param newEmitter The new emitter to use
  92245. * @returns the cloned particle system
  92246. */
  92247. clone(name: string, newEmitter: any): ParticleSystem;
  92248. /**
  92249. * Serializes the particle system to a JSON object
  92250. * @param serializeTexture defines if the texture must be serialized as well
  92251. * @returns the JSON object
  92252. */
  92253. serialize(serializeTexture?: boolean): any;
  92254. /** @hidden */
  92255. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  92256. /** @hidden */
  92257. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  92258. /**
  92259. * Parses a JSON object to create a particle system.
  92260. * @param parsedParticleSystem The JSON object to parse
  92261. * @param sceneOrEngine The scene or the engine to create the particle system in
  92262. * @param rootUrl The root url to use to load external dependencies like texture
  92263. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  92264. * @returns the Parsed particle system
  92265. */
  92266. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  92267. }
  92268. }
  92269. declare module BABYLON {
  92270. /**
  92271. * A particle represents one of the element emitted by a particle system.
  92272. * This is mainly define by its coordinates, direction, velocity and age.
  92273. */
  92274. export class Particle {
  92275. /**
  92276. * The particle system the particle belongs to.
  92277. */
  92278. particleSystem: ParticleSystem;
  92279. private static _Count;
  92280. /**
  92281. * Unique ID of the particle
  92282. */
  92283. id: number;
  92284. /**
  92285. * The world position of the particle in the scene.
  92286. */
  92287. position: Vector3;
  92288. /**
  92289. * The world direction of the particle in the scene.
  92290. */
  92291. direction: Vector3;
  92292. /**
  92293. * The color of the particle.
  92294. */
  92295. color: Color4;
  92296. /**
  92297. * The color change of the particle per step.
  92298. */
  92299. colorStep: Color4;
  92300. /**
  92301. * Defines how long will the life of the particle be.
  92302. */
  92303. lifeTime: number;
  92304. /**
  92305. * The current age of the particle.
  92306. */
  92307. age: number;
  92308. /**
  92309. * The current size of the particle.
  92310. */
  92311. size: number;
  92312. /**
  92313. * The current scale of the particle.
  92314. */
  92315. scale: Vector2;
  92316. /**
  92317. * The current angle of the particle.
  92318. */
  92319. angle: number;
  92320. /**
  92321. * Defines how fast is the angle changing.
  92322. */
  92323. angularSpeed: number;
  92324. /**
  92325. * Defines the cell index used by the particle to be rendered from a sprite.
  92326. */
  92327. cellIndex: number;
  92328. /**
  92329. * The information required to support color remapping
  92330. */
  92331. remapData: Vector4;
  92332. /** @hidden */
  92333. _randomCellOffset?: number;
  92334. /** @hidden */
  92335. _initialDirection: Nullable<Vector3>;
  92336. /** @hidden */
  92337. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  92338. /** @hidden */
  92339. _initialStartSpriteCellID: number;
  92340. /** @hidden */
  92341. _initialEndSpriteCellID: number;
  92342. /** @hidden */
  92343. _currentColorGradient: Nullable<ColorGradient>;
  92344. /** @hidden */
  92345. _currentColor1: Color4;
  92346. /** @hidden */
  92347. _currentColor2: Color4;
  92348. /** @hidden */
  92349. _currentSizeGradient: Nullable<FactorGradient>;
  92350. /** @hidden */
  92351. _currentSize1: number;
  92352. /** @hidden */
  92353. _currentSize2: number;
  92354. /** @hidden */
  92355. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  92356. /** @hidden */
  92357. _currentAngularSpeed1: number;
  92358. /** @hidden */
  92359. _currentAngularSpeed2: number;
  92360. /** @hidden */
  92361. _currentVelocityGradient: Nullable<FactorGradient>;
  92362. /** @hidden */
  92363. _currentVelocity1: number;
  92364. /** @hidden */
  92365. _currentVelocity2: number;
  92366. /** @hidden */
  92367. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  92368. /** @hidden */
  92369. _currentLimitVelocity1: number;
  92370. /** @hidden */
  92371. _currentLimitVelocity2: number;
  92372. /** @hidden */
  92373. _currentDragGradient: Nullable<FactorGradient>;
  92374. /** @hidden */
  92375. _currentDrag1: number;
  92376. /** @hidden */
  92377. _currentDrag2: number;
  92378. /** @hidden */
  92379. _randomNoiseCoordinates1: Vector3;
  92380. /** @hidden */
  92381. _randomNoiseCoordinates2: Vector3;
  92382. /** @hidden */
  92383. _localPosition?: Vector3;
  92384. /**
  92385. * Creates a new instance Particle
  92386. * @param particleSystem the particle system the particle belongs to
  92387. */
  92388. constructor(
  92389. /**
  92390. * The particle system the particle belongs to.
  92391. */
  92392. particleSystem: ParticleSystem);
  92393. private updateCellInfoFromSystem;
  92394. /**
  92395. * Defines how the sprite cell index is updated for the particle
  92396. */
  92397. updateCellIndex(): void;
  92398. /** @hidden */
  92399. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  92400. /** @hidden */
  92401. _inheritParticleInfoToSubEmitters(): void;
  92402. /** @hidden */
  92403. _reset(): void;
  92404. /**
  92405. * Copy the properties of particle to another one.
  92406. * @param other the particle to copy the information to.
  92407. */
  92408. copyTo(other: Particle): void;
  92409. }
  92410. }
  92411. declare module BABYLON {
  92412. /**
  92413. * Particle emitter represents a volume emitting particles.
  92414. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  92415. */
  92416. export interface IParticleEmitterType {
  92417. /**
  92418. * Called by the particle System when the direction is computed for the created particle.
  92419. * @param worldMatrix is the world matrix of the particle system
  92420. * @param directionToUpdate is the direction vector to update with the result
  92421. * @param particle is the particle we are computed the direction for
  92422. * @param isLocal defines if the direction should be set in local space
  92423. */
  92424. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92425. /**
  92426. * Called by the particle System when the position is computed for the created particle.
  92427. * @param worldMatrix is the world matrix of the particle system
  92428. * @param positionToUpdate is the position vector to update with the result
  92429. * @param particle is the particle we are computed the position for
  92430. * @param isLocal defines if the position should be set in local space
  92431. */
  92432. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92433. /**
  92434. * Clones the current emitter and returns a copy of it
  92435. * @returns the new emitter
  92436. */
  92437. clone(): IParticleEmitterType;
  92438. /**
  92439. * Called by the GPUParticleSystem to setup the update shader
  92440. * @param effect defines the update shader
  92441. */
  92442. applyToShader(effect: Effect): void;
  92443. /**
  92444. * Returns a string to use to update the GPU particles update shader
  92445. * @returns the effect defines string
  92446. */
  92447. getEffectDefines(): string;
  92448. /**
  92449. * Returns a string representing the class name
  92450. * @returns a string containing the class name
  92451. */
  92452. getClassName(): string;
  92453. /**
  92454. * Serializes the particle system to a JSON object.
  92455. * @returns the JSON object
  92456. */
  92457. serialize(): any;
  92458. /**
  92459. * Parse properties from a JSON object
  92460. * @param serializationObject defines the JSON object
  92461. * @param scene defines the hosting scene
  92462. */
  92463. parse(serializationObject: any, scene: Nullable<Scene>): void;
  92464. }
  92465. }
  92466. declare module BABYLON {
  92467. /**
  92468. * Particle emitter emitting particles from the inside of a box.
  92469. * It emits the particles randomly between 2 given directions.
  92470. */
  92471. export class BoxParticleEmitter implements IParticleEmitterType {
  92472. /**
  92473. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92474. */
  92475. direction1: Vector3;
  92476. /**
  92477. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92478. */
  92479. direction2: Vector3;
  92480. /**
  92481. * 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.
  92482. */
  92483. minEmitBox: Vector3;
  92484. /**
  92485. * 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.
  92486. */
  92487. maxEmitBox: Vector3;
  92488. /**
  92489. * Creates a new instance BoxParticleEmitter
  92490. */
  92491. constructor();
  92492. /**
  92493. * Called by the particle System when the direction is computed for the created particle.
  92494. * @param worldMatrix is the world matrix of the particle system
  92495. * @param directionToUpdate is the direction vector to update with the result
  92496. * @param particle is the particle we are computed the direction for
  92497. * @param isLocal defines if the direction should be set in local space
  92498. */
  92499. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92500. /**
  92501. * Called by the particle System when the position is computed for the created particle.
  92502. * @param worldMatrix is the world matrix of the particle system
  92503. * @param positionToUpdate is the position vector to update with the result
  92504. * @param particle is the particle we are computed the position for
  92505. * @param isLocal defines if the position should be set in local space
  92506. */
  92507. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92508. /**
  92509. * Clones the current emitter and returns a copy of it
  92510. * @returns the new emitter
  92511. */
  92512. clone(): BoxParticleEmitter;
  92513. /**
  92514. * Called by the GPUParticleSystem to setup the update shader
  92515. * @param effect defines the update shader
  92516. */
  92517. applyToShader(effect: Effect): void;
  92518. /**
  92519. * Returns a string to use to update the GPU particles update shader
  92520. * @returns a string containng the defines string
  92521. */
  92522. getEffectDefines(): string;
  92523. /**
  92524. * Returns the string "BoxParticleEmitter"
  92525. * @returns a string containing the class name
  92526. */
  92527. getClassName(): string;
  92528. /**
  92529. * Serializes the particle system to a JSON object.
  92530. * @returns the JSON object
  92531. */
  92532. serialize(): any;
  92533. /**
  92534. * Parse properties from a JSON object
  92535. * @param serializationObject defines the JSON object
  92536. */
  92537. parse(serializationObject: any): void;
  92538. }
  92539. }
  92540. declare module BABYLON {
  92541. /**
  92542. * Particle emitter emitting particles from the inside of a cone.
  92543. * It emits the particles alongside the cone volume from the base to the particle.
  92544. * The emission direction might be randomized.
  92545. */
  92546. export class ConeParticleEmitter implements IParticleEmitterType {
  92547. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  92548. directionRandomizer: number;
  92549. private _radius;
  92550. private _angle;
  92551. private _height;
  92552. /**
  92553. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  92554. */
  92555. radiusRange: number;
  92556. /**
  92557. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  92558. */
  92559. heightRange: number;
  92560. /**
  92561. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  92562. */
  92563. emitFromSpawnPointOnly: boolean;
  92564. /**
  92565. * Gets or sets the radius of the emission cone
  92566. */
  92567. get radius(): number;
  92568. set radius(value: number);
  92569. /**
  92570. * Gets or sets the angle of the emission cone
  92571. */
  92572. get angle(): number;
  92573. set angle(value: number);
  92574. private _buildHeight;
  92575. /**
  92576. * Creates a new instance ConeParticleEmitter
  92577. * @param radius the radius of the emission cone (1 by default)
  92578. * @param angle the cone base angle (PI by default)
  92579. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  92580. */
  92581. constructor(radius?: number, angle?: number,
  92582. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  92583. directionRandomizer?: number);
  92584. /**
  92585. * Called by the particle System when the direction is computed for the created particle.
  92586. * @param worldMatrix is the world matrix of the particle system
  92587. * @param directionToUpdate is the direction vector to update with the result
  92588. * @param particle is the particle we are computed the direction for
  92589. * @param isLocal defines if the direction should be set in local space
  92590. */
  92591. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92592. /**
  92593. * Called by the particle System when the position is computed for the created particle.
  92594. * @param worldMatrix is the world matrix of the particle system
  92595. * @param positionToUpdate is the position vector to update with the result
  92596. * @param particle is the particle we are computed the position for
  92597. * @param isLocal defines if the position should be set in local space
  92598. */
  92599. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92600. /**
  92601. * Clones the current emitter and returns a copy of it
  92602. * @returns the new emitter
  92603. */
  92604. clone(): ConeParticleEmitter;
  92605. /**
  92606. * Called by the GPUParticleSystem to setup the update shader
  92607. * @param effect defines the update shader
  92608. */
  92609. applyToShader(effect: Effect): void;
  92610. /**
  92611. * Returns a string to use to update the GPU particles update shader
  92612. * @returns a string containng the defines string
  92613. */
  92614. getEffectDefines(): string;
  92615. /**
  92616. * Returns the string "ConeParticleEmitter"
  92617. * @returns a string containing the class name
  92618. */
  92619. getClassName(): string;
  92620. /**
  92621. * Serializes the particle system to a JSON object.
  92622. * @returns the JSON object
  92623. */
  92624. serialize(): any;
  92625. /**
  92626. * Parse properties from a JSON object
  92627. * @param serializationObject defines the JSON object
  92628. */
  92629. parse(serializationObject: any): void;
  92630. }
  92631. }
  92632. declare module BABYLON {
  92633. /**
  92634. * Particle emitter emitting particles from the inside of a cylinder.
  92635. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  92636. */
  92637. export class CylinderParticleEmitter implements IParticleEmitterType {
  92638. /**
  92639. * The radius of the emission cylinder.
  92640. */
  92641. radius: number;
  92642. /**
  92643. * The height of the emission cylinder.
  92644. */
  92645. height: number;
  92646. /**
  92647. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  92648. */
  92649. radiusRange: number;
  92650. /**
  92651. * How much to randomize the particle direction [0-1].
  92652. */
  92653. directionRandomizer: number;
  92654. /**
  92655. * Creates a new instance CylinderParticleEmitter
  92656. * @param radius the radius of the emission cylinder (1 by default)
  92657. * @param height the height of the emission cylinder (1 by default)
  92658. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  92659. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  92660. */
  92661. constructor(
  92662. /**
  92663. * The radius of the emission cylinder.
  92664. */
  92665. radius?: number,
  92666. /**
  92667. * The height of the emission cylinder.
  92668. */
  92669. height?: number,
  92670. /**
  92671. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  92672. */
  92673. radiusRange?: number,
  92674. /**
  92675. * How much to randomize the particle direction [0-1].
  92676. */
  92677. directionRandomizer?: number);
  92678. /**
  92679. * Called by the particle System when the direction is computed for the created particle.
  92680. * @param worldMatrix is the world matrix of the particle system
  92681. * @param directionToUpdate is the direction vector to update with the result
  92682. * @param particle is the particle we are computed the direction for
  92683. * @param isLocal defines if the direction should be set in local space
  92684. */
  92685. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92686. /**
  92687. * Called by the particle System when the position is computed for the created particle.
  92688. * @param worldMatrix is the world matrix of the particle system
  92689. * @param positionToUpdate is the position vector to update with the result
  92690. * @param particle is the particle we are computed the position for
  92691. * @param isLocal defines if the position should be set in local space
  92692. */
  92693. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92694. /**
  92695. * Clones the current emitter and returns a copy of it
  92696. * @returns the new emitter
  92697. */
  92698. clone(): CylinderParticleEmitter;
  92699. /**
  92700. * Called by the GPUParticleSystem to setup the update shader
  92701. * @param effect defines the update shader
  92702. */
  92703. applyToShader(effect: Effect): void;
  92704. /**
  92705. * Returns a string to use to update the GPU particles update shader
  92706. * @returns a string containng the defines string
  92707. */
  92708. getEffectDefines(): string;
  92709. /**
  92710. * Returns the string "CylinderParticleEmitter"
  92711. * @returns a string containing the class name
  92712. */
  92713. getClassName(): string;
  92714. /**
  92715. * Serializes the particle system to a JSON object.
  92716. * @returns the JSON object
  92717. */
  92718. serialize(): any;
  92719. /**
  92720. * Parse properties from a JSON object
  92721. * @param serializationObject defines the JSON object
  92722. */
  92723. parse(serializationObject: any): void;
  92724. }
  92725. /**
  92726. * Particle emitter emitting particles from the inside of a cylinder.
  92727. * It emits the particles randomly between two vectors.
  92728. */
  92729. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  92730. /**
  92731. * The min limit of the emission direction.
  92732. */
  92733. direction1: Vector3;
  92734. /**
  92735. * The max limit of the emission direction.
  92736. */
  92737. direction2: Vector3;
  92738. /**
  92739. * Creates a new instance CylinderDirectedParticleEmitter
  92740. * @param radius the radius of the emission cylinder (1 by default)
  92741. * @param height the height of the emission cylinder (1 by default)
  92742. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  92743. * @param direction1 the min limit of the emission direction (up vector by default)
  92744. * @param direction2 the max limit of the emission direction (up vector by default)
  92745. */
  92746. constructor(radius?: number, height?: number, radiusRange?: number,
  92747. /**
  92748. * The min limit of the emission direction.
  92749. */
  92750. direction1?: Vector3,
  92751. /**
  92752. * The max limit of the emission direction.
  92753. */
  92754. direction2?: Vector3);
  92755. /**
  92756. * Called by the particle System when the direction is computed for the created particle.
  92757. * @param worldMatrix is the world matrix of the particle system
  92758. * @param directionToUpdate is the direction vector to update with the result
  92759. * @param particle is the particle we are computed the direction for
  92760. */
  92761. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  92762. /**
  92763. * Clones the current emitter and returns a copy of it
  92764. * @returns the new emitter
  92765. */
  92766. clone(): CylinderDirectedParticleEmitter;
  92767. /**
  92768. * Called by the GPUParticleSystem to setup the update shader
  92769. * @param effect defines the update shader
  92770. */
  92771. applyToShader(effect: Effect): void;
  92772. /**
  92773. * Returns a string to use to update the GPU particles update shader
  92774. * @returns a string containng the defines string
  92775. */
  92776. getEffectDefines(): string;
  92777. /**
  92778. * Returns the string "CylinderDirectedParticleEmitter"
  92779. * @returns a string containing the class name
  92780. */
  92781. getClassName(): string;
  92782. /**
  92783. * Serializes the particle system to a JSON object.
  92784. * @returns the JSON object
  92785. */
  92786. serialize(): any;
  92787. /**
  92788. * Parse properties from a JSON object
  92789. * @param serializationObject defines the JSON object
  92790. */
  92791. parse(serializationObject: any): void;
  92792. }
  92793. }
  92794. declare module BABYLON {
  92795. /**
  92796. * Particle emitter emitting particles from the inside of a hemisphere.
  92797. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  92798. */
  92799. export class HemisphericParticleEmitter implements IParticleEmitterType {
  92800. /**
  92801. * The radius of the emission hemisphere.
  92802. */
  92803. radius: number;
  92804. /**
  92805. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  92806. */
  92807. radiusRange: number;
  92808. /**
  92809. * How much to randomize the particle direction [0-1].
  92810. */
  92811. directionRandomizer: number;
  92812. /**
  92813. * Creates a new instance HemisphericParticleEmitter
  92814. * @param radius the radius of the emission hemisphere (1 by default)
  92815. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  92816. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  92817. */
  92818. constructor(
  92819. /**
  92820. * The radius of the emission hemisphere.
  92821. */
  92822. radius?: number,
  92823. /**
  92824. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  92825. */
  92826. radiusRange?: number,
  92827. /**
  92828. * How much to randomize the particle direction [0-1].
  92829. */
  92830. directionRandomizer?: number);
  92831. /**
  92832. * Called by the particle System when the direction is computed for the created particle.
  92833. * @param worldMatrix is the world matrix of the particle system
  92834. * @param directionToUpdate is the direction vector to update with the result
  92835. * @param particle is the particle we are computed the direction for
  92836. * @param isLocal defines if the direction should be set in local space
  92837. */
  92838. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92839. /**
  92840. * Called by the particle System when the position is computed for the created particle.
  92841. * @param worldMatrix is the world matrix of the particle system
  92842. * @param positionToUpdate is the position vector to update with the result
  92843. * @param particle is the particle we are computed the position for
  92844. * @param isLocal defines if the position should be set in local space
  92845. */
  92846. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92847. /**
  92848. * Clones the current emitter and returns a copy of it
  92849. * @returns the new emitter
  92850. */
  92851. clone(): HemisphericParticleEmitter;
  92852. /**
  92853. * Called by the GPUParticleSystem to setup the update shader
  92854. * @param effect defines the update shader
  92855. */
  92856. applyToShader(effect: Effect): void;
  92857. /**
  92858. * Returns a string to use to update the GPU particles update shader
  92859. * @returns a string containng the defines string
  92860. */
  92861. getEffectDefines(): string;
  92862. /**
  92863. * Returns the string "HemisphericParticleEmitter"
  92864. * @returns a string containing the class name
  92865. */
  92866. getClassName(): string;
  92867. /**
  92868. * Serializes the particle system to a JSON object.
  92869. * @returns the JSON object
  92870. */
  92871. serialize(): any;
  92872. /**
  92873. * Parse properties from a JSON object
  92874. * @param serializationObject defines the JSON object
  92875. */
  92876. parse(serializationObject: any): void;
  92877. }
  92878. }
  92879. declare module BABYLON {
  92880. /**
  92881. * Particle emitter emitting particles from a point.
  92882. * It emits the particles randomly between 2 given directions.
  92883. */
  92884. export class PointParticleEmitter implements IParticleEmitterType {
  92885. /**
  92886. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92887. */
  92888. direction1: Vector3;
  92889. /**
  92890. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92891. */
  92892. direction2: Vector3;
  92893. /**
  92894. * Creates a new instance PointParticleEmitter
  92895. */
  92896. constructor();
  92897. /**
  92898. * Called by the particle System when the direction is computed for the created particle.
  92899. * @param worldMatrix is the world matrix of the particle system
  92900. * @param directionToUpdate is the direction vector to update with the result
  92901. * @param particle is the particle we are computed the direction for
  92902. * @param isLocal defines if the direction should be set in local space
  92903. */
  92904. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92905. /**
  92906. * Called by the particle System when the position is computed for the created particle.
  92907. * @param worldMatrix is the world matrix of the particle system
  92908. * @param positionToUpdate is the position vector to update with the result
  92909. * @param particle is the particle we are computed the position for
  92910. * @param isLocal defines if the position should be set in local space
  92911. */
  92912. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92913. /**
  92914. * Clones the current emitter and returns a copy of it
  92915. * @returns the new emitter
  92916. */
  92917. clone(): PointParticleEmitter;
  92918. /**
  92919. * Called by the GPUParticleSystem to setup the update shader
  92920. * @param effect defines the update shader
  92921. */
  92922. applyToShader(effect: Effect): void;
  92923. /**
  92924. * Returns a string to use to update the GPU particles update shader
  92925. * @returns a string containng the defines string
  92926. */
  92927. getEffectDefines(): string;
  92928. /**
  92929. * Returns the string "PointParticleEmitter"
  92930. * @returns a string containing the class name
  92931. */
  92932. getClassName(): string;
  92933. /**
  92934. * Serializes the particle system to a JSON object.
  92935. * @returns the JSON object
  92936. */
  92937. serialize(): any;
  92938. /**
  92939. * Parse properties from a JSON object
  92940. * @param serializationObject defines the JSON object
  92941. */
  92942. parse(serializationObject: any): void;
  92943. }
  92944. }
  92945. declare module BABYLON {
  92946. /**
  92947. * Particle emitter emitting particles from the inside of a sphere.
  92948. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  92949. */
  92950. export class SphereParticleEmitter implements IParticleEmitterType {
  92951. /**
  92952. * The radius of the emission sphere.
  92953. */
  92954. radius: number;
  92955. /**
  92956. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  92957. */
  92958. radiusRange: number;
  92959. /**
  92960. * How much to randomize the particle direction [0-1].
  92961. */
  92962. directionRandomizer: number;
  92963. /**
  92964. * Creates a new instance SphereParticleEmitter
  92965. * @param radius the radius of the emission sphere (1 by default)
  92966. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  92967. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  92968. */
  92969. constructor(
  92970. /**
  92971. * The radius of the emission sphere.
  92972. */
  92973. radius?: number,
  92974. /**
  92975. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  92976. */
  92977. radiusRange?: number,
  92978. /**
  92979. * How much to randomize the particle direction [0-1].
  92980. */
  92981. directionRandomizer?: number);
  92982. /**
  92983. * Called by the particle System when the direction is computed for the created particle.
  92984. * @param worldMatrix is the world matrix of the particle system
  92985. * @param directionToUpdate is the direction vector to update with the result
  92986. * @param particle is the particle we are computed the direction for
  92987. * @param isLocal defines if the direction should be set in local space
  92988. */
  92989. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92990. /**
  92991. * Called by the particle System when the position is computed for the created particle.
  92992. * @param worldMatrix is the world matrix of the particle system
  92993. * @param positionToUpdate is the position vector to update with the result
  92994. * @param particle is the particle we are computed the position for
  92995. * @param isLocal defines if the position should be set in local space
  92996. */
  92997. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92998. /**
  92999. * Clones the current emitter and returns a copy of it
  93000. * @returns the new emitter
  93001. */
  93002. clone(): SphereParticleEmitter;
  93003. /**
  93004. * Called by the GPUParticleSystem to setup the update shader
  93005. * @param effect defines the update shader
  93006. */
  93007. applyToShader(effect: Effect): void;
  93008. /**
  93009. * Returns a string to use to update the GPU particles update shader
  93010. * @returns a string containng the defines string
  93011. */
  93012. getEffectDefines(): string;
  93013. /**
  93014. * Returns the string "SphereParticleEmitter"
  93015. * @returns a string containing the class name
  93016. */
  93017. getClassName(): string;
  93018. /**
  93019. * Serializes the particle system to a JSON object.
  93020. * @returns the JSON object
  93021. */
  93022. serialize(): any;
  93023. /**
  93024. * Parse properties from a JSON object
  93025. * @param serializationObject defines the JSON object
  93026. */
  93027. parse(serializationObject: any): void;
  93028. }
  93029. /**
  93030. * Particle emitter emitting particles from the inside of a sphere.
  93031. * It emits the particles randomly between two vectors.
  93032. */
  93033. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  93034. /**
  93035. * The min limit of the emission direction.
  93036. */
  93037. direction1: Vector3;
  93038. /**
  93039. * The max limit of the emission direction.
  93040. */
  93041. direction2: Vector3;
  93042. /**
  93043. * Creates a new instance SphereDirectedParticleEmitter
  93044. * @param radius the radius of the emission sphere (1 by default)
  93045. * @param direction1 the min limit of the emission direction (up vector by default)
  93046. * @param direction2 the max limit of the emission direction (up vector by default)
  93047. */
  93048. constructor(radius?: number,
  93049. /**
  93050. * The min limit of the emission direction.
  93051. */
  93052. direction1?: Vector3,
  93053. /**
  93054. * The max limit of the emission direction.
  93055. */
  93056. direction2?: Vector3);
  93057. /**
  93058. * Called by the particle System when the direction is computed for the created particle.
  93059. * @param worldMatrix is the world matrix of the particle system
  93060. * @param directionToUpdate is the direction vector to update with the result
  93061. * @param particle is the particle we are computed the direction for
  93062. */
  93063. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  93064. /**
  93065. * Clones the current emitter and returns a copy of it
  93066. * @returns the new emitter
  93067. */
  93068. clone(): SphereDirectedParticleEmitter;
  93069. /**
  93070. * Called by the GPUParticleSystem to setup the update shader
  93071. * @param effect defines the update shader
  93072. */
  93073. applyToShader(effect: Effect): void;
  93074. /**
  93075. * Returns a string to use to update the GPU particles update shader
  93076. * @returns a string containng the defines string
  93077. */
  93078. getEffectDefines(): string;
  93079. /**
  93080. * Returns the string "SphereDirectedParticleEmitter"
  93081. * @returns a string containing the class name
  93082. */
  93083. getClassName(): string;
  93084. /**
  93085. * Serializes the particle system to a JSON object.
  93086. * @returns the JSON object
  93087. */
  93088. serialize(): any;
  93089. /**
  93090. * Parse properties from a JSON object
  93091. * @param serializationObject defines the JSON object
  93092. */
  93093. parse(serializationObject: any): void;
  93094. }
  93095. }
  93096. declare module BABYLON {
  93097. /**
  93098. * Particle emitter emitting particles from a custom list of positions.
  93099. */
  93100. export class CustomParticleEmitter implements IParticleEmitterType {
  93101. /**
  93102. * Gets or sets the position generator that will create the inital position of each particle.
  93103. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  93104. */
  93105. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  93106. /**
  93107. * Gets or sets the destination generator that will create the final destination of each particle.
  93108. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  93109. */
  93110. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  93111. /**
  93112. * Creates a new instance CustomParticleEmitter
  93113. */
  93114. constructor();
  93115. /**
  93116. * Called by the particle System when the direction is computed for the created particle.
  93117. * @param worldMatrix is the world matrix of the particle system
  93118. * @param directionToUpdate is the direction vector to update with the result
  93119. * @param particle is the particle we are computed the direction for
  93120. * @param isLocal defines if the direction should be set in local space
  93121. */
  93122. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93123. /**
  93124. * Called by the particle System when the position is computed for the created particle.
  93125. * @param worldMatrix is the world matrix of the particle system
  93126. * @param positionToUpdate is the position vector to update with the result
  93127. * @param particle is the particle we are computed the position for
  93128. * @param isLocal defines if the position should be set in local space
  93129. */
  93130. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93131. /**
  93132. * Clones the current emitter and returns a copy of it
  93133. * @returns the new emitter
  93134. */
  93135. clone(): CustomParticleEmitter;
  93136. /**
  93137. * Called by the GPUParticleSystem to setup the update shader
  93138. * @param effect defines the update shader
  93139. */
  93140. applyToShader(effect: Effect): void;
  93141. /**
  93142. * Returns a string to use to update the GPU particles update shader
  93143. * @returns a string containng the defines string
  93144. */
  93145. getEffectDefines(): string;
  93146. /**
  93147. * Returns the string "PointParticleEmitter"
  93148. * @returns a string containing the class name
  93149. */
  93150. getClassName(): string;
  93151. /**
  93152. * Serializes the particle system to a JSON object.
  93153. * @returns the JSON object
  93154. */
  93155. serialize(): any;
  93156. /**
  93157. * Parse properties from a JSON object
  93158. * @param serializationObject defines the JSON object
  93159. */
  93160. parse(serializationObject: any): void;
  93161. }
  93162. }
  93163. declare module BABYLON {
  93164. /**
  93165. * Particle emitter emitting particles from the inside of a box.
  93166. * It emits the particles randomly between 2 given directions.
  93167. */
  93168. export class MeshParticleEmitter implements IParticleEmitterType {
  93169. private _indices;
  93170. private _positions;
  93171. private _normals;
  93172. private _storedNormal;
  93173. private _mesh;
  93174. /**
  93175. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93176. */
  93177. direction1: Vector3;
  93178. /**
  93179. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93180. */
  93181. direction2: Vector3;
  93182. /**
  93183. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  93184. */
  93185. useMeshNormalsForDirection: boolean;
  93186. /** Defines the mesh to use as source */
  93187. get mesh(): Nullable<AbstractMesh>;
  93188. set mesh(value: Nullable<AbstractMesh>);
  93189. /**
  93190. * Creates a new instance MeshParticleEmitter
  93191. * @param mesh defines the mesh to use as source
  93192. */
  93193. constructor(mesh?: Nullable<AbstractMesh>);
  93194. /**
  93195. * Called by the particle System when the direction is computed for the created particle.
  93196. * @param worldMatrix is the world matrix of the particle system
  93197. * @param directionToUpdate is the direction vector to update with the result
  93198. * @param particle is the particle we are computed the direction for
  93199. * @param isLocal defines if the direction should be set in local space
  93200. */
  93201. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93202. /**
  93203. * Called by the particle System when the position is computed for the created particle.
  93204. * @param worldMatrix is the world matrix of the particle system
  93205. * @param positionToUpdate is the position vector to update with the result
  93206. * @param particle is the particle we are computed the position for
  93207. * @param isLocal defines if the position should be set in local space
  93208. */
  93209. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93210. /**
  93211. * Clones the current emitter and returns a copy of it
  93212. * @returns the new emitter
  93213. */
  93214. clone(): MeshParticleEmitter;
  93215. /**
  93216. * Called by the GPUParticleSystem to setup the update shader
  93217. * @param effect defines the update shader
  93218. */
  93219. applyToShader(effect: Effect): void;
  93220. /**
  93221. * Returns a string to use to update the GPU particles update shader
  93222. * @returns a string containng the defines string
  93223. */
  93224. getEffectDefines(): string;
  93225. /**
  93226. * Returns the string "BoxParticleEmitter"
  93227. * @returns a string containing the class name
  93228. */
  93229. getClassName(): string;
  93230. /**
  93231. * Serializes the particle system to a JSON object.
  93232. * @returns the JSON object
  93233. */
  93234. serialize(): any;
  93235. /**
  93236. * Parse properties from a JSON object
  93237. * @param serializationObject defines the JSON object
  93238. * @param scene defines the hosting scene
  93239. */
  93240. parse(serializationObject: any, scene: Nullable<Scene>): void;
  93241. }
  93242. }
  93243. declare module BABYLON {
  93244. /**
  93245. * Interface representing a particle system in Babylon.js.
  93246. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  93247. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  93248. */
  93249. export interface IParticleSystem {
  93250. /**
  93251. * List of animations used by the particle system.
  93252. */
  93253. animations: Animation[];
  93254. /**
  93255. * The id of the Particle system.
  93256. */
  93257. id: string;
  93258. /**
  93259. * The name of the Particle system.
  93260. */
  93261. name: string;
  93262. /**
  93263. * The emitter represents the Mesh or position we are attaching the particle system to.
  93264. */
  93265. emitter: Nullable<AbstractMesh | Vector3>;
  93266. /**
  93267. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  93268. */
  93269. isBillboardBased: boolean;
  93270. /**
  93271. * The rendering group used by the Particle system to chose when to render.
  93272. */
  93273. renderingGroupId: number;
  93274. /**
  93275. * The layer mask we are rendering the particles through.
  93276. */
  93277. layerMask: number;
  93278. /**
  93279. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  93280. */
  93281. updateSpeed: number;
  93282. /**
  93283. * The amount of time the particle system is running (depends of the overall update speed).
  93284. */
  93285. targetStopDuration: number;
  93286. /**
  93287. * The texture used to render each particle. (this can be a spritesheet)
  93288. */
  93289. particleTexture: Nullable<BaseTexture>;
  93290. /**
  93291. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  93292. */
  93293. blendMode: number;
  93294. /**
  93295. * Minimum life time of emitting particles.
  93296. */
  93297. minLifeTime: number;
  93298. /**
  93299. * Maximum life time of emitting particles.
  93300. */
  93301. maxLifeTime: number;
  93302. /**
  93303. * Minimum Size of emitting particles.
  93304. */
  93305. minSize: number;
  93306. /**
  93307. * Maximum Size of emitting particles.
  93308. */
  93309. maxSize: number;
  93310. /**
  93311. * Minimum scale of emitting particles on X axis.
  93312. */
  93313. minScaleX: number;
  93314. /**
  93315. * Maximum scale of emitting particles on X axis.
  93316. */
  93317. maxScaleX: number;
  93318. /**
  93319. * Minimum scale of emitting particles on Y axis.
  93320. */
  93321. minScaleY: number;
  93322. /**
  93323. * Maximum scale of emitting particles on Y axis.
  93324. */
  93325. maxScaleY: number;
  93326. /**
  93327. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  93328. */
  93329. color1: Color4;
  93330. /**
  93331. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  93332. */
  93333. color2: Color4;
  93334. /**
  93335. * Color the particle will have at the end of its lifetime.
  93336. */
  93337. colorDead: Color4;
  93338. /**
  93339. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  93340. */
  93341. emitRate: number;
  93342. /**
  93343. * You can use gravity if you want to give an orientation to your particles.
  93344. */
  93345. gravity: Vector3;
  93346. /**
  93347. * Minimum power of emitting particles.
  93348. */
  93349. minEmitPower: number;
  93350. /**
  93351. * Maximum power of emitting particles.
  93352. */
  93353. maxEmitPower: number;
  93354. /**
  93355. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  93356. */
  93357. minAngularSpeed: number;
  93358. /**
  93359. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  93360. */
  93361. maxAngularSpeed: number;
  93362. /**
  93363. * Gets or sets the minimal initial rotation in radians.
  93364. */
  93365. minInitialRotation: number;
  93366. /**
  93367. * Gets or sets the maximal initial rotation in radians.
  93368. */
  93369. maxInitialRotation: number;
  93370. /**
  93371. * The particle emitter type defines the emitter used by the particle system.
  93372. * It can be for example box, sphere, or cone...
  93373. */
  93374. particleEmitterType: Nullable<IParticleEmitterType>;
  93375. /**
  93376. * Defines the delay in milliseconds before starting the system (0 by default)
  93377. */
  93378. startDelay: number;
  93379. /**
  93380. * 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
  93381. */
  93382. preWarmCycles: number;
  93383. /**
  93384. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  93385. */
  93386. preWarmStepOffset: number;
  93387. /**
  93388. * 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)
  93389. */
  93390. spriteCellChangeSpeed: number;
  93391. /**
  93392. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  93393. */
  93394. startSpriteCellID: number;
  93395. /**
  93396. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  93397. */
  93398. endSpriteCellID: number;
  93399. /**
  93400. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  93401. */
  93402. spriteCellWidth: number;
  93403. /**
  93404. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  93405. */
  93406. spriteCellHeight: number;
  93407. /**
  93408. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  93409. */
  93410. spriteRandomStartCell: boolean;
  93411. /**
  93412. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  93413. */
  93414. isAnimationSheetEnabled: boolean;
  93415. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  93416. translationPivot: Vector2;
  93417. /**
  93418. * Gets or sets a texture used to add random noise to particle positions
  93419. */
  93420. noiseTexture: Nullable<BaseTexture>;
  93421. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  93422. noiseStrength: Vector3;
  93423. /**
  93424. * Gets or sets the billboard mode to use when isBillboardBased = true.
  93425. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  93426. */
  93427. billboardMode: number;
  93428. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  93429. limitVelocityDamping: number;
  93430. /**
  93431. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  93432. */
  93433. beginAnimationOnStart: boolean;
  93434. /**
  93435. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  93436. */
  93437. beginAnimationFrom: number;
  93438. /**
  93439. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  93440. */
  93441. beginAnimationTo: number;
  93442. /**
  93443. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  93444. */
  93445. beginAnimationLoop: boolean;
  93446. /**
  93447. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  93448. */
  93449. disposeOnStop: boolean;
  93450. /**
  93451. * Specifies if the particles are updated in emitter local space or world space
  93452. */
  93453. isLocal: boolean;
  93454. /** Snippet ID if the particle system was created from the snippet server */
  93455. snippetId: string;
  93456. /** Gets or sets a matrix to use to compute projection */
  93457. defaultProjectionMatrix: Matrix;
  93458. /**
  93459. * Gets the maximum number of particles active at the same time.
  93460. * @returns The max number of active particles.
  93461. */
  93462. getCapacity(): number;
  93463. /**
  93464. * Gets the number of particles active at the same time.
  93465. * @returns The number of active particles.
  93466. */
  93467. getActiveCount(): number;
  93468. /**
  93469. * Gets if the system has been started. (Note: this will still be true after stop is called)
  93470. * @returns True if it has been started, otherwise false.
  93471. */
  93472. isStarted(): boolean;
  93473. /**
  93474. * Animates the particle system for this frame.
  93475. */
  93476. animate(): void;
  93477. /**
  93478. * Renders the particle system in its current state.
  93479. * @returns the current number of particles
  93480. */
  93481. render(): number;
  93482. /**
  93483. * Dispose the particle system and frees its associated resources.
  93484. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  93485. */
  93486. dispose(disposeTexture?: boolean): void;
  93487. /**
  93488. * An event triggered when the system is disposed
  93489. */
  93490. onDisposeObservable: Observable<IParticleSystem>;
  93491. /**
  93492. * Clones the particle system.
  93493. * @param name The name of the cloned object
  93494. * @param newEmitter The new emitter to use
  93495. * @returns the cloned particle system
  93496. */
  93497. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  93498. /**
  93499. * Serializes the particle system to a JSON object
  93500. * @param serializeTexture defines if the texture must be serialized as well
  93501. * @returns the JSON object
  93502. */
  93503. serialize(serializeTexture: boolean): any;
  93504. /**
  93505. * Rebuild the particle system
  93506. */
  93507. rebuild(): void;
  93508. /** Force the system to rebuild all gradients that need to be resync */
  93509. forceRefreshGradients(): void;
  93510. /**
  93511. * Starts the particle system and begins to emit
  93512. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  93513. */
  93514. start(delay?: number): void;
  93515. /**
  93516. * Stops the particle system.
  93517. */
  93518. stop(): void;
  93519. /**
  93520. * Remove all active particles
  93521. */
  93522. reset(): void;
  93523. /**
  93524. * Gets a boolean indicating that the system is stopping
  93525. * @returns true if the system is currently stopping
  93526. */
  93527. isStopping(): boolean;
  93528. /**
  93529. * Is this system ready to be used/rendered
  93530. * @return true if the system is ready
  93531. */
  93532. isReady(): boolean;
  93533. /**
  93534. * Returns the string "ParticleSystem"
  93535. * @returns a string containing the class name
  93536. */
  93537. getClassName(): string;
  93538. /**
  93539. * Gets the custom effect used to render the particles
  93540. * @param blendMode Blend mode for which the effect should be retrieved
  93541. * @returns The effect
  93542. */
  93543. getCustomEffect(blendMode: number): Nullable<Effect>;
  93544. /**
  93545. * Sets the custom effect used to render the particles
  93546. * @param effect The effect to set
  93547. * @param blendMode Blend mode for which the effect should be set
  93548. */
  93549. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  93550. /**
  93551. * Fill the defines array according to the current settings of the particle system
  93552. * @param defines Array to be updated
  93553. * @param blendMode blend mode to take into account when updating the array
  93554. */
  93555. fillDefines(defines: Array<string>, blendMode: number): void;
  93556. /**
  93557. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  93558. * @param uniforms Uniforms array to fill
  93559. * @param attributes Attributes array to fill
  93560. * @param samplers Samplers array to fill
  93561. */
  93562. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  93563. /**
  93564. * Observable that will be called just before the particles are drawn
  93565. */
  93566. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  93567. /**
  93568. * Gets the name of the particle vertex shader
  93569. */
  93570. vertexShaderName: string;
  93571. /**
  93572. * Adds a new color gradient
  93573. * @param gradient defines the gradient to use (between 0 and 1)
  93574. * @param color1 defines the color to affect to the specified gradient
  93575. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  93576. * @returns the current particle system
  93577. */
  93578. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  93579. /**
  93580. * Remove a specific color gradient
  93581. * @param gradient defines the gradient to remove
  93582. * @returns the current particle system
  93583. */
  93584. removeColorGradient(gradient: number): IParticleSystem;
  93585. /**
  93586. * Adds a new size gradient
  93587. * @param gradient defines the gradient to use (between 0 and 1)
  93588. * @param factor defines the size factor to affect to the specified gradient
  93589. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93590. * @returns the current particle system
  93591. */
  93592. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93593. /**
  93594. * Remove a specific size gradient
  93595. * @param gradient defines the gradient to remove
  93596. * @returns the current particle system
  93597. */
  93598. removeSizeGradient(gradient: number): IParticleSystem;
  93599. /**
  93600. * Gets the current list of color gradients.
  93601. * You must use addColorGradient and removeColorGradient to udpate this list
  93602. * @returns the list of color gradients
  93603. */
  93604. getColorGradients(): Nullable<Array<ColorGradient>>;
  93605. /**
  93606. * Gets the current list of size gradients.
  93607. * You must use addSizeGradient and removeSizeGradient to udpate this list
  93608. * @returns the list of size gradients
  93609. */
  93610. getSizeGradients(): Nullable<Array<FactorGradient>>;
  93611. /**
  93612. * Gets the current list of angular speed gradients.
  93613. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  93614. * @returns the list of angular speed gradients
  93615. */
  93616. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  93617. /**
  93618. * Adds a new angular speed gradient
  93619. * @param gradient defines the gradient to use (between 0 and 1)
  93620. * @param factor defines the angular speed to affect to the specified gradient
  93621. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93622. * @returns the current particle system
  93623. */
  93624. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93625. /**
  93626. * Remove a specific angular speed gradient
  93627. * @param gradient defines the gradient to remove
  93628. * @returns the current particle system
  93629. */
  93630. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  93631. /**
  93632. * Gets the current list of velocity gradients.
  93633. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  93634. * @returns the list of velocity gradients
  93635. */
  93636. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  93637. /**
  93638. * Adds a new velocity gradient
  93639. * @param gradient defines the gradient to use (between 0 and 1)
  93640. * @param factor defines the velocity to affect to the specified gradient
  93641. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93642. * @returns the current particle system
  93643. */
  93644. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93645. /**
  93646. * Remove a specific velocity gradient
  93647. * @param gradient defines the gradient to remove
  93648. * @returns the current particle system
  93649. */
  93650. removeVelocityGradient(gradient: number): IParticleSystem;
  93651. /**
  93652. * Gets the current list of limit velocity gradients.
  93653. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  93654. * @returns the list of limit velocity gradients
  93655. */
  93656. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  93657. /**
  93658. * Adds a new limit velocity gradient
  93659. * @param gradient defines the gradient to use (between 0 and 1)
  93660. * @param factor defines the limit velocity to affect to the specified gradient
  93661. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93662. * @returns the current particle system
  93663. */
  93664. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93665. /**
  93666. * Remove a specific limit velocity gradient
  93667. * @param gradient defines the gradient to remove
  93668. * @returns the current particle system
  93669. */
  93670. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  93671. /**
  93672. * Adds a new drag gradient
  93673. * @param gradient defines the gradient to use (between 0 and 1)
  93674. * @param factor defines the drag to affect to the specified gradient
  93675. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93676. * @returns the current particle system
  93677. */
  93678. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93679. /**
  93680. * Remove a specific drag gradient
  93681. * @param gradient defines the gradient to remove
  93682. * @returns the current particle system
  93683. */
  93684. removeDragGradient(gradient: number): IParticleSystem;
  93685. /**
  93686. * Gets the current list of drag gradients.
  93687. * You must use addDragGradient and removeDragGradient to udpate this list
  93688. * @returns the list of drag gradients
  93689. */
  93690. getDragGradients(): Nullable<Array<FactorGradient>>;
  93691. /**
  93692. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  93693. * @param gradient defines the gradient to use (between 0 and 1)
  93694. * @param factor defines the emit rate to affect to the specified gradient
  93695. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93696. * @returns the current particle system
  93697. */
  93698. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93699. /**
  93700. * Remove a specific emit rate gradient
  93701. * @param gradient defines the gradient to remove
  93702. * @returns the current particle system
  93703. */
  93704. removeEmitRateGradient(gradient: number): IParticleSystem;
  93705. /**
  93706. * Gets the current list of emit rate gradients.
  93707. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  93708. * @returns the list of emit rate gradients
  93709. */
  93710. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  93711. /**
  93712. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  93713. * @param gradient defines the gradient to use (between 0 and 1)
  93714. * @param factor defines the start size to affect to the specified gradient
  93715. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93716. * @returns the current particle system
  93717. */
  93718. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93719. /**
  93720. * Remove a specific start size gradient
  93721. * @param gradient defines the gradient to remove
  93722. * @returns the current particle system
  93723. */
  93724. removeStartSizeGradient(gradient: number): IParticleSystem;
  93725. /**
  93726. * Gets the current list of start size gradients.
  93727. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  93728. * @returns the list of start size gradients
  93729. */
  93730. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  93731. /**
  93732. * Adds a new life time gradient
  93733. * @param gradient defines the gradient to use (between 0 and 1)
  93734. * @param factor defines the life time factor to affect to the specified gradient
  93735. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93736. * @returns the current particle system
  93737. */
  93738. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93739. /**
  93740. * Remove a specific life time gradient
  93741. * @param gradient defines the gradient to remove
  93742. * @returns the current particle system
  93743. */
  93744. removeLifeTimeGradient(gradient: number): IParticleSystem;
  93745. /**
  93746. * Gets the current list of life time gradients.
  93747. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  93748. * @returns the list of life time gradients
  93749. */
  93750. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  93751. /**
  93752. * Gets the current list of color gradients.
  93753. * You must use addColorGradient and removeColorGradient to udpate this list
  93754. * @returns the list of color gradients
  93755. */
  93756. getColorGradients(): Nullable<Array<ColorGradient>>;
  93757. /**
  93758. * Adds a new ramp gradient used to remap particle colors
  93759. * @param gradient defines the gradient to use (between 0 and 1)
  93760. * @param color defines the color to affect to the specified gradient
  93761. * @returns the current particle system
  93762. */
  93763. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  93764. /**
  93765. * Gets the current list of ramp gradients.
  93766. * You must use addRampGradient and removeRampGradient to udpate this list
  93767. * @returns the list of ramp gradients
  93768. */
  93769. getRampGradients(): Nullable<Array<Color3Gradient>>;
  93770. /** Gets or sets a boolean indicating that ramp gradients must be used
  93771. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  93772. */
  93773. useRampGradients: boolean;
  93774. /**
  93775. * Adds a new color remap gradient
  93776. * @param gradient defines the gradient to use (between 0 and 1)
  93777. * @param min defines the color remap minimal range
  93778. * @param max defines the color remap maximal range
  93779. * @returns the current particle system
  93780. */
  93781. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  93782. /**
  93783. * Gets the current list of color remap gradients.
  93784. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  93785. * @returns the list of color remap gradients
  93786. */
  93787. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  93788. /**
  93789. * Adds a new alpha remap gradient
  93790. * @param gradient defines the gradient to use (between 0 and 1)
  93791. * @param min defines the alpha remap minimal range
  93792. * @param max defines the alpha remap maximal range
  93793. * @returns the current particle system
  93794. */
  93795. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  93796. /**
  93797. * Gets the current list of alpha remap gradients.
  93798. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  93799. * @returns the list of alpha remap gradients
  93800. */
  93801. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  93802. /**
  93803. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  93804. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  93805. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  93806. * @returns the emitter
  93807. */
  93808. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  93809. /**
  93810. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  93811. * @param radius The radius of the hemisphere to emit from
  93812. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  93813. * @returns the emitter
  93814. */
  93815. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  93816. /**
  93817. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  93818. * @param radius The radius of the sphere to emit from
  93819. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  93820. * @returns the emitter
  93821. */
  93822. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  93823. /**
  93824. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  93825. * @param radius The radius of the sphere to emit from
  93826. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  93827. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  93828. * @returns the emitter
  93829. */
  93830. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  93831. /**
  93832. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  93833. * @param radius The radius of the emission cylinder
  93834. * @param height The height of the emission cylinder
  93835. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  93836. * @param directionRandomizer How much to randomize the particle direction [0-1]
  93837. * @returns the emitter
  93838. */
  93839. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  93840. /**
  93841. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  93842. * @param radius The radius of the cylinder to emit from
  93843. * @param height The height of the emission cylinder
  93844. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93845. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  93846. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  93847. * @returns the emitter
  93848. */
  93849. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  93850. /**
  93851. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  93852. * @param radius The radius of the cone to emit from
  93853. * @param angle The base angle of the cone
  93854. * @returns the emitter
  93855. */
  93856. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  93857. /**
  93858. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  93859. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  93860. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  93861. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  93862. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  93863. * @returns the emitter
  93864. */
  93865. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  93866. /**
  93867. * Get hosting scene
  93868. * @returns the scene
  93869. */
  93870. getScene(): Nullable<Scene>;
  93871. }
  93872. }
  93873. declare module BABYLON {
  93874. /**
  93875. * 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.
  93876. * @see https://doc.babylonjs.com/how_to/transformnode
  93877. */
  93878. export class TransformNode extends Node {
  93879. /**
  93880. * Object will not rotate to face the camera
  93881. */
  93882. static BILLBOARDMODE_NONE: number;
  93883. /**
  93884. * Object will rotate to face the camera but only on the x axis
  93885. */
  93886. static BILLBOARDMODE_X: number;
  93887. /**
  93888. * Object will rotate to face the camera but only on the y axis
  93889. */
  93890. static BILLBOARDMODE_Y: number;
  93891. /**
  93892. * Object will rotate to face the camera but only on the z axis
  93893. */
  93894. static BILLBOARDMODE_Z: number;
  93895. /**
  93896. * Object will rotate to face the camera
  93897. */
  93898. static BILLBOARDMODE_ALL: number;
  93899. /**
  93900. * Object will rotate to face the camera's position instead of orientation
  93901. */
  93902. static BILLBOARDMODE_USE_POSITION: number;
  93903. private static _TmpRotation;
  93904. private static _TmpScaling;
  93905. private static _TmpTranslation;
  93906. private _forward;
  93907. private _forwardInverted;
  93908. private _up;
  93909. private _right;
  93910. private _rightInverted;
  93911. private _position;
  93912. private _rotation;
  93913. private _rotationQuaternion;
  93914. protected _scaling: Vector3;
  93915. protected _isDirty: boolean;
  93916. private _transformToBoneReferal;
  93917. private _isAbsoluteSynced;
  93918. private _billboardMode;
  93919. /**
  93920. * Gets or sets the billboard mode. Default is 0.
  93921. *
  93922. * | Value | Type | Description |
  93923. * | --- | --- | --- |
  93924. * | 0 | BILLBOARDMODE_NONE | |
  93925. * | 1 | BILLBOARDMODE_X | |
  93926. * | 2 | BILLBOARDMODE_Y | |
  93927. * | 4 | BILLBOARDMODE_Z | |
  93928. * | 7 | BILLBOARDMODE_ALL | |
  93929. *
  93930. */
  93931. get billboardMode(): number;
  93932. set billboardMode(value: number);
  93933. private _preserveParentRotationForBillboard;
  93934. /**
  93935. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  93936. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  93937. */
  93938. get preserveParentRotationForBillboard(): boolean;
  93939. set preserveParentRotationForBillboard(value: boolean);
  93940. /**
  93941. * 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
  93942. */
  93943. scalingDeterminant: number;
  93944. private _infiniteDistance;
  93945. /**
  93946. * Gets or sets the distance of the object to max, often used by skybox
  93947. */
  93948. get infiniteDistance(): boolean;
  93949. set infiniteDistance(value: boolean);
  93950. /**
  93951. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  93952. * By default the system will update normals to compensate
  93953. */
  93954. ignoreNonUniformScaling: boolean;
  93955. /**
  93956. * 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
  93957. */
  93958. reIntegrateRotationIntoRotationQuaternion: boolean;
  93959. /** @hidden */
  93960. _poseMatrix: Nullable<Matrix>;
  93961. /** @hidden */
  93962. _localMatrix: Matrix;
  93963. private _usePivotMatrix;
  93964. private _absolutePosition;
  93965. private _absoluteScaling;
  93966. private _absoluteRotationQuaternion;
  93967. private _pivotMatrix;
  93968. private _pivotMatrixInverse;
  93969. protected _postMultiplyPivotMatrix: boolean;
  93970. protected _isWorldMatrixFrozen: boolean;
  93971. /** @hidden */
  93972. _indexInSceneTransformNodesArray: number;
  93973. /**
  93974. * An event triggered after the world matrix is updated
  93975. */
  93976. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  93977. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  93978. /**
  93979. * Gets a string identifying the name of the class
  93980. * @returns "TransformNode" string
  93981. */
  93982. getClassName(): string;
  93983. /**
  93984. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  93985. */
  93986. get position(): Vector3;
  93987. set position(newPosition: Vector3);
  93988. /**
  93989. * 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)).
  93990. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  93991. */
  93992. get rotation(): Vector3;
  93993. set rotation(newRotation: Vector3);
  93994. /**
  93995. * 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)).
  93996. */
  93997. get scaling(): Vector3;
  93998. set scaling(newScaling: Vector3);
  93999. /**
  94000. * 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).
  94001. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  94002. */
  94003. get rotationQuaternion(): Nullable<Quaternion>;
  94004. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  94005. /**
  94006. * The forward direction of that transform in world space.
  94007. */
  94008. get forward(): Vector3;
  94009. /**
  94010. * The up direction of that transform in world space.
  94011. */
  94012. get up(): Vector3;
  94013. /**
  94014. * The right direction of that transform in world space.
  94015. */
  94016. get right(): Vector3;
  94017. /**
  94018. * Copies the parameter passed Matrix into the mesh Pose matrix.
  94019. * @param matrix the matrix to copy the pose from
  94020. * @returns this TransformNode.
  94021. */
  94022. updatePoseMatrix(matrix: Matrix): TransformNode;
  94023. /**
  94024. * Returns the mesh Pose matrix.
  94025. * @returns the pose matrix
  94026. */
  94027. getPoseMatrix(): Matrix;
  94028. /** @hidden */
  94029. _isSynchronized(): boolean;
  94030. /** @hidden */
  94031. _initCache(): void;
  94032. /**
  94033. * Flag the transform node as dirty (Forcing it to update everything)
  94034. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  94035. * @returns this transform node
  94036. */
  94037. markAsDirty(property: string): TransformNode;
  94038. /**
  94039. * Returns the current mesh absolute position.
  94040. * Returns a Vector3.
  94041. */
  94042. get absolutePosition(): Vector3;
  94043. /**
  94044. * Returns the current mesh absolute scaling.
  94045. * Returns a Vector3.
  94046. */
  94047. get absoluteScaling(): Vector3;
  94048. /**
  94049. * Returns the current mesh absolute rotation.
  94050. * Returns a Quaternion.
  94051. */
  94052. get absoluteRotationQuaternion(): Quaternion;
  94053. /**
  94054. * Sets a new matrix to apply before all other transformation
  94055. * @param matrix defines the transform matrix
  94056. * @returns the current TransformNode
  94057. */
  94058. setPreTransformMatrix(matrix: Matrix): TransformNode;
  94059. /**
  94060. * Sets a new pivot matrix to the current node
  94061. * @param matrix defines the new pivot matrix to use
  94062. * @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
  94063. * @returns the current TransformNode
  94064. */
  94065. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  94066. /**
  94067. * Returns the mesh pivot matrix.
  94068. * Default : Identity.
  94069. * @returns the matrix
  94070. */
  94071. getPivotMatrix(): Matrix;
  94072. /**
  94073. * Instantiate (when possible) or clone that node with its hierarchy
  94074. * @param newParent defines the new parent to use for the instance (or clone)
  94075. * @param options defines options to configure how copy is done
  94076. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  94077. * @returns an instance (or a clone) of the current node with its hiearchy
  94078. */
  94079. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  94080. doNotInstantiate: boolean;
  94081. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  94082. /**
  94083. * Prevents the World matrix to be computed any longer
  94084. * @param newWorldMatrix defines an optional matrix to use as world matrix
  94085. * @returns the TransformNode.
  94086. */
  94087. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  94088. /**
  94089. * Allows back the World matrix computation.
  94090. * @returns the TransformNode.
  94091. */
  94092. unfreezeWorldMatrix(): this;
  94093. /**
  94094. * True if the World matrix has been frozen.
  94095. */
  94096. get isWorldMatrixFrozen(): boolean;
  94097. /**
  94098. * Retuns the mesh absolute position in the World.
  94099. * @returns a Vector3.
  94100. */
  94101. getAbsolutePosition(): Vector3;
  94102. /**
  94103. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  94104. * @param absolutePosition the absolute position to set
  94105. * @returns the TransformNode.
  94106. */
  94107. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  94108. /**
  94109. * Sets the mesh position in its local space.
  94110. * @param vector3 the position to set in localspace
  94111. * @returns the TransformNode.
  94112. */
  94113. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  94114. /**
  94115. * Returns the mesh position in the local space from the current World matrix values.
  94116. * @returns a new Vector3.
  94117. */
  94118. getPositionExpressedInLocalSpace(): Vector3;
  94119. /**
  94120. * Translates the mesh along the passed Vector3 in its local space.
  94121. * @param vector3 the distance to translate in localspace
  94122. * @returns the TransformNode.
  94123. */
  94124. locallyTranslate(vector3: Vector3): TransformNode;
  94125. private static _lookAtVectorCache;
  94126. /**
  94127. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  94128. * @param targetPoint the position (must be in same space as current mesh) to look at
  94129. * @param yawCor optional yaw (y-axis) correction in radians
  94130. * @param pitchCor optional pitch (x-axis) correction in radians
  94131. * @param rollCor optional roll (z-axis) correction in radians
  94132. * @param space the choosen space of the target
  94133. * @returns the TransformNode.
  94134. */
  94135. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  94136. /**
  94137. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  94138. * This Vector3 is expressed in the World space.
  94139. * @param localAxis axis to rotate
  94140. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  94141. */
  94142. getDirection(localAxis: Vector3): Vector3;
  94143. /**
  94144. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  94145. * localAxis is expressed in the mesh local space.
  94146. * result is computed in the Wordl space from the mesh World matrix.
  94147. * @param localAxis axis to rotate
  94148. * @param result the resulting transformnode
  94149. * @returns this TransformNode.
  94150. */
  94151. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  94152. /**
  94153. * Sets this transform node rotation to the given local axis.
  94154. * @param localAxis the axis in local space
  94155. * @param yawCor optional yaw (y-axis) correction in radians
  94156. * @param pitchCor optional pitch (x-axis) correction in radians
  94157. * @param rollCor optional roll (z-axis) correction in radians
  94158. * @returns this TransformNode
  94159. */
  94160. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  94161. /**
  94162. * Sets a new pivot point to the current node
  94163. * @param point defines the new pivot point to use
  94164. * @param space defines if the point is in world or local space (local by default)
  94165. * @returns the current TransformNode
  94166. */
  94167. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  94168. /**
  94169. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  94170. * @returns the pivot point
  94171. */
  94172. getPivotPoint(): Vector3;
  94173. /**
  94174. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  94175. * @param result the vector3 to store the result
  94176. * @returns this TransformNode.
  94177. */
  94178. getPivotPointToRef(result: Vector3): TransformNode;
  94179. /**
  94180. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  94181. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  94182. */
  94183. getAbsolutePivotPoint(): Vector3;
  94184. /**
  94185. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  94186. * @param result vector3 to store the result
  94187. * @returns this TransformNode.
  94188. */
  94189. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  94190. /**
  94191. * Defines the passed node as the parent of the current node.
  94192. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  94193. * @see https://doc.babylonjs.com/how_to/parenting
  94194. * @param node the node ot set as the parent
  94195. * @returns this TransformNode.
  94196. */
  94197. setParent(node: Nullable<Node>): TransformNode;
  94198. private _nonUniformScaling;
  94199. /**
  94200. * True if the scaling property of this object is non uniform eg. (1,2,1)
  94201. */
  94202. get nonUniformScaling(): boolean;
  94203. /** @hidden */
  94204. _updateNonUniformScalingState(value: boolean): boolean;
  94205. /**
  94206. * Attach the current TransformNode to another TransformNode associated with a bone
  94207. * @param bone Bone affecting the TransformNode
  94208. * @param affectedTransformNode TransformNode associated with the bone
  94209. * @returns this object
  94210. */
  94211. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  94212. /**
  94213. * Detach the transform node if its associated with a bone
  94214. * @returns this object
  94215. */
  94216. detachFromBone(): TransformNode;
  94217. private static _rotationAxisCache;
  94218. /**
  94219. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  94220. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  94221. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  94222. * The passed axis is also normalized.
  94223. * @param axis the axis to rotate around
  94224. * @param amount the amount to rotate in radians
  94225. * @param space Space to rotate in (Default: local)
  94226. * @returns the TransformNode.
  94227. */
  94228. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  94229. /**
  94230. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  94231. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  94232. * The passed axis is also normalized. .
  94233. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  94234. * @param point the point to rotate around
  94235. * @param axis the axis to rotate around
  94236. * @param amount the amount to rotate in radians
  94237. * @returns the TransformNode
  94238. */
  94239. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  94240. /**
  94241. * Translates the mesh along the axis vector for the passed distance in the given space.
  94242. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  94243. * @param axis the axis to translate in
  94244. * @param distance the distance to translate
  94245. * @param space Space to rotate in (Default: local)
  94246. * @returns the TransformNode.
  94247. */
  94248. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  94249. /**
  94250. * Adds a rotation step to the mesh current rotation.
  94251. * x, y, z are Euler angles expressed in radians.
  94252. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  94253. * This means this rotation is made in the mesh local space only.
  94254. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  94255. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  94256. * ```javascript
  94257. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  94258. * ```
  94259. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  94260. * 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.
  94261. * @param x Rotation to add
  94262. * @param y Rotation to add
  94263. * @param z Rotation to add
  94264. * @returns the TransformNode.
  94265. */
  94266. addRotation(x: number, y: number, z: number): TransformNode;
  94267. /**
  94268. * @hidden
  94269. */
  94270. protected _getEffectiveParent(): Nullable<Node>;
  94271. /**
  94272. * Computes the world matrix of the node
  94273. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  94274. * @returns the world matrix
  94275. */
  94276. computeWorldMatrix(force?: boolean): Matrix;
  94277. /**
  94278. * Resets this nodeTransform's local matrix to Matrix.Identity().
  94279. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  94280. */
  94281. resetLocalMatrix(independentOfChildren?: boolean): void;
  94282. protected _afterComputeWorldMatrix(): void;
  94283. /**
  94284. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  94285. * @param func callback function to add
  94286. *
  94287. * @returns the TransformNode.
  94288. */
  94289. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  94290. /**
  94291. * Removes a registered callback function.
  94292. * @param func callback function to remove
  94293. * @returns the TransformNode.
  94294. */
  94295. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  94296. /**
  94297. * Gets the position of the current mesh in camera space
  94298. * @param camera defines the camera to use
  94299. * @returns a position
  94300. */
  94301. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  94302. /**
  94303. * Returns the distance from the mesh to the active camera
  94304. * @param camera defines the camera to use
  94305. * @returns the distance
  94306. */
  94307. getDistanceToCamera(camera?: Nullable<Camera>): number;
  94308. /**
  94309. * Clone the current transform node
  94310. * @param name Name of the new clone
  94311. * @param newParent New parent for the clone
  94312. * @param doNotCloneChildren Do not clone children hierarchy
  94313. * @returns the new transform node
  94314. */
  94315. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  94316. /**
  94317. * Serializes the objects information.
  94318. * @param currentSerializationObject defines the object to serialize in
  94319. * @returns the serialized object
  94320. */
  94321. serialize(currentSerializationObject?: any): any;
  94322. /**
  94323. * Returns a new TransformNode object parsed from the source provided.
  94324. * @param parsedTransformNode is the source.
  94325. * @param scene the scne the object belongs to
  94326. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  94327. * @returns a new TransformNode object parsed from the source provided.
  94328. */
  94329. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  94330. /**
  94331. * Get all child-transformNodes of this node
  94332. * @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
  94333. * @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
  94334. * @returns an array of TransformNode
  94335. */
  94336. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  94337. /**
  94338. * Releases resources associated with this transform node.
  94339. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  94340. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  94341. */
  94342. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  94343. /**
  94344. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  94345. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  94346. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  94347. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  94348. * @returns the current mesh
  94349. */
  94350. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  94351. private _syncAbsoluteScalingAndRotation;
  94352. }
  94353. }
  94354. declare module BABYLON {
  94355. /**
  94356. * Class used to override all child animations of a given target
  94357. */
  94358. export class AnimationPropertiesOverride {
  94359. /**
  94360. * Gets or sets a value indicating if animation blending must be used
  94361. */
  94362. enableBlending: boolean;
  94363. /**
  94364. * Gets or sets the blending speed to use when enableBlending is true
  94365. */
  94366. blendingSpeed: number;
  94367. /**
  94368. * Gets or sets the default loop mode to use
  94369. */
  94370. loopMode: number;
  94371. }
  94372. }
  94373. declare module BABYLON {
  94374. /**
  94375. * Class used to store bone information
  94376. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  94377. */
  94378. export class Bone extends Node {
  94379. /**
  94380. * defines the bone name
  94381. */
  94382. name: string;
  94383. private static _tmpVecs;
  94384. private static _tmpQuat;
  94385. private static _tmpMats;
  94386. /**
  94387. * Gets the list of child bones
  94388. */
  94389. children: Bone[];
  94390. /** Gets the animations associated with this bone */
  94391. animations: Animation[];
  94392. /**
  94393. * Gets or sets bone length
  94394. */
  94395. length: number;
  94396. /**
  94397. * @hidden Internal only
  94398. * Set this value to map this bone to a different index in the transform matrices
  94399. * Set this value to -1 to exclude the bone from the transform matrices
  94400. */
  94401. _index: Nullable<number>;
  94402. private _skeleton;
  94403. private _localMatrix;
  94404. private _restPose;
  94405. private _bindPose;
  94406. private _baseMatrix;
  94407. private _absoluteTransform;
  94408. private _invertedAbsoluteTransform;
  94409. private _parent;
  94410. private _scalingDeterminant;
  94411. private _worldTransform;
  94412. private _localScaling;
  94413. private _localRotation;
  94414. private _localPosition;
  94415. private _needToDecompose;
  94416. private _needToCompose;
  94417. /** @hidden */
  94418. _linkedTransformNode: Nullable<TransformNode>;
  94419. /** @hidden */
  94420. _waitingTransformNodeId: Nullable<string>;
  94421. /** @hidden */
  94422. get _matrix(): Matrix;
  94423. /** @hidden */
  94424. set _matrix(value: Matrix);
  94425. /**
  94426. * Create a new bone
  94427. * @param name defines the bone name
  94428. * @param skeleton defines the parent skeleton
  94429. * @param parentBone defines the parent (can be null if the bone is the root)
  94430. * @param localMatrix defines the local matrix
  94431. * @param restPose defines the rest pose matrix
  94432. * @param baseMatrix defines the base matrix
  94433. * @param index defines index of the bone in the hiearchy
  94434. */
  94435. constructor(
  94436. /**
  94437. * defines the bone name
  94438. */
  94439. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  94440. /**
  94441. * Gets the current object class name.
  94442. * @return the class name
  94443. */
  94444. getClassName(): string;
  94445. /**
  94446. * Gets the parent skeleton
  94447. * @returns a skeleton
  94448. */
  94449. getSkeleton(): Skeleton;
  94450. /**
  94451. * Gets parent bone
  94452. * @returns a bone or null if the bone is the root of the bone hierarchy
  94453. */
  94454. getParent(): Nullable<Bone>;
  94455. /**
  94456. * Returns an array containing the root bones
  94457. * @returns an array containing the root bones
  94458. */
  94459. getChildren(): Array<Bone>;
  94460. /**
  94461. * Gets the node index in matrix array generated for rendering
  94462. * @returns the node index
  94463. */
  94464. getIndex(): number;
  94465. /**
  94466. * Sets the parent bone
  94467. * @param parent defines the parent (can be null if the bone is the root)
  94468. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  94469. */
  94470. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  94471. /**
  94472. * Gets the local matrix
  94473. * @returns a matrix
  94474. */
  94475. getLocalMatrix(): Matrix;
  94476. /**
  94477. * Gets the base matrix (initial matrix which remains unchanged)
  94478. * @returns a matrix
  94479. */
  94480. getBaseMatrix(): Matrix;
  94481. /**
  94482. * Gets the rest pose matrix
  94483. * @returns a matrix
  94484. */
  94485. getRestPose(): Matrix;
  94486. /**
  94487. * Sets the rest pose matrix
  94488. * @param matrix the local-space rest pose to set for this bone
  94489. */
  94490. setRestPose(matrix: Matrix): void;
  94491. /**
  94492. * Gets the bind pose matrix
  94493. * @returns the bind pose matrix
  94494. */
  94495. getBindPose(): Matrix;
  94496. /**
  94497. * Sets the bind pose matrix
  94498. * @param matrix the local-space bind pose to set for this bone
  94499. */
  94500. setBindPose(matrix: Matrix): void;
  94501. /**
  94502. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  94503. */
  94504. getWorldMatrix(): Matrix;
  94505. /**
  94506. * Sets the local matrix to rest pose matrix
  94507. */
  94508. returnToRest(): void;
  94509. /**
  94510. * Gets the inverse of the absolute transform matrix.
  94511. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  94512. * @returns a matrix
  94513. */
  94514. getInvertedAbsoluteTransform(): Matrix;
  94515. /**
  94516. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  94517. * @returns a matrix
  94518. */
  94519. getAbsoluteTransform(): Matrix;
  94520. /**
  94521. * Links with the given transform node.
  94522. * The local matrix of this bone is copied from the transform node every frame.
  94523. * @param transformNode defines the transform node to link to
  94524. */
  94525. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  94526. /**
  94527. * Gets the node used to drive the bone's transformation
  94528. * @returns a transform node or null
  94529. */
  94530. getTransformNode(): Nullable<TransformNode>;
  94531. /** Gets or sets current position (in local space) */
  94532. get position(): Vector3;
  94533. set position(newPosition: Vector3);
  94534. /** Gets or sets current rotation (in local space) */
  94535. get rotation(): Vector3;
  94536. set rotation(newRotation: Vector3);
  94537. /** Gets or sets current rotation quaternion (in local space) */
  94538. get rotationQuaternion(): Quaternion;
  94539. set rotationQuaternion(newRotation: Quaternion);
  94540. /** Gets or sets current scaling (in local space) */
  94541. get scaling(): Vector3;
  94542. set scaling(newScaling: Vector3);
  94543. /**
  94544. * Gets the animation properties override
  94545. */
  94546. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  94547. private _decompose;
  94548. private _compose;
  94549. /**
  94550. * Update the base and local matrices
  94551. * @param matrix defines the new base or local matrix
  94552. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  94553. * @param updateLocalMatrix defines if the local matrix should be updated
  94554. */
  94555. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  94556. /** @hidden */
  94557. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  94558. /**
  94559. * Flag the bone as dirty (Forcing it to update everything)
  94560. */
  94561. markAsDirty(): void;
  94562. /** @hidden */
  94563. _markAsDirtyAndCompose(): void;
  94564. private _markAsDirtyAndDecompose;
  94565. /**
  94566. * Translate the bone in local or world space
  94567. * @param vec The amount to translate the bone
  94568. * @param space The space that the translation is in
  94569. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94570. */
  94571. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  94572. /**
  94573. * Set the postion of the bone in local or world space
  94574. * @param position The position to set the bone
  94575. * @param space The space that the position is in
  94576. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94577. */
  94578. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  94579. /**
  94580. * Set the absolute position of the bone (world space)
  94581. * @param position The position to set the bone
  94582. * @param mesh The mesh that this bone is attached to
  94583. */
  94584. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  94585. /**
  94586. * Scale the bone on the x, y and z axes (in local space)
  94587. * @param x The amount to scale the bone on the x axis
  94588. * @param y The amount to scale the bone on the y axis
  94589. * @param z The amount to scale the bone on the z axis
  94590. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  94591. */
  94592. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  94593. /**
  94594. * Set the bone scaling in local space
  94595. * @param scale defines the scaling vector
  94596. */
  94597. setScale(scale: Vector3): void;
  94598. /**
  94599. * Gets the current scaling in local space
  94600. * @returns the current scaling vector
  94601. */
  94602. getScale(): Vector3;
  94603. /**
  94604. * Gets the current scaling in local space and stores it in a target vector
  94605. * @param result defines the target vector
  94606. */
  94607. getScaleToRef(result: Vector3): void;
  94608. /**
  94609. * Set the yaw, pitch, and roll of the bone in local or world space
  94610. * @param yaw The rotation of the bone on the y axis
  94611. * @param pitch The rotation of the bone on the x axis
  94612. * @param roll The rotation of the bone on the z axis
  94613. * @param space The space that the axes of rotation are in
  94614. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94615. */
  94616. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  94617. /**
  94618. * Add a rotation to the bone on an axis in local or world space
  94619. * @param axis The axis to rotate the bone on
  94620. * @param amount The amount to rotate the bone
  94621. * @param space The space that the axis is in
  94622. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94623. */
  94624. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  94625. /**
  94626. * Set the rotation of the bone to a particular axis angle in local or world space
  94627. * @param axis The axis to rotate the bone on
  94628. * @param angle The angle that the bone should be rotated to
  94629. * @param space The space that the axis is in
  94630. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94631. */
  94632. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  94633. /**
  94634. * Set the euler rotation of the bone in local of world space
  94635. * @param rotation The euler rotation that the bone should be set to
  94636. * @param space The space that the rotation is in
  94637. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94638. */
  94639. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  94640. /**
  94641. * Set the quaternion rotation of the bone in local of world space
  94642. * @param quat The quaternion rotation that the bone should be set to
  94643. * @param space The space that the rotation is in
  94644. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94645. */
  94646. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  94647. /**
  94648. * Set the rotation matrix of the bone in local of world space
  94649. * @param rotMat The rotation matrix that the bone should be set to
  94650. * @param space The space that the rotation is in
  94651. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94652. */
  94653. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  94654. private _rotateWithMatrix;
  94655. private _getNegativeRotationToRef;
  94656. /**
  94657. * Get the position of the bone in local or world space
  94658. * @param space The space that the returned position is in
  94659. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94660. * @returns The position of the bone
  94661. */
  94662. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  94663. /**
  94664. * Copy the position of the bone to a vector3 in local or world space
  94665. * @param space The space that the returned position is in
  94666. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94667. * @param result The vector3 to copy the position to
  94668. */
  94669. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  94670. /**
  94671. * Get the absolute position of the bone (world space)
  94672. * @param mesh The mesh that this bone is attached to
  94673. * @returns The absolute position of the bone
  94674. */
  94675. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  94676. /**
  94677. * Copy the absolute position of the bone (world space) to the result param
  94678. * @param mesh The mesh that this bone is attached to
  94679. * @param result The vector3 to copy the absolute position to
  94680. */
  94681. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  94682. /**
  94683. * Compute the absolute transforms of this bone and its children
  94684. */
  94685. computeAbsoluteTransforms(): void;
  94686. /**
  94687. * Get the world direction from an axis that is in the local space of the bone
  94688. * @param localAxis The local direction that is used to compute the world direction
  94689. * @param mesh The mesh that this bone is attached to
  94690. * @returns The world direction
  94691. */
  94692. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  94693. /**
  94694. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  94695. * @param localAxis The local direction that is used to compute the world direction
  94696. * @param mesh The mesh that this bone is attached to
  94697. * @param result The vector3 that the world direction will be copied to
  94698. */
  94699. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  94700. /**
  94701. * Get the euler rotation of the bone in local or world space
  94702. * @param space The space that the rotation should be in
  94703. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94704. * @returns The euler rotation
  94705. */
  94706. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  94707. /**
  94708. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  94709. * @param space The space that the rotation should be in
  94710. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94711. * @param result The vector3 that the rotation should be copied to
  94712. */
  94713. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  94714. /**
  94715. * Get the quaternion rotation of the bone in either local or world space
  94716. * @param space The space that the rotation should be in
  94717. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94718. * @returns The quaternion rotation
  94719. */
  94720. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  94721. /**
  94722. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  94723. * @param space The space that the rotation should be in
  94724. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94725. * @param result The quaternion that the rotation should be copied to
  94726. */
  94727. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  94728. /**
  94729. * Get the rotation matrix of the bone in local or world space
  94730. * @param space The space that the rotation should be in
  94731. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94732. * @returns The rotation matrix
  94733. */
  94734. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  94735. /**
  94736. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  94737. * @param space The space that the rotation should be in
  94738. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94739. * @param result The quaternion that the rotation should be copied to
  94740. */
  94741. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  94742. /**
  94743. * Get the world position of a point that is in the local space of the bone
  94744. * @param position The local position
  94745. * @param mesh The mesh that this bone is attached to
  94746. * @returns The world position
  94747. */
  94748. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  94749. /**
  94750. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  94751. * @param position The local position
  94752. * @param mesh The mesh that this bone is attached to
  94753. * @param result The vector3 that the world position should be copied to
  94754. */
  94755. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  94756. /**
  94757. * Get the local position of a point that is in world space
  94758. * @param position The world position
  94759. * @param mesh The mesh that this bone is attached to
  94760. * @returns The local position
  94761. */
  94762. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  94763. /**
  94764. * Get the local position of a point that is in world space and copy it to the result param
  94765. * @param position The world position
  94766. * @param mesh The mesh that this bone is attached to
  94767. * @param result The vector3 that the local position should be copied to
  94768. */
  94769. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  94770. }
  94771. }
  94772. declare module BABYLON {
  94773. /**
  94774. * Defines a runtime animation
  94775. */
  94776. export class RuntimeAnimation {
  94777. private _events;
  94778. /**
  94779. * The current frame of the runtime animation
  94780. */
  94781. private _currentFrame;
  94782. /**
  94783. * The animation used by the runtime animation
  94784. */
  94785. private _animation;
  94786. /**
  94787. * The target of the runtime animation
  94788. */
  94789. private _target;
  94790. /**
  94791. * The initiating animatable
  94792. */
  94793. private _host;
  94794. /**
  94795. * The original value of the runtime animation
  94796. */
  94797. private _originalValue;
  94798. /**
  94799. * The original blend value of the runtime animation
  94800. */
  94801. private _originalBlendValue;
  94802. /**
  94803. * The offsets cache of the runtime animation
  94804. */
  94805. private _offsetsCache;
  94806. /**
  94807. * The high limits cache of the runtime animation
  94808. */
  94809. private _highLimitsCache;
  94810. /**
  94811. * Specifies if the runtime animation has been stopped
  94812. */
  94813. private _stopped;
  94814. /**
  94815. * The blending factor of the runtime animation
  94816. */
  94817. private _blendingFactor;
  94818. /**
  94819. * The BabylonJS scene
  94820. */
  94821. private _scene;
  94822. /**
  94823. * The current value of the runtime animation
  94824. */
  94825. private _currentValue;
  94826. /** @hidden */
  94827. _animationState: _IAnimationState;
  94828. /**
  94829. * The active target of the runtime animation
  94830. */
  94831. private _activeTargets;
  94832. private _currentActiveTarget;
  94833. private _directTarget;
  94834. /**
  94835. * The target path of the runtime animation
  94836. */
  94837. private _targetPath;
  94838. /**
  94839. * The weight of the runtime animation
  94840. */
  94841. private _weight;
  94842. /**
  94843. * The ratio offset of the runtime animation
  94844. */
  94845. private _ratioOffset;
  94846. /**
  94847. * The previous delay of the runtime animation
  94848. */
  94849. private _previousDelay;
  94850. /**
  94851. * The previous ratio of the runtime animation
  94852. */
  94853. private _previousRatio;
  94854. private _enableBlending;
  94855. private _keys;
  94856. private _minFrame;
  94857. private _maxFrame;
  94858. private _minValue;
  94859. private _maxValue;
  94860. private _targetIsArray;
  94861. /**
  94862. * Gets the current frame of the runtime animation
  94863. */
  94864. get currentFrame(): number;
  94865. /**
  94866. * Gets the weight of the runtime animation
  94867. */
  94868. get weight(): number;
  94869. /**
  94870. * Gets the current value of the runtime animation
  94871. */
  94872. get currentValue(): any;
  94873. /**
  94874. * Gets the target path of the runtime animation
  94875. */
  94876. get targetPath(): string;
  94877. /**
  94878. * Gets the actual target of the runtime animation
  94879. */
  94880. get target(): any;
  94881. /**
  94882. * Gets the additive state of the runtime animation
  94883. */
  94884. get isAdditive(): boolean;
  94885. /** @hidden */
  94886. _onLoop: () => void;
  94887. /**
  94888. * Create a new RuntimeAnimation object
  94889. * @param target defines the target of the animation
  94890. * @param animation defines the source animation object
  94891. * @param scene defines the hosting scene
  94892. * @param host defines the initiating Animatable
  94893. */
  94894. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  94895. private _preparePath;
  94896. /**
  94897. * Gets the animation from the runtime animation
  94898. */
  94899. get animation(): Animation;
  94900. /**
  94901. * Resets the runtime animation to the beginning
  94902. * @param restoreOriginal defines whether to restore the target property to the original value
  94903. */
  94904. reset(restoreOriginal?: boolean): void;
  94905. /**
  94906. * Specifies if the runtime animation is stopped
  94907. * @returns Boolean specifying if the runtime animation is stopped
  94908. */
  94909. isStopped(): boolean;
  94910. /**
  94911. * Disposes of the runtime animation
  94912. */
  94913. dispose(): void;
  94914. /**
  94915. * Apply the interpolated value to the target
  94916. * @param currentValue defines the value computed by the animation
  94917. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  94918. */
  94919. setValue(currentValue: any, weight: number): void;
  94920. private _getOriginalValues;
  94921. private _setValue;
  94922. /**
  94923. * Gets the loop pmode of the runtime animation
  94924. * @returns Loop Mode
  94925. */
  94926. private _getCorrectLoopMode;
  94927. /**
  94928. * Move the current animation to a given frame
  94929. * @param frame defines the frame to move to
  94930. */
  94931. goToFrame(frame: number): void;
  94932. /**
  94933. * @hidden Internal use only
  94934. */
  94935. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  94936. /**
  94937. * Execute the current animation
  94938. * @param delay defines the delay to add to the current frame
  94939. * @param from defines the lower bound of the animation range
  94940. * @param to defines the upper bound of the animation range
  94941. * @param loop defines if the current animation must loop
  94942. * @param speedRatio defines the current speed ratio
  94943. * @param weight defines the weight of the animation (default is -1 so no weight)
  94944. * @param onLoop optional callback called when animation loops
  94945. * @returns a boolean indicating if the animation is running
  94946. */
  94947. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  94948. }
  94949. }
  94950. declare module BABYLON {
  94951. /**
  94952. * Class used to store an actual running animation
  94953. */
  94954. export class Animatable {
  94955. /** defines the target object */
  94956. target: any;
  94957. /** defines the starting frame number (default is 0) */
  94958. fromFrame: number;
  94959. /** defines the ending frame number (default is 100) */
  94960. toFrame: number;
  94961. /** defines if the animation must loop (default is false) */
  94962. loopAnimation: boolean;
  94963. /** defines a callback to call when animation ends if it is not looping */
  94964. onAnimationEnd?: (() => void) | null | undefined;
  94965. /** defines a callback to call when animation loops */
  94966. onAnimationLoop?: (() => void) | null | undefined;
  94967. /** defines whether the animation should be evaluated additively */
  94968. isAdditive: boolean;
  94969. private _localDelayOffset;
  94970. private _pausedDelay;
  94971. private _runtimeAnimations;
  94972. private _paused;
  94973. private _scene;
  94974. private _speedRatio;
  94975. private _weight;
  94976. private _syncRoot;
  94977. /**
  94978. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  94979. * This will only apply for non looping animation (default is true)
  94980. */
  94981. disposeOnEnd: boolean;
  94982. /**
  94983. * Gets a boolean indicating if the animation has started
  94984. */
  94985. animationStarted: boolean;
  94986. /**
  94987. * Observer raised when the animation ends
  94988. */
  94989. onAnimationEndObservable: Observable<Animatable>;
  94990. /**
  94991. * Observer raised when the animation loops
  94992. */
  94993. onAnimationLoopObservable: Observable<Animatable>;
  94994. /**
  94995. * Gets the root Animatable used to synchronize and normalize animations
  94996. */
  94997. get syncRoot(): Nullable<Animatable>;
  94998. /**
  94999. * Gets the current frame of the first RuntimeAnimation
  95000. * Used to synchronize Animatables
  95001. */
  95002. get masterFrame(): number;
  95003. /**
  95004. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  95005. */
  95006. get weight(): number;
  95007. set weight(value: number);
  95008. /**
  95009. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  95010. */
  95011. get speedRatio(): number;
  95012. set speedRatio(value: number);
  95013. /**
  95014. * Creates a new Animatable
  95015. * @param scene defines the hosting scene
  95016. * @param target defines the target object
  95017. * @param fromFrame defines the starting frame number (default is 0)
  95018. * @param toFrame defines the ending frame number (default is 100)
  95019. * @param loopAnimation defines if the animation must loop (default is false)
  95020. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  95021. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  95022. * @param animations defines a group of animation to add to the new Animatable
  95023. * @param onAnimationLoop defines a callback to call when animation loops
  95024. * @param isAdditive defines whether the animation should be evaluated additively
  95025. */
  95026. constructor(scene: Scene,
  95027. /** defines the target object */
  95028. target: any,
  95029. /** defines the starting frame number (default is 0) */
  95030. fromFrame?: number,
  95031. /** defines the ending frame number (default is 100) */
  95032. toFrame?: number,
  95033. /** defines if the animation must loop (default is false) */
  95034. loopAnimation?: boolean, speedRatio?: number,
  95035. /** defines a callback to call when animation ends if it is not looping */
  95036. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  95037. /** defines a callback to call when animation loops */
  95038. onAnimationLoop?: (() => void) | null | undefined,
  95039. /** defines whether the animation should be evaluated additively */
  95040. isAdditive?: boolean);
  95041. /**
  95042. * Synchronize and normalize current Animatable with a source Animatable
  95043. * This is useful when using animation weights and when animations are not of the same length
  95044. * @param root defines the root Animatable to synchronize with
  95045. * @returns the current Animatable
  95046. */
  95047. syncWith(root: Animatable): Animatable;
  95048. /**
  95049. * Gets the list of runtime animations
  95050. * @returns an array of RuntimeAnimation
  95051. */
  95052. getAnimations(): RuntimeAnimation[];
  95053. /**
  95054. * Adds more animations to the current animatable
  95055. * @param target defines the target of the animations
  95056. * @param animations defines the new animations to add
  95057. */
  95058. appendAnimations(target: any, animations: Animation[]): void;
  95059. /**
  95060. * Gets the source animation for a specific property
  95061. * @param property defines the propertyu to look for
  95062. * @returns null or the source animation for the given property
  95063. */
  95064. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  95065. /**
  95066. * Gets the runtime animation for a specific property
  95067. * @param property defines the propertyu to look for
  95068. * @returns null or the runtime animation for the given property
  95069. */
  95070. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  95071. /**
  95072. * Resets the animatable to its original state
  95073. */
  95074. reset(): void;
  95075. /**
  95076. * Allows the animatable to blend with current running animations
  95077. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  95078. * @param blendingSpeed defines the blending speed to use
  95079. */
  95080. enableBlending(blendingSpeed: number): void;
  95081. /**
  95082. * Disable animation blending
  95083. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  95084. */
  95085. disableBlending(): void;
  95086. /**
  95087. * Jump directly to a given frame
  95088. * @param frame defines the frame to jump to
  95089. */
  95090. goToFrame(frame: number): void;
  95091. /**
  95092. * Pause the animation
  95093. */
  95094. pause(): void;
  95095. /**
  95096. * Restart the animation
  95097. */
  95098. restart(): void;
  95099. private _raiseOnAnimationEnd;
  95100. /**
  95101. * Stop and delete the current animation
  95102. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  95103. * @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)
  95104. */
  95105. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  95106. /**
  95107. * Wait asynchronously for the animation to end
  95108. * @returns a promise which will be fullfilled when the animation ends
  95109. */
  95110. waitAsync(): Promise<Animatable>;
  95111. /** @hidden */
  95112. _animate(delay: number): boolean;
  95113. }
  95114. interface Scene {
  95115. /** @hidden */
  95116. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  95117. /** @hidden */
  95118. _processLateAnimationBindingsForMatrices(holder: {
  95119. totalWeight: number;
  95120. totalAdditiveWeight: number;
  95121. animations: RuntimeAnimation[];
  95122. additiveAnimations: RuntimeAnimation[];
  95123. originalValue: Matrix;
  95124. }): any;
  95125. /** @hidden */
  95126. _processLateAnimationBindingsForQuaternions(holder: {
  95127. totalWeight: number;
  95128. totalAdditiveWeight: number;
  95129. animations: RuntimeAnimation[];
  95130. additiveAnimations: RuntimeAnimation[];
  95131. originalValue: Quaternion;
  95132. }, refQuaternion: Quaternion): Quaternion;
  95133. /** @hidden */
  95134. _processLateAnimationBindings(): void;
  95135. /**
  95136. * Will start the animation sequence of a given target
  95137. * @param target defines the target
  95138. * @param from defines from which frame should animation start
  95139. * @param to defines until which frame should animation run.
  95140. * @param weight defines the weight to apply to the animation (1.0 by default)
  95141. * @param loop defines if the animation loops
  95142. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  95143. * @param onAnimationEnd defines the function to be executed when the animation ends
  95144. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  95145. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  95146. * @param onAnimationLoop defines the callback to call when an animation loops
  95147. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  95148. * @returns the animatable object created for this animation
  95149. */
  95150. 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;
  95151. /**
  95152. * Will start the animation sequence of a given target
  95153. * @param target defines the target
  95154. * @param from defines from which frame should animation start
  95155. * @param to defines until which frame should animation run.
  95156. * @param loop defines if the animation loops
  95157. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  95158. * @param onAnimationEnd defines the function to be executed when the animation ends
  95159. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  95160. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  95161. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  95162. * @param onAnimationLoop defines the callback to call when an animation loops
  95163. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  95164. * @returns the animatable object created for this animation
  95165. */
  95166. 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;
  95167. /**
  95168. * Will start the animation sequence of a given target and its hierarchy
  95169. * @param target defines the target
  95170. * @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.
  95171. * @param from defines from which frame should animation start
  95172. * @param to defines until which frame should animation run.
  95173. * @param loop defines if the animation loops
  95174. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  95175. * @param onAnimationEnd defines the function to be executed when the animation ends
  95176. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  95177. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  95178. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  95179. * @param onAnimationLoop defines the callback to call when an animation loops
  95180. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  95181. * @returns the list of created animatables
  95182. */
  95183. 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[];
  95184. /**
  95185. * Begin a new animation on a given node
  95186. * @param target defines the target where the animation will take place
  95187. * @param animations defines the list of animations to start
  95188. * @param from defines the initial value
  95189. * @param to defines the final value
  95190. * @param loop defines if you want animation to loop (off by default)
  95191. * @param speedRatio defines the speed ratio to apply to all animations
  95192. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  95193. * @param onAnimationLoop defines the callback to call when an animation loops
  95194. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  95195. * @returns the list of created animatables
  95196. */
  95197. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  95198. /**
  95199. * Begin a new animation on a given node and its hierarchy
  95200. * @param target defines the root node where the animation will take place
  95201. * @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.
  95202. * @param animations defines the list of animations to start
  95203. * @param from defines the initial value
  95204. * @param to defines the final value
  95205. * @param loop defines if you want animation to loop (off by default)
  95206. * @param speedRatio defines the speed ratio to apply to all animations
  95207. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  95208. * @param onAnimationLoop defines the callback to call when an animation loops
  95209. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  95210. * @returns the list of animatables created for all nodes
  95211. */
  95212. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  95213. /**
  95214. * Gets the animatable associated with a specific target
  95215. * @param target defines the target of the animatable
  95216. * @returns the required animatable if found
  95217. */
  95218. getAnimatableByTarget(target: any): Nullable<Animatable>;
  95219. /**
  95220. * Gets all animatables associated with a given target
  95221. * @param target defines the target to look animatables for
  95222. * @returns an array of Animatables
  95223. */
  95224. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  95225. /**
  95226. * Stops and removes all animations that have been applied to the scene
  95227. */
  95228. stopAllAnimations(): void;
  95229. /**
  95230. * Gets the current delta time used by animation engine
  95231. */
  95232. deltaTime: number;
  95233. }
  95234. interface Bone {
  95235. /**
  95236. * Copy an animation range from another bone
  95237. * @param source defines the source bone
  95238. * @param rangeName defines the range name to copy
  95239. * @param frameOffset defines the frame offset
  95240. * @param rescaleAsRequired defines if rescaling must be applied if required
  95241. * @param skelDimensionsRatio defines the scaling ratio
  95242. * @returns true if operation was successful
  95243. */
  95244. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  95245. }
  95246. }
  95247. declare module BABYLON {
  95248. /**
  95249. * Class used to handle skinning animations
  95250. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  95251. */
  95252. export class Skeleton implements IAnimatable {
  95253. /** defines the skeleton name */
  95254. name: string;
  95255. /** defines the skeleton Id */
  95256. id: string;
  95257. /**
  95258. * Defines the list of child bones
  95259. */
  95260. bones: Bone[];
  95261. /**
  95262. * Defines an estimate of the dimension of the skeleton at rest
  95263. */
  95264. dimensionsAtRest: Vector3;
  95265. /**
  95266. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  95267. */
  95268. needInitialSkinMatrix: boolean;
  95269. /**
  95270. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  95271. */
  95272. overrideMesh: Nullable<AbstractMesh>;
  95273. /**
  95274. * Gets the list of animations attached to this skeleton
  95275. */
  95276. animations: Array<Animation>;
  95277. private _scene;
  95278. private _isDirty;
  95279. private _transformMatrices;
  95280. private _transformMatrixTexture;
  95281. private _meshesWithPoseMatrix;
  95282. private _animatables;
  95283. private _identity;
  95284. private _synchronizedWithMesh;
  95285. private _ranges;
  95286. private _lastAbsoluteTransformsUpdateId;
  95287. private _canUseTextureForBones;
  95288. private _uniqueId;
  95289. /** @hidden */
  95290. _numBonesWithLinkedTransformNode: number;
  95291. /** @hidden */
  95292. _hasWaitingData: Nullable<boolean>;
  95293. /**
  95294. * Specifies if the skeleton should be serialized
  95295. */
  95296. doNotSerialize: boolean;
  95297. private _useTextureToStoreBoneMatrices;
  95298. /**
  95299. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  95300. * Please note that this option is not available if the hardware does not support it
  95301. */
  95302. get useTextureToStoreBoneMatrices(): boolean;
  95303. set useTextureToStoreBoneMatrices(value: boolean);
  95304. private _animationPropertiesOverride;
  95305. /**
  95306. * Gets or sets the animation properties override
  95307. */
  95308. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  95309. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  95310. /**
  95311. * List of inspectable custom properties (used by the Inspector)
  95312. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  95313. */
  95314. inspectableCustomProperties: IInspectable[];
  95315. /**
  95316. * An observable triggered before computing the skeleton's matrices
  95317. */
  95318. onBeforeComputeObservable: Observable<Skeleton>;
  95319. /**
  95320. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  95321. */
  95322. get isUsingTextureForMatrices(): boolean;
  95323. /**
  95324. * Gets the unique ID of this skeleton
  95325. */
  95326. get uniqueId(): number;
  95327. /**
  95328. * Creates a new skeleton
  95329. * @param name defines the skeleton name
  95330. * @param id defines the skeleton Id
  95331. * @param scene defines the hosting scene
  95332. */
  95333. constructor(
  95334. /** defines the skeleton name */
  95335. name: string,
  95336. /** defines the skeleton Id */
  95337. id: string, scene: Scene);
  95338. /**
  95339. * Gets the current object class name.
  95340. * @return the class name
  95341. */
  95342. getClassName(): string;
  95343. /**
  95344. * Returns an array containing the root bones
  95345. * @returns an array containing the root bones
  95346. */
  95347. getChildren(): Array<Bone>;
  95348. /**
  95349. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  95350. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  95351. * @returns a Float32Array containing matrices data
  95352. */
  95353. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  95354. /**
  95355. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  95356. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  95357. * @returns a raw texture containing the data
  95358. */
  95359. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  95360. /**
  95361. * Gets the current hosting scene
  95362. * @returns a scene object
  95363. */
  95364. getScene(): Scene;
  95365. /**
  95366. * Gets a string representing the current skeleton data
  95367. * @param fullDetails defines a boolean indicating if we want a verbose version
  95368. * @returns a string representing the current skeleton data
  95369. */
  95370. toString(fullDetails?: boolean): string;
  95371. /**
  95372. * Get bone's index searching by name
  95373. * @param name defines bone's name to search for
  95374. * @return the indice of the bone. Returns -1 if not found
  95375. */
  95376. getBoneIndexByName(name: string): number;
  95377. /**
  95378. * Creater a new animation range
  95379. * @param name defines the name of the range
  95380. * @param from defines the start key
  95381. * @param to defines the end key
  95382. */
  95383. createAnimationRange(name: string, from: number, to: number): void;
  95384. /**
  95385. * Delete a specific animation range
  95386. * @param name defines the name of the range
  95387. * @param deleteFrames defines if frames must be removed as well
  95388. */
  95389. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  95390. /**
  95391. * Gets a specific animation range
  95392. * @param name defines the name of the range to look for
  95393. * @returns the requested animation range or null if not found
  95394. */
  95395. getAnimationRange(name: string): Nullable<AnimationRange>;
  95396. /**
  95397. * Gets the list of all animation ranges defined on this skeleton
  95398. * @returns an array
  95399. */
  95400. getAnimationRanges(): Nullable<AnimationRange>[];
  95401. /**
  95402. * Copy animation range from a source skeleton.
  95403. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  95404. * @param source defines the source skeleton
  95405. * @param name defines the name of the range to copy
  95406. * @param rescaleAsRequired defines if rescaling must be applied if required
  95407. * @returns true if operation was successful
  95408. */
  95409. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  95410. /**
  95411. * Forces the skeleton to go to rest pose
  95412. */
  95413. returnToRest(): void;
  95414. private _getHighestAnimationFrame;
  95415. /**
  95416. * Begin a specific animation range
  95417. * @param name defines the name of the range to start
  95418. * @param loop defines if looping must be turned on (false by default)
  95419. * @param speedRatio defines the speed ratio to apply (1 by default)
  95420. * @param onAnimationEnd defines a callback which will be called when animation will end
  95421. * @returns a new animatable
  95422. */
  95423. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  95424. /**
  95425. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  95426. * @param skeleton defines the Skeleton containing the animation range to convert
  95427. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  95428. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  95429. * @returns the original skeleton
  95430. */
  95431. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  95432. /** @hidden */
  95433. _markAsDirty(): void;
  95434. /** @hidden */
  95435. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  95436. /** @hidden */
  95437. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  95438. private _computeTransformMatrices;
  95439. /**
  95440. * Build all resources required to render a skeleton
  95441. */
  95442. prepare(): void;
  95443. /**
  95444. * Gets the list of animatables currently running for this skeleton
  95445. * @returns an array of animatables
  95446. */
  95447. getAnimatables(): IAnimatable[];
  95448. /**
  95449. * Clone the current skeleton
  95450. * @param name defines the name of the new skeleton
  95451. * @param id defines the id of the new skeleton
  95452. * @returns the new skeleton
  95453. */
  95454. clone(name: string, id?: string): Skeleton;
  95455. /**
  95456. * Enable animation blending for this skeleton
  95457. * @param blendingSpeed defines the blending speed to apply
  95458. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  95459. */
  95460. enableBlending(blendingSpeed?: number): void;
  95461. /**
  95462. * Releases all resources associated with the current skeleton
  95463. */
  95464. dispose(): void;
  95465. /**
  95466. * Serialize the skeleton in a JSON object
  95467. * @returns a JSON object
  95468. */
  95469. serialize(): any;
  95470. /**
  95471. * Creates a new skeleton from serialized data
  95472. * @param parsedSkeleton defines the serialized data
  95473. * @param scene defines the hosting scene
  95474. * @returns a new skeleton
  95475. */
  95476. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  95477. /**
  95478. * Compute all node absolute transforms
  95479. * @param forceUpdate defines if computation must be done even if cache is up to date
  95480. */
  95481. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  95482. /**
  95483. * Gets the root pose matrix
  95484. * @returns a matrix
  95485. */
  95486. getPoseMatrix(): Nullable<Matrix>;
  95487. /**
  95488. * Sorts bones per internal index
  95489. */
  95490. sortBones(): void;
  95491. private _sortBones;
  95492. }
  95493. }
  95494. declare module BABYLON {
  95495. /**
  95496. * Creates an instance based on a source mesh.
  95497. */
  95498. export class InstancedMesh extends AbstractMesh {
  95499. private _sourceMesh;
  95500. private _currentLOD;
  95501. /** @hidden */
  95502. _indexInSourceMeshInstanceArray: number;
  95503. constructor(name: string, source: Mesh);
  95504. /**
  95505. * Returns the string "InstancedMesh".
  95506. */
  95507. getClassName(): string;
  95508. /** Gets the list of lights affecting that mesh */
  95509. get lightSources(): Light[];
  95510. _resyncLightSources(): void;
  95511. _resyncLightSource(light: Light): void;
  95512. _removeLightSource(light: Light, dispose: boolean): void;
  95513. /**
  95514. * If the source mesh receives shadows
  95515. */
  95516. get receiveShadows(): boolean;
  95517. /**
  95518. * The material of the source mesh
  95519. */
  95520. get material(): Nullable<Material>;
  95521. /**
  95522. * Visibility of the source mesh
  95523. */
  95524. get visibility(): number;
  95525. /**
  95526. * Skeleton of the source mesh
  95527. */
  95528. get skeleton(): Nullable<Skeleton>;
  95529. /**
  95530. * Rendering ground id of the source mesh
  95531. */
  95532. get renderingGroupId(): number;
  95533. set renderingGroupId(value: number);
  95534. /**
  95535. * Returns the total number of vertices (integer).
  95536. */
  95537. getTotalVertices(): number;
  95538. /**
  95539. * Returns a positive integer : the total number of indices in this mesh geometry.
  95540. * @returns the numner of indices or zero if the mesh has no geometry.
  95541. */
  95542. getTotalIndices(): number;
  95543. /**
  95544. * The source mesh of the instance
  95545. */
  95546. get sourceMesh(): Mesh;
  95547. /**
  95548. * Creates a new InstancedMesh object from the mesh model.
  95549. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  95550. * @param name defines the name of the new instance
  95551. * @returns a new InstancedMesh
  95552. */
  95553. createInstance(name: string): InstancedMesh;
  95554. /**
  95555. * Is this node ready to be used/rendered
  95556. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  95557. * @return {boolean} is it ready
  95558. */
  95559. isReady(completeCheck?: boolean): boolean;
  95560. /**
  95561. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  95562. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  95563. * @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.
  95564. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  95565. */
  95566. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  95567. /**
  95568. * Sets the vertex data of the mesh geometry for the requested `kind`.
  95569. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  95570. * The `data` are either a numeric array either a Float32Array.
  95571. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  95572. * 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).
  95573. * Note that a new underlying VertexBuffer object is created each call.
  95574. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  95575. *
  95576. * Possible `kind` values :
  95577. * - VertexBuffer.PositionKind
  95578. * - VertexBuffer.UVKind
  95579. * - VertexBuffer.UV2Kind
  95580. * - VertexBuffer.UV3Kind
  95581. * - VertexBuffer.UV4Kind
  95582. * - VertexBuffer.UV5Kind
  95583. * - VertexBuffer.UV6Kind
  95584. * - VertexBuffer.ColorKind
  95585. * - VertexBuffer.MatricesIndicesKind
  95586. * - VertexBuffer.MatricesIndicesExtraKind
  95587. * - VertexBuffer.MatricesWeightsKind
  95588. * - VertexBuffer.MatricesWeightsExtraKind
  95589. *
  95590. * Returns the Mesh.
  95591. */
  95592. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  95593. /**
  95594. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  95595. * If the mesh has no geometry, it is simply returned as it is.
  95596. * The `data` are either a numeric array either a Float32Array.
  95597. * No new underlying VertexBuffer object is created.
  95598. * 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.
  95599. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  95600. *
  95601. * Possible `kind` values :
  95602. * - VertexBuffer.PositionKind
  95603. * - VertexBuffer.UVKind
  95604. * - VertexBuffer.UV2Kind
  95605. * - VertexBuffer.UV3Kind
  95606. * - VertexBuffer.UV4Kind
  95607. * - VertexBuffer.UV5Kind
  95608. * - VertexBuffer.UV6Kind
  95609. * - VertexBuffer.ColorKind
  95610. * - VertexBuffer.MatricesIndicesKind
  95611. * - VertexBuffer.MatricesIndicesExtraKind
  95612. * - VertexBuffer.MatricesWeightsKind
  95613. * - VertexBuffer.MatricesWeightsExtraKind
  95614. *
  95615. * Returns the Mesh.
  95616. */
  95617. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  95618. /**
  95619. * Sets the mesh indices.
  95620. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  95621. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  95622. * This method creates a new index buffer each call.
  95623. * Returns the Mesh.
  95624. */
  95625. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  95626. /**
  95627. * Boolean : True if the mesh owns the requested kind of data.
  95628. */
  95629. isVerticesDataPresent(kind: string): boolean;
  95630. /**
  95631. * Returns an array of indices (IndicesArray).
  95632. */
  95633. getIndices(): Nullable<IndicesArray>;
  95634. get _positions(): Nullable<Vector3[]>;
  95635. /**
  95636. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  95637. * This means the mesh underlying bounding box and sphere are recomputed.
  95638. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  95639. * @returns the current mesh
  95640. */
  95641. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  95642. /** @hidden */
  95643. _preActivate(): InstancedMesh;
  95644. /** @hidden */
  95645. _activate(renderId: number, intermediateRendering: boolean): boolean;
  95646. /** @hidden */
  95647. _postActivate(): void;
  95648. getWorldMatrix(): Matrix;
  95649. get isAnInstance(): boolean;
  95650. /**
  95651. * Returns the current associated LOD AbstractMesh.
  95652. */
  95653. getLOD(camera: Camera): AbstractMesh;
  95654. /** @hidden */
  95655. _preActivateForIntermediateRendering(renderId: number): Mesh;
  95656. /** @hidden */
  95657. _syncSubMeshes(): InstancedMesh;
  95658. /** @hidden */
  95659. _generatePointsArray(): boolean;
  95660. /** @hidden */
  95661. _updateBoundingInfo(): AbstractMesh;
  95662. /**
  95663. * Creates a new InstancedMesh from the current mesh.
  95664. * - name (string) : the cloned mesh name
  95665. * - newParent (optional Node) : the optional Node to parent the clone to.
  95666. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  95667. *
  95668. * Returns the clone.
  95669. */
  95670. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  95671. /**
  95672. * Disposes the InstancedMesh.
  95673. * Returns nothing.
  95674. */
  95675. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  95676. }
  95677. interface Mesh {
  95678. /**
  95679. * Register a custom buffer that will be instanced
  95680. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  95681. * @param kind defines the buffer kind
  95682. * @param stride defines the stride in floats
  95683. */
  95684. registerInstancedBuffer(kind: string, stride: number): void;
  95685. /**
  95686. * true to use the edge renderer for all instances of this mesh
  95687. */
  95688. edgesShareWithInstances: boolean;
  95689. /** @hidden */
  95690. _userInstancedBuffersStorage: {
  95691. data: {
  95692. [key: string]: Float32Array;
  95693. };
  95694. sizes: {
  95695. [key: string]: number;
  95696. };
  95697. vertexBuffers: {
  95698. [key: string]: Nullable<VertexBuffer>;
  95699. };
  95700. strides: {
  95701. [key: string]: number;
  95702. };
  95703. };
  95704. }
  95705. interface AbstractMesh {
  95706. /**
  95707. * Object used to store instanced buffers defined by user
  95708. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  95709. */
  95710. instancedBuffers: {
  95711. [key: string]: any;
  95712. };
  95713. }
  95714. }
  95715. declare module BABYLON {
  95716. /**
  95717. * Defines the options associated with the creation of a shader material.
  95718. */
  95719. export interface IShaderMaterialOptions {
  95720. /**
  95721. * Does the material work in alpha blend mode
  95722. */
  95723. needAlphaBlending: boolean;
  95724. /**
  95725. * Does the material work in alpha test mode
  95726. */
  95727. needAlphaTesting: boolean;
  95728. /**
  95729. * The list of attribute names used in the shader
  95730. */
  95731. attributes: string[];
  95732. /**
  95733. * The list of unifrom names used in the shader
  95734. */
  95735. uniforms: string[];
  95736. /**
  95737. * The list of UBO names used in the shader
  95738. */
  95739. uniformBuffers: string[];
  95740. /**
  95741. * The list of sampler names used in the shader
  95742. */
  95743. samplers: string[];
  95744. /**
  95745. * The list of defines used in the shader
  95746. */
  95747. defines: string[];
  95748. }
  95749. /**
  95750. * 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.
  95751. *
  95752. * This returned material effects how the mesh will look based on the code in the shaders.
  95753. *
  95754. * @see https://doc.babylonjs.com/how_to/shader_material
  95755. */
  95756. export class ShaderMaterial extends Material {
  95757. private _shaderPath;
  95758. private _options;
  95759. private _textures;
  95760. private _textureArrays;
  95761. private _floats;
  95762. private _ints;
  95763. private _floatsArrays;
  95764. private _colors3;
  95765. private _colors3Arrays;
  95766. private _colors4;
  95767. private _colors4Arrays;
  95768. private _vectors2;
  95769. private _vectors3;
  95770. private _vectors4;
  95771. private _matrices;
  95772. private _matrixArrays;
  95773. private _matrices3x3;
  95774. private _matrices2x2;
  95775. private _vectors2Arrays;
  95776. private _vectors3Arrays;
  95777. private _vectors4Arrays;
  95778. private _cachedWorldViewMatrix;
  95779. private _cachedWorldViewProjectionMatrix;
  95780. private _renderId;
  95781. private _multiview;
  95782. private _cachedDefines;
  95783. /** Define the Url to load snippets */
  95784. static SnippetUrl: string;
  95785. /** Snippet ID if the material was created from the snippet server */
  95786. snippetId: string;
  95787. /**
  95788. * Instantiate a new shader material.
  95789. * 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.
  95790. * This returned material effects how the mesh will look based on the code in the shaders.
  95791. * @see https://doc.babylonjs.com/how_to/shader_material
  95792. * @param name Define the name of the material in the scene
  95793. * @param scene Define the scene the material belongs to
  95794. * @param shaderPath Defines the route to the shader code in one of three ways:
  95795. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  95796. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  95797. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  95798. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  95799. * @param options Define the options used to create the shader
  95800. */
  95801. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  95802. /**
  95803. * Gets the shader path used to define the shader code
  95804. * It can be modified to trigger a new compilation
  95805. */
  95806. get shaderPath(): any;
  95807. /**
  95808. * Sets the shader path used to define the shader code
  95809. * It can be modified to trigger a new compilation
  95810. */
  95811. set shaderPath(shaderPath: any);
  95812. /**
  95813. * Gets the options used to compile the shader.
  95814. * They can be modified to trigger a new compilation
  95815. */
  95816. get options(): IShaderMaterialOptions;
  95817. /**
  95818. * Gets the current class name of the material e.g. "ShaderMaterial"
  95819. * Mainly use in serialization.
  95820. * @returns the class name
  95821. */
  95822. getClassName(): string;
  95823. /**
  95824. * Specifies if the material will require alpha blending
  95825. * @returns a boolean specifying if alpha blending is needed
  95826. */
  95827. needAlphaBlending(): boolean;
  95828. /**
  95829. * Specifies if this material should be rendered in alpha test mode
  95830. * @returns a boolean specifying if an alpha test is needed.
  95831. */
  95832. needAlphaTesting(): boolean;
  95833. private _checkUniform;
  95834. /**
  95835. * Set a texture in the shader.
  95836. * @param name Define the name of the uniform samplers as defined in the shader
  95837. * @param texture Define the texture to bind to this sampler
  95838. * @return the material itself allowing "fluent" like uniform updates
  95839. */
  95840. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  95841. /**
  95842. * Set a texture array in the shader.
  95843. * @param name Define the name of the uniform sampler array as defined in the shader
  95844. * @param textures Define the list of textures to bind to this sampler
  95845. * @return the material itself allowing "fluent" like uniform updates
  95846. */
  95847. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  95848. /**
  95849. * Set a float in the shader.
  95850. * @param name Define the name of the uniform as defined in the shader
  95851. * @param value Define the value to give to the uniform
  95852. * @return the material itself allowing "fluent" like uniform updates
  95853. */
  95854. setFloat(name: string, value: number): ShaderMaterial;
  95855. /**
  95856. * Set a int in the shader.
  95857. * @param name Define the name of the uniform as defined in the shader
  95858. * @param value Define the value to give to the uniform
  95859. * @return the material itself allowing "fluent" like uniform updates
  95860. */
  95861. setInt(name: string, value: number): ShaderMaterial;
  95862. /**
  95863. * Set an array of floats in the shader.
  95864. * @param name Define the name of the uniform as defined in the shader
  95865. * @param value Define the value to give to the uniform
  95866. * @return the material itself allowing "fluent" like uniform updates
  95867. */
  95868. setFloats(name: string, value: number[]): ShaderMaterial;
  95869. /**
  95870. * Set a vec3 in the shader from a Color3.
  95871. * @param name Define the name of the uniform as defined in the shader
  95872. * @param value Define the value to give to the uniform
  95873. * @return the material itself allowing "fluent" like uniform updates
  95874. */
  95875. setColor3(name: string, value: Color3): ShaderMaterial;
  95876. /**
  95877. * Set a vec3 array in the shader from a Color3 array.
  95878. * @param name Define the name of the uniform as defined in the shader
  95879. * @param value Define the value to give to the uniform
  95880. * @return the material itself allowing "fluent" like uniform updates
  95881. */
  95882. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  95883. /**
  95884. * Set a vec4 in the shader from a Color4.
  95885. * @param name Define the name of the uniform as defined in the shader
  95886. * @param value Define the value to give to the uniform
  95887. * @return the material itself allowing "fluent" like uniform updates
  95888. */
  95889. setColor4(name: string, value: Color4): ShaderMaterial;
  95890. /**
  95891. * Set a vec4 array in the shader from a Color4 array.
  95892. * @param name Define the name of the uniform as defined in the shader
  95893. * @param value Define the value to give to the uniform
  95894. * @return the material itself allowing "fluent" like uniform updates
  95895. */
  95896. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  95897. /**
  95898. * Set a vec2 in the shader from a Vector2.
  95899. * @param name Define the name of the uniform as defined in the shader
  95900. * @param value Define the value to give to the uniform
  95901. * @return the material itself allowing "fluent" like uniform updates
  95902. */
  95903. setVector2(name: string, value: Vector2): ShaderMaterial;
  95904. /**
  95905. * Set a vec3 in the shader from a Vector3.
  95906. * @param name Define the name of the uniform as defined in the shader
  95907. * @param value Define the value to give to the uniform
  95908. * @return the material itself allowing "fluent" like uniform updates
  95909. */
  95910. setVector3(name: string, value: Vector3): ShaderMaterial;
  95911. /**
  95912. * Set a vec4 in the shader from a Vector4.
  95913. * @param name Define the name of the uniform as defined in the shader
  95914. * @param value Define the value to give to the uniform
  95915. * @return the material itself allowing "fluent" like uniform updates
  95916. */
  95917. setVector4(name: string, value: Vector4): ShaderMaterial;
  95918. /**
  95919. * Set a mat4 in the shader from a Matrix.
  95920. * @param name Define the name of the uniform as defined in the shader
  95921. * @param value Define the value to give to the uniform
  95922. * @return the material itself allowing "fluent" like uniform updates
  95923. */
  95924. setMatrix(name: string, value: Matrix): ShaderMaterial;
  95925. /**
  95926. * Set a float32Array in the shader from a matrix array.
  95927. * @param name Define the name of the uniform as defined in the shader
  95928. * @param value Define the value to give to the uniform
  95929. * @return the material itself allowing "fluent" like uniform updates
  95930. */
  95931. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  95932. /**
  95933. * Set a mat3 in the shader from a Float32Array.
  95934. * @param name Define the name of the uniform as defined in the shader
  95935. * @param value Define the value to give to the uniform
  95936. * @return the material itself allowing "fluent" like uniform updates
  95937. */
  95938. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  95939. /**
  95940. * Set a mat2 in the shader from a Float32Array.
  95941. * @param name Define the name of the uniform as defined in the shader
  95942. * @param value Define the value to give to the uniform
  95943. * @return the material itself allowing "fluent" like uniform updates
  95944. */
  95945. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  95946. /**
  95947. * Set a vec2 array in the shader from a number array.
  95948. * @param name Define the name of the uniform as defined in the shader
  95949. * @param value Define the value to give to the uniform
  95950. * @return the material itself allowing "fluent" like uniform updates
  95951. */
  95952. setArray2(name: string, value: number[]): ShaderMaterial;
  95953. /**
  95954. * Set a vec3 array in the shader from a number array.
  95955. * @param name Define the name of the uniform as defined in the shader
  95956. * @param value Define the value to give to the uniform
  95957. * @return the material itself allowing "fluent" like uniform updates
  95958. */
  95959. setArray3(name: string, value: number[]): ShaderMaterial;
  95960. /**
  95961. * Set a vec4 array in the shader from a number array.
  95962. * @param name Define the name of the uniform as defined in the shader
  95963. * @param value Define the value to give to the uniform
  95964. * @return the material itself allowing "fluent" like uniform updates
  95965. */
  95966. setArray4(name: string, value: number[]): ShaderMaterial;
  95967. private _checkCache;
  95968. /**
  95969. * Specifies that the submesh is ready to be used
  95970. * @param mesh defines the mesh to check
  95971. * @param subMesh defines which submesh to check
  95972. * @param useInstances specifies that instances should be used
  95973. * @returns a boolean indicating that the submesh is ready or not
  95974. */
  95975. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  95976. /**
  95977. * Checks if the material is ready to render the requested mesh
  95978. * @param mesh Define the mesh to render
  95979. * @param useInstances Define whether or not the material is used with instances
  95980. * @returns true if ready, otherwise false
  95981. */
  95982. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  95983. /**
  95984. * Binds the world matrix to the material
  95985. * @param world defines the world transformation matrix
  95986. * @param effectOverride - If provided, use this effect instead of internal effect
  95987. */
  95988. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  95989. /**
  95990. * Binds the submesh to this material by preparing the effect and shader to draw
  95991. * @param world defines the world transformation matrix
  95992. * @param mesh defines the mesh containing the submesh
  95993. * @param subMesh defines the submesh to bind the material to
  95994. */
  95995. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  95996. /**
  95997. * Binds the material to the mesh
  95998. * @param world defines the world transformation matrix
  95999. * @param mesh defines the mesh to bind the material to
  96000. * @param effectOverride - If provided, use this effect instead of internal effect
  96001. */
  96002. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  96003. protected _afterBind(mesh?: Mesh): void;
  96004. /**
  96005. * Gets the active textures from the material
  96006. * @returns an array of textures
  96007. */
  96008. getActiveTextures(): BaseTexture[];
  96009. /**
  96010. * Specifies if the material uses a texture
  96011. * @param texture defines the texture to check against the material
  96012. * @returns a boolean specifying if the material uses the texture
  96013. */
  96014. hasTexture(texture: BaseTexture): boolean;
  96015. /**
  96016. * Makes a duplicate of the material, and gives it a new name
  96017. * @param name defines the new name for the duplicated material
  96018. * @returns the cloned material
  96019. */
  96020. clone(name: string): ShaderMaterial;
  96021. /**
  96022. * Disposes the material
  96023. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  96024. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  96025. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  96026. */
  96027. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  96028. /**
  96029. * Serializes this material in a JSON representation
  96030. * @returns the serialized material object
  96031. */
  96032. serialize(): any;
  96033. /**
  96034. * Creates a shader material from parsed shader material data
  96035. * @param source defines the JSON represnetation of the material
  96036. * @param scene defines the hosting scene
  96037. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  96038. * @returns a new material
  96039. */
  96040. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  96041. /**
  96042. * Creates a new ShaderMaterial from a snippet saved in a remote file
  96043. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  96044. * @param url defines the url to load from
  96045. * @param scene defines the hosting scene
  96046. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  96047. * @returns a promise that will resolve to the new ShaderMaterial
  96048. */
  96049. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  96050. /**
  96051. * Creates a ShaderMaterial from a snippet saved by the Inspector
  96052. * @param snippetId defines the snippet to load
  96053. * @param scene defines the hosting scene
  96054. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  96055. * @returns a promise that will resolve to the new ShaderMaterial
  96056. */
  96057. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  96058. }
  96059. }
  96060. declare module BABYLON {
  96061. /** @hidden */
  96062. export var colorPixelShader: {
  96063. name: string;
  96064. shader: string;
  96065. };
  96066. }
  96067. declare module BABYLON {
  96068. /** @hidden */
  96069. export var colorVertexShader: {
  96070. name: string;
  96071. shader: string;
  96072. };
  96073. }
  96074. declare module BABYLON {
  96075. /**
  96076. * Line mesh
  96077. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  96078. */
  96079. export class LinesMesh extends Mesh {
  96080. /**
  96081. * If vertex color should be applied to the mesh
  96082. */
  96083. readonly useVertexColor?: boolean | undefined;
  96084. /**
  96085. * If vertex alpha should be applied to the mesh
  96086. */
  96087. readonly useVertexAlpha?: boolean | undefined;
  96088. /**
  96089. * Color of the line (Default: White)
  96090. */
  96091. color: Color3;
  96092. /**
  96093. * Alpha of the line (Default: 1)
  96094. */
  96095. alpha: number;
  96096. /**
  96097. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  96098. * This margin is expressed in world space coordinates, so its value may vary.
  96099. * Default value is 0.1
  96100. */
  96101. intersectionThreshold: number;
  96102. private _colorShader;
  96103. private color4;
  96104. /**
  96105. * Creates a new LinesMesh
  96106. * @param name defines the name
  96107. * @param scene defines the hosting scene
  96108. * @param parent defines the parent mesh if any
  96109. * @param source defines the optional source LinesMesh used to clone data from
  96110. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  96111. * When false, achieved by calling a clone(), also passing False.
  96112. * This will make creation of children, recursive.
  96113. * @param useVertexColor defines if this LinesMesh supports vertex color
  96114. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  96115. */
  96116. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  96117. /**
  96118. * If vertex color should be applied to the mesh
  96119. */
  96120. useVertexColor?: boolean | undefined,
  96121. /**
  96122. * If vertex alpha should be applied to the mesh
  96123. */
  96124. useVertexAlpha?: boolean | undefined);
  96125. private _addClipPlaneDefine;
  96126. private _removeClipPlaneDefine;
  96127. isReady(): boolean;
  96128. /**
  96129. * Returns the string "LineMesh"
  96130. */
  96131. getClassName(): string;
  96132. /**
  96133. * @hidden
  96134. */
  96135. get material(): Material;
  96136. /**
  96137. * @hidden
  96138. */
  96139. set material(value: Material);
  96140. /**
  96141. * @hidden
  96142. */
  96143. get checkCollisions(): boolean;
  96144. /** @hidden */
  96145. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  96146. /** @hidden */
  96147. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  96148. /**
  96149. * Disposes of the line mesh
  96150. * @param doNotRecurse If children should be disposed
  96151. */
  96152. dispose(doNotRecurse?: boolean): void;
  96153. /**
  96154. * Returns a new LineMesh object cloned from the current one.
  96155. */
  96156. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  96157. /**
  96158. * Creates a new InstancedLinesMesh object from the mesh model.
  96159. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  96160. * @param name defines the name of the new instance
  96161. * @returns a new InstancedLinesMesh
  96162. */
  96163. createInstance(name: string): InstancedLinesMesh;
  96164. }
  96165. /**
  96166. * Creates an instance based on a source LinesMesh
  96167. */
  96168. export class InstancedLinesMesh extends InstancedMesh {
  96169. /**
  96170. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  96171. * This margin is expressed in world space coordinates, so its value may vary.
  96172. * Initilized with the intersectionThreshold value of the source LinesMesh
  96173. */
  96174. intersectionThreshold: number;
  96175. constructor(name: string, source: LinesMesh);
  96176. /**
  96177. * Returns the string "InstancedLinesMesh".
  96178. */
  96179. getClassName(): string;
  96180. }
  96181. }
  96182. declare module BABYLON {
  96183. /** @hidden */
  96184. export var linePixelShader: {
  96185. name: string;
  96186. shader: string;
  96187. };
  96188. }
  96189. declare module BABYLON {
  96190. /** @hidden */
  96191. export var lineVertexShader: {
  96192. name: string;
  96193. shader: string;
  96194. };
  96195. }
  96196. declare module BABYLON {
  96197. interface Scene {
  96198. /** @hidden */
  96199. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  96200. }
  96201. interface AbstractMesh {
  96202. /**
  96203. * Gets the edgesRenderer associated with the mesh
  96204. */
  96205. edgesRenderer: Nullable<EdgesRenderer>;
  96206. }
  96207. interface LinesMesh {
  96208. /**
  96209. * Enables the edge rendering mode on the mesh.
  96210. * This mode makes the mesh edges visible
  96211. * @param epsilon defines the maximal distance between two angles to detect a face
  96212. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  96213. * @returns the currentAbstractMesh
  96214. * @see https://www.babylonjs-playground.com/#19O9TU#0
  96215. */
  96216. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  96217. }
  96218. interface InstancedLinesMesh {
  96219. /**
  96220. * Enables the edge rendering mode on the mesh.
  96221. * This mode makes the mesh edges visible
  96222. * @param epsilon defines the maximal distance between two angles to detect a face
  96223. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  96224. * @returns the current InstancedLinesMesh
  96225. * @see https://www.babylonjs-playground.com/#19O9TU#0
  96226. */
  96227. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  96228. }
  96229. /**
  96230. * Defines the minimum contract an Edges renderer should follow.
  96231. */
  96232. export interface IEdgesRenderer extends IDisposable {
  96233. /**
  96234. * Gets or sets a boolean indicating if the edgesRenderer is active
  96235. */
  96236. isEnabled: boolean;
  96237. /**
  96238. * Renders the edges of the attached mesh,
  96239. */
  96240. render(): void;
  96241. /**
  96242. * Checks wether or not the edges renderer is ready to render.
  96243. * @return true if ready, otherwise false.
  96244. */
  96245. isReady(): boolean;
  96246. /**
  96247. * List of instances to render in case the source mesh has instances
  96248. */
  96249. customInstances: SmartArray<Matrix>;
  96250. }
  96251. /**
  96252. * Defines the additional options of the edges renderer
  96253. */
  96254. export interface IEdgesRendererOptions {
  96255. /**
  96256. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  96257. * If not defined, the default value is true
  96258. */
  96259. useAlternateEdgeFinder?: boolean;
  96260. /**
  96261. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  96262. * If not defined, the default value is true.
  96263. * 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)
  96264. * This option is used only if useAlternateEdgeFinder = true
  96265. */
  96266. useFastVertexMerger?: boolean;
  96267. /**
  96268. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  96269. * The default value is 1e-6
  96270. * This option is used only if useAlternateEdgeFinder = true
  96271. */
  96272. epsilonVertexMerge?: number;
  96273. /**
  96274. * 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
  96275. * 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.
  96276. * This option is used only if useAlternateEdgeFinder = true
  96277. */
  96278. applyTessellation?: boolean;
  96279. /**
  96280. * 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
  96281. * The default value is 1e-6
  96282. * This option is used only if useAlternateEdgeFinder = true
  96283. */
  96284. epsilonVertexAligned?: number;
  96285. }
  96286. /**
  96287. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  96288. */
  96289. export class EdgesRenderer implements IEdgesRenderer {
  96290. /**
  96291. * Define the size of the edges with an orthographic camera
  96292. */
  96293. edgesWidthScalerForOrthographic: number;
  96294. /**
  96295. * Define the size of the edges with a perspective camera
  96296. */
  96297. edgesWidthScalerForPerspective: number;
  96298. protected _source: AbstractMesh;
  96299. protected _linesPositions: number[];
  96300. protected _linesNormals: number[];
  96301. protected _linesIndices: number[];
  96302. protected _epsilon: number;
  96303. protected _indicesCount: number;
  96304. protected _lineShader: ShaderMaterial;
  96305. protected _ib: DataBuffer;
  96306. protected _buffers: {
  96307. [key: string]: Nullable<VertexBuffer>;
  96308. };
  96309. protected _buffersForInstances: {
  96310. [key: string]: Nullable<VertexBuffer>;
  96311. };
  96312. protected _checkVerticesInsteadOfIndices: boolean;
  96313. protected _options: Nullable<IEdgesRendererOptions>;
  96314. private _meshRebuildObserver;
  96315. private _meshDisposeObserver;
  96316. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  96317. isEnabled: boolean;
  96318. /**
  96319. * List of instances to render in case the source mesh has instances
  96320. */
  96321. customInstances: SmartArray<Matrix>;
  96322. private static GetShader;
  96323. /**
  96324. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  96325. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  96326. * @param source Mesh used to create edges
  96327. * @param epsilon sum of angles in adjacency to check for edge
  96328. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  96329. * @param generateEdgesLines - should generate Lines or only prepare resources.
  96330. * @param options The options to apply when generating the edges
  96331. */
  96332. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  96333. protected _prepareRessources(): void;
  96334. /** @hidden */
  96335. _rebuild(): void;
  96336. /**
  96337. * Releases the required resources for the edges renderer
  96338. */
  96339. dispose(): void;
  96340. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  96341. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  96342. /**
  96343. * Checks if the pair of p0 and p1 is en edge
  96344. * @param faceIndex
  96345. * @param edge
  96346. * @param faceNormals
  96347. * @param p0
  96348. * @param p1
  96349. * @private
  96350. */
  96351. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  96352. /**
  96353. * push line into the position, normal and index buffer
  96354. * @protected
  96355. */
  96356. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  96357. /**
  96358. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  96359. */
  96360. private _tessellateTriangle;
  96361. private _generateEdgesLinesAlternate;
  96362. /**
  96363. * Generates lines edges from adjacencjes
  96364. * @private
  96365. */
  96366. _generateEdgesLines(): void;
  96367. /**
  96368. * Checks wether or not the edges renderer is ready to render.
  96369. * @return true if ready, otherwise false.
  96370. */
  96371. isReady(): boolean;
  96372. /**
  96373. * Renders the edges of the attached mesh,
  96374. */
  96375. render(): void;
  96376. }
  96377. /**
  96378. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  96379. */
  96380. export class LineEdgesRenderer extends EdgesRenderer {
  96381. /**
  96382. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  96383. * @param source LineMesh used to generate edges
  96384. * @param epsilon not important (specified angle for edge detection)
  96385. * @param checkVerticesInsteadOfIndices not important for LineMesh
  96386. */
  96387. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  96388. /**
  96389. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  96390. */
  96391. _generateEdgesLines(): void;
  96392. }
  96393. }
  96394. declare module BABYLON {
  96395. /**
  96396. * This represents the object necessary to create a rendering group.
  96397. * This is exclusively used and created by the rendering manager.
  96398. * To modify the behavior, you use the available helpers in your scene or meshes.
  96399. * @hidden
  96400. */
  96401. export class RenderingGroup {
  96402. index: number;
  96403. private static _zeroVector;
  96404. private _scene;
  96405. private _opaqueSubMeshes;
  96406. private _transparentSubMeshes;
  96407. private _alphaTestSubMeshes;
  96408. private _depthOnlySubMeshes;
  96409. private _particleSystems;
  96410. private _spriteManagers;
  96411. private _opaqueSortCompareFn;
  96412. private _alphaTestSortCompareFn;
  96413. private _transparentSortCompareFn;
  96414. private _renderOpaque;
  96415. private _renderAlphaTest;
  96416. private _renderTransparent;
  96417. /** @hidden */
  96418. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  96419. onBeforeTransparentRendering: () => void;
  96420. /**
  96421. * Set the opaque sort comparison function.
  96422. * If null the sub meshes will be render in the order they were created
  96423. */
  96424. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  96425. /**
  96426. * Set the alpha test sort comparison function.
  96427. * If null the sub meshes will be render in the order they were created
  96428. */
  96429. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  96430. /**
  96431. * Set the transparent sort comparison function.
  96432. * If null the sub meshes will be render in the order they were created
  96433. */
  96434. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  96435. /**
  96436. * Creates a new rendering group.
  96437. * @param index The rendering group index
  96438. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  96439. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  96440. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  96441. */
  96442. 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>);
  96443. /**
  96444. * Render all the sub meshes contained in the group.
  96445. * @param customRenderFunction Used to override the default render behaviour of the group.
  96446. * @returns true if rendered some submeshes.
  96447. */
  96448. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  96449. /**
  96450. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  96451. * @param subMeshes The submeshes to render
  96452. */
  96453. private renderOpaqueSorted;
  96454. /**
  96455. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  96456. * @param subMeshes The submeshes to render
  96457. */
  96458. private renderAlphaTestSorted;
  96459. /**
  96460. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  96461. * @param subMeshes The submeshes to render
  96462. */
  96463. private renderTransparentSorted;
  96464. /**
  96465. * Renders the submeshes in a specified order.
  96466. * @param subMeshes The submeshes to sort before render
  96467. * @param sortCompareFn The comparison function use to sort
  96468. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  96469. * @param transparent Specifies to activate blending if true
  96470. */
  96471. private static renderSorted;
  96472. /**
  96473. * Renders the submeshes in the order they were dispatched (no sort applied).
  96474. * @param subMeshes The submeshes to render
  96475. */
  96476. private static renderUnsorted;
  96477. /**
  96478. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  96479. * are rendered back to front if in the same alpha index.
  96480. *
  96481. * @param a The first submesh
  96482. * @param b The second submesh
  96483. * @returns The result of the comparison
  96484. */
  96485. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  96486. /**
  96487. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  96488. * are rendered back to front.
  96489. *
  96490. * @param a The first submesh
  96491. * @param b The second submesh
  96492. * @returns The result of the comparison
  96493. */
  96494. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  96495. /**
  96496. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  96497. * are rendered front to back (prevent overdraw).
  96498. *
  96499. * @param a The first submesh
  96500. * @param b The second submesh
  96501. * @returns The result of the comparison
  96502. */
  96503. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  96504. /**
  96505. * Resets the different lists of submeshes to prepare a new frame.
  96506. */
  96507. prepare(): void;
  96508. dispose(): void;
  96509. /**
  96510. * Inserts the submesh in its correct queue depending on its material.
  96511. * @param subMesh The submesh to dispatch
  96512. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  96513. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  96514. */
  96515. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  96516. dispatchSprites(spriteManager: ISpriteManager): void;
  96517. dispatchParticles(particleSystem: IParticleSystem): void;
  96518. private _renderParticles;
  96519. private _renderSprites;
  96520. }
  96521. }
  96522. declare module BABYLON {
  96523. /**
  96524. * Interface describing the different options available in the rendering manager
  96525. * regarding Auto Clear between groups.
  96526. */
  96527. export interface IRenderingManagerAutoClearSetup {
  96528. /**
  96529. * Defines whether or not autoclear is enable.
  96530. */
  96531. autoClear: boolean;
  96532. /**
  96533. * Defines whether or not to autoclear the depth buffer.
  96534. */
  96535. depth: boolean;
  96536. /**
  96537. * Defines whether or not to autoclear the stencil buffer.
  96538. */
  96539. stencil: boolean;
  96540. }
  96541. /**
  96542. * This class is used by the onRenderingGroupObservable
  96543. */
  96544. export class RenderingGroupInfo {
  96545. /**
  96546. * The Scene that being rendered
  96547. */
  96548. scene: Scene;
  96549. /**
  96550. * The camera currently used for the rendering pass
  96551. */
  96552. camera: Nullable<Camera>;
  96553. /**
  96554. * The ID of the renderingGroup being processed
  96555. */
  96556. renderingGroupId: number;
  96557. }
  96558. /**
  96559. * This is the manager responsible of all the rendering for meshes sprites and particles.
  96560. * It is enable to manage the different groups as well as the different necessary sort functions.
  96561. * This should not be used directly aside of the few static configurations
  96562. */
  96563. export class RenderingManager {
  96564. /**
  96565. * The max id used for rendering groups (not included)
  96566. */
  96567. static MAX_RENDERINGGROUPS: number;
  96568. /**
  96569. * The min id used for rendering groups (included)
  96570. */
  96571. static MIN_RENDERINGGROUPS: number;
  96572. /**
  96573. * Used to globally prevent autoclearing scenes.
  96574. */
  96575. static AUTOCLEAR: boolean;
  96576. /**
  96577. * @hidden
  96578. */
  96579. _useSceneAutoClearSetup: boolean;
  96580. private _scene;
  96581. private _renderingGroups;
  96582. private _depthStencilBufferAlreadyCleaned;
  96583. private _autoClearDepthStencil;
  96584. private _customOpaqueSortCompareFn;
  96585. private _customAlphaTestSortCompareFn;
  96586. private _customTransparentSortCompareFn;
  96587. private _renderingGroupInfo;
  96588. /**
  96589. * Instantiates a new rendering group for a particular scene
  96590. * @param scene Defines the scene the groups belongs to
  96591. */
  96592. constructor(scene: Scene);
  96593. private _clearDepthStencilBuffer;
  96594. /**
  96595. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  96596. * @hidden
  96597. */
  96598. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  96599. /**
  96600. * Resets the different information of the group to prepare a new frame
  96601. * @hidden
  96602. */
  96603. reset(): void;
  96604. /**
  96605. * Dispose and release the group and its associated resources.
  96606. * @hidden
  96607. */
  96608. dispose(): void;
  96609. /**
  96610. * Clear the info related to rendering groups preventing retention points during dispose.
  96611. */
  96612. freeRenderingGroups(): void;
  96613. private _prepareRenderingGroup;
  96614. /**
  96615. * Add a sprite manager to the rendering manager in order to render it this frame.
  96616. * @param spriteManager Define the sprite manager to render
  96617. */
  96618. dispatchSprites(spriteManager: ISpriteManager): void;
  96619. /**
  96620. * Add a particle system to the rendering manager in order to render it this frame.
  96621. * @param particleSystem Define the particle system to render
  96622. */
  96623. dispatchParticles(particleSystem: IParticleSystem): void;
  96624. /**
  96625. * Add a submesh to the manager in order to render it this frame
  96626. * @param subMesh The submesh to dispatch
  96627. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  96628. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  96629. */
  96630. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  96631. /**
  96632. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  96633. * This allowed control for front to back rendering or reversly depending of the special needs.
  96634. *
  96635. * @param renderingGroupId The rendering group id corresponding to its index
  96636. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  96637. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  96638. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  96639. */
  96640. 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;
  96641. /**
  96642. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  96643. *
  96644. * @param renderingGroupId The rendering group id corresponding to its index
  96645. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  96646. * @param depth Automatically clears depth between groups if true and autoClear is true.
  96647. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  96648. */
  96649. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  96650. /**
  96651. * Gets the current auto clear configuration for one rendering group of the rendering
  96652. * manager.
  96653. * @param index the rendering group index to get the information for
  96654. * @returns The auto clear setup for the requested rendering group
  96655. */
  96656. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  96657. }
  96658. }
  96659. declare module BABYLON {
  96660. /**
  96661. * Defines the options associated with the creation of a custom shader for a shadow generator.
  96662. */
  96663. export interface ICustomShaderOptions {
  96664. /**
  96665. * Gets or sets the custom shader name to use
  96666. */
  96667. shaderName: string;
  96668. /**
  96669. * The list of attribute names used in the shader
  96670. */
  96671. attributes?: string[];
  96672. /**
  96673. * The list of unifrom names used in the shader
  96674. */
  96675. uniforms?: string[];
  96676. /**
  96677. * The list of sampler names used in the shader
  96678. */
  96679. samplers?: string[];
  96680. /**
  96681. * The list of defines used in the shader
  96682. */
  96683. defines?: string[];
  96684. }
  96685. /**
  96686. * Interface to implement to create a shadow generator compatible with BJS.
  96687. */
  96688. export interface IShadowGenerator {
  96689. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  96690. id: string;
  96691. /**
  96692. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  96693. * @returns The render target texture if present otherwise, null
  96694. */
  96695. getShadowMap(): Nullable<RenderTargetTexture>;
  96696. /**
  96697. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  96698. * @param subMesh The submesh we want to render in the shadow map
  96699. * @param useInstances Defines wether will draw in the map using instances
  96700. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  96701. * @returns true if ready otherwise, false
  96702. */
  96703. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  96704. /**
  96705. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  96706. * @param defines Defines of the material we want to update
  96707. * @param lightIndex Index of the light in the enabled light list of the material
  96708. */
  96709. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  96710. /**
  96711. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  96712. * defined in the generator but impacting the effect).
  96713. * It implies the unifroms available on the materials are the standard BJS ones.
  96714. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  96715. * @param effect The effect we are binfing the information for
  96716. */
  96717. bindShadowLight(lightIndex: string, effect: Effect): void;
  96718. /**
  96719. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  96720. * (eq to shadow prjection matrix * light transform matrix)
  96721. * @returns The transform matrix used to create the shadow map
  96722. */
  96723. getTransformMatrix(): Matrix;
  96724. /**
  96725. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  96726. * Cube and 2D textures for instance.
  96727. */
  96728. recreateShadowMap(): void;
  96729. /**
  96730. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  96731. * @param onCompiled Callback triggered at the and of the effects compilation
  96732. * @param options Sets of optional options forcing the compilation with different modes
  96733. */
  96734. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  96735. useInstances: boolean;
  96736. }>): void;
  96737. /**
  96738. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  96739. * @param options Sets of optional options forcing the compilation with different modes
  96740. * @returns A promise that resolves when the compilation completes
  96741. */
  96742. forceCompilationAsync(options?: Partial<{
  96743. useInstances: boolean;
  96744. }>): Promise<void>;
  96745. /**
  96746. * Serializes the shadow generator setup to a json object.
  96747. * @returns The serialized JSON object
  96748. */
  96749. serialize(): any;
  96750. /**
  96751. * Disposes the Shadow map and related Textures and effects.
  96752. */
  96753. dispose(): void;
  96754. }
  96755. /**
  96756. * Default implementation IShadowGenerator.
  96757. * This is the main object responsible of generating shadows in the framework.
  96758. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  96759. */
  96760. export class ShadowGenerator implements IShadowGenerator {
  96761. /**
  96762. * Name of the shadow generator class
  96763. */
  96764. static CLASSNAME: string;
  96765. /**
  96766. * Shadow generator mode None: no filtering applied.
  96767. */
  96768. static readonly FILTER_NONE: number;
  96769. /**
  96770. * Shadow generator mode ESM: Exponential Shadow Mapping.
  96771. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  96772. */
  96773. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  96774. /**
  96775. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  96776. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  96777. */
  96778. static readonly FILTER_POISSONSAMPLING: number;
  96779. /**
  96780. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  96781. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  96782. */
  96783. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  96784. /**
  96785. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  96786. * edge artifacts on steep falloff.
  96787. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  96788. */
  96789. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  96790. /**
  96791. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  96792. * edge artifacts on steep falloff.
  96793. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  96794. */
  96795. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  96796. /**
  96797. * Shadow generator mode PCF: Percentage Closer Filtering
  96798. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  96799. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  96800. */
  96801. static readonly FILTER_PCF: number;
  96802. /**
  96803. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  96804. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  96805. * Contact Hardening
  96806. */
  96807. static readonly FILTER_PCSS: number;
  96808. /**
  96809. * Reserved for PCF and PCSS
  96810. * Highest Quality.
  96811. *
  96812. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  96813. *
  96814. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  96815. */
  96816. static readonly QUALITY_HIGH: number;
  96817. /**
  96818. * Reserved for PCF and PCSS
  96819. * Good tradeoff for quality/perf cross devices
  96820. *
  96821. * Execute PCF on a 3*3 kernel.
  96822. *
  96823. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  96824. */
  96825. static readonly QUALITY_MEDIUM: number;
  96826. /**
  96827. * Reserved for PCF and PCSS
  96828. * The lowest quality but the fastest.
  96829. *
  96830. * Execute PCF on a 1*1 kernel.
  96831. *
  96832. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  96833. */
  96834. static readonly QUALITY_LOW: number;
  96835. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  96836. id: string;
  96837. /** Gets or sets the custom shader name to use */
  96838. customShaderOptions: ICustomShaderOptions;
  96839. /**
  96840. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  96841. */
  96842. onBeforeShadowMapRenderObservable: Observable<Effect>;
  96843. /**
  96844. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  96845. */
  96846. onAfterShadowMapRenderObservable: Observable<Effect>;
  96847. /**
  96848. * Observable triggered before a mesh is rendered in the shadow map.
  96849. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  96850. */
  96851. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  96852. /**
  96853. * Observable triggered after a mesh is rendered in the shadow map.
  96854. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  96855. */
  96856. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  96857. protected _bias: number;
  96858. /**
  96859. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  96860. */
  96861. get bias(): number;
  96862. /**
  96863. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  96864. */
  96865. set bias(bias: number);
  96866. protected _normalBias: number;
  96867. /**
  96868. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  96869. */
  96870. get normalBias(): number;
  96871. /**
  96872. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  96873. */
  96874. set normalBias(normalBias: number);
  96875. protected _blurBoxOffset: number;
  96876. /**
  96877. * Gets the blur box offset: offset applied during the blur pass.
  96878. * Only useful if useKernelBlur = false
  96879. */
  96880. get blurBoxOffset(): number;
  96881. /**
  96882. * Sets the blur box offset: offset applied during the blur pass.
  96883. * Only useful if useKernelBlur = false
  96884. */
  96885. set blurBoxOffset(value: number);
  96886. protected _blurScale: number;
  96887. /**
  96888. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  96889. * 2 means half of the size.
  96890. */
  96891. get blurScale(): number;
  96892. /**
  96893. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  96894. * 2 means half of the size.
  96895. */
  96896. set blurScale(value: number);
  96897. protected _blurKernel: number;
  96898. /**
  96899. * Gets the blur kernel: kernel size of the blur pass.
  96900. * Only useful if useKernelBlur = true
  96901. */
  96902. get blurKernel(): number;
  96903. /**
  96904. * Sets the blur kernel: kernel size of the blur pass.
  96905. * Only useful if useKernelBlur = true
  96906. */
  96907. set blurKernel(value: number);
  96908. protected _useKernelBlur: boolean;
  96909. /**
  96910. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  96911. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  96912. */
  96913. get useKernelBlur(): boolean;
  96914. /**
  96915. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  96916. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  96917. */
  96918. set useKernelBlur(value: boolean);
  96919. protected _depthScale: number;
  96920. /**
  96921. * Gets the depth scale used in ESM mode.
  96922. */
  96923. get depthScale(): number;
  96924. /**
  96925. * Sets the depth scale used in ESM mode.
  96926. * This can override the scale stored on the light.
  96927. */
  96928. set depthScale(value: number);
  96929. protected _validateFilter(filter: number): number;
  96930. protected _filter: number;
  96931. /**
  96932. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  96933. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  96934. */
  96935. get filter(): number;
  96936. /**
  96937. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  96938. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  96939. */
  96940. set filter(value: number);
  96941. /**
  96942. * Gets if the current filter is set to Poisson Sampling.
  96943. */
  96944. get usePoissonSampling(): boolean;
  96945. /**
  96946. * Sets the current filter to Poisson Sampling.
  96947. */
  96948. set usePoissonSampling(value: boolean);
  96949. /**
  96950. * Gets if the current filter is set to ESM.
  96951. */
  96952. get useExponentialShadowMap(): boolean;
  96953. /**
  96954. * Sets the current filter is to ESM.
  96955. */
  96956. set useExponentialShadowMap(value: boolean);
  96957. /**
  96958. * Gets if the current filter is set to filtered ESM.
  96959. */
  96960. get useBlurExponentialShadowMap(): boolean;
  96961. /**
  96962. * Gets if the current filter is set to filtered ESM.
  96963. */
  96964. set useBlurExponentialShadowMap(value: boolean);
  96965. /**
  96966. * Gets if the current filter is set to "close ESM" (using the inverse of the
  96967. * exponential to prevent steep falloff artifacts).
  96968. */
  96969. get useCloseExponentialShadowMap(): boolean;
  96970. /**
  96971. * Sets the current filter to "close ESM" (using the inverse of the
  96972. * exponential to prevent steep falloff artifacts).
  96973. */
  96974. set useCloseExponentialShadowMap(value: boolean);
  96975. /**
  96976. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  96977. * exponential to prevent steep falloff artifacts).
  96978. */
  96979. get useBlurCloseExponentialShadowMap(): boolean;
  96980. /**
  96981. * Sets the current filter to filtered "close ESM" (using the inverse of the
  96982. * exponential to prevent steep falloff artifacts).
  96983. */
  96984. set useBlurCloseExponentialShadowMap(value: boolean);
  96985. /**
  96986. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  96987. */
  96988. get usePercentageCloserFiltering(): boolean;
  96989. /**
  96990. * Sets the current filter to "PCF" (percentage closer filtering).
  96991. */
  96992. set usePercentageCloserFiltering(value: boolean);
  96993. protected _filteringQuality: number;
  96994. /**
  96995. * Gets the PCF or PCSS Quality.
  96996. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  96997. */
  96998. get filteringQuality(): number;
  96999. /**
  97000. * Sets the PCF or PCSS Quality.
  97001. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  97002. */
  97003. set filteringQuality(filteringQuality: number);
  97004. /**
  97005. * Gets if the current filter is set to "PCSS" (contact hardening).
  97006. */
  97007. get useContactHardeningShadow(): boolean;
  97008. /**
  97009. * Sets the current filter to "PCSS" (contact hardening).
  97010. */
  97011. set useContactHardeningShadow(value: boolean);
  97012. protected _contactHardeningLightSizeUVRatio: number;
  97013. /**
  97014. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  97015. * Using a ratio helps keeping shape stability independently of the map size.
  97016. *
  97017. * It does not account for the light projection as it was having too much
  97018. * instability during the light setup or during light position changes.
  97019. *
  97020. * Only valid if useContactHardeningShadow is true.
  97021. */
  97022. get contactHardeningLightSizeUVRatio(): number;
  97023. /**
  97024. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  97025. * Using a ratio helps keeping shape stability independently of the map size.
  97026. *
  97027. * It does not account for the light projection as it was having too much
  97028. * instability during the light setup or during light position changes.
  97029. *
  97030. * Only valid if useContactHardeningShadow is true.
  97031. */
  97032. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  97033. protected _darkness: number;
  97034. /** Gets or sets the actual darkness of a shadow */
  97035. get darkness(): number;
  97036. set darkness(value: number);
  97037. /**
  97038. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  97039. * 0 means strongest and 1 would means no shadow.
  97040. * @returns the darkness.
  97041. */
  97042. getDarkness(): number;
  97043. /**
  97044. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  97045. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  97046. * @returns the shadow generator allowing fluent coding.
  97047. */
  97048. setDarkness(darkness: number): ShadowGenerator;
  97049. protected _transparencyShadow: boolean;
  97050. /** Gets or sets the ability to have transparent shadow */
  97051. get transparencyShadow(): boolean;
  97052. set transparencyShadow(value: boolean);
  97053. /**
  97054. * Sets the ability to have transparent shadow (boolean).
  97055. * @param transparent True if transparent else False
  97056. * @returns the shadow generator allowing fluent coding
  97057. */
  97058. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  97059. /**
  97060. * Enables or disables shadows with varying strength based on the transparency
  97061. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  97062. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  97063. * mesh.visibility * alphaTexture.a
  97064. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  97065. */
  97066. enableSoftTransparentShadow: boolean;
  97067. protected _shadowMap: Nullable<RenderTargetTexture>;
  97068. protected _shadowMap2: Nullable<RenderTargetTexture>;
  97069. /**
  97070. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  97071. * @returns The render target texture if present otherwise, null
  97072. */
  97073. getShadowMap(): Nullable<RenderTargetTexture>;
  97074. /**
  97075. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  97076. * @returns The render target texture if the shadow map is present otherwise, null
  97077. */
  97078. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  97079. /**
  97080. * Gets the class name of that object
  97081. * @returns "ShadowGenerator"
  97082. */
  97083. getClassName(): string;
  97084. /**
  97085. * Helper function to add a mesh and its descendants to the list of shadow casters.
  97086. * @param mesh Mesh to add
  97087. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  97088. * @returns the Shadow Generator itself
  97089. */
  97090. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  97091. /**
  97092. * Helper function to remove a mesh and its descendants from the list of shadow casters
  97093. * @param mesh Mesh to remove
  97094. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  97095. * @returns the Shadow Generator itself
  97096. */
  97097. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  97098. /**
  97099. * Controls the extent to which the shadows fade out at the edge of the frustum
  97100. */
  97101. frustumEdgeFalloff: number;
  97102. protected _light: IShadowLight;
  97103. /**
  97104. * Returns the associated light object.
  97105. * @returns the light generating the shadow
  97106. */
  97107. getLight(): IShadowLight;
  97108. /**
  97109. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  97110. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  97111. * It might on the other hand introduce peter panning.
  97112. */
  97113. forceBackFacesOnly: boolean;
  97114. protected _scene: Scene;
  97115. protected _lightDirection: Vector3;
  97116. protected _effect: Effect;
  97117. protected _viewMatrix: Matrix;
  97118. protected _projectionMatrix: Matrix;
  97119. protected _transformMatrix: Matrix;
  97120. protected _cachedPosition: Vector3;
  97121. protected _cachedDirection: Vector3;
  97122. protected _cachedDefines: string;
  97123. protected _currentRenderID: number;
  97124. protected _boxBlurPostprocess: Nullable<PostProcess>;
  97125. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  97126. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  97127. protected _blurPostProcesses: PostProcess[];
  97128. protected _mapSize: number;
  97129. protected _currentFaceIndex: number;
  97130. protected _currentFaceIndexCache: number;
  97131. protected _textureType: number;
  97132. protected _defaultTextureMatrix: Matrix;
  97133. protected _storedUniqueId: Nullable<number>;
  97134. /** @hidden */
  97135. static _SceneComponentInitialization: (scene: Scene) => void;
  97136. /**
  97137. * Creates a ShadowGenerator object.
  97138. * A ShadowGenerator is the required tool to use the shadows.
  97139. * Each light casting shadows needs to use its own ShadowGenerator.
  97140. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  97141. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  97142. * @param light The light object generating the shadows.
  97143. * @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.
  97144. */
  97145. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  97146. protected _initializeGenerator(): void;
  97147. protected _createTargetRenderTexture(): void;
  97148. protected _initializeShadowMap(): void;
  97149. protected _initializeBlurRTTAndPostProcesses(): void;
  97150. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  97151. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  97152. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  97153. protected _applyFilterValues(): void;
  97154. /**
  97155. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  97156. * @param onCompiled Callback triggered at the and of the effects compilation
  97157. * @param options Sets of optional options forcing the compilation with different modes
  97158. */
  97159. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  97160. useInstances: boolean;
  97161. }>): void;
  97162. /**
  97163. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  97164. * @param options Sets of optional options forcing the compilation with different modes
  97165. * @returns A promise that resolves when the compilation completes
  97166. */
  97167. forceCompilationAsync(options?: Partial<{
  97168. useInstances: boolean;
  97169. }>): Promise<void>;
  97170. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  97171. private _prepareShadowDefines;
  97172. /**
  97173. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  97174. * @param subMesh The submesh we want to render in the shadow map
  97175. * @param useInstances Defines wether will draw in the map using instances
  97176. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  97177. * @returns true if ready otherwise, false
  97178. */
  97179. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  97180. /**
  97181. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  97182. * @param defines Defines of the material we want to update
  97183. * @param lightIndex Index of the light in the enabled light list of the material
  97184. */
  97185. prepareDefines(defines: any, lightIndex: number): void;
  97186. /**
  97187. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  97188. * defined in the generator but impacting the effect).
  97189. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  97190. * @param effect The effect we are binfing the information for
  97191. */
  97192. bindShadowLight(lightIndex: string, effect: Effect): void;
  97193. /**
  97194. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  97195. * (eq to shadow prjection matrix * light transform matrix)
  97196. * @returns The transform matrix used to create the shadow map
  97197. */
  97198. getTransformMatrix(): Matrix;
  97199. /**
  97200. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  97201. * Cube and 2D textures for instance.
  97202. */
  97203. recreateShadowMap(): void;
  97204. protected _disposeBlurPostProcesses(): void;
  97205. protected _disposeRTTandPostProcesses(): void;
  97206. /**
  97207. * Disposes the ShadowGenerator.
  97208. * Returns nothing.
  97209. */
  97210. dispose(): void;
  97211. /**
  97212. * Serializes the shadow generator setup to a json object.
  97213. * @returns The serialized JSON object
  97214. */
  97215. serialize(): any;
  97216. /**
  97217. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  97218. * @param parsedShadowGenerator The JSON object to parse
  97219. * @param scene The scene to create the shadow map for
  97220. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  97221. * @returns The parsed shadow generator
  97222. */
  97223. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  97224. }
  97225. }
  97226. declare module BABYLON {
  97227. /**
  97228. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  97229. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  97230. * 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.
  97231. */
  97232. export abstract class Light extends Node {
  97233. /**
  97234. * Falloff Default: light is falling off following the material specification:
  97235. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  97236. */
  97237. static readonly FALLOFF_DEFAULT: number;
  97238. /**
  97239. * Falloff Physical: light is falling off following the inverse squared distance law.
  97240. */
  97241. static readonly FALLOFF_PHYSICAL: number;
  97242. /**
  97243. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  97244. * to enhance interoperability with other engines.
  97245. */
  97246. static readonly FALLOFF_GLTF: number;
  97247. /**
  97248. * Falloff Standard: light is falling off like in the standard material
  97249. * to enhance interoperability with other materials.
  97250. */
  97251. static readonly FALLOFF_STANDARD: number;
  97252. /**
  97253. * If every light affecting the material is in this lightmapMode,
  97254. * material.lightmapTexture adds or multiplies
  97255. * (depends on material.useLightmapAsShadowmap)
  97256. * after every other light calculations.
  97257. */
  97258. static readonly LIGHTMAP_DEFAULT: number;
  97259. /**
  97260. * material.lightmapTexture as only diffuse lighting from this light
  97261. * adds only specular lighting from this light
  97262. * adds dynamic shadows
  97263. */
  97264. static readonly LIGHTMAP_SPECULAR: number;
  97265. /**
  97266. * material.lightmapTexture as only lighting
  97267. * no light calculation from this light
  97268. * only adds dynamic shadows from this light
  97269. */
  97270. static readonly LIGHTMAP_SHADOWSONLY: number;
  97271. /**
  97272. * Each light type uses the default quantity according to its type:
  97273. * point/spot lights use luminous intensity
  97274. * directional lights use illuminance
  97275. */
  97276. static readonly INTENSITYMODE_AUTOMATIC: number;
  97277. /**
  97278. * lumen (lm)
  97279. */
  97280. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  97281. /**
  97282. * candela (lm/sr)
  97283. */
  97284. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  97285. /**
  97286. * lux (lm/m^2)
  97287. */
  97288. static readonly INTENSITYMODE_ILLUMINANCE: number;
  97289. /**
  97290. * nit (cd/m^2)
  97291. */
  97292. static readonly INTENSITYMODE_LUMINANCE: number;
  97293. /**
  97294. * Light type const id of the point light.
  97295. */
  97296. static readonly LIGHTTYPEID_POINTLIGHT: number;
  97297. /**
  97298. * Light type const id of the directional light.
  97299. */
  97300. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  97301. /**
  97302. * Light type const id of the spot light.
  97303. */
  97304. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  97305. /**
  97306. * Light type const id of the hemispheric light.
  97307. */
  97308. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  97309. /**
  97310. * Diffuse gives the basic color to an object.
  97311. */
  97312. diffuse: Color3;
  97313. /**
  97314. * Specular produces a highlight color on an object.
  97315. * Note: This is note affecting PBR materials.
  97316. */
  97317. specular: Color3;
  97318. /**
  97319. * Defines the falloff type for this light. This lets overrriding how punctual light are
  97320. * falling off base on range or angle.
  97321. * This can be set to any values in Light.FALLOFF_x.
  97322. *
  97323. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  97324. * other types of materials.
  97325. */
  97326. falloffType: number;
  97327. /**
  97328. * Strength of the light.
  97329. * Note: By default it is define in the framework own unit.
  97330. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  97331. */
  97332. intensity: number;
  97333. private _range;
  97334. protected _inverseSquaredRange: number;
  97335. /**
  97336. * Defines how far from the source the light is impacting in scene units.
  97337. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  97338. */
  97339. get range(): number;
  97340. /**
  97341. * Defines how far from the source the light is impacting in scene units.
  97342. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  97343. */
  97344. set range(value: number);
  97345. /**
  97346. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  97347. * of light.
  97348. */
  97349. private _photometricScale;
  97350. private _intensityMode;
  97351. /**
  97352. * Gets the photometric scale used to interpret the intensity.
  97353. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  97354. */
  97355. get intensityMode(): number;
  97356. /**
  97357. * Sets the photometric scale used to interpret the intensity.
  97358. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  97359. */
  97360. set intensityMode(value: number);
  97361. private _radius;
  97362. /**
  97363. * Gets the light radius used by PBR Materials to simulate soft area lights.
  97364. */
  97365. get radius(): number;
  97366. /**
  97367. * sets the light radius used by PBR Materials to simulate soft area lights.
  97368. */
  97369. set radius(value: number);
  97370. private _renderPriority;
  97371. /**
  97372. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  97373. * exceeding the number allowed of the materials.
  97374. */
  97375. renderPriority: number;
  97376. private _shadowEnabled;
  97377. /**
  97378. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  97379. * the current shadow generator.
  97380. */
  97381. get shadowEnabled(): boolean;
  97382. /**
  97383. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  97384. * the current shadow generator.
  97385. */
  97386. set shadowEnabled(value: boolean);
  97387. private _includedOnlyMeshes;
  97388. /**
  97389. * Gets the only meshes impacted by this light.
  97390. */
  97391. get includedOnlyMeshes(): AbstractMesh[];
  97392. /**
  97393. * Sets the only meshes impacted by this light.
  97394. */
  97395. set includedOnlyMeshes(value: AbstractMesh[]);
  97396. private _excludedMeshes;
  97397. /**
  97398. * Gets the meshes not impacted by this light.
  97399. */
  97400. get excludedMeshes(): AbstractMesh[];
  97401. /**
  97402. * Sets the meshes not impacted by this light.
  97403. */
  97404. set excludedMeshes(value: AbstractMesh[]);
  97405. private _excludeWithLayerMask;
  97406. /**
  97407. * Gets the layer id use to find what meshes are not impacted by the light.
  97408. * Inactive if 0
  97409. */
  97410. get excludeWithLayerMask(): number;
  97411. /**
  97412. * Sets the layer id use to find what meshes are not impacted by the light.
  97413. * Inactive if 0
  97414. */
  97415. set excludeWithLayerMask(value: number);
  97416. private _includeOnlyWithLayerMask;
  97417. /**
  97418. * Gets the layer id use to find what meshes are impacted by the light.
  97419. * Inactive if 0
  97420. */
  97421. get includeOnlyWithLayerMask(): number;
  97422. /**
  97423. * Sets the layer id use to find what meshes are impacted by the light.
  97424. * Inactive if 0
  97425. */
  97426. set includeOnlyWithLayerMask(value: number);
  97427. private _lightmapMode;
  97428. /**
  97429. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  97430. */
  97431. get lightmapMode(): number;
  97432. /**
  97433. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  97434. */
  97435. set lightmapMode(value: number);
  97436. /**
  97437. * Shadow generator associted to the light.
  97438. * @hidden Internal use only.
  97439. */
  97440. _shadowGenerator: Nullable<IShadowGenerator>;
  97441. /**
  97442. * @hidden Internal use only.
  97443. */
  97444. _excludedMeshesIds: string[];
  97445. /**
  97446. * @hidden Internal use only.
  97447. */
  97448. _includedOnlyMeshesIds: string[];
  97449. /**
  97450. * The current light unifom buffer.
  97451. * @hidden Internal use only.
  97452. */
  97453. _uniformBuffer: UniformBuffer;
  97454. /** @hidden */
  97455. _renderId: number;
  97456. /**
  97457. * Creates a Light object in the scene.
  97458. * Documentation : https://doc.babylonjs.com/babylon101/lights
  97459. * @param name The firendly name of the light
  97460. * @param scene The scene the light belongs too
  97461. */
  97462. constructor(name: string, scene: Scene);
  97463. protected abstract _buildUniformLayout(): void;
  97464. /**
  97465. * Sets the passed Effect "effect" with the Light information.
  97466. * @param effect The effect to update
  97467. * @param lightIndex The index of the light in the effect to update
  97468. * @returns The light
  97469. */
  97470. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  97471. /**
  97472. * Sets the passed Effect "effect" with the Light textures.
  97473. * @param effect The effect to update
  97474. * @param lightIndex The index of the light in the effect to update
  97475. * @returns The light
  97476. */
  97477. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  97478. /**
  97479. * Binds the lights information from the scene to the effect for the given mesh.
  97480. * @param lightIndex Light index
  97481. * @param scene The scene where the light belongs to
  97482. * @param effect The effect we are binding the data to
  97483. * @param useSpecular Defines if specular is supported
  97484. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  97485. */
  97486. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  97487. /**
  97488. * Sets the passed Effect "effect" with the Light information.
  97489. * @param effect The effect to update
  97490. * @param lightDataUniformName The uniform used to store light data (position or direction)
  97491. * @returns The light
  97492. */
  97493. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  97494. /**
  97495. * Returns the string "Light".
  97496. * @returns the class name
  97497. */
  97498. getClassName(): string;
  97499. /** @hidden */
  97500. readonly _isLight: boolean;
  97501. /**
  97502. * Converts the light information to a readable string for debug purpose.
  97503. * @param fullDetails Supports for multiple levels of logging within scene loading
  97504. * @returns the human readable light info
  97505. */
  97506. toString(fullDetails?: boolean): string;
  97507. /** @hidden */
  97508. protected _syncParentEnabledState(): void;
  97509. /**
  97510. * Set the enabled state of this node.
  97511. * @param value - the new enabled state
  97512. */
  97513. setEnabled(value: boolean): void;
  97514. /**
  97515. * Returns the Light associated shadow generator if any.
  97516. * @return the associated shadow generator.
  97517. */
  97518. getShadowGenerator(): Nullable<IShadowGenerator>;
  97519. /**
  97520. * Returns a Vector3, the absolute light position in the World.
  97521. * @returns the world space position of the light
  97522. */
  97523. getAbsolutePosition(): Vector3;
  97524. /**
  97525. * Specifies if the light will affect the passed mesh.
  97526. * @param mesh The mesh to test against the light
  97527. * @return true the mesh is affected otherwise, false.
  97528. */
  97529. canAffectMesh(mesh: AbstractMesh): boolean;
  97530. /**
  97531. * Sort function to order lights for rendering.
  97532. * @param a First Light object to compare to second.
  97533. * @param b Second Light object to compare first.
  97534. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  97535. */
  97536. static CompareLightsPriority(a: Light, b: Light): number;
  97537. /**
  97538. * Releases resources associated with this node.
  97539. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  97540. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  97541. */
  97542. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  97543. /**
  97544. * Returns the light type ID (integer).
  97545. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  97546. */
  97547. getTypeID(): number;
  97548. /**
  97549. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  97550. * @returns the scaled intensity in intensity mode unit
  97551. */
  97552. getScaledIntensity(): number;
  97553. /**
  97554. * Returns a new Light object, named "name", from the current one.
  97555. * @param name The name of the cloned light
  97556. * @param newParent The parent of this light, if it has one
  97557. * @returns the new created light
  97558. */
  97559. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  97560. /**
  97561. * Serializes the current light into a Serialization object.
  97562. * @returns the serialized object.
  97563. */
  97564. serialize(): any;
  97565. /**
  97566. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  97567. * This new light is named "name" and added to the passed scene.
  97568. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  97569. * @param name The friendly name of the light
  97570. * @param scene The scene the new light will belong to
  97571. * @returns the constructor function
  97572. */
  97573. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  97574. /**
  97575. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  97576. * @param parsedLight The JSON representation of the light
  97577. * @param scene The scene to create the parsed light in
  97578. * @returns the created light after parsing
  97579. */
  97580. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  97581. private _hookArrayForExcluded;
  97582. private _hookArrayForIncludedOnly;
  97583. private _resyncMeshes;
  97584. /**
  97585. * Forces the meshes to update their light related information in their rendering used effects
  97586. * @hidden Internal Use Only
  97587. */
  97588. _markMeshesAsLightDirty(): void;
  97589. /**
  97590. * Recomputes the cached photometric scale if needed.
  97591. */
  97592. private _computePhotometricScale;
  97593. /**
  97594. * Returns the Photometric Scale according to the light type and intensity mode.
  97595. */
  97596. private _getPhotometricScale;
  97597. /**
  97598. * Reorder the light in the scene according to their defined priority.
  97599. * @hidden Internal Use Only
  97600. */
  97601. _reorderLightsInScene(): void;
  97602. /**
  97603. * Prepares the list of defines specific to the light type.
  97604. * @param defines the list of defines
  97605. * @param lightIndex defines the index of the light for the effect
  97606. */
  97607. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  97608. }
  97609. }
  97610. declare module BABYLON {
  97611. /**
  97612. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  97613. * This is the base of the follow, arc rotate cameras and Free camera
  97614. * @see https://doc.babylonjs.com/features/cameras
  97615. */
  97616. export class TargetCamera extends Camera {
  97617. private static _RigCamTransformMatrix;
  97618. private static _TargetTransformMatrix;
  97619. private static _TargetFocalPoint;
  97620. private _tmpUpVector;
  97621. private _tmpTargetVector;
  97622. /**
  97623. * Define the current direction the camera is moving to
  97624. */
  97625. cameraDirection: Vector3;
  97626. /**
  97627. * Define the current rotation the camera is rotating to
  97628. */
  97629. cameraRotation: Vector2;
  97630. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  97631. ignoreParentScaling: boolean;
  97632. /**
  97633. * When set, the up vector of the camera will be updated by the rotation of the camera
  97634. */
  97635. updateUpVectorFromRotation: boolean;
  97636. private _tmpQuaternion;
  97637. /**
  97638. * Define the current rotation of the camera
  97639. */
  97640. rotation: Vector3;
  97641. /**
  97642. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  97643. */
  97644. rotationQuaternion: Quaternion;
  97645. /**
  97646. * Define the current speed of the camera
  97647. */
  97648. speed: number;
  97649. /**
  97650. * Add constraint to the camera to prevent it to move freely in all directions and
  97651. * around all axis.
  97652. */
  97653. noRotationConstraint: boolean;
  97654. /**
  97655. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  97656. * panning
  97657. */
  97658. invertRotation: boolean;
  97659. /**
  97660. * Speed multiplier for inverse camera panning
  97661. */
  97662. inverseRotationSpeed: number;
  97663. /**
  97664. * Define the current target of the camera as an object or a position.
  97665. */
  97666. lockedTarget: any;
  97667. /** @hidden */
  97668. _currentTarget: Vector3;
  97669. /** @hidden */
  97670. _initialFocalDistance: number;
  97671. /** @hidden */
  97672. _viewMatrix: Matrix;
  97673. /** @hidden */
  97674. _camMatrix: Matrix;
  97675. /** @hidden */
  97676. _cameraTransformMatrix: Matrix;
  97677. /** @hidden */
  97678. _cameraRotationMatrix: Matrix;
  97679. /** @hidden */
  97680. _referencePoint: Vector3;
  97681. /** @hidden */
  97682. _transformedReferencePoint: Vector3;
  97683. /** @hidden */
  97684. _reset: () => void;
  97685. private _defaultUp;
  97686. /**
  97687. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  97688. * This is the base of the follow, arc rotate cameras and Free camera
  97689. * @see https://doc.babylonjs.com/features/cameras
  97690. * @param name Defines the name of the camera in the scene
  97691. * @param position Defines the start position of the camera in the scene
  97692. * @param scene Defines the scene the camera belongs to
  97693. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  97694. */
  97695. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  97696. /**
  97697. * Gets the position in front of the camera at a given distance.
  97698. * @param distance The distance from the camera we want the position to be
  97699. * @returns the position
  97700. */
  97701. getFrontPosition(distance: number): Vector3;
  97702. /** @hidden */
  97703. _getLockedTargetPosition(): Nullable<Vector3>;
  97704. private _storedPosition;
  97705. private _storedRotation;
  97706. private _storedRotationQuaternion;
  97707. /**
  97708. * Store current camera state of the camera (fov, position, rotation, etc..)
  97709. * @returns the camera
  97710. */
  97711. storeState(): Camera;
  97712. /**
  97713. * Restored camera state. You must call storeState() first
  97714. * @returns whether it was successful or not
  97715. * @hidden
  97716. */
  97717. _restoreStateValues(): boolean;
  97718. /** @hidden */
  97719. _initCache(): void;
  97720. /** @hidden */
  97721. _updateCache(ignoreParentClass?: boolean): void;
  97722. /** @hidden */
  97723. _isSynchronizedViewMatrix(): boolean;
  97724. /** @hidden */
  97725. _computeLocalCameraSpeed(): number;
  97726. /**
  97727. * Defines the target the camera should look at.
  97728. * @param target Defines the new target as a Vector or a mesh
  97729. */
  97730. setTarget(target: Vector3): void;
  97731. /**
  97732. * Defines the target point of the camera.
  97733. * The camera looks towards it form the radius distance.
  97734. */
  97735. get target(): Vector3;
  97736. set target(value: Vector3);
  97737. /**
  97738. * Return the current target position of the camera. This value is expressed in local space.
  97739. * @returns the target position
  97740. */
  97741. getTarget(): Vector3;
  97742. /** @hidden */
  97743. _decideIfNeedsToMove(): boolean;
  97744. /** @hidden */
  97745. _updatePosition(): void;
  97746. /** @hidden */
  97747. _checkInputs(): void;
  97748. protected _updateCameraRotationMatrix(): void;
  97749. /**
  97750. * 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)
  97751. * @returns the current camera
  97752. */
  97753. private _rotateUpVectorWithCameraRotationMatrix;
  97754. private _cachedRotationZ;
  97755. private _cachedQuaternionRotationZ;
  97756. /** @hidden */
  97757. _getViewMatrix(): Matrix;
  97758. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  97759. /**
  97760. * @hidden
  97761. */
  97762. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  97763. /**
  97764. * @hidden
  97765. */
  97766. _updateRigCameras(): void;
  97767. private _getRigCamPositionAndTarget;
  97768. /**
  97769. * Gets the current object class name.
  97770. * @return the class name
  97771. */
  97772. getClassName(): string;
  97773. }
  97774. }
  97775. declare module BABYLON {
  97776. /**
  97777. * Gather the list of keyboard event types as constants.
  97778. */
  97779. export class KeyboardEventTypes {
  97780. /**
  97781. * The keydown event is fired when a key becomes active (pressed).
  97782. */
  97783. static readonly KEYDOWN: number;
  97784. /**
  97785. * The keyup event is fired when a key has been released.
  97786. */
  97787. static readonly KEYUP: number;
  97788. }
  97789. /**
  97790. * This class is used to store keyboard related info for the onKeyboardObservable event.
  97791. */
  97792. export class KeyboardInfo {
  97793. /**
  97794. * Defines the type of event (KeyboardEventTypes)
  97795. */
  97796. type: number;
  97797. /**
  97798. * Defines the related dom event
  97799. */
  97800. event: KeyboardEvent;
  97801. /**
  97802. * Instantiates a new keyboard info.
  97803. * This class is used to store keyboard related info for the onKeyboardObservable event.
  97804. * @param type Defines the type of event (KeyboardEventTypes)
  97805. * @param event Defines the related dom event
  97806. */
  97807. constructor(
  97808. /**
  97809. * Defines the type of event (KeyboardEventTypes)
  97810. */
  97811. type: number,
  97812. /**
  97813. * Defines the related dom event
  97814. */
  97815. event: KeyboardEvent);
  97816. }
  97817. /**
  97818. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  97819. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  97820. */
  97821. export class KeyboardInfoPre extends KeyboardInfo {
  97822. /**
  97823. * Defines the type of event (KeyboardEventTypes)
  97824. */
  97825. type: number;
  97826. /**
  97827. * Defines the related dom event
  97828. */
  97829. event: KeyboardEvent;
  97830. /**
  97831. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  97832. */
  97833. skipOnPointerObservable: boolean;
  97834. /**
  97835. * Instantiates a new keyboard pre info.
  97836. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  97837. * @param type Defines the type of event (KeyboardEventTypes)
  97838. * @param event Defines the related dom event
  97839. */
  97840. constructor(
  97841. /**
  97842. * Defines the type of event (KeyboardEventTypes)
  97843. */
  97844. type: number,
  97845. /**
  97846. * Defines the related dom event
  97847. */
  97848. event: KeyboardEvent);
  97849. }
  97850. }
  97851. declare module BABYLON {
  97852. /**
  97853. * Manage the keyboard inputs to control the movement of a free camera.
  97854. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  97855. */
  97856. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  97857. /**
  97858. * Defines the camera the input is attached to.
  97859. */
  97860. camera: FreeCamera;
  97861. /**
  97862. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  97863. */
  97864. keysUp: number[];
  97865. /**
  97866. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  97867. */
  97868. keysUpward: number[];
  97869. /**
  97870. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  97871. */
  97872. keysDown: number[];
  97873. /**
  97874. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  97875. */
  97876. keysDownward: number[];
  97877. /**
  97878. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  97879. */
  97880. keysLeft: number[];
  97881. /**
  97882. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  97883. */
  97884. keysRight: number[];
  97885. private _keys;
  97886. private _onCanvasBlurObserver;
  97887. private _onKeyboardObserver;
  97888. private _engine;
  97889. private _scene;
  97890. /**
  97891. * Attach the input controls to a specific dom element to get the input from.
  97892. * @param element Defines the element the controls should be listened from
  97893. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97894. */
  97895. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97896. /**
  97897. * Detach the current controls from the specified dom element.
  97898. * @param element Defines the element to stop listening the inputs from
  97899. */
  97900. detachControl(element: Nullable<HTMLElement>): void;
  97901. /**
  97902. * Update the current camera state depending on the inputs that have been used this frame.
  97903. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  97904. */
  97905. checkInputs(): void;
  97906. /**
  97907. * Gets the class name of the current intput.
  97908. * @returns the class name
  97909. */
  97910. getClassName(): string;
  97911. /** @hidden */
  97912. _onLostFocus(): void;
  97913. /**
  97914. * Get the friendly name associated with the input class.
  97915. * @returns the input friendly name
  97916. */
  97917. getSimpleName(): string;
  97918. }
  97919. }
  97920. declare module BABYLON {
  97921. /**
  97922. * Gather the list of pointer event types as constants.
  97923. */
  97924. export class PointerEventTypes {
  97925. /**
  97926. * 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.
  97927. */
  97928. static readonly POINTERDOWN: number;
  97929. /**
  97930. * The pointerup event is fired when a pointer is no longer active.
  97931. */
  97932. static readonly POINTERUP: number;
  97933. /**
  97934. * The pointermove event is fired when a pointer changes coordinates.
  97935. */
  97936. static readonly POINTERMOVE: number;
  97937. /**
  97938. * The pointerwheel event is fired when a mouse wheel has been rotated.
  97939. */
  97940. static readonly POINTERWHEEL: number;
  97941. /**
  97942. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  97943. */
  97944. static readonly POINTERPICK: number;
  97945. /**
  97946. * The pointertap event is fired when a the object has been touched and released without drag.
  97947. */
  97948. static readonly POINTERTAP: number;
  97949. /**
  97950. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  97951. */
  97952. static readonly POINTERDOUBLETAP: number;
  97953. }
  97954. /**
  97955. * Base class of pointer info types.
  97956. */
  97957. export class PointerInfoBase {
  97958. /**
  97959. * Defines the type of event (PointerEventTypes)
  97960. */
  97961. type: number;
  97962. /**
  97963. * Defines the related dom event
  97964. */
  97965. event: PointerEvent | MouseWheelEvent;
  97966. /**
  97967. * Instantiates the base class of pointers info.
  97968. * @param type Defines the type of event (PointerEventTypes)
  97969. * @param event Defines the related dom event
  97970. */
  97971. constructor(
  97972. /**
  97973. * Defines the type of event (PointerEventTypes)
  97974. */
  97975. type: number,
  97976. /**
  97977. * Defines the related dom event
  97978. */
  97979. event: PointerEvent | MouseWheelEvent);
  97980. }
  97981. /**
  97982. * This class is used to store pointer related info for the onPrePointerObservable event.
  97983. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  97984. */
  97985. export class PointerInfoPre extends PointerInfoBase {
  97986. /**
  97987. * Ray from a pointer if availible (eg. 6dof controller)
  97988. */
  97989. ray: Nullable<Ray>;
  97990. /**
  97991. * Defines the local position of the pointer on the canvas.
  97992. */
  97993. localPosition: Vector2;
  97994. /**
  97995. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  97996. */
  97997. skipOnPointerObservable: boolean;
  97998. /**
  97999. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  98000. * @param type Defines the type of event (PointerEventTypes)
  98001. * @param event Defines the related dom event
  98002. * @param localX Defines the local x coordinates of the pointer when the event occured
  98003. * @param localY Defines the local y coordinates of the pointer when the event occured
  98004. */
  98005. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  98006. }
  98007. /**
  98008. * This type contains all the data related to a pointer event in Babylon.js.
  98009. * 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.
  98010. */
  98011. export class PointerInfo extends PointerInfoBase {
  98012. /**
  98013. * Defines the picking info associated to the info (if any)\
  98014. */
  98015. pickInfo: Nullable<PickingInfo>;
  98016. /**
  98017. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  98018. * @param type Defines the type of event (PointerEventTypes)
  98019. * @param event Defines the related dom event
  98020. * @param pickInfo Defines the picking info associated to the info (if any)\
  98021. */
  98022. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  98023. /**
  98024. * Defines the picking info associated to the info (if any)\
  98025. */
  98026. pickInfo: Nullable<PickingInfo>);
  98027. }
  98028. /**
  98029. * Data relating to a touch event on the screen.
  98030. */
  98031. export interface PointerTouch {
  98032. /**
  98033. * X coordinate of touch.
  98034. */
  98035. x: number;
  98036. /**
  98037. * Y coordinate of touch.
  98038. */
  98039. y: number;
  98040. /**
  98041. * Id of touch. Unique for each finger.
  98042. */
  98043. pointerId: number;
  98044. /**
  98045. * Event type passed from DOM.
  98046. */
  98047. type: any;
  98048. }
  98049. }
  98050. declare module BABYLON {
  98051. /**
  98052. * Manage the mouse inputs to control the movement of a free camera.
  98053. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  98054. */
  98055. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  98056. /**
  98057. * Define if touch is enabled in the mouse input
  98058. */
  98059. touchEnabled: boolean;
  98060. /**
  98061. * Defines the camera the input is attached to.
  98062. */
  98063. camera: FreeCamera;
  98064. /**
  98065. * Defines the buttons associated with the input to handle camera move.
  98066. */
  98067. buttons: number[];
  98068. /**
  98069. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  98070. */
  98071. angularSensibility: number;
  98072. private _pointerInput;
  98073. private _onMouseMove;
  98074. private _observer;
  98075. private previousPosition;
  98076. /**
  98077. * Observable for when a pointer move event occurs containing the move offset
  98078. */
  98079. onPointerMovedObservable: Observable<{
  98080. offsetX: number;
  98081. offsetY: number;
  98082. }>;
  98083. /**
  98084. * @hidden
  98085. * If the camera should be rotated automatically based on pointer movement
  98086. */
  98087. _allowCameraRotation: boolean;
  98088. /**
  98089. * Manage the mouse inputs to control the movement of a free camera.
  98090. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  98091. * @param touchEnabled Defines if touch is enabled or not
  98092. */
  98093. constructor(
  98094. /**
  98095. * Define if touch is enabled in the mouse input
  98096. */
  98097. touchEnabled?: boolean);
  98098. /**
  98099. * Attach the input controls to a specific dom element to get the input from.
  98100. * @param element Defines the element the controls should be listened from
  98101. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98102. */
  98103. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98104. /**
  98105. * Called on JS contextmenu event.
  98106. * Override this method to provide functionality.
  98107. */
  98108. protected onContextMenu(evt: PointerEvent): void;
  98109. /**
  98110. * Detach the current controls from the specified dom element.
  98111. * @param element Defines the element to stop listening the inputs from
  98112. */
  98113. detachControl(element: Nullable<HTMLElement>): void;
  98114. /**
  98115. * Gets the class name of the current intput.
  98116. * @returns the class name
  98117. */
  98118. getClassName(): string;
  98119. /**
  98120. * Get the friendly name associated with the input class.
  98121. * @returns the input friendly name
  98122. */
  98123. getSimpleName(): string;
  98124. }
  98125. }
  98126. declare module BABYLON {
  98127. /**
  98128. * Manage the touch inputs to control the movement of a free camera.
  98129. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  98130. */
  98131. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  98132. /**
  98133. * Defines the camera the input is attached to.
  98134. */
  98135. camera: FreeCamera;
  98136. /**
  98137. * Defines the touch sensibility for rotation.
  98138. * The higher the faster.
  98139. */
  98140. touchAngularSensibility: number;
  98141. /**
  98142. * Defines the touch sensibility for move.
  98143. * The higher the faster.
  98144. */
  98145. touchMoveSensibility: number;
  98146. private _offsetX;
  98147. private _offsetY;
  98148. private _pointerPressed;
  98149. private _pointerInput;
  98150. private _observer;
  98151. private _onLostFocus;
  98152. /**
  98153. * Attach the input controls to a specific dom element to get the input from.
  98154. * @param element Defines the element the controls should be listened from
  98155. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98156. */
  98157. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98158. /**
  98159. * Detach the current controls from the specified dom element.
  98160. * @param element Defines the element to stop listening the inputs from
  98161. */
  98162. detachControl(element: Nullable<HTMLElement>): void;
  98163. /**
  98164. * Update the current camera state depending on the inputs that have been used this frame.
  98165. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  98166. */
  98167. checkInputs(): void;
  98168. /**
  98169. * Gets the class name of the current intput.
  98170. * @returns the class name
  98171. */
  98172. getClassName(): string;
  98173. /**
  98174. * Get the friendly name associated with the input class.
  98175. * @returns the input friendly name
  98176. */
  98177. getSimpleName(): string;
  98178. }
  98179. }
  98180. declare module BABYLON {
  98181. /**
  98182. * Default Inputs manager for the FreeCamera.
  98183. * It groups all the default supported inputs for ease of use.
  98184. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  98185. */
  98186. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  98187. /**
  98188. * @hidden
  98189. */
  98190. _mouseInput: Nullable<FreeCameraMouseInput>;
  98191. /**
  98192. * Instantiates a new FreeCameraInputsManager.
  98193. * @param camera Defines the camera the inputs belong to
  98194. */
  98195. constructor(camera: FreeCamera);
  98196. /**
  98197. * Add keyboard input support to the input manager.
  98198. * @returns the current input manager
  98199. */
  98200. addKeyboard(): FreeCameraInputsManager;
  98201. /**
  98202. * Add mouse input support to the input manager.
  98203. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  98204. * @returns the current input manager
  98205. */
  98206. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  98207. /**
  98208. * Removes the mouse input support from the manager
  98209. * @returns the current input manager
  98210. */
  98211. removeMouse(): FreeCameraInputsManager;
  98212. /**
  98213. * Add touch input support to the input manager.
  98214. * @returns the current input manager
  98215. */
  98216. addTouch(): FreeCameraInputsManager;
  98217. /**
  98218. * Remove all attached input methods from a camera
  98219. */
  98220. clear(): void;
  98221. }
  98222. }
  98223. declare module BABYLON {
  98224. /**
  98225. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  98226. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  98227. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  98228. */
  98229. export class FreeCamera extends TargetCamera {
  98230. /**
  98231. * Define the collision ellipsoid of the camera.
  98232. * This is helpful to simulate a camera body like the player body around the camera
  98233. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  98234. */
  98235. ellipsoid: Vector3;
  98236. /**
  98237. * Define an offset for the position of the ellipsoid around the camera.
  98238. * This can be helpful to determine the center of the body near the gravity center of the body
  98239. * instead of its head.
  98240. */
  98241. ellipsoidOffset: Vector3;
  98242. /**
  98243. * Enable or disable collisions of the camera with the rest of the scene objects.
  98244. */
  98245. checkCollisions: boolean;
  98246. /**
  98247. * Enable or disable gravity on the camera.
  98248. */
  98249. applyGravity: boolean;
  98250. /**
  98251. * Define the input manager associated to the camera.
  98252. */
  98253. inputs: FreeCameraInputsManager;
  98254. /**
  98255. * Gets the input sensibility for a mouse input. (default is 2000.0)
  98256. * Higher values reduce sensitivity.
  98257. */
  98258. get angularSensibility(): number;
  98259. /**
  98260. * Sets the input sensibility for a mouse input. (default is 2000.0)
  98261. * Higher values reduce sensitivity.
  98262. */
  98263. set angularSensibility(value: number);
  98264. /**
  98265. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  98266. */
  98267. get keysUp(): number[];
  98268. set keysUp(value: number[]);
  98269. /**
  98270. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  98271. */
  98272. get keysUpward(): number[];
  98273. set keysUpward(value: number[]);
  98274. /**
  98275. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  98276. */
  98277. get keysDown(): number[];
  98278. set keysDown(value: number[]);
  98279. /**
  98280. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  98281. */
  98282. get keysDownward(): number[];
  98283. set keysDownward(value: number[]);
  98284. /**
  98285. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  98286. */
  98287. get keysLeft(): number[];
  98288. set keysLeft(value: number[]);
  98289. /**
  98290. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  98291. */
  98292. get keysRight(): number[];
  98293. set keysRight(value: number[]);
  98294. /**
  98295. * Event raised when the camera collide with a mesh in the scene.
  98296. */
  98297. onCollide: (collidedMesh: AbstractMesh) => void;
  98298. private _collider;
  98299. private _needMoveForGravity;
  98300. private _oldPosition;
  98301. private _diffPosition;
  98302. private _newPosition;
  98303. /** @hidden */
  98304. _localDirection: Vector3;
  98305. /** @hidden */
  98306. _transformedDirection: Vector3;
  98307. /**
  98308. * Instantiates a Free Camera.
  98309. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  98310. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  98311. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  98312. * @param name Define the name of the camera in the scene
  98313. * @param position Define the start position of the camera in the scene
  98314. * @param scene Define the scene the camera belongs to
  98315. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  98316. */
  98317. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  98318. /**
  98319. * Attached controls to the current camera.
  98320. * @param element Defines the element the controls should be listened from
  98321. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98322. */
  98323. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98324. /**
  98325. * Detach the current controls from the camera.
  98326. * The camera will stop reacting to inputs.
  98327. * @param element Defines the element to stop listening the inputs from
  98328. */
  98329. detachControl(element: HTMLElement): void;
  98330. private _collisionMask;
  98331. /**
  98332. * Define a collision mask to limit the list of object the camera can collide with
  98333. */
  98334. get collisionMask(): number;
  98335. set collisionMask(mask: number);
  98336. /** @hidden */
  98337. _collideWithWorld(displacement: Vector3): void;
  98338. private _onCollisionPositionChange;
  98339. /** @hidden */
  98340. _checkInputs(): void;
  98341. /** @hidden */
  98342. _decideIfNeedsToMove(): boolean;
  98343. /** @hidden */
  98344. _updatePosition(): void;
  98345. /**
  98346. * Destroy the camera and release the current resources hold by it.
  98347. */
  98348. dispose(): void;
  98349. /**
  98350. * Gets the current object class name.
  98351. * @return the class name
  98352. */
  98353. getClassName(): string;
  98354. }
  98355. }
  98356. declare module BABYLON {
  98357. /**
  98358. * Represents a gamepad control stick position
  98359. */
  98360. export class StickValues {
  98361. /**
  98362. * The x component of the control stick
  98363. */
  98364. x: number;
  98365. /**
  98366. * The y component of the control stick
  98367. */
  98368. y: number;
  98369. /**
  98370. * Initializes the gamepad x and y control stick values
  98371. * @param x The x component of the gamepad control stick value
  98372. * @param y The y component of the gamepad control stick value
  98373. */
  98374. constructor(
  98375. /**
  98376. * The x component of the control stick
  98377. */
  98378. x: number,
  98379. /**
  98380. * The y component of the control stick
  98381. */
  98382. y: number);
  98383. }
  98384. /**
  98385. * An interface which manages callbacks for gamepad button changes
  98386. */
  98387. export interface GamepadButtonChanges {
  98388. /**
  98389. * Called when a gamepad has been changed
  98390. */
  98391. changed: boolean;
  98392. /**
  98393. * Called when a gamepad press event has been triggered
  98394. */
  98395. pressChanged: boolean;
  98396. /**
  98397. * Called when a touch event has been triggered
  98398. */
  98399. touchChanged: boolean;
  98400. /**
  98401. * Called when a value has changed
  98402. */
  98403. valueChanged: boolean;
  98404. }
  98405. /**
  98406. * Represents a gamepad
  98407. */
  98408. export class Gamepad {
  98409. /**
  98410. * The id of the gamepad
  98411. */
  98412. id: string;
  98413. /**
  98414. * The index of the gamepad
  98415. */
  98416. index: number;
  98417. /**
  98418. * The browser gamepad
  98419. */
  98420. browserGamepad: any;
  98421. /**
  98422. * Specifies what type of gamepad this represents
  98423. */
  98424. type: number;
  98425. private _leftStick;
  98426. private _rightStick;
  98427. /** @hidden */
  98428. _isConnected: boolean;
  98429. private _leftStickAxisX;
  98430. private _leftStickAxisY;
  98431. private _rightStickAxisX;
  98432. private _rightStickAxisY;
  98433. /**
  98434. * Triggered when the left control stick has been changed
  98435. */
  98436. private _onleftstickchanged;
  98437. /**
  98438. * Triggered when the right control stick has been changed
  98439. */
  98440. private _onrightstickchanged;
  98441. /**
  98442. * Represents a gamepad controller
  98443. */
  98444. static GAMEPAD: number;
  98445. /**
  98446. * Represents a generic controller
  98447. */
  98448. static GENERIC: number;
  98449. /**
  98450. * Represents an XBox controller
  98451. */
  98452. static XBOX: number;
  98453. /**
  98454. * Represents a pose-enabled controller
  98455. */
  98456. static POSE_ENABLED: number;
  98457. /**
  98458. * Represents an Dual Shock controller
  98459. */
  98460. static DUALSHOCK: number;
  98461. /**
  98462. * Specifies whether the left control stick should be Y-inverted
  98463. */
  98464. protected _invertLeftStickY: boolean;
  98465. /**
  98466. * Specifies if the gamepad has been connected
  98467. */
  98468. get isConnected(): boolean;
  98469. /**
  98470. * Initializes the gamepad
  98471. * @param id The id of the gamepad
  98472. * @param index The index of the gamepad
  98473. * @param browserGamepad The browser gamepad
  98474. * @param leftStickX The x component of the left joystick
  98475. * @param leftStickY The y component of the left joystick
  98476. * @param rightStickX The x component of the right joystick
  98477. * @param rightStickY The y component of the right joystick
  98478. */
  98479. constructor(
  98480. /**
  98481. * The id of the gamepad
  98482. */
  98483. id: string,
  98484. /**
  98485. * The index of the gamepad
  98486. */
  98487. index: number,
  98488. /**
  98489. * The browser gamepad
  98490. */
  98491. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  98492. /**
  98493. * Callback triggered when the left joystick has changed
  98494. * @param callback
  98495. */
  98496. onleftstickchanged(callback: (values: StickValues) => void): void;
  98497. /**
  98498. * Callback triggered when the right joystick has changed
  98499. * @param callback
  98500. */
  98501. onrightstickchanged(callback: (values: StickValues) => void): void;
  98502. /**
  98503. * Gets the left joystick
  98504. */
  98505. get leftStick(): StickValues;
  98506. /**
  98507. * Sets the left joystick values
  98508. */
  98509. set leftStick(newValues: StickValues);
  98510. /**
  98511. * Gets the right joystick
  98512. */
  98513. get rightStick(): StickValues;
  98514. /**
  98515. * Sets the right joystick value
  98516. */
  98517. set rightStick(newValues: StickValues);
  98518. /**
  98519. * Updates the gamepad joystick positions
  98520. */
  98521. update(): void;
  98522. /**
  98523. * Disposes the gamepad
  98524. */
  98525. dispose(): void;
  98526. }
  98527. /**
  98528. * Represents a generic gamepad
  98529. */
  98530. export class GenericPad extends Gamepad {
  98531. private _buttons;
  98532. private _onbuttondown;
  98533. private _onbuttonup;
  98534. /**
  98535. * Observable triggered when a button has been pressed
  98536. */
  98537. onButtonDownObservable: Observable<number>;
  98538. /**
  98539. * Observable triggered when a button has been released
  98540. */
  98541. onButtonUpObservable: Observable<number>;
  98542. /**
  98543. * Callback triggered when a button has been pressed
  98544. * @param callback Called when a button has been pressed
  98545. */
  98546. onbuttondown(callback: (buttonPressed: number) => void): void;
  98547. /**
  98548. * Callback triggered when a button has been released
  98549. * @param callback Called when a button has been released
  98550. */
  98551. onbuttonup(callback: (buttonReleased: number) => void): void;
  98552. /**
  98553. * Initializes the generic gamepad
  98554. * @param id The id of the generic gamepad
  98555. * @param index The index of the generic gamepad
  98556. * @param browserGamepad The browser gamepad
  98557. */
  98558. constructor(id: string, index: number, browserGamepad: any);
  98559. private _setButtonValue;
  98560. /**
  98561. * Updates the generic gamepad
  98562. */
  98563. update(): void;
  98564. /**
  98565. * Disposes the generic gamepad
  98566. */
  98567. dispose(): void;
  98568. }
  98569. }
  98570. declare module BABYLON {
  98571. /**
  98572. * Defines the types of pose enabled controllers that are supported
  98573. */
  98574. export enum PoseEnabledControllerType {
  98575. /**
  98576. * HTC Vive
  98577. */
  98578. VIVE = 0,
  98579. /**
  98580. * Oculus Rift
  98581. */
  98582. OCULUS = 1,
  98583. /**
  98584. * Windows mixed reality
  98585. */
  98586. WINDOWS = 2,
  98587. /**
  98588. * Samsung gear VR
  98589. */
  98590. GEAR_VR = 3,
  98591. /**
  98592. * Google Daydream
  98593. */
  98594. DAYDREAM = 4,
  98595. /**
  98596. * Generic
  98597. */
  98598. GENERIC = 5
  98599. }
  98600. /**
  98601. * Defines the MutableGamepadButton interface for the state of a gamepad button
  98602. */
  98603. export interface MutableGamepadButton {
  98604. /**
  98605. * Value of the button/trigger
  98606. */
  98607. value: number;
  98608. /**
  98609. * If the button/trigger is currently touched
  98610. */
  98611. touched: boolean;
  98612. /**
  98613. * If the button/trigger is currently pressed
  98614. */
  98615. pressed: boolean;
  98616. }
  98617. /**
  98618. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  98619. * @hidden
  98620. */
  98621. export interface ExtendedGamepadButton extends GamepadButton {
  98622. /**
  98623. * If the button/trigger is currently pressed
  98624. */
  98625. readonly pressed: boolean;
  98626. /**
  98627. * If the button/trigger is currently touched
  98628. */
  98629. readonly touched: boolean;
  98630. /**
  98631. * Value of the button/trigger
  98632. */
  98633. readonly value: number;
  98634. }
  98635. /** @hidden */
  98636. export interface _GamePadFactory {
  98637. /**
  98638. * Returns whether or not the current gamepad can be created for this type of controller.
  98639. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  98640. * @returns true if it can be created, otherwise false
  98641. */
  98642. canCreate(gamepadInfo: any): boolean;
  98643. /**
  98644. * Creates a new instance of the Gamepad.
  98645. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  98646. * @returns the new gamepad instance
  98647. */
  98648. create(gamepadInfo: any): Gamepad;
  98649. }
  98650. /**
  98651. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  98652. */
  98653. export class PoseEnabledControllerHelper {
  98654. /** @hidden */
  98655. static _ControllerFactories: _GamePadFactory[];
  98656. /** @hidden */
  98657. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  98658. /**
  98659. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  98660. * @param vrGamepad the gamepad to initialized
  98661. * @returns a vr controller of the type the gamepad identified as
  98662. */
  98663. static InitiateController(vrGamepad: any): Gamepad;
  98664. }
  98665. /**
  98666. * Defines the PoseEnabledController object that contains state of a vr capable controller
  98667. */
  98668. export class PoseEnabledController extends Gamepad implements PoseControlled {
  98669. /**
  98670. * If the controller is used in a webXR session
  98671. */
  98672. isXR: boolean;
  98673. private _deviceRoomPosition;
  98674. private _deviceRoomRotationQuaternion;
  98675. /**
  98676. * The device position in babylon space
  98677. */
  98678. devicePosition: Vector3;
  98679. /**
  98680. * The device rotation in babylon space
  98681. */
  98682. deviceRotationQuaternion: Quaternion;
  98683. /**
  98684. * The scale factor of the device in babylon space
  98685. */
  98686. deviceScaleFactor: number;
  98687. /**
  98688. * (Likely devicePosition should be used instead) The device position in its room space
  98689. */
  98690. position: Vector3;
  98691. /**
  98692. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  98693. */
  98694. rotationQuaternion: Quaternion;
  98695. /**
  98696. * The type of controller (Eg. Windows mixed reality)
  98697. */
  98698. controllerType: PoseEnabledControllerType;
  98699. protected _calculatedPosition: Vector3;
  98700. private _calculatedRotation;
  98701. /**
  98702. * The raw pose from the device
  98703. */
  98704. rawPose: DevicePose;
  98705. private _trackPosition;
  98706. private _maxRotationDistFromHeadset;
  98707. private _draggedRoomRotation;
  98708. /**
  98709. * @hidden
  98710. */
  98711. _disableTrackPosition(fixedPosition: Vector3): void;
  98712. /**
  98713. * Internal, the mesh attached to the controller
  98714. * @hidden
  98715. */
  98716. _mesh: Nullable<AbstractMesh>;
  98717. private _poseControlledCamera;
  98718. private _leftHandSystemQuaternion;
  98719. /**
  98720. * Internal, matrix used to convert room space to babylon space
  98721. * @hidden
  98722. */
  98723. _deviceToWorld: Matrix;
  98724. /**
  98725. * Node to be used when casting a ray from the controller
  98726. * @hidden
  98727. */
  98728. _pointingPoseNode: Nullable<TransformNode>;
  98729. /**
  98730. * Name of the child mesh that can be used to cast a ray from the controller
  98731. */
  98732. static readonly POINTING_POSE: string;
  98733. /**
  98734. * Creates a new PoseEnabledController from a gamepad
  98735. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  98736. */
  98737. constructor(browserGamepad: any);
  98738. private _workingMatrix;
  98739. /**
  98740. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  98741. */
  98742. update(): void;
  98743. /**
  98744. * Updates only the pose device and mesh without doing any button event checking
  98745. */
  98746. protected _updatePoseAndMesh(): void;
  98747. /**
  98748. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  98749. * @param poseData raw pose fromthe device
  98750. */
  98751. updateFromDevice(poseData: DevicePose): void;
  98752. /**
  98753. * @hidden
  98754. */
  98755. _meshAttachedObservable: Observable<AbstractMesh>;
  98756. /**
  98757. * Attaches a mesh to the controller
  98758. * @param mesh the mesh to be attached
  98759. */
  98760. attachToMesh(mesh: AbstractMesh): void;
  98761. /**
  98762. * Attaches the controllers mesh to a camera
  98763. * @param camera the camera the mesh should be attached to
  98764. */
  98765. attachToPoseControlledCamera(camera: TargetCamera): void;
  98766. /**
  98767. * Disposes of the controller
  98768. */
  98769. dispose(): void;
  98770. /**
  98771. * The mesh that is attached to the controller
  98772. */
  98773. get mesh(): Nullable<AbstractMesh>;
  98774. /**
  98775. * Gets the ray of the controller in the direction the controller is pointing
  98776. * @param length the length the resulting ray should be
  98777. * @returns a ray in the direction the controller is pointing
  98778. */
  98779. getForwardRay(length?: number): Ray;
  98780. }
  98781. }
  98782. declare module BABYLON {
  98783. /**
  98784. * Defines the WebVRController object that represents controllers tracked in 3D space
  98785. */
  98786. export abstract class WebVRController extends PoseEnabledController {
  98787. /**
  98788. * Internal, the default controller model for the controller
  98789. */
  98790. protected _defaultModel: Nullable<AbstractMesh>;
  98791. /**
  98792. * Fired when the trigger state has changed
  98793. */
  98794. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  98795. /**
  98796. * Fired when the main button state has changed
  98797. */
  98798. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98799. /**
  98800. * Fired when the secondary button state has changed
  98801. */
  98802. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98803. /**
  98804. * Fired when the pad state has changed
  98805. */
  98806. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  98807. /**
  98808. * Fired when controllers stick values have changed
  98809. */
  98810. onPadValuesChangedObservable: Observable<StickValues>;
  98811. /**
  98812. * Array of button availible on the controller
  98813. */
  98814. protected _buttons: Array<MutableGamepadButton>;
  98815. private _onButtonStateChange;
  98816. /**
  98817. * Fired when a controller button's state has changed
  98818. * @param callback the callback containing the button that was modified
  98819. */
  98820. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  98821. /**
  98822. * X and Y axis corresponding to the controllers joystick
  98823. */
  98824. pad: StickValues;
  98825. /**
  98826. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  98827. */
  98828. hand: string;
  98829. /**
  98830. * The default controller model for the controller
  98831. */
  98832. get defaultModel(): Nullable<AbstractMesh>;
  98833. /**
  98834. * Creates a new WebVRController from a gamepad
  98835. * @param vrGamepad the gamepad that the WebVRController should be created from
  98836. */
  98837. constructor(vrGamepad: any);
  98838. /**
  98839. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  98840. */
  98841. update(): void;
  98842. /**
  98843. * Function to be called when a button is modified
  98844. */
  98845. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98846. /**
  98847. * Loads a mesh and attaches it to the controller
  98848. * @param scene the scene the mesh should be added to
  98849. * @param meshLoaded callback for when the mesh has been loaded
  98850. */
  98851. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  98852. private _setButtonValue;
  98853. private _changes;
  98854. private _checkChanges;
  98855. /**
  98856. * Disposes of th webVRCOntroller
  98857. */
  98858. dispose(): void;
  98859. }
  98860. }
  98861. declare module BABYLON {
  98862. /**
  98863. * The HemisphericLight simulates the ambient environment light,
  98864. * so the passed direction is the light reflection direction, not the incoming direction.
  98865. */
  98866. export class HemisphericLight extends Light {
  98867. /**
  98868. * The groundColor is the light in the opposite direction to the one specified during creation.
  98869. * 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.
  98870. */
  98871. groundColor: Color3;
  98872. /**
  98873. * The light reflection direction, not the incoming direction.
  98874. */
  98875. direction: Vector3;
  98876. /**
  98877. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  98878. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  98879. * The HemisphericLight can't cast shadows.
  98880. * Documentation : https://doc.babylonjs.com/babylon101/lights
  98881. * @param name The friendly name of the light
  98882. * @param direction The direction of the light reflection
  98883. * @param scene The scene the light belongs to
  98884. */
  98885. constructor(name: string, direction: Vector3, scene: Scene);
  98886. protected _buildUniformLayout(): void;
  98887. /**
  98888. * Returns the string "HemisphericLight".
  98889. * @return The class name
  98890. */
  98891. getClassName(): string;
  98892. /**
  98893. * Sets the HemisphericLight direction towards the passed target (Vector3).
  98894. * Returns the updated direction.
  98895. * @param target The target the direction should point to
  98896. * @return The computed direction
  98897. */
  98898. setDirectionToTarget(target: Vector3): Vector3;
  98899. /**
  98900. * Returns the shadow generator associated to the light.
  98901. * @returns Always null for hemispheric lights because it does not support shadows.
  98902. */
  98903. getShadowGenerator(): Nullable<IShadowGenerator>;
  98904. /**
  98905. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  98906. * @param effect The effect to update
  98907. * @param lightIndex The index of the light in the effect to update
  98908. * @returns The hemispheric light
  98909. */
  98910. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  98911. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  98912. /**
  98913. * Computes the world matrix of the node
  98914. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  98915. * @param useWasUpdatedFlag defines a reserved property
  98916. * @returns the world matrix
  98917. */
  98918. computeWorldMatrix(): Matrix;
  98919. /**
  98920. * Returns the integer 3.
  98921. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  98922. */
  98923. getTypeID(): number;
  98924. /**
  98925. * Prepares the list of defines specific to the light type.
  98926. * @param defines the list of defines
  98927. * @param lightIndex defines the index of the light for the effect
  98928. */
  98929. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  98930. }
  98931. }
  98932. declare module BABYLON {
  98933. /** @hidden */
  98934. export var vrMultiviewToSingleviewPixelShader: {
  98935. name: string;
  98936. shader: string;
  98937. };
  98938. }
  98939. declare module BABYLON {
  98940. /**
  98941. * Renders to multiple views with a single draw call
  98942. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  98943. */
  98944. export class MultiviewRenderTarget extends RenderTargetTexture {
  98945. /**
  98946. * Creates a multiview render target
  98947. * @param scene scene used with the render target
  98948. * @param size the size of the render target (used for each view)
  98949. */
  98950. constructor(scene: Scene, size?: number | {
  98951. width: number;
  98952. height: number;
  98953. } | {
  98954. ratio: number;
  98955. });
  98956. /**
  98957. * @hidden
  98958. * @param faceIndex the face index, if its a cube texture
  98959. */
  98960. _bindFrameBuffer(faceIndex?: number): void;
  98961. /**
  98962. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  98963. * @returns the view count
  98964. */
  98965. getViewCount(): number;
  98966. }
  98967. }
  98968. declare module BABYLON {
  98969. interface Engine {
  98970. /**
  98971. * Creates a new multiview render target
  98972. * @param width defines the width of the texture
  98973. * @param height defines the height of the texture
  98974. * @returns the created multiview texture
  98975. */
  98976. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  98977. /**
  98978. * Binds a multiview framebuffer to be drawn to
  98979. * @param multiviewTexture texture to bind
  98980. */
  98981. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  98982. }
  98983. interface Camera {
  98984. /**
  98985. * @hidden
  98986. * 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)
  98987. */
  98988. _useMultiviewToSingleView: boolean;
  98989. /**
  98990. * @hidden
  98991. * 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)
  98992. */
  98993. _multiviewTexture: Nullable<RenderTargetTexture>;
  98994. /**
  98995. * @hidden
  98996. * ensures the multiview texture of the camera exists and has the specified width/height
  98997. * @param width height to set on the multiview texture
  98998. * @param height width to set on the multiview texture
  98999. */
  99000. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  99001. }
  99002. interface Scene {
  99003. /** @hidden */
  99004. _transformMatrixR: Matrix;
  99005. /** @hidden */
  99006. _multiviewSceneUbo: Nullable<UniformBuffer>;
  99007. /** @hidden */
  99008. _createMultiviewUbo(): void;
  99009. /** @hidden */
  99010. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  99011. /** @hidden */
  99012. _renderMultiviewToSingleView(camera: Camera): void;
  99013. }
  99014. }
  99015. declare module BABYLON {
  99016. /**
  99017. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  99018. * This will not be used for webXR as it supports displaying texture arrays directly
  99019. */
  99020. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  99021. /**
  99022. * Gets a string identifying the name of the class
  99023. * @returns "VRMultiviewToSingleviewPostProcess" string
  99024. */
  99025. getClassName(): string;
  99026. /**
  99027. * Initializes a VRMultiviewToSingleview
  99028. * @param name name of the post process
  99029. * @param camera camera to be applied to
  99030. * @param scaleFactor scaling factor to the size of the output texture
  99031. */
  99032. constructor(name: string, camera: Camera, scaleFactor: number);
  99033. }
  99034. }
  99035. declare module BABYLON {
  99036. /**
  99037. * Interface used to define additional presentation attributes
  99038. */
  99039. export interface IVRPresentationAttributes {
  99040. /**
  99041. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  99042. */
  99043. highRefreshRate: boolean;
  99044. /**
  99045. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  99046. */
  99047. foveationLevel: number;
  99048. }
  99049. interface Engine {
  99050. /** @hidden */
  99051. _vrDisplay: any;
  99052. /** @hidden */
  99053. _vrSupported: boolean;
  99054. /** @hidden */
  99055. _oldSize: Size;
  99056. /** @hidden */
  99057. _oldHardwareScaleFactor: number;
  99058. /** @hidden */
  99059. _vrExclusivePointerMode: boolean;
  99060. /** @hidden */
  99061. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  99062. /** @hidden */
  99063. _onVRDisplayPointerRestricted: () => void;
  99064. /** @hidden */
  99065. _onVRDisplayPointerUnrestricted: () => void;
  99066. /** @hidden */
  99067. _onVrDisplayConnect: Nullable<(display: any) => void>;
  99068. /** @hidden */
  99069. _onVrDisplayDisconnect: Nullable<() => void>;
  99070. /** @hidden */
  99071. _onVrDisplayPresentChange: Nullable<() => void>;
  99072. /**
  99073. * Observable signaled when VR display mode changes
  99074. */
  99075. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  99076. /**
  99077. * Observable signaled when VR request present is complete
  99078. */
  99079. onVRRequestPresentComplete: Observable<boolean>;
  99080. /**
  99081. * Observable signaled when VR request present starts
  99082. */
  99083. onVRRequestPresentStart: Observable<Engine>;
  99084. /**
  99085. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  99086. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  99087. */
  99088. isInVRExclusivePointerMode: boolean;
  99089. /**
  99090. * Gets a boolean indicating if a webVR device was detected
  99091. * @returns true if a webVR device was detected
  99092. */
  99093. isVRDevicePresent(): boolean;
  99094. /**
  99095. * Gets the current webVR device
  99096. * @returns the current webVR device (or null)
  99097. */
  99098. getVRDevice(): any;
  99099. /**
  99100. * Initializes a webVR display and starts listening to display change events
  99101. * The onVRDisplayChangedObservable will be notified upon these changes
  99102. * @returns A promise containing a VRDisplay and if vr is supported
  99103. */
  99104. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  99105. /** @hidden */
  99106. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  99107. /**
  99108. * Gets or sets the presentation attributes used to configure VR rendering
  99109. */
  99110. vrPresentationAttributes?: IVRPresentationAttributes;
  99111. /**
  99112. * Call this function to switch to webVR mode
  99113. * Will do nothing if webVR is not supported or if there is no webVR device
  99114. * @param options the webvr options provided to the camera. mainly used for multiview
  99115. * @see https://doc.babylonjs.com/how_to/webvr_camera
  99116. */
  99117. enableVR(options: WebVROptions): void;
  99118. /** @hidden */
  99119. _onVRFullScreenTriggered(): void;
  99120. }
  99121. }
  99122. declare module BABYLON {
  99123. /**
  99124. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  99125. * IMPORTANT!! The data is right-hand data.
  99126. * @export
  99127. * @interface DevicePose
  99128. */
  99129. export interface DevicePose {
  99130. /**
  99131. * The position of the device, values in array are [x,y,z].
  99132. */
  99133. readonly position: Nullable<Float32Array>;
  99134. /**
  99135. * The linearVelocity of the device, values in array are [x,y,z].
  99136. */
  99137. readonly linearVelocity: Nullable<Float32Array>;
  99138. /**
  99139. * The linearAcceleration of the device, values in array are [x,y,z].
  99140. */
  99141. readonly linearAcceleration: Nullable<Float32Array>;
  99142. /**
  99143. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  99144. */
  99145. readonly orientation: Nullable<Float32Array>;
  99146. /**
  99147. * The angularVelocity of the device, values in array are [x,y,z].
  99148. */
  99149. readonly angularVelocity: Nullable<Float32Array>;
  99150. /**
  99151. * The angularAcceleration of the device, values in array are [x,y,z].
  99152. */
  99153. readonly angularAcceleration: Nullable<Float32Array>;
  99154. }
  99155. /**
  99156. * Interface representing a pose controlled object in Babylon.
  99157. * A pose controlled object has both regular pose values as well as pose values
  99158. * from an external device such as a VR head mounted display
  99159. */
  99160. export interface PoseControlled {
  99161. /**
  99162. * The position of the object in babylon space.
  99163. */
  99164. position: Vector3;
  99165. /**
  99166. * The rotation quaternion of the object in babylon space.
  99167. */
  99168. rotationQuaternion: Quaternion;
  99169. /**
  99170. * The position of the device in babylon space.
  99171. */
  99172. devicePosition?: Vector3;
  99173. /**
  99174. * The rotation quaternion of the device in babylon space.
  99175. */
  99176. deviceRotationQuaternion: Quaternion;
  99177. /**
  99178. * The raw pose coming from the device.
  99179. */
  99180. rawPose: Nullable<DevicePose>;
  99181. /**
  99182. * The scale of the device to be used when translating from device space to babylon space.
  99183. */
  99184. deviceScaleFactor: number;
  99185. /**
  99186. * Updates the poseControlled values based on the input device pose.
  99187. * @param poseData the pose data to update the object with
  99188. */
  99189. updateFromDevice(poseData: DevicePose): void;
  99190. }
  99191. /**
  99192. * Set of options to customize the webVRCamera
  99193. */
  99194. export interface WebVROptions {
  99195. /**
  99196. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  99197. */
  99198. trackPosition?: boolean;
  99199. /**
  99200. * Sets the scale of the vrDevice in babylon space. (default: 1)
  99201. */
  99202. positionScale?: number;
  99203. /**
  99204. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  99205. */
  99206. displayName?: string;
  99207. /**
  99208. * Should the native controller meshes be initialized. (default: true)
  99209. */
  99210. controllerMeshes?: boolean;
  99211. /**
  99212. * Creating a default HemiLight only on controllers. (default: true)
  99213. */
  99214. defaultLightingOnControllers?: boolean;
  99215. /**
  99216. * If you don't want to use the default VR button of the helper. (default: false)
  99217. */
  99218. useCustomVRButton?: boolean;
  99219. /**
  99220. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  99221. */
  99222. customVRButton?: HTMLButtonElement;
  99223. /**
  99224. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  99225. */
  99226. rayLength?: number;
  99227. /**
  99228. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  99229. */
  99230. defaultHeight?: number;
  99231. /**
  99232. * If multiview should be used if availible (default: false)
  99233. */
  99234. useMultiview?: boolean;
  99235. }
  99236. /**
  99237. * This represents a WebVR camera.
  99238. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  99239. * @example https://doc.babylonjs.com/how_to/webvr_camera
  99240. */
  99241. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  99242. private webVROptions;
  99243. /**
  99244. * @hidden
  99245. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  99246. */
  99247. _vrDevice: any;
  99248. /**
  99249. * The rawPose of the vrDevice.
  99250. */
  99251. rawPose: Nullable<DevicePose>;
  99252. private _onVREnabled;
  99253. private _specsVersion;
  99254. private _attached;
  99255. private _frameData;
  99256. protected _descendants: Array<Node>;
  99257. private _deviceRoomPosition;
  99258. /** @hidden */
  99259. _deviceRoomRotationQuaternion: Quaternion;
  99260. private _standingMatrix;
  99261. /**
  99262. * Represents device position in babylon space.
  99263. */
  99264. devicePosition: Vector3;
  99265. /**
  99266. * Represents device rotation in babylon space.
  99267. */
  99268. deviceRotationQuaternion: Quaternion;
  99269. /**
  99270. * The scale of the device to be used when translating from device space to babylon space.
  99271. */
  99272. deviceScaleFactor: number;
  99273. private _deviceToWorld;
  99274. private _worldToDevice;
  99275. /**
  99276. * References to the webVR controllers for the vrDevice.
  99277. */
  99278. controllers: Array<WebVRController>;
  99279. /**
  99280. * Emits an event when a controller is attached.
  99281. */
  99282. onControllersAttachedObservable: Observable<WebVRController[]>;
  99283. /**
  99284. * Emits an event when a controller's mesh has been loaded;
  99285. */
  99286. onControllerMeshLoadedObservable: Observable<WebVRController>;
  99287. /**
  99288. * Emits an event when the HMD's pose has been updated.
  99289. */
  99290. onPoseUpdatedFromDeviceObservable: Observable<any>;
  99291. private _poseSet;
  99292. /**
  99293. * If the rig cameras be used as parent instead of this camera.
  99294. */
  99295. rigParenting: boolean;
  99296. private _lightOnControllers;
  99297. private _defaultHeight?;
  99298. /**
  99299. * Instantiates a WebVRFreeCamera.
  99300. * @param name The name of the WebVRFreeCamera
  99301. * @param position The starting anchor position for the camera
  99302. * @param scene The scene the camera belongs to
  99303. * @param webVROptions a set of customizable options for the webVRCamera
  99304. */
  99305. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  99306. /**
  99307. * Gets the device distance from the ground in meters.
  99308. * @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.
  99309. */
  99310. deviceDistanceToRoomGround(): number;
  99311. /**
  99312. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  99313. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  99314. */
  99315. useStandingMatrix(callback?: (bool: boolean) => void): void;
  99316. /**
  99317. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  99318. * @returns A promise with a boolean set to if the standing matrix is supported.
  99319. */
  99320. useStandingMatrixAsync(): Promise<boolean>;
  99321. /**
  99322. * Disposes the camera
  99323. */
  99324. dispose(): void;
  99325. /**
  99326. * Gets a vrController by name.
  99327. * @param name The name of the controller to retreive
  99328. * @returns the controller matching the name specified or null if not found
  99329. */
  99330. getControllerByName(name: string): Nullable<WebVRController>;
  99331. private _leftController;
  99332. /**
  99333. * The controller corresponding to the users left hand.
  99334. */
  99335. get leftController(): Nullable<WebVRController>;
  99336. private _rightController;
  99337. /**
  99338. * The controller corresponding to the users right hand.
  99339. */
  99340. get rightController(): Nullable<WebVRController>;
  99341. /**
  99342. * Casts a ray forward from the vrCamera's gaze.
  99343. * @param length Length of the ray (default: 100)
  99344. * @returns the ray corresponding to the gaze
  99345. */
  99346. getForwardRay(length?: number): Ray;
  99347. /**
  99348. * @hidden
  99349. * Updates the camera based on device's frame data
  99350. */
  99351. _checkInputs(): void;
  99352. /**
  99353. * Updates the poseControlled values based on the input device pose.
  99354. * @param poseData Pose coming from the device
  99355. */
  99356. updateFromDevice(poseData: DevicePose): void;
  99357. private _htmlElementAttached;
  99358. private _detachIfAttached;
  99359. /**
  99360. * WebVR's attach control will start broadcasting frames to the device.
  99361. * Note that in certain browsers (chrome for example) this function must be called
  99362. * within a user-interaction callback. Example:
  99363. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  99364. *
  99365. * @param element html element to attach the vrDevice to
  99366. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  99367. */
  99368. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99369. /**
  99370. * Detaches the camera from the html element and disables VR
  99371. *
  99372. * @param element html element to detach from
  99373. */
  99374. detachControl(element: HTMLElement): void;
  99375. /**
  99376. * @returns the name of this class
  99377. */
  99378. getClassName(): string;
  99379. /**
  99380. * Calls resetPose on the vrDisplay
  99381. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  99382. */
  99383. resetToCurrentRotation(): void;
  99384. /**
  99385. * @hidden
  99386. * Updates the rig cameras (left and right eye)
  99387. */
  99388. _updateRigCameras(): void;
  99389. private _workingVector;
  99390. private _oneVector;
  99391. private _workingMatrix;
  99392. private updateCacheCalled;
  99393. private _correctPositionIfNotTrackPosition;
  99394. /**
  99395. * @hidden
  99396. * Updates the cached values of the camera
  99397. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  99398. */
  99399. _updateCache(ignoreParentClass?: boolean): void;
  99400. /**
  99401. * @hidden
  99402. * Get current device position in babylon world
  99403. */
  99404. _computeDevicePosition(): void;
  99405. /**
  99406. * Updates the current device position and rotation in the babylon world
  99407. */
  99408. update(): void;
  99409. /**
  99410. * @hidden
  99411. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  99412. * @returns an identity matrix
  99413. */
  99414. _getViewMatrix(): Matrix;
  99415. private _tmpMatrix;
  99416. /**
  99417. * This function is called by the two RIG cameras.
  99418. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  99419. * @hidden
  99420. */
  99421. _getWebVRViewMatrix(): Matrix;
  99422. /** @hidden */
  99423. _getWebVRProjectionMatrix(): Matrix;
  99424. private _onGamepadConnectedObserver;
  99425. private _onGamepadDisconnectedObserver;
  99426. private _updateCacheWhenTrackingDisabledObserver;
  99427. /**
  99428. * Initializes the controllers and their meshes
  99429. */
  99430. initControllers(): void;
  99431. }
  99432. }
  99433. declare module BABYLON {
  99434. /**
  99435. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  99436. *
  99437. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  99438. *
  99439. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  99440. */
  99441. export class MaterialHelper {
  99442. /**
  99443. * Bind the current view position to an effect.
  99444. * @param effect The effect to be bound
  99445. * @param scene The scene the eyes position is used from
  99446. * @param variableName name of the shader variable that will hold the eye position
  99447. */
  99448. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  99449. /**
  99450. * Helps preparing the defines values about the UVs in used in the effect.
  99451. * UVs are shared as much as we can accross channels in the shaders.
  99452. * @param texture The texture we are preparing the UVs for
  99453. * @param defines The defines to update
  99454. * @param key The channel key "diffuse", "specular"... used in the shader
  99455. */
  99456. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  99457. /**
  99458. * Binds a texture matrix value to its corrsponding uniform
  99459. * @param texture The texture to bind the matrix for
  99460. * @param uniformBuffer The uniform buffer receivin the data
  99461. * @param key The channel key "diffuse", "specular"... used in the shader
  99462. */
  99463. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  99464. /**
  99465. * Gets the current status of the fog (should it be enabled?)
  99466. * @param mesh defines the mesh to evaluate for fog support
  99467. * @param scene defines the hosting scene
  99468. * @returns true if fog must be enabled
  99469. */
  99470. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  99471. /**
  99472. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  99473. * @param mesh defines the current mesh
  99474. * @param scene defines the current scene
  99475. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  99476. * @param pointsCloud defines if point cloud rendering has to be turned on
  99477. * @param fogEnabled defines if fog has to be turned on
  99478. * @param alphaTest defines if alpha testing has to be turned on
  99479. * @param defines defines the current list of defines
  99480. */
  99481. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  99482. /**
  99483. * Helper used to prepare the list of defines associated with frame values for shader compilation
  99484. * @param scene defines the current scene
  99485. * @param engine defines the current engine
  99486. * @param defines specifies the list of active defines
  99487. * @param useInstances defines if instances have to be turned on
  99488. * @param useClipPlane defines if clip plane have to be turned on
  99489. * @param useInstances defines if instances have to be turned on
  99490. * @param useThinInstances defines if thin instances have to be turned on
  99491. */
  99492. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  99493. /**
  99494. * Prepares the defines for bones
  99495. * @param mesh The mesh containing the geometry data we will draw
  99496. * @param defines The defines to update
  99497. */
  99498. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  99499. /**
  99500. * Prepares the defines for morph targets
  99501. * @param mesh The mesh containing the geometry data we will draw
  99502. * @param defines The defines to update
  99503. */
  99504. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  99505. /**
  99506. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  99507. * @param mesh The mesh containing the geometry data we will draw
  99508. * @param defines The defines to update
  99509. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  99510. * @param useBones Precise whether bones should be used or not (override mesh info)
  99511. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  99512. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  99513. * @returns false if defines are considered not dirty and have not been checked
  99514. */
  99515. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  99516. /**
  99517. * Prepares the defines related to multiview
  99518. * @param scene The scene we are intending to draw
  99519. * @param defines The defines to update
  99520. */
  99521. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  99522. /**
  99523. * Prepares the defines related to the prepass
  99524. * @param scene The scene we are intending to draw
  99525. * @param defines The defines to update
  99526. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  99527. */
  99528. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  99529. /**
  99530. * Prepares the defines related to the light information passed in parameter
  99531. * @param scene The scene we are intending to draw
  99532. * @param mesh The mesh the effect is compiling for
  99533. * @param light The light the effect is compiling for
  99534. * @param lightIndex The index of the light
  99535. * @param defines The defines to update
  99536. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  99537. * @param state Defines the current state regarding what is needed (normals, etc...)
  99538. */
  99539. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  99540. needNormals: boolean;
  99541. needRebuild: boolean;
  99542. shadowEnabled: boolean;
  99543. specularEnabled: boolean;
  99544. lightmapMode: boolean;
  99545. }): void;
  99546. /**
  99547. * Prepares the defines related to the light information passed in parameter
  99548. * @param scene The scene we are intending to draw
  99549. * @param mesh The mesh the effect is compiling for
  99550. * @param defines The defines to update
  99551. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  99552. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  99553. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  99554. * @returns true if normals will be required for the rest of the effect
  99555. */
  99556. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  99557. /**
  99558. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  99559. * @param lightIndex defines the light index
  99560. * @param uniformsList The uniform list
  99561. * @param samplersList The sampler list
  99562. * @param projectedLightTexture defines if projected texture must be used
  99563. * @param uniformBuffersList defines an optional list of uniform buffers
  99564. */
  99565. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  99566. /**
  99567. * Prepares the uniforms and samplers list to be used in the effect
  99568. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  99569. * @param samplersList The sampler list
  99570. * @param defines The defines helping in the list generation
  99571. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  99572. */
  99573. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  99574. /**
  99575. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  99576. * @param defines The defines to update while falling back
  99577. * @param fallbacks The authorized effect fallbacks
  99578. * @param maxSimultaneousLights The maximum number of lights allowed
  99579. * @param rank the current rank of the Effect
  99580. * @returns The newly affected rank
  99581. */
  99582. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  99583. private static _TmpMorphInfluencers;
  99584. /**
  99585. * Prepares the list of attributes required for morph targets according to the effect defines.
  99586. * @param attribs The current list of supported attribs
  99587. * @param mesh The mesh to prepare the morph targets attributes for
  99588. * @param influencers The number of influencers
  99589. */
  99590. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  99591. /**
  99592. * Prepares the list of attributes required for morph targets according to the effect defines.
  99593. * @param attribs The current list of supported attribs
  99594. * @param mesh The mesh to prepare the morph targets attributes for
  99595. * @param defines The current Defines of the effect
  99596. */
  99597. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  99598. /**
  99599. * Prepares the list of attributes required for bones according to the effect defines.
  99600. * @param attribs The current list of supported attribs
  99601. * @param mesh The mesh to prepare the bones attributes for
  99602. * @param defines The current Defines of the effect
  99603. * @param fallbacks The current efffect fallback strategy
  99604. */
  99605. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  99606. /**
  99607. * Check and prepare the list of attributes required for instances according to the effect defines.
  99608. * @param attribs The current list of supported attribs
  99609. * @param defines The current MaterialDefines of the effect
  99610. */
  99611. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  99612. /**
  99613. * Add the list of attributes required for instances to the attribs array.
  99614. * @param attribs The current list of supported attribs
  99615. */
  99616. static PushAttributesForInstances(attribs: string[]): void;
  99617. /**
  99618. * Binds the light information to the effect.
  99619. * @param light The light containing the generator
  99620. * @param effect The effect we are binding the data to
  99621. * @param lightIndex The light index in the effect used to render
  99622. */
  99623. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  99624. /**
  99625. * Binds the lights information from the scene to the effect for the given mesh.
  99626. * @param light Light to bind
  99627. * @param lightIndex Light index
  99628. * @param scene The scene where the light belongs to
  99629. * @param effect The effect we are binding the data to
  99630. * @param useSpecular Defines if specular is supported
  99631. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  99632. */
  99633. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  99634. /**
  99635. * Binds the lights information from the scene to the effect for the given mesh.
  99636. * @param scene The scene the lights belongs to
  99637. * @param mesh The mesh we are binding the information to render
  99638. * @param effect The effect we are binding the data to
  99639. * @param defines The generated defines for the effect
  99640. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  99641. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  99642. */
  99643. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  99644. private static _tempFogColor;
  99645. /**
  99646. * Binds the fog information from the scene to the effect for the given mesh.
  99647. * @param scene The scene the lights belongs to
  99648. * @param mesh The mesh we are binding the information to render
  99649. * @param effect The effect we are binding the data to
  99650. * @param linearSpace Defines if the fog effect is applied in linear space
  99651. */
  99652. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  99653. /**
  99654. * Binds the bones information from the mesh to the effect.
  99655. * @param mesh The mesh we are binding the information to render
  99656. * @param effect The effect we are binding the data to
  99657. */
  99658. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  99659. /**
  99660. * Binds the morph targets information from the mesh to the effect.
  99661. * @param abstractMesh The mesh we are binding the information to render
  99662. * @param effect The effect we are binding the data to
  99663. */
  99664. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  99665. /**
  99666. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  99667. * @param defines The generated defines used in the effect
  99668. * @param effect The effect we are binding the data to
  99669. * @param scene The scene we are willing to render with logarithmic scale for
  99670. */
  99671. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  99672. /**
  99673. * Binds the clip plane information from the scene to the effect.
  99674. * @param scene The scene the clip plane information are extracted from
  99675. * @param effect The effect we are binding the data to
  99676. */
  99677. static BindClipPlane(effect: Effect, scene: Scene): void;
  99678. }
  99679. }
  99680. declare module BABYLON {
  99681. /**
  99682. * Block used to expose an input value
  99683. */
  99684. export class InputBlock extends NodeMaterialBlock {
  99685. private _mode;
  99686. private _associatedVariableName;
  99687. private _storedValue;
  99688. private _valueCallback;
  99689. private _type;
  99690. private _animationType;
  99691. /** Gets or set a value used to limit the range of float values */
  99692. min: number;
  99693. /** Gets or set a value used to limit the range of float values */
  99694. max: number;
  99695. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  99696. isBoolean: boolean;
  99697. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  99698. matrixMode: number;
  99699. /** @hidden */
  99700. _systemValue: Nullable<NodeMaterialSystemValues>;
  99701. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  99702. visibleInInspector: boolean;
  99703. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  99704. isConstant: boolean;
  99705. /** Gets or sets the group to use to display this block in the Inspector */
  99706. groupInInspector: string;
  99707. /** Gets an observable raised when the value is changed */
  99708. onValueChangedObservable: Observable<InputBlock>;
  99709. /**
  99710. * Gets or sets the connection point type (default is float)
  99711. */
  99712. get type(): NodeMaterialBlockConnectionPointTypes;
  99713. /**
  99714. * Creates a new InputBlock
  99715. * @param name defines the block name
  99716. * @param target defines the target of that block (Vertex by default)
  99717. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  99718. */
  99719. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  99720. /**
  99721. * Validates if a name is a reserve word.
  99722. * @param newName the new name to be given to the node.
  99723. * @returns false if the name is a reserve word, else true.
  99724. */
  99725. validateBlockName(newName: string): boolean;
  99726. /**
  99727. * Gets the output component
  99728. */
  99729. get output(): NodeMaterialConnectionPoint;
  99730. /**
  99731. * Set the source of this connection point to a vertex attribute
  99732. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  99733. * @returns the current connection point
  99734. */
  99735. setAsAttribute(attributeName?: string): InputBlock;
  99736. /**
  99737. * Set the source of this connection point to a system value
  99738. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  99739. * @returns the current connection point
  99740. */
  99741. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  99742. /**
  99743. * Gets or sets the value of that point.
  99744. * Please note that this value will be ignored if valueCallback is defined
  99745. */
  99746. get value(): any;
  99747. set value(value: any);
  99748. /**
  99749. * Gets or sets a callback used to get the value of that point.
  99750. * Please note that setting this value will force the connection point to ignore the value property
  99751. */
  99752. get valueCallback(): () => any;
  99753. set valueCallback(value: () => any);
  99754. /**
  99755. * Gets or sets the associated variable name in the shader
  99756. */
  99757. get associatedVariableName(): string;
  99758. set associatedVariableName(value: string);
  99759. /** Gets or sets the type of animation applied to the input */
  99760. get animationType(): AnimatedInputBlockTypes;
  99761. set animationType(value: AnimatedInputBlockTypes);
  99762. /**
  99763. * Gets a boolean indicating that this connection point not defined yet
  99764. */
  99765. get isUndefined(): boolean;
  99766. /**
  99767. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  99768. * In this case the connection point name must be the name of the uniform to use.
  99769. * Can only be set on inputs
  99770. */
  99771. get isUniform(): boolean;
  99772. set isUniform(value: boolean);
  99773. /**
  99774. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  99775. * In this case the connection point name must be the name of the attribute to use
  99776. * Can only be set on inputs
  99777. */
  99778. get isAttribute(): boolean;
  99779. set isAttribute(value: boolean);
  99780. /**
  99781. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  99782. * Can only be set on exit points
  99783. */
  99784. get isVarying(): boolean;
  99785. set isVarying(value: boolean);
  99786. /**
  99787. * Gets a boolean indicating that the current connection point is a system value
  99788. */
  99789. get isSystemValue(): boolean;
  99790. /**
  99791. * Gets or sets the current well known value or null if not defined as a system value
  99792. */
  99793. get systemValue(): Nullable<NodeMaterialSystemValues>;
  99794. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  99795. /**
  99796. * Gets the current class name
  99797. * @returns the class name
  99798. */
  99799. getClassName(): string;
  99800. /**
  99801. * Animate the input if animationType !== None
  99802. * @param scene defines the rendering scene
  99803. */
  99804. animate(scene: Scene): void;
  99805. private _emitDefine;
  99806. initialize(state: NodeMaterialBuildState): void;
  99807. /**
  99808. * Set the input block to its default value (based on its type)
  99809. */
  99810. setDefaultValue(): void;
  99811. private _emitConstant;
  99812. /** @hidden */
  99813. get _noContextSwitch(): boolean;
  99814. private _emit;
  99815. /** @hidden */
  99816. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  99817. /** @hidden */
  99818. _transmit(effect: Effect, scene: Scene): void;
  99819. protected _buildBlock(state: NodeMaterialBuildState): void;
  99820. protected _dumpPropertiesCode(): string;
  99821. dispose(): void;
  99822. serialize(): any;
  99823. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99824. }
  99825. }
  99826. declare module BABYLON {
  99827. /**
  99828. * Enum used to define the compatibility state between two connection points
  99829. */
  99830. export enum NodeMaterialConnectionPointCompatibilityStates {
  99831. /** Points are compatibles */
  99832. Compatible = 0,
  99833. /** Points are incompatible because of their types */
  99834. TypeIncompatible = 1,
  99835. /** Points are incompatible because of their targets (vertex vs fragment) */
  99836. TargetIncompatible = 2
  99837. }
  99838. /**
  99839. * Defines the direction of a connection point
  99840. */
  99841. export enum NodeMaterialConnectionPointDirection {
  99842. /** Input */
  99843. Input = 0,
  99844. /** Output */
  99845. Output = 1
  99846. }
  99847. /**
  99848. * Defines a connection point for a block
  99849. */
  99850. export class NodeMaterialConnectionPoint {
  99851. /** @hidden */
  99852. _ownerBlock: NodeMaterialBlock;
  99853. /** @hidden */
  99854. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  99855. private _endpoints;
  99856. private _associatedVariableName;
  99857. private _direction;
  99858. /** @hidden */
  99859. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  99860. /** @hidden */
  99861. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  99862. private _type;
  99863. /** @hidden */
  99864. _enforceAssociatedVariableName: boolean;
  99865. /** Gets the direction of the point */
  99866. get direction(): NodeMaterialConnectionPointDirection;
  99867. /** Indicates that this connection point needs dual validation before being connected to another point */
  99868. needDualDirectionValidation: boolean;
  99869. /**
  99870. * Gets or sets the additional types supported by this connection point
  99871. */
  99872. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  99873. /**
  99874. * Gets or sets the additional types excluded by this connection point
  99875. */
  99876. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  99877. /**
  99878. * Observable triggered when this point is connected
  99879. */
  99880. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  99881. /**
  99882. * Gets or sets the associated variable name in the shader
  99883. */
  99884. get associatedVariableName(): string;
  99885. set associatedVariableName(value: string);
  99886. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  99887. get innerType(): NodeMaterialBlockConnectionPointTypes;
  99888. /**
  99889. * Gets or sets the connection point type (default is float)
  99890. */
  99891. get type(): NodeMaterialBlockConnectionPointTypes;
  99892. set type(value: NodeMaterialBlockConnectionPointTypes);
  99893. /**
  99894. * Gets or sets the connection point name
  99895. */
  99896. name: string;
  99897. /**
  99898. * Gets or sets the connection point name
  99899. */
  99900. displayName: string;
  99901. /**
  99902. * Gets or sets a boolean indicating that this connection point can be omitted
  99903. */
  99904. isOptional: boolean;
  99905. /**
  99906. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  99907. */
  99908. isExposedOnFrame: boolean;
  99909. /**
  99910. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  99911. */
  99912. define: string;
  99913. /** @hidden */
  99914. _prioritizeVertex: boolean;
  99915. private _target;
  99916. /** Gets or sets the target of that connection point */
  99917. get target(): NodeMaterialBlockTargets;
  99918. set target(value: NodeMaterialBlockTargets);
  99919. /**
  99920. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  99921. */
  99922. get isConnected(): boolean;
  99923. /**
  99924. * Gets a boolean indicating that the current point is connected to an input block
  99925. */
  99926. get isConnectedToInputBlock(): boolean;
  99927. /**
  99928. * Gets a the connected input block (if any)
  99929. */
  99930. get connectInputBlock(): Nullable<InputBlock>;
  99931. /** Get the other side of the connection (if any) */
  99932. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  99933. /** Get the block that owns this connection point */
  99934. get ownerBlock(): NodeMaterialBlock;
  99935. /** Get the block connected on the other side of this connection (if any) */
  99936. get sourceBlock(): Nullable<NodeMaterialBlock>;
  99937. /** Get the block connected on the endpoints of this connection (if any) */
  99938. get connectedBlocks(): Array<NodeMaterialBlock>;
  99939. /** Gets the list of connected endpoints */
  99940. get endpoints(): NodeMaterialConnectionPoint[];
  99941. /** Gets a boolean indicating if that output point is connected to at least one input */
  99942. get hasEndpoints(): boolean;
  99943. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  99944. get isConnectedInVertexShader(): boolean;
  99945. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  99946. get isConnectedInFragmentShader(): boolean;
  99947. /**
  99948. * Creates a block suitable to be used as an input for this input point.
  99949. * If null is returned, a block based on the point type will be created.
  99950. * @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
  99951. */
  99952. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  99953. /**
  99954. * Creates a new connection point
  99955. * @param name defines the connection point name
  99956. * @param ownerBlock defines the block hosting this connection point
  99957. * @param direction defines the direction of the connection point
  99958. */
  99959. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  99960. /**
  99961. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  99962. * @returns the class name
  99963. */
  99964. getClassName(): string;
  99965. /**
  99966. * Gets a boolean indicating if the current point can be connected to another point
  99967. * @param connectionPoint defines the other connection point
  99968. * @returns a boolean
  99969. */
  99970. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  99971. /**
  99972. * Gets a number indicating if the current point can be connected to another point
  99973. * @param connectionPoint defines the other connection point
  99974. * @returns a number defining the compatibility state
  99975. */
  99976. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  99977. /**
  99978. * Connect this point to another connection point
  99979. * @param connectionPoint defines the other connection point
  99980. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  99981. * @returns the current connection point
  99982. */
  99983. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  99984. /**
  99985. * Disconnect this point from one of his endpoint
  99986. * @param endpoint defines the other connection point
  99987. * @returns the current connection point
  99988. */
  99989. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  99990. /**
  99991. * Serializes this point in a JSON representation
  99992. * @param isInput defines if the connection point is an input (default is true)
  99993. * @returns the serialized point object
  99994. */
  99995. serialize(isInput?: boolean): any;
  99996. /**
  99997. * Release resources
  99998. */
  99999. dispose(): void;
  100000. }
  100001. }
  100002. declare module BABYLON {
  100003. /**
  100004. * Enum used to define the material modes
  100005. */
  100006. export enum NodeMaterialModes {
  100007. /** Regular material */
  100008. Material = 0,
  100009. /** For post process */
  100010. PostProcess = 1,
  100011. /** For particle system */
  100012. Particle = 2
  100013. }
  100014. }
  100015. declare module BABYLON {
  100016. /**
  100017. * Block used to read a texture from a sampler
  100018. */
  100019. export class TextureBlock extends NodeMaterialBlock {
  100020. private _defineName;
  100021. private _linearDefineName;
  100022. private _gammaDefineName;
  100023. private _tempTextureRead;
  100024. private _samplerName;
  100025. private _transformedUVName;
  100026. private _textureTransformName;
  100027. private _textureInfoName;
  100028. private _mainUVName;
  100029. private _mainUVDefineName;
  100030. private _fragmentOnly;
  100031. /**
  100032. * Gets or sets the texture associated with the node
  100033. */
  100034. texture: Nullable<Texture>;
  100035. /**
  100036. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  100037. */
  100038. convertToGammaSpace: boolean;
  100039. /**
  100040. * Gets or sets a boolean indicating if content needs to be converted to linear space
  100041. */
  100042. convertToLinearSpace: boolean;
  100043. /**
  100044. * Create a new TextureBlock
  100045. * @param name defines the block name
  100046. */
  100047. constructor(name: string, fragmentOnly?: boolean);
  100048. /**
  100049. * Gets the current class name
  100050. * @returns the class name
  100051. */
  100052. getClassName(): string;
  100053. /**
  100054. * Gets the uv input component
  100055. */
  100056. get uv(): NodeMaterialConnectionPoint;
  100057. /**
  100058. * Gets the rgba output component
  100059. */
  100060. get rgba(): NodeMaterialConnectionPoint;
  100061. /**
  100062. * Gets the rgb output component
  100063. */
  100064. get rgb(): NodeMaterialConnectionPoint;
  100065. /**
  100066. * Gets the r output component
  100067. */
  100068. get r(): NodeMaterialConnectionPoint;
  100069. /**
  100070. * Gets the g output component
  100071. */
  100072. get g(): NodeMaterialConnectionPoint;
  100073. /**
  100074. * Gets the b output component
  100075. */
  100076. get b(): NodeMaterialConnectionPoint;
  100077. /**
  100078. * Gets the a output component
  100079. */
  100080. get a(): NodeMaterialConnectionPoint;
  100081. get target(): NodeMaterialBlockTargets;
  100082. autoConfigure(material: NodeMaterial): void;
  100083. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  100084. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  100085. isReady(): boolean;
  100086. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  100087. private get _isMixed();
  100088. private _injectVertexCode;
  100089. private _writeTextureRead;
  100090. private _writeOutput;
  100091. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  100092. protected _dumpPropertiesCode(): string;
  100093. serialize(): any;
  100094. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100095. }
  100096. }
  100097. declare module BABYLON {
  100098. /** @hidden */
  100099. export var reflectionFunction: {
  100100. name: string;
  100101. shader: string;
  100102. };
  100103. }
  100104. declare module BABYLON {
  100105. /**
  100106. * Base block used to read a reflection texture from a sampler
  100107. */
  100108. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  100109. /** @hidden */
  100110. _define3DName: string;
  100111. /** @hidden */
  100112. _defineCubicName: string;
  100113. /** @hidden */
  100114. _defineExplicitName: string;
  100115. /** @hidden */
  100116. _defineProjectionName: string;
  100117. /** @hidden */
  100118. _defineLocalCubicName: string;
  100119. /** @hidden */
  100120. _defineSphericalName: string;
  100121. /** @hidden */
  100122. _definePlanarName: string;
  100123. /** @hidden */
  100124. _defineEquirectangularName: string;
  100125. /** @hidden */
  100126. _defineMirroredEquirectangularFixedName: string;
  100127. /** @hidden */
  100128. _defineEquirectangularFixedName: string;
  100129. /** @hidden */
  100130. _defineSkyboxName: string;
  100131. /** @hidden */
  100132. _defineOppositeZ: string;
  100133. /** @hidden */
  100134. _cubeSamplerName: string;
  100135. /** @hidden */
  100136. _2DSamplerName: string;
  100137. protected _positionUVWName: string;
  100138. protected _directionWName: string;
  100139. protected _reflectionVectorName: string;
  100140. /** @hidden */
  100141. _reflectionCoordsName: string;
  100142. /** @hidden */
  100143. _reflectionMatrixName: string;
  100144. protected _reflectionColorName: string;
  100145. /**
  100146. * Gets or sets the texture associated with the node
  100147. */
  100148. texture: Nullable<BaseTexture>;
  100149. /**
  100150. * Create a new ReflectionTextureBaseBlock
  100151. * @param name defines the block name
  100152. */
  100153. constructor(name: string);
  100154. /**
  100155. * Gets the current class name
  100156. * @returns the class name
  100157. */
  100158. getClassName(): string;
  100159. /**
  100160. * Gets the world position input component
  100161. */
  100162. abstract get position(): NodeMaterialConnectionPoint;
  100163. /**
  100164. * Gets the world position input component
  100165. */
  100166. abstract get worldPosition(): NodeMaterialConnectionPoint;
  100167. /**
  100168. * Gets the world normal input component
  100169. */
  100170. abstract get worldNormal(): NodeMaterialConnectionPoint;
  100171. /**
  100172. * Gets the world input component
  100173. */
  100174. abstract get world(): NodeMaterialConnectionPoint;
  100175. /**
  100176. * Gets the camera (or eye) position component
  100177. */
  100178. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  100179. /**
  100180. * Gets the view input component
  100181. */
  100182. abstract get view(): NodeMaterialConnectionPoint;
  100183. protected _getTexture(): Nullable<BaseTexture>;
  100184. autoConfigure(material: NodeMaterial): void;
  100185. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  100186. isReady(): boolean;
  100187. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  100188. /**
  100189. * Gets the code to inject in the vertex shader
  100190. * @param state current state of the node material building
  100191. * @returns the shader code
  100192. */
  100193. handleVertexSide(state: NodeMaterialBuildState): string;
  100194. /**
  100195. * Handles the inits for the fragment code path
  100196. * @param state node material build state
  100197. */
  100198. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  100199. /**
  100200. * Generates the reflection coords code for the fragment code path
  100201. * @param worldNormalVarName name of the world normal variable
  100202. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  100203. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  100204. * @returns the shader code
  100205. */
  100206. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  100207. /**
  100208. * Generates the reflection color code for the fragment code path
  100209. * @param lodVarName name of the lod variable
  100210. * @param swizzleLookupTexture swizzle to use for the final color variable
  100211. * @returns the shader code
  100212. */
  100213. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  100214. /**
  100215. * Generates the code corresponding to the connected output points
  100216. * @param state node material build state
  100217. * @param varName name of the variable to output
  100218. * @returns the shader code
  100219. */
  100220. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  100221. protected _buildBlock(state: NodeMaterialBuildState): this;
  100222. protected _dumpPropertiesCode(): string;
  100223. serialize(): any;
  100224. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100225. }
  100226. }
  100227. declare module BABYLON {
  100228. /**
  100229. * Defines a connection point to be used for points with a custom object type
  100230. */
  100231. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  100232. private _blockType;
  100233. private _blockName;
  100234. private _nameForCheking?;
  100235. /**
  100236. * Creates a new connection point
  100237. * @param name defines the connection point name
  100238. * @param ownerBlock defines the block hosting this connection point
  100239. * @param direction defines the direction of the connection point
  100240. */
  100241. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  100242. /**
  100243. * Gets a number indicating if the current point can be connected to another point
  100244. * @param connectionPoint defines the other connection point
  100245. * @returns a number defining the compatibility state
  100246. */
  100247. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  100248. /**
  100249. * Creates a block suitable to be used as an input for this input point.
  100250. * If null is returned, a block based on the point type will be created.
  100251. * @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
  100252. */
  100253. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  100254. }
  100255. }
  100256. declare module BABYLON {
  100257. /**
  100258. * Enum defining the type of properties that can be edited in the property pages in the NME
  100259. */
  100260. export enum PropertyTypeForEdition {
  100261. /** property is a boolean */
  100262. Boolean = 0,
  100263. /** property is a float */
  100264. Float = 1,
  100265. /** property is a Vector2 */
  100266. Vector2 = 2,
  100267. /** property is a list of values */
  100268. List = 3
  100269. }
  100270. /**
  100271. * Interface that defines an option in a variable of type list
  100272. */
  100273. export interface IEditablePropertyListOption {
  100274. /** label of the option */
  100275. "label": string;
  100276. /** value of the option */
  100277. "value": number;
  100278. }
  100279. /**
  100280. * Interface that defines the options available for an editable property
  100281. */
  100282. export interface IEditablePropertyOption {
  100283. /** min value */
  100284. "min"?: number;
  100285. /** max value */
  100286. "max"?: number;
  100287. /** notifiers: indicates which actions to take when the property is changed */
  100288. "notifiers"?: {
  100289. /** the material should be rebuilt */
  100290. "rebuild"?: boolean;
  100291. /** the preview should be updated */
  100292. "update"?: boolean;
  100293. };
  100294. /** list of the options for a variable of type list */
  100295. "options"?: IEditablePropertyListOption[];
  100296. }
  100297. /**
  100298. * Interface that describes an editable property
  100299. */
  100300. export interface IPropertyDescriptionForEdition {
  100301. /** name of the property */
  100302. "propertyName": string;
  100303. /** display name of the property */
  100304. "displayName": string;
  100305. /** type of the property */
  100306. "type": PropertyTypeForEdition;
  100307. /** group of the property - all properties with the same group value will be displayed in a specific section */
  100308. "groupName": string;
  100309. /** options for the property */
  100310. "options": IEditablePropertyOption;
  100311. }
  100312. /**
  100313. * Decorator that flags a property in a node material block as being editable
  100314. */
  100315. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  100316. }
  100317. declare module BABYLON {
  100318. /**
  100319. * Block used to implement the refraction part of the sub surface module of the PBR material
  100320. */
  100321. export class RefractionBlock extends NodeMaterialBlock {
  100322. /** @hidden */
  100323. _define3DName: string;
  100324. /** @hidden */
  100325. _refractionMatrixName: string;
  100326. /** @hidden */
  100327. _defineLODRefractionAlpha: string;
  100328. /** @hidden */
  100329. _defineLinearSpecularRefraction: string;
  100330. /** @hidden */
  100331. _defineOppositeZ: string;
  100332. /** @hidden */
  100333. _cubeSamplerName: string;
  100334. /** @hidden */
  100335. _2DSamplerName: string;
  100336. /** @hidden */
  100337. _vRefractionMicrosurfaceInfosName: string;
  100338. /** @hidden */
  100339. _vRefractionInfosName: string;
  100340. private _scene;
  100341. /**
  100342. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  100343. * Materials half opaque for instance using refraction could benefit from this control.
  100344. */
  100345. linkRefractionWithTransparency: boolean;
  100346. /**
  100347. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  100348. */
  100349. invertRefractionY: boolean;
  100350. /**
  100351. * Gets or sets the texture associated with the node
  100352. */
  100353. texture: Nullable<BaseTexture>;
  100354. /**
  100355. * Create a new RefractionBlock
  100356. * @param name defines the block name
  100357. */
  100358. constructor(name: string);
  100359. /**
  100360. * Gets the current class name
  100361. * @returns the class name
  100362. */
  100363. getClassName(): string;
  100364. /**
  100365. * Gets the intensity input component
  100366. */
  100367. get intensity(): NodeMaterialConnectionPoint;
  100368. /**
  100369. * Gets the index of refraction input component
  100370. */
  100371. get indexOfRefraction(): NodeMaterialConnectionPoint;
  100372. /**
  100373. * Gets the tint at distance input component
  100374. */
  100375. get tintAtDistance(): NodeMaterialConnectionPoint;
  100376. /**
  100377. * Gets the view input component
  100378. */
  100379. get view(): NodeMaterialConnectionPoint;
  100380. /**
  100381. * Gets the refraction object output component
  100382. */
  100383. get refraction(): NodeMaterialConnectionPoint;
  100384. /**
  100385. * Returns true if the block has a texture
  100386. */
  100387. get hasTexture(): boolean;
  100388. protected _getTexture(): Nullable<BaseTexture>;
  100389. autoConfigure(material: NodeMaterial): void;
  100390. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  100391. isReady(): boolean;
  100392. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  100393. /**
  100394. * Gets the main code of the block (fragment side)
  100395. * @param state current state of the node material building
  100396. * @returns the shader code
  100397. */
  100398. getCode(state: NodeMaterialBuildState): string;
  100399. protected _buildBlock(state: NodeMaterialBuildState): this;
  100400. protected _dumpPropertiesCode(): string;
  100401. serialize(): any;
  100402. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100403. }
  100404. }
  100405. declare module BABYLON {
  100406. /**
  100407. * Base block used as input for post process
  100408. */
  100409. export class CurrentScreenBlock extends NodeMaterialBlock {
  100410. private _samplerName;
  100411. private _linearDefineName;
  100412. private _gammaDefineName;
  100413. private _mainUVName;
  100414. private _tempTextureRead;
  100415. /**
  100416. * Gets or sets the texture associated with the node
  100417. */
  100418. texture: Nullable<BaseTexture>;
  100419. /**
  100420. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  100421. */
  100422. convertToGammaSpace: boolean;
  100423. /**
  100424. * Gets or sets a boolean indicating if content needs to be converted to linear space
  100425. */
  100426. convertToLinearSpace: boolean;
  100427. /**
  100428. * Create a new CurrentScreenBlock
  100429. * @param name defines the block name
  100430. */
  100431. constructor(name: string);
  100432. /**
  100433. * Gets the current class name
  100434. * @returns the class name
  100435. */
  100436. getClassName(): string;
  100437. /**
  100438. * Gets the uv input component
  100439. */
  100440. get uv(): NodeMaterialConnectionPoint;
  100441. /**
  100442. * Gets the rgba output component
  100443. */
  100444. get rgba(): NodeMaterialConnectionPoint;
  100445. /**
  100446. * Gets the rgb output component
  100447. */
  100448. get rgb(): NodeMaterialConnectionPoint;
  100449. /**
  100450. * Gets the r output component
  100451. */
  100452. get r(): NodeMaterialConnectionPoint;
  100453. /**
  100454. * Gets the g output component
  100455. */
  100456. get g(): NodeMaterialConnectionPoint;
  100457. /**
  100458. * Gets the b output component
  100459. */
  100460. get b(): NodeMaterialConnectionPoint;
  100461. /**
  100462. * Gets the a output component
  100463. */
  100464. get a(): NodeMaterialConnectionPoint;
  100465. /**
  100466. * Initialize the block and prepare the context for build
  100467. * @param state defines the state that will be used for the build
  100468. */
  100469. initialize(state: NodeMaterialBuildState): void;
  100470. get target(): NodeMaterialBlockTargets;
  100471. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  100472. isReady(): boolean;
  100473. private _injectVertexCode;
  100474. private _writeTextureRead;
  100475. private _writeOutput;
  100476. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  100477. serialize(): any;
  100478. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100479. }
  100480. }
  100481. declare module BABYLON {
  100482. /**
  100483. * Base block used for the particle texture
  100484. */
  100485. export class ParticleTextureBlock extends NodeMaterialBlock {
  100486. private _samplerName;
  100487. private _linearDefineName;
  100488. private _gammaDefineName;
  100489. private _tempTextureRead;
  100490. /**
  100491. * Gets or sets the texture associated with the node
  100492. */
  100493. texture: Nullable<BaseTexture>;
  100494. /**
  100495. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  100496. */
  100497. convertToGammaSpace: boolean;
  100498. /**
  100499. * Gets or sets a boolean indicating if content needs to be converted to linear space
  100500. */
  100501. convertToLinearSpace: boolean;
  100502. /**
  100503. * Create a new ParticleTextureBlock
  100504. * @param name defines the block name
  100505. */
  100506. constructor(name: string);
  100507. /**
  100508. * Gets the current class name
  100509. * @returns the class name
  100510. */
  100511. getClassName(): string;
  100512. /**
  100513. * Gets the uv input component
  100514. */
  100515. get uv(): NodeMaterialConnectionPoint;
  100516. /**
  100517. * Gets the rgba output component
  100518. */
  100519. get rgba(): NodeMaterialConnectionPoint;
  100520. /**
  100521. * Gets the rgb output component
  100522. */
  100523. get rgb(): NodeMaterialConnectionPoint;
  100524. /**
  100525. * Gets the r output component
  100526. */
  100527. get r(): NodeMaterialConnectionPoint;
  100528. /**
  100529. * Gets the g output component
  100530. */
  100531. get g(): NodeMaterialConnectionPoint;
  100532. /**
  100533. * Gets the b output component
  100534. */
  100535. get b(): NodeMaterialConnectionPoint;
  100536. /**
  100537. * Gets the a output component
  100538. */
  100539. get a(): NodeMaterialConnectionPoint;
  100540. /**
  100541. * Initialize the block and prepare the context for build
  100542. * @param state defines the state that will be used for the build
  100543. */
  100544. initialize(state: NodeMaterialBuildState): void;
  100545. autoConfigure(material: NodeMaterial): void;
  100546. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  100547. isReady(): boolean;
  100548. private _writeOutput;
  100549. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  100550. serialize(): any;
  100551. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100552. }
  100553. }
  100554. declare module BABYLON {
  100555. /**
  100556. * Class used to store shared data between 2 NodeMaterialBuildState
  100557. */
  100558. export class NodeMaterialBuildStateSharedData {
  100559. /**
  100560. * Gets the list of emitted varyings
  100561. */
  100562. temps: string[];
  100563. /**
  100564. * Gets the list of emitted varyings
  100565. */
  100566. varyings: string[];
  100567. /**
  100568. * Gets the varying declaration string
  100569. */
  100570. varyingDeclaration: string;
  100571. /**
  100572. * Input blocks
  100573. */
  100574. inputBlocks: InputBlock[];
  100575. /**
  100576. * Input blocks
  100577. */
  100578. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  100579. /**
  100580. * Bindable blocks (Blocks that need to set data to the effect)
  100581. */
  100582. bindableBlocks: NodeMaterialBlock[];
  100583. /**
  100584. * List of blocks that can provide a compilation fallback
  100585. */
  100586. blocksWithFallbacks: NodeMaterialBlock[];
  100587. /**
  100588. * List of blocks that can provide a define update
  100589. */
  100590. blocksWithDefines: NodeMaterialBlock[];
  100591. /**
  100592. * List of blocks that can provide a repeatable content
  100593. */
  100594. repeatableContentBlocks: NodeMaterialBlock[];
  100595. /**
  100596. * List of blocks that can provide a dynamic list of uniforms
  100597. */
  100598. dynamicUniformBlocks: NodeMaterialBlock[];
  100599. /**
  100600. * List of blocks that can block the isReady function for the material
  100601. */
  100602. blockingBlocks: NodeMaterialBlock[];
  100603. /**
  100604. * Gets the list of animated inputs
  100605. */
  100606. animatedInputs: InputBlock[];
  100607. /**
  100608. * Build Id used to avoid multiple recompilations
  100609. */
  100610. buildId: number;
  100611. /** List of emitted variables */
  100612. variableNames: {
  100613. [key: string]: number;
  100614. };
  100615. /** List of emitted defines */
  100616. defineNames: {
  100617. [key: string]: number;
  100618. };
  100619. /** Should emit comments? */
  100620. emitComments: boolean;
  100621. /** Emit build activity */
  100622. verbose: boolean;
  100623. /** Gets or sets the hosting scene */
  100624. scene: Scene;
  100625. /**
  100626. * Gets the compilation hints emitted at compilation time
  100627. */
  100628. hints: {
  100629. needWorldViewMatrix: boolean;
  100630. needWorldViewProjectionMatrix: boolean;
  100631. needAlphaBlending: boolean;
  100632. needAlphaTesting: boolean;
  100633. };
  100634. /**
  100635. * List of compilation checks
  100636. */
  100637. checks: {
  100638. emitVertex: boolean;
  100639. emitFragment: boolean;
  100640. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  100641. };
  100642. /**
  100643. * Is vertex program allowed to be empty?
  100644. */
  100645. allowEmptyVertexProgram: boolean;
  100646. /** Creates a new shared data */
  100647. constructor();
  100648. /**
  100649. * Emits console errors and exceptions if there is a failing check
  100650. */
  100651. emitErrors(): void;
  100652. }
  100653. }
  100654. declare module BABYLON {
  100655. /**
  100656. * Class used to store node based material build state
  100657. */
  100658. export class NodeMaterialBuildState {
  100659. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  100660. supportUniformBuffers: boolean;
  100661. /**
  100662. * Gets the list of emitted attributes
  100663. */
  100664. attributes: string[];
  100665. /**
  100666. * Gets the list of emitted uniforms
  100667. */
  100668. uniforms: string[];
  100669. /**
  100670. * Gets the list of emitted constants
  100671. */
  100672. constants: string[];
  100673. /**
  100674. * Gets the list of emitted samplers
  100675. */
  100676. samplers: string[];
  100677. /**
  100678. * Gets the list of emitted functions
  100679. */
  100680. functions: {
  100681. [key: string]: string;
  100682. };
  100683. /**
  100684. * Gets the list of emitted extensions
  100685. */
  100686. extensions: {
  100687. [key: string]: string;
  100688. };
  100689. /**
  100690. * Gets the target of the compilation state
  100691. */
  100692. target: NodeMaterialBlockTargets;
  100693. /**
  100694. * Gets the list of emitted counters
  100695. */
  100696. counters: {
  100697. [key: string]: number;
  100698. };
  100699. /**
  100700. * Shared data between multiple NodeMaterialBuildState instances
  100701. */
  100702. sharedData: NodeMaterialBuildStateSharedData;
  100703. /** @hidden */
  100704. _vertexState: NodeMaterialBuildState;
  100705. /** @hidden */
  100706. _attributeDeclaration: string;
  100707. /** @hidden */
  100708. _uniformDeclaration: string;
  100709. /** @hidden */
  100710. _constantDeclaration: string;
  100711. /** @hidden */
  100712. _samplerDeclaration: string;
  100713. /** @hidden */
  100714. _varyingTransfer: string;
  100715. /** @hidden */
  100716. _injectAtEnd: string;
  100717. private _repeatableContentAnchorIndex;
  100718. /** @hidden */
  100719. _builtCompilationString: string;
  100720. /**
  100721. * Gets the emitted compilation strings
  100722. */
  100723. compilationString: string;
  100724. /**
  100725. * Finalize the compilation strings
  100726. * @param state defines the current compilation state
  100727. */
  100728. finalize(state: NodeMaterialBuildState): void;
  100729. /** @hidden */
  100730. get _repeatableContentAnchor(): string;
  100731. /** @hidden */
  100732. _getFreeVariableName(prefix: string): string;
  100733. /** @hidden */
  100734. _getFreeDefineName(prefix: string): string;
  100735. /** @hidden */
  100736. _excludeVariableName(name: string): void;
  100737. /** @hidden */
  100738. _emit2DSampler(name: string): void;
  100739. /** @hidden */
  100740. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  100741. /** @hidden */
  100742. _emitExtension(name: string, extension: string, define?: string): void;
  100743. /** @hidden */
  100744. _emitFunction(name: string, code: string, comments: string): void;
  100745. /** @hidden */
  100746. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  100747. replaceStrings?: {
  100748. search: RegExp;
  100749. replace: string;
  100750. }[];
  100751. repeatKey?: string;
  100752. }): string;
  100753. /** @hidden */
  100754. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  100755. repeatKey?: string;
  100756. removeAttributes?: boolean;
  100757. removeUniforms?: boolean;
  100758. removeVaryings?: boolean;
  100759. removeIfDef?: boolean;
  100760. replaceStrings?: {
  100761. search: RegExp;
  100762. replace: string;
  100763. }[];
  100764. }, storeKey?: string): void;
  100765. /** @hidden */
  100766. _registerTempVariable(name: string): boolean;
  100767. /** @hidden */
  100768. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  100769. /** @hidden */
  100770. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  100771. /** @hidden */
  100772. _emitFloat(value: number): string;
  100773. }
  100774. }
  100775. declare module BABYLON {
  100776. /**
  100777. * Helper class used to generate session unique ID
  100778. */
  100779. export class UniqueIdGenerator {
  100780. private static _UniqueIdCounter;
  100781. /**
  100782. * Gets an unique (relatively to the current scene) Id
  100783. */
  100784. static get UniqueId(): number;
  100785. }
  100786. }
  100787. declare module BABYLON {
  100788. /**
  100789. * Defines a block that can be used inside a node based material
  100790. */
  100791. export class NodeMaterialBlock {
  100792. private _buildId;
  100793. private _buildTarget;
  100794. private _target;
  100795. private _isFinalMerger;
  100796. private _isInput;
  100797. private _name;
  100798. protected _isUnique: boolean;
  100799. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  100800. inputsAreExclusive: boolean;
  100801. /** @hidden */
  100802. _codeVariableName: string;
  100803. /** @hidden */
  100804. _inputs: NodeMaterialConnectionPoint[];
  100805. /** @hidden */
  100806. _outputs: NodeMaterialConnectionPoint[];
  100807. /** @hidden */
  100808. _preparationId: number;
  100809. /**
  100810. * Gets the name of the block
  100811. */
  100812. get name(): string;
  100813. /**
  100814. * Sets the name of the block. Will check if the name is valid.
  100815. */
  100816. set name(newName: string);
  100817. /**
  100818. * Gets or sets the unique id of the node
  100819. */
  100820. uniqueId: number;
  100821. /**
  100822. * Gets or sets the comments associated with this block
  100823. */
  100824. comments: string;
  100825. /**
  100826. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  100827. */
  100828. get isUnique(): boolean;
  100829. /**
  100830. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  100831. */
  100832. get isFinalMerger(): boolean;
  100833. /**
  100834. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  100835. */
  100836. get isInput(): boolean;
  100837. /**
  100838. * Gets or sets the build Id
  100839. */
  100840. get buildId(): number;
  100841. set buildId(value: number);
  100842. /**
  100843. * Gets or sets the target of the block
  100844. */
  100845. get target(): NodeMaterialBlockTargets;
  100846. set target(value: NodeMaterialBlockTargets);
  100847. /**
  100848. * Gets the list of input points
  100849. */
  100850. get inputs(): NodeMaterialConnectionPoint[];
  100851. /** Gets the list of output points */
  100852. get outputs(): NodeMaterialConnectionPoint[];
  100853. /**
  100854. * Find an input by its name
  100855. * @param name defines the name of the input to look for
  100856. * @returns the input or null if not found
  100857. */
  100858. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  100859. /**
  100860. * Find an output by its name
  100861. * @param name defines the name of the outputto look for
  100862. * @returns the output or null if not found
  100863. */
  100864. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  100865. /**
  100866. * Creates a new NodeMaterialBlock
  100867. * @param name defines the block name
  100868. * @param target defines the target of that block (Vertex by default)
  100869. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  100870. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  100871. */
  100872. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  100873. /**
  100874. * Initialize the block and prepare the context for build
  100875. * @param state defines the state that will be used for the build
  100876. */
  100877. initialize(state: NodeMaterialBuildState): void;
  100878. /**
  100879. * Bind data to effect. Will only be called for blocks with isBindable === true
  100880. * @param effect defines the effect to bind data to
  100881. * @param nodeMaterial defines the hosting NodeMaterial
  100882. * @param mesh defines the mesh that will be rendered
  100883. * @param subMesh defines the submesh that will be rendered
  100884. */
  100885. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  100886. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  100887. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  100888. protected _writeFloat(value: number): string;
  100889. /**
  100890. * Gets the current class name e.g. "NodeMaterialBlock"
  100891. * @returns the class name
  100892. */
  100893. getClassName(): string;
  100894. /**
  100895. * Register a new input. Must be called inside a block constructor
  100896. * @param name defines the connection point name
  100897. * @param type defines the connection point type
  100898. * @param isOptional defines a boolean indicating that this input can be omitted
  100899. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  100900. * @param point an already created connection point. If not provided, create a new one
  100901. * @returns the current block
  100902. */
  100903. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  100904. /**
  100905. * Register a new output. Must be called inside a block constructor
  100906. * @param name defines the connection point name
  100907. * @param type defines the connection point type
  100908. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  100909. * @param point an already created connection point. If not provided, create a new one
  100910. * @returns the current block
  100911. */
  100912. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  100913. /**
  100914. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  100915. * @param forOutput defines an optional connection point to check compatibility with
  100916. * @returns the first available input or null
  100917. */
  100918. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  100919. /**
  100920. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  100921. * @param forBlock defines an optional block to check compatibility with
  100922. * @returns the first available input or null
  100923. */
  100924. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  100925. /**
  100926. * Gets the sibling of the given output
  100927. * @param current defines the current output
  100928. * @returns the next output in the list or null
  100929. */
  100930. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  100931. /**
  100932. * Connect current block with another block
  100933. * @param other defines the block to connect with
  100934. * @param options define the various options to help pick the right connections
  100935. * @returns the current block
  100936. */
  100937. connectTo(other: NodeMaterialBlock, options?: {
  100938. input?: string;
  100939. output?: string;
  100940. outputSwizzle?: string;
  100941. }): this | undefined;
  100942. protected _buildBlock(state: NodeMaterialBuildState): void;
  100943. /**
  100944. * Add uniforms, samplers and uniform buffers at compilation time
  100945. * @param state defines the state to update
  100946. * @param nodeMaterial defines the node material requesting the update
  100947. * @param defines defines the material defines to update
  100948. * @param uniformBuffers defines the list of uniform buffer names
  100949. */
  100950. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  100951. /**
  100952. * Add potential fallbacks if shader compilation fails
  100953. * @param mesh defines the mesh to be rendered
  100954. * @param fallbacks defines the current prioritized list of fallbacks
  100955. */
  100956. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  100957. /**
  100958. * Initialize defines for shader compilation
  100959. * @param mesh defines the mesh to be rendered
  100960. * @param nodeMaterial defines the node material requesting the update
  100961. * @param defines defines the material defines to update
  100962. * @param useInstances specifies that instances should be used
  100963. */
  100964. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  100965. /**
  100966. * Update defines for shader compilation
  100967. * @param mesh defines the mesh to be rendered
  100968. * @param nodeMaterial defines the node material requesting the update
  100969. * @param defines defines the material defines to update
  100970. * @param useInstances specifies that instances should be used
  100971. * @param subMesh defines which submesh to render
  100972. */
  100973. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  100974. /**
  100975. * Lets the block try to connect some inputs automatically
  100976. * @param material defines the hosting NodeMaterial
  100977. */
  100978. autoConfigure(material: NodeMaterial): void;
  100979. /**
  100980. * Function called when a block is declared as repeatable content generator
  100981. * @param vertexShaderState defines the current compilation state for the vertex shader
  100982. * @param fragmentShaderState defines the current compilation state for the fragment shader
  100983. * @param mesh defines the mesh to be rendered
  100984. * @param defines defines the material defines to update
  100985. */
  100986. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  100987. /**
  100988. * Checks if the block is ready
  100989. * @param mesh defines the mesh to be rendered
  100990. * @param nodeMaterial defines the node material requesting the update
  100991. * @param defines defines the material defines to update
  100992. * @param useInstances specifies that instances should be used
  100993. * @returns true if the block is ready
  100994. */
  100995. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  100996. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  100997. private _processBuild;
  100998. /**
  100999. * Validates the new name for the block node.
  101000. * @param newName the new name to be given to the node.
  101001. * @returns false if the name is a reserve word, else true.
  101002. */
  101003. validateBlockName(newName: string): boolean;
  101004. /**
  101005. * Compile the current node and generate the shader code
  101006. * @param state defines the current compilation state (uniforms, samplers, current string)
  101007. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  101008. * @returns true if already built
  101009. */
  101010. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  101011. protected _inputRename(name: string): string;
  101012. protected _outputRename(name: string): string;
  101013. protected _dumpPropertiesCode(): string;
  101014. /** @hidden */
  101015. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  101016. /** @hidden */
  101017. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  101018. /**
  101019. * Clone the current block to a new identical block
  101020. * @param scene defines the hosting scene
  101021. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  101022. * @returns a copy of the current block
  101023. */
  101024. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  101025. /**
  101026. * Serializes this block in a JSON representation
  101027. * @returns the serialized block object
  101028. */
  101029. serialize(): any;
  101030. /** @hidden */
  101031. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101032. private _deserializePortDisplayNamesAndExposedOnFrame;
  101033. /**
  101034. * Release resources
  101035. */
  101036. dispose(): void;
  101037. }
  101038. }
  101039. declare module BABYLON {
  101040. /**
  101041. * Base class of materials working in push mode in babylon JS
  101042. * @hidden
  101043. */
  101044. export class PushMaterial extends Material {
  101045. protected _activeEffect: Effect;
  101046. protected _normalMatrix: Matrix;
  101047. constructor(name: string, scene: Scene);
  101048. getEffect(): Effect;
  101049. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  101050. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  101051. /**
  101052. * Binds the given world matrix to the active effect
  101053. *
  101054. * @param world the matrix to bind
  101055. */
  101056. bindOnlyWorldMatrix(world: Matrix): void;
  101057. /**
  101058. * Binds the given normal matrix to the active effect
  101059. *
  101060. * @param normalMatrix the matrix to bind
  101061. */
  101062. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  101063. bind(world: Matrix, mesh?: Mesh): void;
  101064. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  101065. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  101066. }
  101067. }
  101068. declare module BABYLON {
  101069. /**
  101070. * Root class for all node material optimizers
  101071. */
  101072. export class NodeMaterialOptimizer {
  101073. /**
  101074. * Function used to optimize a NodeMaterial graph
  101075. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  101076. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  101077. */
  101078. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  101079. }
  101080. }
  101081. declare module BABYLON {
  101082. /**
  101083. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  101084. */
  101085. export class TransformBlock extends NodeMaterialBlock {
  101086. /**
  101087. * Defines the value to use to complement W value to transform it to a Vector4
  101088. */
  101089. complementW: number;
  101090. /**
  101091. * Defines the value to use to complement z value to transform it to a Vector4
  101092. */
  101093. complementZ: number;
  101094. /**
  101095. * Creates a new TransformBlock
  101096. * @param name defines the block name
  101097. */
  101098. constructor(name: string);
  101099. /**
  101100. * Gets the current class name
  101101. * @returns the class name
  101102. */
  101103. getClassName(): string;
  101104. /**
  101105. * Gets the vector input
  101106. */
  101107. get vector(): NodeMaterialConnectionPoint;
  101108. /**
  101109. * Gets the output component
  101110. */
  101111. get output(): NodeMaterialConnectionPoint;
  101112. /**
  101113. * Gets the xyz output component
  101114. */
  101115. get xyz(): NodeMaterialConnectionPoint;
  101116. /**
  101117. * Gets the matrix transform input
  101118. */
  101119. get transform(): NodeMaterialConnectionPoint;
  101120. protected _buildBlock(state: NodeMaterialBuildState): this;
  101121. /**
  101122. * Update defines for shader compilation
  101123. * @param mesh defines the mesh to be rendered
  101124. * @param nodeMaterial defines the node material requesting the update
  101125. * @param defines defines the material defines to update
  101126. * @param useInstances specifies that instances should be used
  101127. * @param subMesh defines which submesh to render
  101128. */
  101129. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  101130. serialize(): any;
  101131. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101132. protected _dumpPropertiesCode(): string;
  101133. }
  101134. }
  101135. declare module BABYLON {
  101136. /**
  101137. * Block used to output the vertex position
  101138. */
  101139. export class VertexOutputBlock extends NodeMaterialBlock {
  101140. /**
  101141. * Creates a new VertexOutputBlock
  101142. * @param name defines the block name
  101143. */
  101144. constructor(name: string);
  101145. /**
  101146. * Gets the current class name
  101147. * @returns the class name
  101148. */
  101149. getClassName(): string;
  101150. /**
  101151. * Gets the vector input component
  101152. */
  101153. get vector(): NodeMaterialConnectionPoint;
  101154. protected _buildBlock(state: NodeMaterialBuildState): this;
  101155. }
  101156. }
  101157. declare module BABYLON {
  101158. /**
  101159. * Block used to output the final color
  101160. */
  101161. export class FragmentOutputBlock extends NodeMaterialBlock {
  101162. /**
  101163. * Create a new FragmentOutputBlock
  101164. * @param name defines the block name
  101165. */
  101166. constructor(name: string);
  101167. /**
  101168. * Gets the current class name
  101169. * @returns the class name
  101170. */
  101171. getClassName(): string;
  101172. /**
  101173. * Gets the rgba input component
  101174. */
  101175. get rgba(): NodeMaterialConnectionPoint;
  101176. /**
  101177. * Gets the rgb input component
  101178. */
  101179. get rgb(): NodeMaterialConnectionPoint;
  101180. /**
  101181. * Gets the a input component
  101182. */
  101183. get a(): NodeMaterialConnectionPoint;
  101184. protected _buildBlock(state: NodeMaterialBuildState): this;
  101185. }
  101186. }
  101187. declare module BABYLON {
  101188. /**
  101189. * Block used for the particle ramp gradient section
  101190. */
  101191. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  101192. /**
  101193. * Create a new ParticleRampGradientBlock
  101194. * @param name defines the block name
  101195. */
  101196. constructor(name: string);
  101197. /**
  101198. * Gets the current class name
  101199. * @returns the class name
  101200. */
  101201. getClassName(): string;
  101202. /**
  101203. * Gets the color input component
  101204. */
  101205. get color(): NodeMaterialConnectionPoint;
  101206. /**
  101207. * Gets the rampColor output component
  101208. */
  101209. get rampColor(): NodeMaterialConnectionPoint;
  101210. /**
  101211. * Initialize the block and prepare the context for build
  101212. * @param state defines the state that will be used for the build
  101213. */
  101214. initialize(state: NodeMaterialBuildState): void;
  101215. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101216. }
  101217. }
  101218. declare module BABYLON {
  101219. /**
  101220. * Block used for the particle blend multiply section
  101221. */
  101222. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  101223. /**
  101224. * Create a new ParticleBlendMultiplyBlock
  101225. * @param name defines the block name
  101226. */
  101227. constructor(name: string);
  101228. /**
  101229. * Gets the current class name
  101230. * @returns the class name
  101231. */
  101232. getClassName(): string;
  101233. /**
  101234. * Gets the color input component
  101235. */
  101236. get color(): NodeMaterialConnectionPoint;
  101237. /**
  101238. * Gets the alphaTexture input component
  101239. */
  101240. get alphaTexture(): NodeMaterialConnectionPoint;
  101241. /**
  101242. * Gets the alphaColor input component
  101243. */
  101244. get alphaColor(): NodeMaterialConnectionPoint;
  101245. /**
  101246. * Gets the blendColor output component
  101247. */
  101248. get blendColor(): NodeMaterialConnectionPoint;
  101249. /**
  101250. * Initialize the block and prepare the context for build
  101251. * @param state defines the state that will be used for the build
  101252. */
  101253. initialize(state: NodeMaterialBuildState): void;
  101254. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101255. }
  101256. }
  101257. declare module BABYLON {
  101258. /**
  101259. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  101260. */
  101261. export class VectorMergerBlock extends NodeMaterialBlock {
  101262. /**
  101263. * Create a new VectorMergerBlock
  101264. * @param name defines the block name
  101265. */
  101266. constructor(name: string);
  101267. /**
  101268. * Gets the current class name
  101269. * @returns the class name
  101270. */
  101271. getClassName(): string;
  101272. /**
  101273. * Gets the xyz component (input)
  101274. */
  101275. get xyzIn(): NodeMaterialConnectionPoint;
  101276. /**
  101277. * Gets the xy component (input)
  101278. */
  101279. get xyIn(): NodeMaterialConnectionPoint;
  101280. /**
  101281. * Gets the x component (input)
  101282. */
  101283. get x(): NodeMaterialConnectionPoint;
  101284. /**
  101285. * Gets the y component (input)
  101286. */
  101287. get y(): NodeMaterialConnectionPoint;
  101288. /**
  101289. * Gets the z component (input)
  101290. */
  101291. get z(): NodeMaterialConnectionPoint;
  101292. /**
  101293. * Gets the w component (input)
  101294. */
  101295. get w(): NodeMaterialConnectionPoint;
  101296. /**
  101297. * Gets the xyzw component (output)
  101298. */
  101299. get xyzw(): NodeMaterialConnectionPoint;
  101300. /**
  101301. * Gets the xyz component (output)
  101302. */
  101303. get xyzOut(): NodeMaterialConnectionPoint;
  101304. /**
  101305. * Gets the xy component (output)
  101306. */
  101307. get xyOut(): NodeMaterialConnectionPoint;
  101308. /**
  101309. * Gets the xy component (output)
  101310. * @deprecated Please use xyOut instead.
  101311. */
  101312. get xy(): NodeMaterialConnectionPoint;
  101313. /**
  101314. * Gets the xyz component (output)
  101315. * @deprecated Please use xyzOut instead.
  101316. */
  101317. get xyz(): NodeMaterialConnectionPoint;
  101318. protected _buildBlock(state: NodeMaterialBuildState): this;
  101319. }
  101320. }
  101321. declare module BABYLON {
  101322. /**
  101323. * Block used to remap a float from a range to a new one
  101324. */
  101325. export class RemapBlock extends NodeMaterialBlock {
  101326. /**
  101327. * Gets or sets the source range
  101328. */
  101329. sourceRange: Vector2;
  101330. /**
  101331. * Gets or sets the target range
  101332. */
  101333. targetRange: Vector2;
  101334. /**
  101335. * Creates a new RemapBlock
  101336. * @param name defines the block name
  101337. */
  101338. constructor(name: string);
  101339. /**
  101340. * Gets the current class name
  101341. * @returns the class name
  101342. */
  101343. getClassName(): string;
  101344. /**
  101345. * Gets the input component
  101346. */
  101347. get input(): NodeMaterialConnectionPoint;
  101348. /**
  101349. * Gets the source min input component
  101350. */
  101351. get sourceMin(): NodeMaterialConnectionPoint;
  101352. /**
  101353. * Gets the source max input component
  101354. */
  101355. get sourceMax(): NodeMaterialConnectionPoint;
  101356. /**
  101357. * Gets the target min input component
  101358. */
  101359. get targetMin(): NodeMaterialConnectionPoint;
  101360. /**
  101361. * Gets the target max input component
  101362. */
  101363. get targetMax(): NodeMaterialConnectionPoint;
  101364. /**
  101365. * Gets the output component
  101366. */
  101367. get output(): NodeMaterialConnectionPoint;
  101368. protected _buildBlock(state: NodeMaterialBuildState): this;
  101369. protected _dumpPropertiesCode(): string;
  101370. serialize(): any;
  101371. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101372. }
  101373. }
  101374. declare module BABYLON {
  101375. /**
  101376. * Block used to multiply 2 values
  101377. */
  101378. export class MultiplyBlock extends NodeMaterialBlock {
  101379. /**
  101380. * Creates a new MultiplyBlock
  101381. * @param name defines the block name
  101382. */
  101383. constructor(name: string);
  101384. /**
  101385. * Gets the current class name
  101386. * @returns the class name
  101387. */
  101388. getClassName(): string;
  101389. /**
  101390. * Gets the left operand input component
  101391. */
  101392. get left(): NodeMaterialConnectionPoint;
  101393. /**
  101394. * Gets the right operand input component
  101395. */
  101396. get right(): NodeMaterialConnectionPoint;
  101397. /**
  101398. * Gets the output component
  101399. */
  101400. get output(): NodeMaterialConnectionPoint;
  101401. protected _buildBlock(state: NodeMaterialBuildState): this;
  101402. }
  101403. }
  101404. declare module BABYLON {
  101405. /**
  101406. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  101407. */
  101408. export class ColorSplitterBlock extends NodeMaterialBlock {
  101409. /**
  101410. * Create a new ColorSplitterBlock
  101411. * @param name defines the block name
  101412. */
  101413. constructor(name: string);
  101414. /**
  101415. * Gets the current class name
  101416. * @returns the class name
  101417. */
  101418. getClassName(): string;
  101419. /**
  101420. * Gets the rgba component (input)
  101421. */
  101422. get rgba(): NodeMaterialConnectionPoint;
  101423. /**
  101424. * Gets the rgb component (input)
  101425. */
  101426. get rgbIn(): NodeMaterialConnectionPoint;
  101427. /**
  101428. * Gets the rgb component (output)
  101429. */
  101430. get rgbOut(): NodeMaterialConnectionPoint;
  101431. /**
  101432. * Gets the r component (output)
  101433. */
  101434. get r(): NodeMaterialConnectionPoint;
  101435. /**
  101436. * Gets the g component (output)
  101437. */
  101438. get g(): NodeMaterialConnectionPoint;
  101439. /**
  101440. * Gets the b component (output)
  101441. */
  101442. get b(): NodeMaterialConnectionPoint;
  101443. /**
  101444. * Gets the a component (output)
  101445. */
  101446. get a(): NodeMaterialConnectionPoint;
  101447. protected _inputRename(name: string): string;
  101448. protected _outputRename(name: string): string;
  101449. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101450. }
  101451. }
  101452. declare module BABYLON {
  101453. /**
  101454. * Interface used to configure the node material editor
  101455. */
  101456. export interface INodeMaterialEditorOptions {
  101457. /** Define the URl to load node editor script */
  101458. editorURL?: string;
  101459. }
  101460. /** @hidden */
  101461. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  101462. NORMAL: boolean;
  101463. TANGENT: boolean;
  101464. UV1: boolean;
  101465. /** BONES */
  101466. NUM_BONE_INFLUENCERS: number;
  101467. BonesPerMesh: number;
  101468. BONETEXTURE: boolean;
  101469. /** MORPH TARGETS */
  101470. MORPHTARGETS: boolean;
  101471. MORPHTARGETS_NORMAL: boolean;
  101472. MORPHTARGETS_TANGENT: boolean;
  101473. MORPHTARGETS_UV: boolean;
  101474. NUM_MORPH_INFLUENCERS: number;
  101475. /** IMAGE PROCESSING */
  101476. IMAGEPROCESSING: boolean;
  101477. VIGNETTE: boolean;
  101478. VIGNETTEBLENDMODEMULTIPLY: boolean;
  101479. VIGNETTEBLENDMODEOPAQUE: boolean;
  101480. TONEMAPPING: boolean;
  101481. TONEMAPPING_ACES: boolean;
  101482. CONTRAST: boolean;
  101483. EXPOSURE: boolean;
  101484. COLORCURVES: boolean;
  101485. COLORGRADING: boolean;
  101486. COLORGRADING3D: boolean;
  101487. SAMPLER3DGREENDEPTH: boolean;
  101488. SAMPLER3DBGRMAP: boolean;
  101489. IMAGEPROCESSINGPOSTPROCESS: boolean;
  101490. /** MISC. */
  101491. BUMPDIRECTUV: number;
  101492. constructor();
  101493. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  101494. }
  101495. /**
  101496. * Class used to configure NodeMaterial
  101497. */
  101498. export interface INodeMaterialOptions {
  101499. /**
  101500. * Defines if blocks should emit comments
  101501. */
  101502. emitComments: boolean;
  101503. }
  101504. /**
  101505. * Class used to create a node based material built by assembling shader blocks
  101506. */
  101507. export class NodeMaterial extends PushMaterial {
  101508. private static _BuildIdGenerator;
  101509. private _options;
  101510. private _vertexCompilationState;
  101511. private _fragmentCompilationState;
  101512. private _sharedData;
  101513. private _buildId;
  101514. private _buildWasSuccessful;
  101515. private _cachedWorldViewMatrix;
  101516. private _cachedWorldViewProjectionMatrix;
  101517. private _optimizers;
  101518. private _animationFrame;
  101519. /** Define the Url to load node editor script */
  101520. static EditorURL: string;
  101521. /** Define the Url to load snippets */
  101522. static SnippetUrl: string;
  101523. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  101524. static IgnoreTexturesAtLoadTime: boolean;
  101525. private BJSNODEMATERIALEDITOR;
  101526. /** Get the inspector from bundle or global */
  101527. private _getGlobalNodeMaterialEditor;
  101528. /**
  101529. * Snippet ID if the material was created from the snippet server
  101530. */
  101531. snippetId: string;
  101532. /**
  101533. * Gets or sets data used by visual editor
  101534. * @see https://nme.babylonjs.com
  101535. */
  101536. editorData: any;
  101537. /**
  101538. * 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)
  101539. */
  101540. ignoreAlpha: boolean;
  101541. /**
  101542. * Defines the maximum number of lights that can be used in the material
  101543. */
  101544. maxSimultaneousLights: number;
  101545. /**
  101546. * Observable raised when the material is built
  101547. */
  101548. onBuildObservable: Observable<NodeMaterial>;
  101549. /**
  101550. * Gets or sets the root nodes of the material vertex shader
  101551. */
  101552. _vertexOutputNodes: NodeMaterialBlock[];
  101553. /**
  101554. * Gets or sets the root nodes of the material fragment (pixel) shader
  101555. */
  101556. _fragmentOutputNodes: NodeMaterialBlock[];
  101557. /** Gets or sets options to control the node material overall behavior */
  101558. get options(): INodeMaterialOptions;
  101559. set options(options: INodeMaterialOptions);
  101560. /**
  101561. * Default configuration related to image processing available in the standard Material.
  101562. */
  101563. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  101564. /**
  101565. * Gets the image processing configuration used either in this material.
  101566. */
  101567. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  101568. /**
  101569. * Sets the Default image processing configuration used either in the this material.
  101570. *
  101571. * If sets to null, the scene one is in use.
  101572. */
  101573. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  101574. /**
  101575. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  101576. */
  101577. attachedBlocks: NodeMaterialBlock[];
  101578. /**
  101579. * Specifies the mode of the node material
  101580. * @hidden
  101581. */
  101582. _mode: NodeMaterialModes;
  101583. /**
  101584. * Gets the mode property
  101585. */
  101586. get mode(): NodeMaterialModes;
  101587. /**
  101588. * Create a new node based material
  101589. * @param name defines the material name
  101590. * @param scene defines the hosting scene
  101591. * @param options defines creation option
  101592. */
  101593. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  101594. /**
  101595. * Gets the current class name of the material e.g. "NodeMaterial"
  101596. * @returns the class name
  101597. */
  101598. getClassName(): string;
  101599. /**
  101600. * Keep track of the image processing observer to allow dispose and replace.
  101601. */
  101602. private _imageProcessingObserver;
  101603. /**
  101604. * Attaches a new image processing configuration to the Standard Material.
  101605. * @param configuration
  101606. */
  101607. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  101608. /**
  101609. * Get a block by its name
  101610. * @param name defines the name of the block to retrieve
  101611. * @returns the required block or null if not found
  101612. */
  101613. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  101614. /**
  101615. * Get a block by its name
  101616. * @param predicate defines the predicate used to find the good candidate
  101617. * @returns the required block or null if not found
  101618. */
  101619. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  101620. /**
  101621. * Get an input block by its name
  101622. * @param predicate defines the predicate used to find the good candidate
  101623. * @returns the required input block or null if not found
  101624. */
  101625. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  101626. /**
  101627. * Gets the list of input blocks attached to this material
  101628. * @returns an array of InputBlocks
  101629. */
  101630. getInputBlocks(): InputBlock[];
  101631. /**
  101632. * Adds a new optimizer to the list of optimizers
  101633. * @param optimizer defines the optimizers to add
  101634. * @returns the current material
  101635. */
  101636. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  101637. /**
  101638. * Remove an optimizer from the list of optimizers
  101639. * @param optimizer defines the optimizers to remove
  101640. * @returns the current material
  101641. */
  101642. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  101643. /**
  101644. * Add a new block to the list of output nodes
  101645. * @param node defines the node to add
  101646. * @returns the current material
  101647. */
  101648. addOutputNode(node: NodeMaterialBlock): this;
  101649. /**
  101650. * Remove a block from the list of root nodes
  101651. * @param node defines the node to remove
  101652. * @returns the current material
  101653. */
  101654. removeOutputNode(node: NodeMaterialBlock): this;
  101655. private _addVertexOutputNode;
  101656. private _removeVertexOutputNode;
  101657. private _addFragmentOutputNode;
  101658. private _removeFragmentOutputNode;
  101659. /**
  101660. * Specifies if the material will require alpha blending
  101661. * @returns a boolean specifying if alpha blending is needed
  101662. */
  101663. needAlphaBlending(): boolean;
  101664. /**
  101665. * Specifies if this material should be rendered in alpha test mode
  101666. * @returns a boolean specifying if an alpha test is needed.
  101667. */
  101668. needAlphaTesting(): boolean;
  101669. private _initializeBlock;
  101670. private _resetDualBlocks;
  101671. /**
  101672. * Remove a block from the current node material
  101673. * @param block defines the block to remove
  101674. */
  101675. removeBlock(block: NodeMaterialBlock): void;
  101676. /**
  101677. * Build the material and generates the inner effect
  101678. * @param verbose defines if the build should log activity
  101679. */
  101680. build(verbose?: boolean): void;
  101681. /**
  101682. * Runs an otpimization phase to try to improve the shader code
  101683. */
  101684. optimize(): void;
  101685. private _prepareDefinesForAttributes;
  101686. /**
  101687. * Create a post process from the material
  101688. * @param camera The camera to apply the render pass to.
  101689. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  101690. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  101691. * @param engine The engine which the post process will be applied. (default: current engine)
  101692. * @param reusable If the post process can be reused on the same frame. (default: false)
  101693. * @param textureType Type of textures used when performing the post process. (default: 0)
  101694. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  101695. * @returns the post process created
  101696. */
  101697. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  101698. /**
  101699. * Create the post process effect from the material
  101700. * @param postProcess The post process to create the effect for
  101701. */
  101702. createEffectForPostProcess(postProcess: PostProcess): void;
  101703. private _createEffectOrPostProcess;
  101704. private _createEffectForParticles;
  101705. /**
  101706. * Create the effect to be used as the custom effect for a particle system
  101707. * @param particleSystem Particle system to create the effect for
  101708. * @param onCompiled defines a function to call when the effect creation is successful
  101709. * @param onError defines a function to call when the effect creation has failed
  101710. */
  101711. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  101712. private _processDefines;
  101713. /**
  101714. * Get if the submesh is ready to be used and all its information available.
  101715. * Child classes can use it to update shaders
  101716. * @param mesh defines the mesh to check
  101717. * @param subMesh defines which submesh to check
  101718. * @param useInstances specifies that instances should be used
  101719. * @returns a boolean indicating that the submesh is ready or not
  101720. */
  101721. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  101722. /**
  101723. * Get a string representing the shaders built by the current node graph
  101724. */
  101725. get compiledShaders(): string;
  101726. /**
  101727. * Binds the world matrix to the material
  101728. * @param world defines the world transformation matrix
  101729. */
  101730. bindOnlyWorldMatrix(world: Matrix): void;
  101731. /**
  101732. * Binds the submesh to this material by preparing the effect and shader to draw
  101733. * @param world defines the world transformation matrix
  101734. * @param mesh defines the mesh containing the submesh
  101735. * @param subMesh defines the submesh to bind the material to
  101736. */
  101737. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  101738. /**
  101739. * Gets the active textures from the material
  101740. * @returns an array of textures
  101741. */
  101742. getActiveTextures(): BaseTexture[];
  101743. /**
  101744. * Gets the list of texture blocks
  101745. * @returns an array of texture blocks
  101746. */
  101747. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  101748. /**
  101749. * Specifies if the material uses a texture
  101750. * @param texture defines the texture to check against the material
  101751. * @returns a boolean specifying if the material uses the texture
  101752. */
  101753. hasTexture(texture: BaseTexture): boolean;
  101754. /**
  101755. * Disposes the material
  101756. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  101757. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  101758. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  101759. */
  101760. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  101761. /** Creates the node editor window. */
  101762. private _createNodeEditor;
  101763. /**
  101764. * Launch the node material editor
  101765. * @param config Define the configuration of the editor
  101766. * @return a promise fulfilled when the node editor is visible
  101767. */
  101768. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  101769. /**
  101770. * Clear the current material
  101771. */
  101772. clear(): void;
  101773. /**
  101774. * Clear the current material and set it to a default state
  101775. */
  101776. setToDefault(): void;
  101777. /**
  101778. * Clear the current material and set it to a default state for post process
  101779. */
  101780. setToDefaultPostProcess(): void;
  101781. /**
  101782. * Clear the current material and set it to a default state for particle
  101783. */
  101784. setToDefaultParticle(): void;
  101785. /**
  101786. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  101787. * @param url defines the url to load from
  101788. * @returns a promise that will fullfil when the material is fully loaded
  101789. */
  101790. loadAsync(url: string): Promise<void>;
  101791. private _gatherBlocks;
  101792. /**
  101793. * Generate a string containing the code declaration required to create an equivalent of this material
  101794. * @returns a string
  101795. */
  101796. generateCode(): string;
  101797. /**
  101798. * Serializes this material in a JSON representation
  101799. * @returns the serialized material object
  101800. */
  101801. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  101802. private _restoreConnections;
  101803. /**
  101804. * Clear the current graph and load a new one from a serialization object
  101805. * @param source defines the JSON representation of the material
  101806. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  101807. * @param merge defines whether or not the source must be merged or replace the current content
  101808. */
  101809. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  101810. /**
  101811. * Makes a duplicate of the current material.
  101812. * @param name - name to use for the new material.
  101813. */
  101814. clone(name: string): NodeMaterial;
  101815. /**
  101816. * Creates a node material from parsed material data
  101817. * @param source defines the JSON representation of the material
  101818. * @param scene defines the hosting scene
  101819. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  101820. * @returns a new node material
  101821. */
  101822. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  101823. /**
  101824. * Creates a node material from a snippet saved in a remote file
  101825. * @param name defines the name of the material to create
  101826. * @param url defines the url to load from
  101827. * @param scene defines the hosting scene
  101828. * @returns a promise that will resolve to the new node material
  101829. */
  101830. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  101831. /**
  101832. * Creates a node material from a snippet saved by the node material editor
  101833. * @param snippetId defines the snippet to load
  101834. * @param scene defines the hosting scene
  101835. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  101836. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  101837. * @returns a promise that will resolve to the new node material
  101838. */
  101839. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  101840. /**
  101841. * Creates a new node material set to default basic configuration
  101842. * @param name defines the name of the material
  101843. * @param scene defines the hosting scene
  101844. * @returns a new NodeMaterial
  101845. */
  101846. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  101847. }
  101848. }
  101849. declare module BABYLON {
  101850. /**
  101851. * Size options for a post process
  101852. */
  101853. export type PostProcessOptions = {
  101854. width: number;
  101855. height: number;
  101856. };
  101857. /**
  101858. * PostProcess can be used to apply a shader to a texture after it has been rendered
  101859. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  101860. */
  101861. export class PostProcess {
  101862. /**
  101863. * Gets or sets the unique id of the post process
  101864. */
  101865. uniqueId: number;
  101866. /** Name of the PostProcess. */
  101867. name: string;
  101868. /**
  101869. * Width of the texture to apply the post process on
  101870. */
  101871. width: number;
  101872. /**
  101873. * Height of the texture to apply the post process on
  101874. */
  101875. height: number;
  101876. /**
  101877. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  101878. */
  101879. nodeMaterialSource: Nullable<NodeMaterial>;
  101880. /**
  101881. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  101882. * @hidden
  101883. */
  101884. _outputTexture: Nullable<InternalTexture>;
  101885. /**
  101886. * Sampling mode used by the shader
  101887. * See https://doc.babylonjs.com/classes/3.1/texture
  101888. */
  101889. renderTargetSamplingMode: number;
  101890. /**
  101891. * Clear color to use when screen clearing
  101892. */
  101893. clearColor: Color4;
  101894. /**
  101895. * If the buffer needs to be cleared before applying the post process. (default: true)
  101896. * Should be set to false if shader will overwrite all previous pixels.
  101897. */
  101898. autoClear: boolean;
  101899. /**
  101900. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  101901. */
  101902. alphaMode: number;
  101903. /**
  101904. * Sets the setAlphaBlendConstants of the babylon engine
  101905. */
  101906. alphaConstants: Color4;
  101907. /**
  101908. * Animations to be used for the post processing
  101909. */
  101910. animations: Animation[];
  101911. /**
  101912. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  101913. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  101914. */
  101915. enablePixelPerfectMode: boolean;
  101916. /**
  101917. * Force the postprocess to be applied without taking in account viewport
  101918. */
  101919. forceFullscreenViewport: boolean;
  101920. /**
  101921. * List of inspectable custom properties (used by the Inspector)
  101922. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  101923. */
  101924. inspectableCustomProperties: IInspectable[];
  101925. /**
  101926. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  101927. *
  101928. * | Value | Type | Description |
  101929. * | ----- | ----------------------------------- | ----------- |
  101930. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  101931. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  101932. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  101933. *
  101934. */
  101935. scaleMode: number;
  101936. /**
  101937. * Force textures to be a power of two (default: false)
  101938. */
  101939. alwaysForcePOT: boolean;
  101940. private _samples;
  101941. /**
  101942. * Number of sample textures (default: 1)
  101943. */
  101944. get samples(): number;
  101945. set samples(n: number);
  101946. /**
  101947. * Modify the scale of the post process to be the same as the viewport (default: false)
  101948. */
  101949. adaptScaleToCurrentViewport: boolean;
  101950. private _camera;
  101951. protected _scene: Scene;
  101952. private _engine;
  101953. private _options;
  101954. private _reusable;
  101955. private _textureType;
  101956. private _textureFormat;
  101957. /**
  101958. * Smart array of input and output textures for the post process.
  101959. * @hidden
  101960. */
  101961. _textures: SmartArray<InternalTexture>;
  101962. /**
  101963. * The index in _textures that corresponds to the output texture.
  101964. * @hidden
  101965. */
  101966. _currentRenderTextureInd: number;
  101967. private _effect;
  101968. private _samplers;
  101969. private _fragmentUrl;
  101970. private _vertexUrl;
  101971. private _parameters;
  101972. private _scaleRatio;
  101973. protected _indexParameters: any;
  101974. private _shareOutputWithPostProcess;
  101975. private _texelSize;
  101976. private _forcedOutputTexture;
  101977. /**
  101978. * Returns the fragment url or shader name used in the post process.
  101979. * @returns the fragment url or name in the shader store.
  101980. */
  101981. getEffectName(): string;
  101982. /**
  101983. * An event triggered when the postprocess is activated.
  101984. */
  101985. onActivateObservable: Observable<Camera>;
  101986. private _onActivateObserver;
  101987. /**
  101988. * A function that is added to the onActivateObservable
  101989. */
  101990. set onActivate(callback: Nullable<(camera: Camera) => void>);
  101991. /**
  101992. * An event triggered when the postprocess changes its size.
  101993. */
  101994. onSizeChangedObservable: Observable<PostProcess>;
  101995. private _onSizeChangedObserver;
  101996. /**
  101997. * A function that is added to the onSizeChangedObservable
  101998. */
  101999. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  102000. /**
  102001. * An event triggered when the postprocess applies its effect.
  102002. */
  102003. onApplyObservable: Observable<Effect>;
  102004. private _onApplyObserver;
  102005. /**
  102006. * A function that is added to the onApplyObservable
  102007. */
  102008. set onApply(callback: (effect: Effect) => void);
  102009. /**
  102010. * An event triggered before rendering the postprocess
  102011. */
  102012. onBeforeRenderObservable: Observable<Effect>;
  102013. private _onBeforeRenderObserver;
  102014. /**
  102015. * A function that is added to the onBeforeRenderObservable
  102016. */
  102017. set onBeforeRender(callback: (effect: Effect) => void);
  102018. /**
  102019. * An event triggered after rendering the postprocess
  102020. */
  102021. onAfterRenderObservable: Observable<Effect>;
  102022. private _onAfterRenderObserver;
  102023. /**
  102024. * A function that is added to the onAfterRenderObservable
  102025. */
  102026. set onAfterRender(callback: (efect: Effect) => void);
  102027. /**
  102028. * 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
  102029. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  102030. */
  102031. get inputTexture(): InternalTexture;
  102032. set inputTexture(value: InternalTexture);
  102033. /**
  102034. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  102035. * the only way to unset it is to use this function to restore its internal state
  102036. */
  102037. restoreDefaultInputTexture(): void;
  102038. /**
  102039. * Gets the camera which post process is applied to.
  102040. * @returns The camera the post process is applied to.
  102041. */
  102042. getCamera(): Camera;
  102043. /**
  102044. * Gets the texel size of the postprocess.
  102045. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  102046. */
  102047. get texelSize(): Vector2;
  102048. /**
  102049. * Creates a new instance PostProcess
  102050. * @param name The name of the PostProcess.
  102051. * @param fragmentUrl The url of the fragment shader to be used.
  102052. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  102053. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  102054. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  102055. * @param camera The camera to apply the render pass to.
  102056. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  102057. * @param engine The engine which the post process will be applied. (default: current engine)
  102058. * @param reusable If the post process can be reused on the same frame. (default: false)
  102059. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  102060. * @param textureType Type of textures used when performing the post process. (default: 0)
  102061. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  102062. * @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
  102063. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  102064. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  102065. */
  102066. 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);
  102067. /**
  102068. * Gets a string identifying the name of the class
  102069. * @returns "PostProcess" string
  102070. */
  102071. getClassName(): string;
  102072. /**
  102073. * Gets the engine which this post process belongs to.
  102074. * @returns The engine the post process was enabled with.
  102075. */
  102076. getEngine(): Engine;
  102077. /**
  102078. * The effect that is created when initializing the post process.
  102079. * @returns The created effect corresponding the the postprocess.
  102080. */
  102081. getEffect(): Effect;
  102082. /**
  102083. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  102084. * @param postProcess The post process to share the output with.
  102085. * @returns This post process.
  102086. */
  102087. shareOutputWith(postProcess: PostProcess): PostProcess;
  102088. /**
  102089. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  102090. * This should be called if the post process that shares output with this post process is disabled/disposed.
  102091. */
  102092. useOwnOutput(): void;
  102093. /**
  102094. * Updates the effect with the current post process compile time values and recompiles the shader.
  102095. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  102096. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  102097. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  102098. * @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
  102099. * @param onCompiled Called when the shader has been compiled.
  102100. * @param onError Called if there is an error when compiling a shader.
  102101. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  102102. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  102103. */
  102104. 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;
  102105. /**
  102106. * The post process is reusable if it can be used multiple times within one frame.
  102107. * @returns If the post process is reusable
  102108. */
  102109. isReusable(): boolean;
  102110. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  102111. markTextureDirty(): void;
  102112. /**
  102113. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  102114. * 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.
  102115. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  102116. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  102117. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  102118. * @returns The target texture that was bound to be written to.
  102119. */
  102120. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  102121. /**
  102122. * If the post process is supported.
  102123. */
  102124. get isSupported(): boolean;
  102125. /**
  102126. * The aspect ratio of the output texture.
  102127. */
  102128. get aspectRatio(): number;
  102129. /**
  102130. * Get a value indicating if the post-process is ready to be used
  102131. * @returns true if the post-process is ready (shader is compiled)
  102132. */
  102133. isReady(): boolean;
  102134. /**
  102135. * Binds all textures and uniforms to the shader, this will be run on every pass.
  102136. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  102137. */
  102138. apply(): Nullable<Effect>;
  102139. private _disposeTextures;
  102140. /**
  102141. * Disposes the post process.
  102142. * @param camera The camera to dispose the post process on.
  102143. */
  102144. dispose(camera?: Camera): void;
  102145. /**
  102146. * Serializes the particle system to a JSON object
  102147. * @returns the JSON object
  102148. */
  102149. serialize(): any;
  102150. /**
  102151. * Creates a material from parsed material data
  102152. * @param parsedPostProcess defines parsed post process data
  102153. * @param scene defines the hosting scene
  102154. * @param rootUrl defines the root URL to use to load textures
  102155. * @returns a new post process
  102156. */
  102157. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  102158. }
  102159. }
  102160. declare module BABYLON {
  102161. /** @hidden */
  102162. export var kernelBlurVaryingDeclaration: {
  102163. name: string;
  102164. shader: string;
  102165. };
  102166. }
  102167. declare module BABYLON {
  102168. /** @hidden */
  102169. export var kernelBlurFragment: {
  102170. name: string;
  102171. shader: string;
  102172. };
  102173. }
  102174. declare module BABYLON {
  102175. /** @hidden */
  102176. export var kernelBlurFragment2: {
  102177. name: string;
  102178. shader: string;
  102179. };
  102180. }
  102181. declare module BABYLON {
  102182. /** @hidden */
  102183. export var kernelBlurPixelShader: {
  102184. name: string;
  102185. shader: string;
  102186. };
  102187. }
  102188. declare module BABYLON {
  102189. /** @hidden */
  102190. export var kernelBlurVertex: {
  102191. name: string;
  102192. shader: string;
  102193. };
  102194. }
  102195. declare module BABYLON {
  102196. /** @hidden */
  102197. export var kernelBlurVertexShader: {
  102198. name: string;
  102199. shader: string;
  102200. };
  102201. }
  102202. declare module BABYLON {
  102203. /**
  102204. * The Blur Post Process which blurs an image based on a kernel and direction.
  102205. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  102206. */
  102207. export class BlurPostProcess extends PostProcess {
  102208. private blockCompilation;
  102209. protected _kernel: number;
  102210. protected _idealKernel: number;
  102211. protected _packedFloat: boolean;
  102212. private _staticDefines;
  102213. /** The direction in which to blur the image. */
  102214. direction: Vector2;
  102215. /**
  102216. * Sets the length in pixels of the blur sample region
  102217. */
  102218. set kernel(v: number);
  102219. /**
  102220. * Gets the length in pixels of the blur sample region
  102221. */
  102222. get kernel(): number;
  102223. /**
  102224. * Sets wether or not the blur needs to unpack/repack floats
  102225. */
  102226. set packedFloat(v: boolean);
  102227. /**
  102228. * Gets wether or not the blur is unpacking/repacking floats
  102229. */
  102230. get packedFloat(): boolean;
  102231. /**
  102232. * Gets a string identifying the name of the class
  102233. * @returns "BlurPostProcess" string
  102234. */
  102235. getClassName(): string;
  102236. /**
  102237. * Creates a new instance BlurPostProcess
  102238. * @param name The name of the effect.
  102239. * @param direction The direction in which to blur the image.
  102240. * @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.
  102241. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  102242. * @param camera The camera to apply the render pass to.
  102243. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  102244. * @param engine The engine which the post process will be applied. (default: current engine)
  102245. * @param reusable If the post process can be reused on the same frame. (default: false)
  102246. * @param textureType Type of textures used when performing the post process. (default: 0)
  102247. * @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)
  102248. */
  102249. 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);
  102250. /**
  102251. * Updates the effect with the current post process compile time values and recompiles the shader.
  102252. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  102253. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  102254. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  102255. * @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
  102256. * @param onCompiled Called when the shader has been compiled.
  102257. * @param onError Called if there is an error when compiling a shader.
  102258. */
  102259. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  102260. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  102261. /**
  102262. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  102263. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  102264. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  102265. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  102266. * The gaps between physical kernels are compensated for in the weighting of the samples
  102267. * @param idealKernel Ideal blur kernel.
  102268. * @return Nearest best kernel.
  102269. */
  102270. protected _nearestBestKernel(idealKernel: number): number;
  102271. /**
  102272. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  102273. * @param x The point on the Gaussian distribution to sample.
  102274. * @return the value of the Gaussian function at x.
  102275. */
  102276. protected _gaussianWeight(x: number): number;
  102277. /**
  102278. * Generates a string that can be used as a floating point number in GLSL.
  102279. * @param x Value to print.
  102280. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  102281. * @return GLSL float string.
  102282. */
  102283. protected _glslFloat(x: number, decimalFigures?: number): string;
  102284. /** @hidden */
  102285. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  102286. }
  102287. }
  102288. declare module BABYLON {
  102289. /**
  102290. * Mirror texture can be used to simulate the view from a mirror in a scene.
  102291. * It will dynamically be rendered every frame to adapt to the camera point of view.
  102292. * You can then easily use it as a reflectionTexture on a flat surface.
  102293. * In case the surface is not a plane, please consider relying on reflection probes.
  102294. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  102295. */
  102296. export class MirrorTexture extends RenderTargetTexture {
  102297. private scene;
  102298. /**
  102299. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  102300. * 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.
  102301. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  102302. */
  102303. mirrorPlane: Plane;
  102304. /**
  102305. * Define the blur ratio used to blur the reflection if needed.
  102306. */
  102307. set blurRatio(value: number);
  102308. get blurRatio(): number;
  102309. /**
  102310. * Define the adaptive blur kernel used to blur the reflection if needed.
  102311. * This will autocompute the closest best match for the `blurKernel`
  102312. */
  102313. set adaptiveBlurKernel(value: number);
  102314. /**
  102315. * Define the blur kernel used to blur the reflection if needed.
  102316. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  102317. */
  102318. set blurKernel(value: number);
  102319. /**
  102320. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  102321. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  102322. */
  102323. set blurKernelX(value: number);
  102324. get blurKernelX(): number;
  102325. /**
  102326. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  102327. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  102328. */
  102329. set blurKernelY(value: number);
  102330. get blurKernelY(): number;
  102331. private _autoComputeBlurKernel;
  102332. protected _onRatioRescale(): void;
  102333. private _updateGammaSpace;
  102334. private _imageProcessingConfigChangeObserver;
  102335. private _transformMatrix;
  102336. private _mirrorMatrix;
  102337. private _savedViewMatrix;
  102338. private _blurX;
  102339. private _blurY;
  102340. private _adaptiveBlurKernel;
  102341. private _blurKernelX;
  102342. private _blurKernelY;
  102343. private _blurRatio;
  102344. /**
  102345. * Instantiates a Mirror Texture.
  102346. * Mirror texture can be used to simulate the view from a mirror in a scene.
  102347. * It will dynamically be rendered every frame to adapt to the camera point of view.
  102348. * You can then easily use it as a reflectionTexture on a flat surface.
  102349. * In case the surface is not a plane, please consider relying on reflection probes.
  102350. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  102351. * @param name
  102352. * @param size
  102353. * @param scene
  102354. * @param generateMipMaps
  102355. * @param type
  102356. * @param samplingMode
  102357. * @param generateDepthBuffer
  102358. */
  102359. constructor(name: string, size: number | {
  102360. width: number;
  102361. height: number;
  102362. } | {
  102363. ratio: number;
  102364. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  102365. private _preparePostProcesses;
  102366. /**
  102367. * Clone the mirror texture.
  102368. * @returns the cloned texture
  102369. */
  102370. clone(): MirrorTexture;
  102371. /**
  102372. * Serialize the texture to a JSON representation you could use in Parse later on
  102373. * @returns the serialized JSON representation
  102374. */
  102375. serialize(): any;
  102376. /**
  102377. * Dispose the texture and release its associated resources.
  102378. */
  102379. dispose(): void;
  102380. }
  102381. }
  102382. declare module BABYLON {
  102383. /**
  102384. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  102385. * @see https://doc.babylonjs.com/babylon101/materials#texture
  102386. */
  102387. export class Texture extends BaseTexture {
  102388. /**
  102389. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  102390. */
  102391. static SerializeBuffers: boolean;
  102392. /** @hidden */
  102393. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  102394. /** @hidden */
  102395. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  102396. /** @hidden */
  102397. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  102398. /** nearest is mag = nearest and min = nearest and mip = linear */
  102399. static readonly NEAREST_SAMPLINGMODE: number;
  102400. /** nearest is mag = nearest and min = nearest and mip = linear */
  102401. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  102402. /** Bilinear is mag = linear and min = linear and mip = nearest */
  102403. static readonly BILINEAR_SAMPLINGMODE: number;
  102404. /** Bilinear is mag = linear and min = linear and mip = nearest */
  102405. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  102406. /** Trilinear is mag = linear and min = linear and mip = linear */
  102407. static readonly TRILINEAR_SAMPLINGMODE: number;
  102408. /** Trilinear is mag = linear and min = linear and mip = linear */
  102409. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  102410. /** mag = nearest and min = nearest and mip = nearest */
  102411. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  102412. /** mag = nearest and min = linear and mip = nearest */
  102413. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  102414. /** mag = nearest and min = linear and mip = linear */
  102415. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  102416. /** mag = nearest and min = linear and mip = none */
  102417. static readonly NEAREST_LINEAR: number;
  102418. /** mag = nearest and min = nearest and mip = none */
  102419. static readonly NEAREST_NEAREST: number;
  102420. /** mag = linear and min = nearest and mip = nearest */
  102421. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  102422. /** mag = linear and min = nearest and mip = linear */
  102423. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  102424. /** mag = linear and min = linear and mip = none */
  102425. static readonly LINEAR_LINEAR: number;
  102426. /** mag = linear and min = nearest and mip = none */
  102427. static readonly LINEAR_NEAREST: number;
  102428. /** Explicit coordinates mode */
  102429. static readonly EXPLICIT_MODE: number;
  102430. /** Spherical coordinates mode */
  102431. static readonly SPHERICAL_MODE: number;
  102432. /** Planar coordinates mode */
  102433. static readonly PLANAR_MODE: number;
  102434. /** Cubic coordinates mode */
  102435. static readonly CUBIC_MODE: number;
  102436. /** Projection coordinates mode */
  102437. static readonly PROJECTION_MODE: number;
  102438. /** Inverse Cubic coordinates mode */
  102439. static readonly SKYBOX_MODE: number;
  102440. /** Inverse Cubic coordinates mode */
  102441. static readonly INVCUBIC_MODE: number;
  102442. /** Equirectangular coordinates mode */
  102443. static readonly EQUIRECTANGULAR_MODE: number;
  102444. /** Equirectangular Fixed coordinates mode */
  102445. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  102446. /** Equirectangular Fixed Mirrored coordinates mode */
  102447. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  102448. /** Texture is not repeating outside of 0..1 UVs */
  102449. static readonly CLAMP_ADDRESSMODE: number;
  102450. /** Texture is repeating outside of 0..1 UVs */
  102451. static readonly WRAP_ADDRESSMODE: number;
  102452. /** Texture is repeating and mirrored */
  102453. static readonly MIRROR_ADDRESSMODE: number;
  102454. /**
  102455. * 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
  102456. */
  102457. static UseSerializedUrlIfAny: boolean;
  102458. /**
  102459. * Define the url of the texture.
  102460. */
  102461. url: Nullable<string>;
  102462. /**
  102463. * Define an offset on the texture to offset the u coordinates of the UVs
  102464. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  102465. */
  102466. uOffset: number;
  102467. /**
  102468. * Define an offset on the texture to offset the v coordinates of the UVs
  102469. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  102470. */
  102471. vOffset: number;
  102472. /**
  102473. * Define an offset on the texture to scale the u coordinates of the UVs
  102474. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  102475. */
  102476. uScale: number;
  102477. /**
  102478. * Define an offset on the texture to scale the v coordinates of the UVs
  102479. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  102480. */
  102481. vScale: number;
  102482. /**
  102483. * Define an offset on the texture to rotate around the u coordinates of the UVs
  102484. * @see https://doc.babylonjs.com/how_to/more_materials
  102485. */
  102486. uAng: number;
  102487. /**
  102488. * Define an offset on the texture to rotate around the v coordinates of the UVs
  102489. * @see https://doc.babylonjs.com/how_to/more_materials
  102490. */
  102491. vAng: number;
  102492. /**
  102493. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  102494. * @see https://doc.babylonjs.com/how_to/more_materials
  102495. */
  102496. wAng: number;
  102497. /**
  102498. * Defines the center of rotation (U)
  102499. */
  102500. uRotationCenter: number;
  102501. /**
  102502. * Defines the center of rotation (V)
  102503. */
  102504. vRotationCenter: number;
  102505. /**
  102506. * Defines the center of rotation (W)
  102507. */
  102508. wRotationCenter: number;
  102509. /**
  102510. * Are mip maps generated for this texture or not.
  102511. */
  102512. get noMipmap(): boolean;
  102513. /**
  102514. * List of inspectable custom properties (used by the Inspector)
  102515. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  102516. */
  102517. inspectableCustomProperties: Nullable<IInspectable[]>;
  102518. private _noMipmap;
  102519. /** @hidden */
  102520. _invertY: boolean;
  102521. private _rowGenerationMatrix;
  102522. private _cachedTextureMatrix;
  102523. private _projectionModeMatrix;
  102524. private _t0;
  102525. private _t1;
  102526. private _t2;
  102527. private _cachedUOffset;
  102528. private _cachedVOffset;
  102529. private _cachedUScale;
  102530. private _cachedVScale;
  102531. private _cachedUAng;
  102532. private _cachedVAng;
  102533. private _cachedWAng;
  102534. private _cachedProjectionMatrixId;
  102535. private _cachedCoordinatesMode;
  102536. /** @hidden */
  102537. protected _initialSamplingMode: number;
  102538. /** @hidden */
  102539. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  102540. private _deleteBuffer;
  102541. protected _format: Nullable<number>;
  102542. private _delayedOnLoad;
  102543. private _delayedOnError;
  102544. private _mimeType?;
  102545. /**
  102546. * Observable triggered once the texture has been loaded.
  102547. */
  102548. onLoadObservable: Observable<Texture>;
  102549. protected _isBlocking: boolean;
  102550. /**
  102551. * Is the texture preventing material to render while loading.
  102552. * If false, a default texture will be used instead of the loading one during the preparation step.
  102553. */
  102554. set isBlocking(value: boolean);
  102555. get isBlocking(): boolean;
  102556. /**
  102557. * Get the current sampling mode associated with the texture.
  102558. */
  102559. get samplingMode(): number;
  102560. /**
  102561. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  102562. */
  102563. get invertY(): boolean;
  102564. /**
  102565. * Instantiates a new texture.
  102566. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  102567. * @see https://doc.babylonjs.com/babylon101/materials#texture
  102568. * @param url defines the url of the picture to load as a texture
  102569. * @param sceneOrEngine defines the scene or engine the texture will belong to
  102570. * @param noMipmap defines if the texture will require mip maps or not
  102571. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  102572. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  102573. * @param onLoad defines a callback triggered when the texture has been loaded
  102574. * @param onError defines a callback triggered when an error occurred during the loading session
  102575. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  102576. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  102577. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  102578. * @param mimeType defines an optional mime type information
  102579. */
  102580. 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);
  102581. /**
  102582. * Update the url (and optional buffer) of this texture if url was null during construction.
  102583. * @param url the url of the texture
  102584. * @param buffer the buffer of the texture (defaults to null)
  102585. * @param onLoad callback called when the texture is loaded (defaults to null)
  102586. */
  102587. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  102588. /**
  102589. * Finish the loading sequence of a texture flagged as delayed load.
  102590. * @hidden
  102591. */
  102592. delayLoad(): void;
  102593. private _prepareRowForTextureGeneration;
  102594. /**
  102595. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  102596. * @returns the transform matrix of the texture.
  102597. */
  102598. getTextureMatrix(uBase?: number): Matrix;
  102599. /**
  102600. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  102601. * @returns The reflection texture transform
  102602. */
  102603. getReflectionTextureMatrix(): Matrix;
  102604. /**
  102605. * Clones the texture.
  102606. * @returns the cloned texture
  102607. */
  102608. clone(): Texture;
  102609. /**
  102610. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  102611. * @returns The JSON representation of the texture
  102612. */
  102613. serialize(): any;
  102614. /**
  102615. * Get the current class name of the texture useful for serialization or dynamic coding.
  102616. * @returns "Texture"
  102617. */
  102618. getClassName(): string;
  102619. /**
  102620. * Dispose the texture and release its associated resources.
  102621. */
  102622. dispose(): void;
  102623. /**
  102624. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  102625. * @param parsedTexture Define the JSON representation of the texture
  102626. * @param scene Define the scene the parsed texture should be instantiated in
  102627. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  102628. * @returns The parsed texture if successful
  102629. */
  102630. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  102631. /**
  102632. * Creates a texture from its base 64 representation.
  102633. * @param data Define the base64 payload without the data: prefix
  102634. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  102635. * @param scene Define the scene the texture should belong to
  102636. * @param noMipmap Forces the texture to not create mip map information if true
  102637. * @param invertY define if the texture needs to be inverted on the y axis during loading
  102638. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  102639. * @param onLoad define a callback triggered when the texture has been loaded
  102640. * @param onError define a callback triggered when an error occurred during the loading session
  102641. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  102642. * @returns the created texture
  102643. */
  102644. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  102645. /**
  102646. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  102647. * @param data Define the base64 payload without the data: prefix
  102648. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  102649. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  102650. * @param scene Define the scene the texture should belong to
  102651. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  102652. * @param noMipmap Forces the texture to not create mip map information if true
  102653. * @param invertY define if the texture needs to be inverted on the y axis during loading
  102654. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  102655. * @param onLoad define a callback triggered when the texture has been loaded
  102656. * @param onError define a callback triggered when an error occurred during the loading session
  102657. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  102658. * @returns the created texture
  102659. */
  102660. 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;
  102661. }
  102662. }
  102663. declare module BABYLON {
  102664. /**
  102665. * PostProcessManager is used to manage one or more post processes or post process pipelines
  102666. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  102667. */
  102668. export class PostProcessManager {
  102669. private _scene;
  102670. private _indexBuffer;
  102671. private _vertexBuffers;
  102672. /**
  102673. * Creates a new instance PostProcess
  102674. * @param scene The scene that the post process is associated with.
  102675. */
  102676. constructor(scene: Scene);
  102677. private _prepareBuffers;
  102678. private _buildIndexBuffer;
  102679. /**
  102680. * Rebuilds the vertex buffers of the manager.
  102681. * @hidden
  102682. */
  102683. _rebuild(): void;
  102684. /**
  102685. * Prepares a frame to be run through a post process.
  102686. * @param sourceTexture The input texture to the post procesess. (default: null)
  102687. * @param postProcesses An array of post processes to be run. (default: null)
  102688. * @returns True if the post processes were able to be run.
  102689. * @hidden
  102690. */
  102691. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  102692. /**
  102693. * Manually render a set of post processes to a texture.
  102694. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  102695. * @param postProcesses An array of post processes to be run.
  102696. * @param targetTexture The target texture to render to.
  102697. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  102698. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  102699. * @param lodLevel defines which lod of the texture to render to
  102700. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  102701. */
  102702. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  102703. /**
  102704. * Finalize the result of the output of the postprocesses.
  102705. * @param doNotPresent If true the result will not be displayed to the screen.
  102706. * @param targetTexture The target texture to render to.
  102707. * @param faceIndex The index of the face to bind the target texture to.
  102708. * @param postProcesses The array of post processes to render.
  102709. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  102710. * @hidden
  102711. */
  102712. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  102713. /**
  102714. * Disposes of the post process manager.
  102715. */
  102716. dispose(): void;
  102717. }
  102718. }
  102719. declare module BABYLON {
  102720. /**
  102721. * This Helps creating a texture that will be created from a camera in your scene.
  102722. * It is basically a dynamic texture that could be used to create special effects for instance.
  102723. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  102724. */
  102725. export class RenderTargetTexture extends Texture {
  102726. isCube: boolean;
  102727. /**
  102728. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  102729. */
  102730. static readonly REFRESHRATE_RENDER_ONCE: number;
  102731. /**
  102732. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  102733. */
  102734. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  102735. /**
  102736. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  102737. * the central point of your effect and can save a lot of performances.
  102738. */
  102739. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  102740. /**
  102741. * Use this predicate to dynamically define the list of mesh you want to render.
  102742. * If set, the renderList property will be overwritten.
  102743. */
  102744. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  102745. private _renderList;
  102746. /**
  102747. * Use this list to define the list of mesh you want to render.
  102748. */
  102749. get renderList(): Nullable<Array<AbstractMesh>>;
  102750. set renderList(value: Nullable<Array<AbstractMesh>>);
  102751. /**
  102752. * Use this function to overload the renderList array at rendering time.
  102753. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  102754. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  102755. * the cube (if the RTT is a cube, else layerOrFace=0).
  102756. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  102757. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  102758. * hold dummy elements!
  102759. */
  102760. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  102761. private _hookArray;
  102762. /**
  102763. * Define if particles should be rendered in your texture.
  102764. */
  102765. renderParticles: boolean;
  102766. /**
  102767. * Define if sprites should be rendered in your texture.
  102768. */
  102769. renderSprites: boolean;
  102770. /**
  102771. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  102772. */
  102773. coordinatesMode: number;
  102774. /**
  102775. * Define the camera used to render the texture.
  102776. */
  102777. activeCamera: Nullable<Camera>;
  102778. /**
  102779. * Override the mesh isReady function with your own one.
  102780. */
  102781. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  102782. /**
  102783. * Override the render function of the texture with your own one.
  102784. */
  102785. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  102786. /**
  102787. * Define if camera post processes should be use while rendering the texture.
  102788. */
  102789. useCameraPostProcesses: boolean;
  102790. /**
  102791. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  102792. */
  102793. ignoreCameraViewport: boolean;
  102794. private _postProcessManager;
  102795. private _postProcesses;
  102796. private _resizeObserver;
  102797. /**
  102798. * An event triggered when the texture is unbind.
  102799. */
  102800. onBeforeBindObservable: Observable<RenderTargetTexture>;
  102801. /**
  102802. * An event triggered when the texture is unbind.
  102803. */
  102804. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  102805. private _onAfterUnbindObserver;
  102806. /**
  102807. * Set a after unbind callback in the texture.
  102808. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  102809. */
  102810. set onAfterUnbind(callback: () => void);
  102811. /**
  102812. * An event triggered before rendering the texture
  102813. */
  102814. onBeforeRenderObservable: Observable<number>;
  102815. private _onBeforeRenderObserver;
  102816. /**
  102817. * Set a before render callback in the texture.
  102818. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  102819. */
  102820. set onBeforeRender(callback: (faceIndex: number) => void);
  102821. /**
  102822. * An event triggered after rendering the texture
  102823. */
  102824. onAfterRenderObservable: Observable<number>;
  102825. private _onAfterRenderObserver;
  102826. /**
  102827. * Set a after render callback in the texture.
  102828. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  102829. */
  102830. set onAfterRender(callback: (faceIndex: number) => void);
  102831. /**
  102832. * An event triggered after the texture clear
  102833. */
  102834. onClearObservable: Observable<Engine>;
  102835. private _onClearObserver;
  102836. /**
  102837. * Set a clear callback in the texture.
  102838. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  102839. */
  102840. set onClear(callback: (Engine: Engine) => void);
  102841. /**
  102842. * An event triggered when the texture is resized.
  102843. */
  102844. onResizeObservable: Observable<RenderTargetTexture>;
  102845. /**
  102846. * Define the clear color of the Render Target if it should be different from the scene.
  102847. */
  102848. clearColor: Color4;
  102849. protected _size: number | {
  102850. width: number;
  102851. height: number;
  102852. layers?: number;
  102853. };
  102854. protected _initialSizeParameter: number | {
  102855. width: number;
  102856. height: number;
  102857. } | {
  102858. ratio: number;
  102859. };
  102860. protected _sizeRatio: Nullable<number>;
  102861. /** @hidden */
  102862. _generateMipMaps: boolean;
  102863. protected _renderingManager: RenderingManager;
  102864. /** @hidden */
  102865. _waitingRenderList: string[];
  102866. protected _doNotChangeAspectRatio: boolean;
  102867. protected _currentRefreshId: number;
  102868. protected _refreshRate: number;
  102869. protected _textureMatrix: Matrix;
  102870. protected _samples: number;
  102871. protected _renderTargetOptions: RenderTargetCreationOptions;
  102872. /**
  102873. * Gets render target creation options that were used.
  102874. */
  102875. get renderTargetOptions(): RenderTargetCreationOptions;
  102876. protected _onRatioRescale(): void;
  102877. /**
  102878. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  102879. * It must define where the camera used to render the texture is set
  102880. */
  102881. boundingBoxPosition: Vector3;
  102882. private _boundingBoxSize;
  102883. /**
  102884. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  102885. * When defined, the cubemap will switch to local mode
  102886. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  102887. * @example https://www.babylonjs-playground.com/#RNASML
  102888. */
  102889. set boundingBoxSize(value: Vector3);
  102890. get boundingBoxSize(): Vector3;
  102891. /**
  102892. * In case the RTT has been created with a depth texture, get the associated
  102893. * depth texture.
  102894. * Otherwise, return null.
  102895. */
  102896. get depthStencilTexture(): Nullable<InternalTexture>;
  102897. /**
  102898. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  102899. * or used a shadow, depth texture...
  102900. * @param name The friendly name of the texture
  102901. * @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)
  102902. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  102903. * @param generateMipMaps True if mip maps need to be generated after render.
  102904. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  102905. * @param type The type of the buffer in the RTT (int, half float, float...)
  102906. * @param isCube True if a cube texture needs to be created
  102907. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  102908. * @param generateDepthBuffer True to generate a depth buffer
  102909. * @param generateStencilBuffer True to generate a stencil buffer
  102910. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  102911. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  102912. * @param delayAllocation if the texture allocation should be delayed (default: false)
  102913. */
  102914. constructor(name: string, size: number | {
  102915. width: number;
  102916. height: number;
  102917. layers?: number;
  102918. } | {
  102919. ratio: number;
  102920. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  102921. /**
  102922. * Creates a depth stencil texture.
  102923. * This is only available in WebGL 2 or with the depth texture extension available.
  102924. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  102925. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  102926. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  102927. */
  102928. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  102929. private _processSizeParameter;
  102930. /**
  102931. * Define the number of samples to use in case of MSAA.
  102932. * It defaults to one meaning no MSAA has been enabled.
  102933. */
  102934. get samples(): number;
  102935. set samples(value: number);
  102936. /**
  102937. * Resets the refresh counter of the texture and start bak from scratch.
  102938. * Could be useful to regenerate the texture if it is setup to render only once.
  102939. */
  102940. resetRefreshCounter(): void;
  102941. /**
  102942. * Define the refresh rate of the texture or the rendering frequency.
  102943. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  102944. */
  102945. get refreshRate(): number;
  102946. set refreshRate(value: number);
  102947. /**
  102948. * Adds a post process to the render target rendering passes.
  102949. * @param postProcess define the post process to add
  102950. */
  102951. addPostProcess(postProcess: PostProcess): void;
  102952. /**
  102953. * Clear all the post processes attached to the render target
  102954. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  102955. */
  102956. clearPostProcesses(dispose?: boolean): void;
  102957. /**
  102958. * Remove one of the post process from the list of attached post processes to the texture
  102959. * @param postProcess define the post process to remove from the list
  102960. */
  102961. removePostProcess(postProcess: PostProcess): void;
  102962. /** @hidden */
  102963. _shouldRender(): boolean;
  102964. /**
  102965. * Gets the actual render size of the texture.
  102966. * @returns the width of the render size
  102967. */
  102968. getRenderSize(): number;
  102969. /**
  102970. * Gets the actual render width of the texture.
  102971. * @returns the width of the render size
  102972. */
  102973. getRenderWidth(): number;
  102974. /**
  102975. * Gets the actual render height of the texture.
  102976. * @returns the height of the render size
  102977. */
  102978. getRenderHeight(): number;
  102979. /**
  102980. * Gets the actual number of layers of the texture.
  102981. * @returns the number of layers
  102982. */
  102983. getRenderLayers(): number;
  102984. /**
  102985. * Get if the texture can be rescaled or not.
  102986. */
  102987. get canRescale(): boolean;
  102988. /**
  102989. * Resize the texture using a ratio.
  102990. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  102991. */
  102992. scale(ratio: number): void;
  102993. /**
  102994. * Get the texture reflection matrix used to rotate/transform the reflection.
  102995. * @returns the reflection matrix
  102996. */
  102997. getReflectionTextureMatrix(): Matrix;
  102998. /**
  102999. * Resize the texture to a new desired size.
  103000. * Be carrefull as it will recreate all the data in the new texture.
  103001. * @param size Define the new size. It can be:
  103002. * - a number for squared texture,
  103003. * - an object containing { width: number, height: number }
  103004. * - or an object containing a ratio { ratio: number }
  103005. */
  103006. resize(size: number | {
  103007. width: number;
  103008. height: number;
  103009. } | {
  103010. ratio: number;
  103011. }): void;
  103012. private _defaultRenderListPrepared;
  103013. /**
  103014. * Renders all the objects from the render list into the texture.
  103015. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  103016. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  103017. */
  103018. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  103019. private _bestReflectionRenderTargetDimension;
  103020. private _prepareRenderingManager;
  103021. /**
  103022. * @hidden
  103023. * @param faceIndex face index to bind to if this is a cubetexture
  103024. * @param layer defines the index of the texture to bind in the array
  103025. */
  103026. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  103027. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  103028. private renderToTarget;
  103029. /**
  103030. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  103031. * This allowed control for front to back rendering or reversly depending of the special needs.
  103032. *
  103033. * @param renderingGroupId The rendering group id corresponding to its index
  103034. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  103035. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  103036. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  103037. */
  103038. 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;
  103039. /**
  103040. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  103041. *
  103042. * @param renderingGroupId The rendering group id corresponding to its index
  103043. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  103044. */
  103045. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  103046. /**
  103047. * Clones the texture.
  103048. * @returns the cloned texture
  103049. */
  103050. clone(): RenderTargetTexture;
  103051. /**
  103052. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  103053. * @returns The JSON representation of the texture
  103054. */
  103055. serialize(): any;
  103056. /**
  103057. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  103058. */
  103059. disposeFramebufferObjects(): void;
  103060. /**
  103061. * Dispose the texture and release its associated resources.
  103062. */
  103063. dispose(): void;
  103064. /** @hidden */
  103065. _rebuild(): void;
  103066. /**
  103067. * Clear the info related to rendering groups preventing retention point in material dispose.
  103068. */
  103069. freeRenderingGroups(): void;
  103070. /**
  103071. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  103072. * @returns the view count
  103073. */
  103074. getViewCount(): number;
  103075. }
  103076. }
  103077. declare module BABYLON {
  103078. /**
  103079. * Class used to manipulate GUIDs
  103080. */
  103081. export class GUID {
  103082. /**
  103083. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  103084. * Be aware Math.random() could cause collisions, but:
  103085. * "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"
  103086. * @returns a pseudo random id
  103087. */
  103088. static RandomId(): string;
  103089. }
  103090. }
  103091. declare module BABYLON {
  103092. /**
  103093. * Options to be used when creating a shadow depth material
  103094. */
  103095. export interface IIOptionShadowDepthMaterial {
  103096. /** Variables in the vertex shader code that need to have their names remapped.
  103097. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  103098. * "var_name" should be either: worldPos or vNormalW
  103099. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  103100. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  103101. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  103102. */
  103103. remappedVariables?: string[];
  103104. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  103105. standalone?: boolean;
  103106. }
  103107. /**
  103108. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  103109. */
  103110. export class ShadowDepthWrapper {
  103111. private _scene;
  103112. private _options?;
  103113. private _baseMaterial;
  103114. private _onEffectCreatedObserver;
  103115. private _subMeshToEffect;
  103116. private _subMeshToDepthEffect;
  103117. private _meshes;
  103118. /** @hidden */
  103119. _matriceNames: any;
  103120. /** Gets the standalone status of the wrapper */
  103121. get standalone(): boolean;
  103122. /** Gets the base material the wrapper is built upon */
  103123. get baseMaterial(): Material;
  103124. /**
  103125. * Instantiate a new shadow depth wrapper.
  103126. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  103127. * generate the shadow depth map. For more information, please refer to the documentation:
  103128. * https://doc.babylonjs.com/babylon101/shadows
  103129. * @param baseMaterial Material to wrap
  103130. * @param scene Define the scene the material belongs to
  103131. * @param options Options used to create the wrapper
  103132. */
  103133. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  103134. /**
  103135. * Gets the effect to use to generate the depth map
  103136. * @param subMesh subMesh to get the effect for
  103137. * @param shadowGenerator shadow generator to get the effect for
  103138. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  103139. */
  103140. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  103141. /**
  103142. * Specifies that the submesh is ready to be used for depth rendering
  103143. * @param subMesh submesh to check
  103144. * @param defines the list of defines to take into account when checking the effect
  103145. * @param shadowGenerator combined with subMesh, it defines the effect to check
  103146. * @param useInstances specifies that instances should be used
  103147. * @returns a boolean indicating that the submesh is ready or not
  103148. */
  103149. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  103150. /**
  103151. * Disposes the resources
  103152. */
  103153. dispose(): void;
  103154. private _makeEffect;
  103155. }
  103156. }
  103157. declare module BABYLON {
  103158. interface ThinEngine {
  103159. /**
  103160. * Unbind a list of render target textures from the webGL context
  103161. * This is used only when drawBuffer extension or webGL2 are active
  103162. * @param textures defines the render target textures to unbind
  103163. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  103164. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  103165. */
  103166. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  103167. /**
  103168. * Create a multi render target texture
  103169. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  103170. * @param size defines the size of the texture
  103171. * @param options defines the creation options
  103172. * @returns the cube texture as an InternalTexture
  103173. */
  103174. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  103175. /**
  103176. * Update the sample count for a given multiple render target texture
  103177. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  103178. * @param textures defines the textures to update
  103179. * @param samples defines the sample count to set
  103180. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  103181. */
  103182. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  103183. /**
  103184. * Select a subsets of attachments to draw to.
  103185. * @param attachments gl attachments
  103186. */
  103187. bindAttachments(attachments: number[]): void;
  103188. }
  103189. }
  103190. declare module BABYLON {
  103191. /**
  103192. * Creation options of the multi render target texture.
  103193. */
  103194. export interface IMultiRenderTargetOptions {
  103195. /**
  103196. * Define if the texture needs to create mip maps after render.
  103197. */
  103198. generateMipMaps?: boolean;
  103199. /**
  103200. * Define the types of all the draw buffers we want to create
  103201. */
  103202. types?: number[];
  103203. /**
  103204. * Define the sampling modes of all the draw buffers we want to create
  103205. */
  103206. samplingModes?: number[];
  103207. /**
  103208. * Define if a depth buffer is required
  103209. */
  103210. generateDepthBuffer?: boolean;
  103211. /**
  103212. * Define if a stencil buffer is required
  103213. */
  103214. generateStencilBuffer?: boolean;
  103215. /**
  103216. * Define if a depth texture is required instead of a depth buffer
  103217. */
  103218. generateDepthTexture?: boolean;
  103219. /**
  103220. * Define the number of desired draw buffers
  103221. */
  103222. textureCount?: number;
  103223. /**
  103224. * Define if aspect ratio should be adapted to the texture or stay the scene one
  103225. */
  103226. doNotChangeAspectRatio?: boolean;
  103227. /**
  103228. * Define the default type of the buffers we are creating
  103229. */
  103230. defaultType?: number;
  103231. }
  103232. /**
  103233. * A multi render target, like a render target provides the ability to render to a texture.
  103234. * Unlike the render target, it can render to several draw buffers in one draw.
  103235. * This is specially interesting in deferred rendering or for any effects requiring more than
  103236. * just one color from a single pass.
  103237. */
  103238. export class MultiRenderTarget extends RenderTargetTexture {
  103239. private _internalTextures;
  103240. private _textures;
  103241. private _multiRenderTargetOptions;
  103242. private _count;
  103243. /**
  103244. * Get if draw buffers are currently supported by the used hardware and browser.
  103245. */
  103246. get isSupported(): boolean;
  103247. /**
  103248. * Get the list of textures generated by the multi render target.
  103249. */
  103250. get textures(): Texture[];
  103251. /**
  103252. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  103253. */
  103254. get count(): number;
  103255. /**
  103256. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  103257. */
  103258. get depthTexture(): Texture;
  103259. /**
  103260. * Set the wrapping mode on U of all the textures we are rendering to.
  103261. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  103262. */
  103263. set wrapU(wrap: number);
  103264. /**
  103265. * Set the wrapping mode on V of all the textures we are rendering to.
  103266. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  103267. */
  103268. set wrapV(wrap: number);
  103269. /**
  103270. * Instantiate a new multi render target texture.
  103271. * A multi render target, like a render target provides the ability to render to a texture.
  103272. * Unlike the render target, it can render to several draw buffers in one draw.
  103273. * This is specially interesting in deferred rendering or for any effects requiring more than
  103274. * just one color from a single pass.
  103275. * @param name Define the name of the texture
  103276. * @param size Define the size of the buffers to render to
  103277. * @param count Define the number of target we are rendering into
  103278. * @param scene Define the scene the texture belongs to
  103279. * @param options Define the options used to create the multi render target
  103280. */
  103281. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  103282. /** @hidden */
  103283. _rebuild(): void;
  103284. private _createInternalTextures;
  103285. private _createTextures;
  103286. /**
  103287. * Define the number of samples used if MSAA is enabled.
  103288. */
  103289. get samples(): number;
  103290. set samples(value: number);
  103291. /**
  103292. * Resize all the textures in the multi render target.
  103293. * Be carrefull as it will recreate all the data in the new texture.
  103294. * @param size Define the new size
  103295. */
  103296. resize(size: any): void;
  103297. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  103298. /**
  103299. * Dispose the render targets and their associated resources
  103300. */
  103301. dispose(): void;
  103302. /**
  103303. * Release all the underlying texture used as draw buffers.
  103304. */
  103305. releaseInternalTextures(): void;
  103306. }
  103307. }
  103308. declare module BABYLON {
  103309. /** @hidden */
  103310. export var imageProcessingPixelShader: {
  103311. name: string;
  103312. shader: string;
  103313. };
  103314. }
  103315. declare module BABYLON {
  103316. /**
  103317. * ImageProcessingPostProcess
  103318. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  103319. */
  103320. export class ImageProcessingPostProcess extends PostProcess {
  103321. /**
  103322. * Default configuration related to image processing available in the PBR Material.
  103323. */
  103324. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103325. /**
  103326. * Gets the image processing configuration used either in this material.
  103327. */
  103328. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  103329. /**
  103330. * Sets the Default image processing configuration used either in the this material.
  103331. *
  103332. * If sets to null, the scene one is in use.
  103333. */
  103334. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  103335. /**
  103336. * Keep track of the image processing observer to allow dispose and replace.
  103337. */
  103338. private _imageProcessingObserver;
  103339. /**
  103340. * Attaches a new image processing configuration to the PBR Material.
  103341. * @param configuration
  103342. */
  103343. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  103344. /**
  103345. * If the post process is supported.
  103346. */
  103347. get isSupported(): boolean;
  103348. /**
  103349. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  103350. */
  103351. get colorCurves(): Nullable<ColorCurves>;
  103352. /**
  103353. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  103354. */
  103355. set colorCurves(value: Nullable<ColorCurves>);
  103356. /**
  103357. * Gets wether the color curves effect is enabled.
  103358. */
  103359. get colorCurvesEnabled(): boolean;
  103360. /**
  103361. * Sets wether the color curves effect is enabled.
  103362. */
  103363. set colorCurvesEnabled(value: boolean);
  103364. /**
  103365. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  103366. */
  103367. get colorGradingTexture(): Nullable<BaseTexture>;
  103368. /**
  103369. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  103370. */
  103371. set colorGradingTexture(value: Nullable<BaseTexture>);
  103372. /**
  103373. * Gets wether the color grading effect is enabled.
  103374. */
  103375. get colorGradingEnabled(): boolean;
  103376. /**
  103377. * Gets wether the color grading effect is enabled.
  103378. */
  103379. set colorGradingEnabled(value: boolean);
  103380. /**
  103381. * Gets exposure used in the effect.
  103382. */
  103383. get exposure(): number;
  103384. /**
  103385. * Sets exposure used in the effect.
  103386. */
  103387. set exposure(value: number);
  103388. /**
  103389. * Gets wether tonemapping is enabled or not.
  103390. */
  103391. get toneMappingEnabled(): boolean;
  103392. /**
  103393. * Sets wether tonemapping is enabled or not
  103394. */
  103395. set toneMappingEnabled(value: boolean);
  103396. /**
  103397. * Gets the type of tone mapping effect.
  103398. */
  103399. get toneMappingType(): number;
  103400. /**
  103401. * Sets the type of tone mapping effect.
  103402. */
  103403. set toneMappingType(value: number);
  103404. /**
  103405. * Gets contrast used in the effect.
  103406. */
  103407. get contrast(): number;
  103408. /**
  103409. * Sets contrast used in the effect.
  103410. */
  103411. set contrast(value: number);
  103412. /**
  103413. * Gets Vignette stretch size.
  103414. */
  103415. get vignetteStretch(): number;
  103416. /**
  103417. * Sets Vignette stretch size.
  103418. */
  103419. set vignetteStretch(value: number);
  103420. /**
  103421. * Gets Vignette centre X Offset.
  103422. */
  103423. get vignetteCentreX(): number;
  103424. /**
  103425. * Sets Vignette centre X Offset.
  103426. */
  103427. set vignetteCentreX(value: number);
  103428. /**
  103429. * Gets Vignette centre Y Offset.
  103430. */
  103431. get vignetteCentreY(): number;
  103432. /**
  103433. * Sets Vignette centre Y Offset.
  103434. */
  103435. set vignetteCentreY(value: number);
  103436. /**
  103437. * Gets Vignette weight or intensity of the vignette effect.
  103438. */
  103439. get vignetteWeight(): number;
  103440. /**
  103441. * Sets Vignette weight or intensity of the vignette effect.
  103442. */
  103443. set vignetteWeight(value: number);
  103444. /**
  103445. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  103446. * if vignetteEnabled is set to true.
  103447. */
  103448. get vignetteColor(): Color4;
  103449. /**
  103450. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  103451. * if vignetteEnabled is set to true.
  103452. */
  103453. set vignetteColor(value: Color4);
  103454. /**
  103455. * Gets Camera field of view used by the Vignette effect.
  103456. */
  103457. get vignetteCameraFov(): number;
  103458. /**
  103459. * Sets Camera field of view used by the Vignette effect.
  103460. */
  103461. set vignetteCameraFov(value: number);
  103462. /**
  103463. * Gets the vignette blend mode allowing different kind of effect.
  103464. */
  103465. get vignetteBlendMode(): number;
  103466. /**
  103467. * Sets the vignette blend mode allowing different kind of effect.
  103468. */
  103469. set vignetteBlendMode(value: number);
  103470. /**
  103471. * Gets wether the vignette effect is enabled.
  103472. */
  103473. get vignetteEnabled(): boolean;
  103474. /**
  103475. * Sets wether the vignette effect is enabled.
  103476. */
  103477. set vignetteEnabled(value: boolean);
  103478. private _fromLinearSpace;
  103479. /**
  103480. * Gets wether the input of the processing is in Gamma or Linear Space.
  103481. */
  103482. get fromLinearSpace(): boolean;
  103483. /**
  103484. * Sets wether the input of the processing is in Gamma or Linear Space.
  103485. */
  103486. set fromLinearSpace(value: boolean);
  103487. /**
  103488. * Defines cache preventing GC.
  103489. */
  103490. private _defines;
  103491. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  103492. /**
  103493. * "ImageProcessingPostProcess"
  103494. * @returns "ImageProcessingPostProcess"
  103495. */
  103496. getClassName(): string;
  103497. /**
  103498. * @hidden
  103499. */
  103500. _updateParameters(): void;
  103501. dispose(camera?: Camera): void;
  103502. }
  103503. }
  103504. declare module BABYLON {
  103505. /** @hidden */
  103506. export var fibonacci: {
  103507. name: string;
  103508. shader: string;
  103509. };
  103510. }
  103511. declare module BABYLON {
  103512. /** @hidden */
  103513. export var subSurfaceScatteringFunctions: {
  103514. name: string;
  103515. shader: string;
  103516. };
  103517. }
  103518. declare module BABYLON {
  103519. /** @hidden */
  103520. export var diffusionProfile: {
  103521. name: string;
  103522. shader: string;
  103523. };
  103524. }
  103525. declare module BABYLON {
  103526. /** @hidden */
  103527. export var subSurfaceScatteringPixelShader: {
  103528. name: string;
  103529. shader: string;
  103530. };
  103531. }
  103532. declare module BABYLON {
  103533. /**
  103534. * Sub surface scattering post process
  103535. */
  103536. export class SubSurfaceScatteringPostProcess extends PostProcess {
  103537. /**
  103538. * Gets a string identifying the name of the class
  103539. * @returns "SubSurfaceScatteringPostProcess" string
  103540. */
  103541. getClassName(): string;
  103542. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  103543. }
  103544. }
  103545. declare module BABYLON {
  103546. /**
  103547. * Interface for defining prepass effects in the prepass post-process pipeline
  103548. */
  103549. export interface PrePassEffectConfiguration {
  103550. /**
  103551. * Post process to attach for this effect
  103552. */
  103553. postProcess: PostProcess;
  103554. /**
  103555. * Is the effect enabled
  103556. */
  103557. enabled: boolean;
  103558. /**
  103559. * Disposes the effect configuration
  103560. */
  103561. dispose(): void;
  103562. /**
  103563. * Disposes the effect configuration
  103564. */
  103565. createPostProcess: () => PostProcess;
  103566. }
  103567. }
  103568. declare module BABYLON {
  103569. /**
  103570. * Contains all parameters needed for the prepass to perform
  103571. * screen space subsurface scattering
  103572. */
  103573. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  103574. private _ssDiffusionS;
  103575. private _ssFilterRadii;
  103576. private _ssDiffusionD;
  103577. /**
  103578. * Post process to attach for screen space subsurface scattering
  103579. */
  103580. postProcess: SubSurfaceScatteringPostProcess;
  103581. /**
  103582. * Diffusion profile color for subsurface scattering
  103583. */
  103584. get ssDiffusionS(): number[];
  103585. /**
  103586. * Diffusion profile max color channel value for subsurface scattering
  103587. */
  103588. get ssDiffusionD(): number[];
  103589. /**
  103590. * Diffusion profile filter radius for subsurface scattering
  103591. */
  103592. get ssFilterRadii(): number[];
  103593. /**
  103594. * Is subsurface enabled
  103595. */
  103596. enabled: boolean;
  103597. /**
  103598. * Diffusion profile colors for subsurface scattering
  103599. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  103600. * See ...
  103601. * Note that you can only store up to 5 of them
  103602. */
  103603. ssDiffusionProfileColors: Color3[];
  103604. /**
  103605. * Defines the ratio real world => scene units.
  103606. * Used for subsurface scattering
  103607. */
  103608. metersPerUnit: number;
  103609. private _scene;
  103610. /**
  103611. * Builds a subsurface configuration object
  103612. * @param scene The scene
  103613. */
  103614. constructor(scene: Scene);
  103615. /**
  103616. * Adds a new diffusion profile.
  103617. * Useful for more realistic subsurface scattering on diverse materials.
  103618. * @param color The color of the diffusion profile. Should be the average color of the material.
  103619. * @return The index of the diffusion profile for the material subsurface configuration
  103620. */
  103621. addDiffusionProfile(color: Color3): number;
  103622. /**
  103623. * Creates the sss post process
  103624. * @return The created post process
  103625. */
  103626. createPostProcess(): SubSurfaceScatteringPostProcess;
  103627. /**
  103628. * Deletes all diffusion profiles.
  103629. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  103630. */
  103631. clearAllDiffusionProfiles(): void;
  103632. /**
  103633. * Disposes this object
  103634. */
  103635. dispose(): void;
  103636. /**
  103637. * @hidden
  103638. * https://zero-radiance.github.io/post/sampling-diffusion/
  103639. *
  103640. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  103641. * ------------------------------------------------------------------------------------
  103642. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  103643. * PDF[r, phi, s] = r * R[r, phi, s]
  103644. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  103645. * ------------------------------------------------------------------------------------
  103646. * We importance sample the color channel with the widest scattering distance.
  103647. */
  103648. getDiffusionProfileParameters(color: Color3): number;
  103649. /**
  103650. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  103651. * 'u' is the random number (the value of the CDF): [0, 1).
  103652. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  103653. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  103654. */
  103655. private _sampleBurleyDiffusionProfile;
  103656. }
  103657. }
  103658. declare module BABYLON {
  103659. /**
  103660. * Renders a pre pass of the scene
  103661. * This means every mesh in the scene will be rendered to a render target texture
  103662. * And then this texture will be composited to the rendering canvas with post processes
  103663. * It is necessary for effects like subsurface scattering or deferred shading
  103664. */
  103665. export class PrePassRenderer {
  103666. /** @hidden */
  103667. static _SceneComponentInitialization: (scene: Scene) => void;
  103668. private _scene;
  103669. private _engine;
  103670. private _isDirty;
  103671. /**
  103672. * Number of textures in the multi render target texture where the scene is directly rendered
  103673. */
  103674. readonly mrtCount: number;
  103675. /**
  103676. * The render target where the scene is directly rendered
  103677. */
  103678. prePassRT: MultiRenderTarget;
  103679. private _mrtTypes;
  103680. private _multiRenderAttachments;
  103681. private _defaultAttachments;
  103682. private _clearAttachments;
  103683. private _postProcesses;
  103684. private readonly _clearColor;
  103685. /**
  103686. * Image processing post process for composition
  103687. */
  103688. imageProcessingPostProcess: ImageProcessingPostProcess;
  103689. /**
  103690. * Configuration for sub surface scattering post process
  103691. */
  103692. subSurfaceConfiguration: SubSurfaceConfiguration;
  103693. /**
  103694. * Should materials render their geometry on the MRT
  103695. */
  103696. materialsShouldRenderGeometry: boolean;
  103697. /**
  103698. * Should materials render the irradiance information on the MRT
  103699. */
  103700. materialsShouldRenderIrradiance: boolean;
  103701. private _enabled;
  103702. /**
  103703. * Indicates if the prepass is enabled
  103704. */
  103705. get enabled(): boolean;
  103706. /**
  103707. * How many samples are used for MSAA of the scene render target
  103708. */
  103709. get samples(): number;
  103710. set samples(n: number);
  103711. /**
  103712. * Instanciates a prepass renderer
  103713. * @param scene The scene
  103714. */
  103715. constructor(scene: Scene);
  103716. private _initializeAttachments;
  103717. private _createCompositionEffect;
  103718. /**
  103719. * Indicates if rendering a prepass is supported
  103720. */
  103721. get isSupported(): boolean;
  103722. /**
  103723. * Sets the proper output textures to draw in the engine.
  103724. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  103725. */
  103726. bindAttachmentsForEffect(effect: Effect): void;
  103727. /**
  103728. * @hidden
  103729. */
  103730. _beforeCameraDraw(): void;
  103731. /**
  103732. * @hidden
  103733. */
  103734. _afterCameraDraw(): void;
  103735. private _checkRTSize;
  103736. private _bindFrameBuffer;
  103737. /**
  103738. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  103739. */
  103740. clear(): void;
  103741. private _setState;
  103742. private _enable;
  103743. private _disable;
  103744. private _resetPostProcessChain;
  103745. private _bindPostProcessChain;
  103746. /**
  103747. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  103748. */
  103749. markAsDirty(): void;
  103750. private _update;
  103751. /**
  103752. * Disposes the prepass renderer.
  103753. */
  103754. dispose(): void;
  103755. }
  103756. }
  103757. declare module BABYLON {
  103758. /**
  103759. * Options for compiling materials.
  103760. */
  103761. export interface IMaterialCompilationOptions {
  103762. /**
  103763. * Defines whether clip planes are enabled.
  103764. */
  103765. clipPlane: boolean;
  103766. /**
  103767. * Defines whether instances are enabled.
  103768. */
  103769. useInstances: boolean;
  103770. }
  103771. /**
  103772. * Options passed when calling customShaderNameResolve
  103773. */
  103774. export interface ICustomShaderNameResolveOptions {
  103775. /**
  103776. * 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
  103777. */
  103778. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  103779. }
  103780. /**
  103781. * Base class for the main features of a material in Babylon.js
  103782. */
  103783. export class Material implements IAnimatable {
  103784. /**
  103785. * Returns the triangle fill mode
  103786. */
  103787. static readonly TriangleFillMode: number;
  103788. /**
  103789. * Returns the wireframe mode
  103790. */
  103791. static readonly WireFrameFillMode: number;
  103792. /**
  103793. * Returns the point fill mode
  103794. */
  103795. static readonly PointFillMode: number;
  103796. /**
  103797. * Returns the point list draw mode
  103798. */
  103799. static readonly PointListDrawMode: number;
  103800. /**
  103801. * Returns the line list draw mode
  103802. */
  103803. static readonly LineListDrawMode: number;
  103804. /**
  103805. * Returns the line loop draw mode
  103806. */
  103807. static readonly LineLoopDrawMode: number;
  103808. /**
  103809. * Returns the line strip draw mode
  103810. */
  103811. static readonly LineStripDrawMode: number;
  103812. /**
  103813. * Returns the triangle strip draw mode
  103814. */
  103815. static readonly TriangleStripDrawMode: number;
  103816. /**
  103817. * Returns the triangle fan draw mode
  103818. */
  103819. static readonly TriangleFanDrawMode: number;
  103820. /**
  103821. * Stores the clock-wise side orientation
  103822. */
  103823. static readonly ClockWiseSideOrientation: number;
  103824. /**
  103825. * Stores the counter clock-wise side orientation
  103826. */
  103827. static readonly CounterClockWiseSideOrientation: number;
  103828. /**
  103829. * The dirty texture flag value
  103830. */
  103831. static readonly TextureDirtyFlag: number;
  103832. /**
  103833. * The dirty light flag value
  103834. */
  103835. static readonly LightDirtyFlag: number;
  103836. /**
  103837. * The dirty fresnel flag value
  103838. */
  103839. static readonly FresnelDirtyFlag: number;
  103840. /**
  103841. * The dirty attribute flag value
  103842. */
  103843. static readonly AttributesDirtyFlag: number;
  103844. /**
  103845. * The dirty misc flag value
  103846. */
  103847. static readonly MiscDirtyFlag: number;
  103848. /**
  103849. * The all dirty flag value
  103850. */
  103851. static readonly AllDirtyFlag: number;
  103852. /**
  103853. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  103854. */
  103855. static readonly MATERIAL_OPAQUE: number;
  103856. /**
  103857. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  103858. */
  103859. static readonly MATERIAL_ALPHATEST: number;
  103860. /**
  103861. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  103862. */
  103863. static readonly MATERIAL_ALPHABLEND: number;
  103864. /**
  103865. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  103866. * They are also discarded below the alpha cutoff threshold to improve performances.
  103867. */
  103868. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  103869. /**
  103870. * The Whiteout method is used to blend normals.
  103871. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  103872. */
  103873. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  103874. /**
  103875. * The Reoriented Normal Mapping method is used to blend normals.
  103876. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  103877. */
  103878. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  103879. /**
  103880. * Custom callback helping to override the default shader used in the material.
  103881. */
  103882. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  103883. /**
  103884. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  103885. */
  103886. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  103887. /**
  103888. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  103889. * This means that the material can keep using a previous shader while a new one is being compiled.
  103890. * This is mostly used when shader parallel compilation is supported (true by default)
  103891. */
  103892. allowShaderHotSwapping: boolean;
  103893. /**
  103894. * The ID of the material
  103895. */
  103896. id: string;
  103897. /**
  103898. * Gets or sets the unique id of the material
  103899. */
  103900. uniqueId: number;
  103901. /**
  103902. * The name of the material
  103903. */
  103904. name: string;
  103905. /**
  103906. * Gets or sets user defined metadata
  103907. */
  103908. metadata: any;
  103909. /**
  103910. * For internal use only. Please do not use.
  103911. */
  103912. reservedDataStore: any;
  103913. /**
  103914. * Specifies if the ready state should be checked on each call
  103915. */
  103916. checkReadyOnEveryCall: boolean;
  103917. /**
  103918. * Specifies if the ready state should be checked once
  103919. */
  103920. checkReadyOnlyOnce: boolean;
  103921. /**
  103922. * The state of the material
  103923. */
  103924. state: string;
  103925. /**
  103926. * If the material can be rendered to several textures with MRT extension
  103927. */
  103928. get canRenderToMRT(): boolean;
  103929. /**
  103930. * The alpha value of the material
  103931. */
  103932. protected _alpha: number;
  103933. /**
  103934. * List of inspectable custom properties (used by the Inspector)
  103935. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  103936. */
  103937. inspectableCustomProperties: IInspectable[];
  103938. /**
  103939. * Sets the alpha value of the material
  103940. */
  103941. set alpha(value: number);
  103942. /**
  103943. * Gets the alpha value of the material
  103944. */
  103945. get alpha(): number;
  103946. /**
  103947. * Specifies if back face culling is enabled
  103948. */
  103949. protected _backFaceCulling: boolean;
  103950. /**
  103951. * Sets the back-face culling state
  103952. */
  103953. set backFaceCulling(value: boolean);
  103954. /**
  103955. * Gets the back-face culling state
  103956. */
  103957. get backFaceCulling(): boolean;
  103958. /**
  103959. * Stores the value for side orientation
  103960. */
  103961. sideOrientation: number;
  103962. /**
  103963. * Callback triggered when the material is compiled
  103964. */
  103965. onCompiled: Nullable<(effect: Effect) => void>;
  103966. /**
  103967. * Callback triggered when an error occurs
  103968. */
  103969. onError: Nullable<(effect: Effect, errors: string) => void>;
  103970. /**
  103971. * Callback triggered to get the render target textures
  103972. */
  103973. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  103974. /**
  103975. * Gets a boolean indicating that current material needs to register RTT
  103976. */
  103977. get hasRenderTargetTextures(): boolean;
  103978. /**
  103979. * Specifies if the material should be serialized
  103980. */
  103981. doNotSerialize: boolean;
  103982. /**
  103983. * @hidden
  103984. */
  103985. _storeEffectOnSubMeshes: boolean;
  103986. /**
  103987. * Stores the animations for the material
  103988. */
  103989. animations: Nullable<Array<Animation>>;
  103990. /**
  103991. * An event triggered when the material is disposed
  103992. */
  103993. onDisposeObservable: Observable<Material>;
  103994. /**
  103995. * An observer which watches for dispose events
  103996. */
  103997. private _onDisposeObserver;
  103998. private _onUnBindObservable;
  103999. /**
  104000. * Called during a dispose event
  104001. */
  104002. set onDispose(callback: () => void);
  104003. private _onBindObservable;
  104004. /**
  104005. * An event triggered when the material is bound
  104006. */
  104007. get onBindObservable(): Observable<AbstractMesh>;
  104008. /**
  104009. * An observer which watches for bind events
  104010. */
  104011. private _onBindObserver;
  104012. /**
  104013. * Called during a bind event
  104014. */
  104015. set onBind(callback: (Mesh: AbstractMesh) => void);
  104016. /**
  104017. * An event triggered when the material is unbound
  104018. */
  104019. get onUnBindObservable(): Observable<Material>;
  104020. protected _onEffectCreatedObservable: Nullable<Observable<{
  104021. effect: Effect;
  104022. subMesh: Nullable<SubMesh>;
  104023. }>>;
  104024. /**
  104025. * An event triggered when the effect is (re)created
  104026. */
  104027. get onEffectCreatedObservable(): Observable<{
  104028. effect: Effect;
  104029. subMesh: Nullable<SubMesh>;
  104030. }>;
  104031. /**
  104032. * Stores the value of the alpha mode
  104033. */
  104034. private _alphaMode;
  104035. /**
  104036. * Sets the value of the alpha mode.
  104037. *
  104038. * | Value | Type | Description |
  104039. * | --- | --- | --- |
  104040. * | 0 | ALPHA_DISABLE | |
  104041. * | 1 | ALPHA_ADD | |
  104042. * | 2 | ALPHA_COMBINE | |
  104043. * | 3 | ALPHA_SUBTRACT | |
  104044. * | 4 | ALPHA_MULTIPLY | |
  104045. * | 5 | ALPHA_MAXIMIZED | |
  104046. * | 6 | ALPHA_ONEONE | |
  104047. * | 7 | ALPHA_PREMULTIPLIED | |
  104048. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  104049. * | 9 | ALPHA_INTERPOLATE | |
  104050. * | 10 | ALPHA_SCREENMODE | |
  104051. *
  104052. */
  104053. set alphaMode(value: number);
  104054. /**
  104055. * Gets the value of the alpha mode
  104056. */
  104057. get alphaMode(): number;
  104058. /**
  104059. * Stores the state of the need depth pre-pass value
  104060. */
  104061. private _needDepthPrePass;
  104062. /**
  104063. * Sets the need depth pre-pass value
  104064. */
  104065. set needDepthPrePass(value: boolean);
  104066. /**
  104067. * Gets the depth pre-pass value
  104068. */
  104069. get needDepthPrePass(): boolean;
  104070. /**
  104071. * Specifies if depth writing should be disabled
  104072. */
  104073. disableDepthWrite: boolean;
  104074. /**
  104075. * Specifies if color writing should be disabled
  104076. */
  104077. disableColorWrite: boolean;
  104078. /**
  104079. * Specifies if depth writing should be forced
  104080. */
  104081. forceDepthWrite: boolean;
  104082. /**
  104083. * Specifies the depth function that should be used. 0 means the default engine function
  104084. */
  104085. depthFunction: number;
  104086. /**
  104087. * Specifies if there should be a separate pass for culling
  104088. */
  104089. separateCullingPass: boolean;
  104090. /**
  104091. * Stores the state specifing if fog should be enabled
  104092. */
  104093. private _fogEnabled;
  104094. /**
  104095. * Sets the state for enabling fog
  104096. */
  104097. set fogEnabled(value: boolean);
  104098. /**
  104099. * Gets the value of the fog enabled state
  104100. */
  104101. get fogEnabled(): boolean;
  104102. /**
  104103. * Stores the size of points
  104104. */
  104105. pointSize: number;
  104106. /**
  104107. * Stores the z offset value
  104108. */
  104109. zOffset: number;
  104110. get wireframe(): boolean;
  104111. /**
  104112. * Sets the state of wireframe mode
  104113. */
  104114. set wireframe(value: boolean);
  104115. /**
  104116. * Gets the value specifying if point clouds are enabled
  104117. */
  104118. get pointsCloud(): boolean;
  104119. /**
  104120. * Sets the state of point cloud mode
  104121. */
  104122. set pointsCloud(value: boolean);
  104123. /**
  104124. * Gets the material fill mode
  104125. */
  104126. get fillMode(): number;
  104127. /**
  104128. * Sets the material fill mode
  104129. */
  104130. set fillMode(value: number);
  104131. /**
  104132. * @hidden
  104133. * Stores the effects for the material
  104134. */
  104135. _effect: Nullable<Effect>;
  104136. /**
  104137. * Specifies if uniform buffers should be used
  104138. */
  104139. private _useUBO;
  104140. /**
  104141. * Stores a reference to the scene
  104142. */
  104143. private _scene;
  104144. /**
  104145. * Stores the fill mode state
  104146. */
  104147. private _fillMode;
  104148. /**
  104149. * Specifies if the depth write state should be cached
  104150. */
  104151. private _cachedDepthWriteState;
  104152. /**
  104153. * Specifies if the color write state should be cached
  104154. */
  104155. private _cachedColorWriteState;
  104156. /**
  104157. * Specifies if the depth function state should be cached
  104158. */
  104159. private _cachedDepthFunctionState;
  104160. /**
  104161. * Stores the uniform buffer
  104162. */
  104163. protected _uniformBuffer: UniformBuffer;
  104164. /** @hidden */
  104165. _indexInSceneMaterialArray: number;
  104166. /** @hidden */
  104167. meshMap: Nullable<{
  104168. [id: string]: AbstractMesh | undefined;
  104169. }>;
  104170. /**
  104171. * Creates a material instance
  104172. * @param name defines the name of the material
  104173. * @param scene defines the scene to reference
  104174. * @param doNotAdd specifies if the material should be added to the scene
  104175. */
  104176. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  104177. /**
  104178. * Returns a string representation of the current material
  104179. * @param fullDetails defines a boolean indicating which levels of logging is desired
  104180. * @returns a string with material information
  104181. */
  104182. toString(fullDetails?: boolean): string;
  104183. /**
  104184. * Gets the class name of the material
  104185. * @returns a string with the class name of the material
  104186. */
  104187. getClassName(): string;
  104188. /**
  104189. * Specifies if updates for the material been locked
  104190. */
  104191. get isFrozen(): boolean;
  104192. /**
  104193. * Locks updates for the material
  104194. */
  104195. freeze(): void;
  104196. /**
  104197. * Unlocks updates for the material
  104198. */
  104199. unfreeze(): void;
  104200. /**
  104201. * Specifies if the material is ready to be used
  104202. * @param mesh defines the mesh to check
  104203. * @param useInstances specifies if instances should be used
  104204. * @returns a boolean indicating if the material is ready to be used
  104205. */
  104206. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  104207. /**
  104208. * Specifies that the submesh is ready to be used
  104209. * @param mesh defines the mesh to check
  104210. * @param subMesh defines which submesh to check
  104211. * @param useInstances specifies that instances should be used
  104212. * @returns a boolean indicating that the submesh is ready or not
  104213. */
  104214. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  104215. /**
  104216. * Returns the material effect
  104217. * @returns the effect associated with the material
  104218. */
  104219. getEffect(): Nullable<Effect>;
  104220. /**
  104221. * Returns the current scene
  104222. * @returns a Scene
  104223. */
  104224. getScene(): Scene;
  104225. /**
  104226. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  104227. */
  104228. protected _forceAlphaTest: boolean;
  104229. /**
  104230. * The transparency mode of the material.
  104231. */
  104232. protected _transparencyMode: Nullable<number>;
  104233. /**
  104234. * Gets the current transparency mode.
  104235. */
  104236. get transparencyMode(): Nullable<number>;
  104237. /**
  104238. * Sets the transparency mode of the material.
  104239. *
  104240. * | Value | Type | Description |
  104241. * | ----- | ----------------------------------- | ----------- |
  104242. * | 0 | OPAQUE | |
  104243. * | 1 | ALPHATEST | |
  104244. * | 2 | ALPHABLEND | |
  104245. * | 3 | ALPHATESTANDBLEND | |
  104246. *
  104247. */
  104248. set transparencyMode(value: Nullable<number>);
  104249. /**
  104250. * Returns true if alpha blending should be disabled.
  104251. */
  104252. protected get _disableAlphaBlending(): boolean;
  104253. /**
  104254. * Specifies whether or not this material should be rendered in alpha blend mode.
  104255. * @returns a boolean specifying if alpha blending is needed
  104256. */
  104257. needAlphaBlending(): boolean;
  104258. /**
  104259. * Specifies if the mesh will require alpha blending
  104260. * @param mesh defines the mesh to check
  104261. * @returns a boolean specifying if alpha blending is needed for the mesh
  104262. */
  104263. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  104264. /**
  104265. * Specifies whether or not this material should be rendered in alpha test mode.
  104266. * @returns a boolean specifying if an alpha test is needed.
  104267. */
  104268. needAlphaTesting(): boolean;
  104269. /**
  104270. * Specifies if material alpha testing should be turned on for the mesh
  104271. * @param mesh defines the mesh to check
  104272. */
  104273. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  104274. /**
  104275. * Gets the texture used for the alpha test
  104276. * @returns the texture to use for alpha testing
  104277. */
  104278. getAlphaTestTexture(): Nullable<BaseTexture>;
  104279. /**
  104280. * Marks the material to indicate that it needs to be re-calculated
  104281. */
  104282. markDirty(): void;
  104283. /** @hidden */
  104284. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  104285. /**
  104286. * Binds the material to the mesh
  104287. * @param world defines the world transformation matrix
  104288. * @param mesh defines the mesh to bind the material to
  104289. */
  104290. bind(world: Matrix, mesh?: Mesh): void;
  104291. /**
  104292. * Binds the submesh to the material
  104293. * @param world defines the world transformation matrix
  104294. * @param mesh defines the mesh containing the submesh
  104295. * @param subMesh defines the submesh to bind the material to
  104296. */
  104297. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  104298. /**
  104299. * Binds the world matrix to the material
  104300. * @param world defines the world transformation matrix
  104301. */
  104302. bindOnlyWorldMatrix(world: Matrix): void;
  104303. /**
  104304. * Binds the scene's uniform buffer to the effect.
  104305. * @param effect defines the effect to bind to the scene uniform buffer
  104306. * @param sceneUbo defines the uniform buffer storing scene data
  104307. */
  104308. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  104309. /**
  104310. * Binds the view matrix to the effect
  104311. * @param effect defines the effect to bind the view matrix to
  104312. */
  104313. bindView(effect: Effect): void;
  104314. /**
  104315. * Binds the view projection matrix to the effect
  104316. * @param effect defines the effect to bind the view projection matrix to
  104317. */
  104318. bindViewProjection(effect: Effect): void;
  104319. /**
  104320. * Processes to execute after binding the material to a mesh
  104321. * @param mesh defines the rendered mesh
  104322. */
  104323. protected _afterBind(mesh?: Mesh): void;
  104324. /**
  104325. * Unbinds the material from the mesh
  104326. */
  104327. unbind(): void;
  104328. /**
  104329. * Gets the active textures from the material
  104330. * @returns an array of textures
  104331. */
  104332. getActiveTextures(): BaseTexture[];
  104333. /**
  104334. * Specifies if the material uses a texture
  104335. * @param texture defines the texture to check against the material
  104336. * @returns a boolean specifying if the material uses the texture
  104337. */
  104338. hasTexture(texture: BaseTexture): boolean;
  104339. /**
  104340. * Makes a duplicate of the material, and gives it a new name
  104341. * @param name defines the new name for the duplicated material
  104342. * @returns the cloned material
  104343. */
  104344. clone(name: string): Nullable<Material>;
  104345. /**
  104346. * Gets the meshes bound to the material
  104347. * @returns an array of meshes bound to the material
  104348. */
  104349. getBindedMeshes(): AbstractMesh[];
  104350. /**
  104351. * Force shader compilation
  104352. * @param mesh defines the mesh associated with this material
  104353. * @param onCompiled defines a function to execute once the material is compiled
  104354. * @param options defines the options to configure the compilation
  104355. * @param onError defines a function to execute if the material fails compiling
  104356. */
  104357. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  104358. /**
  104359. * Force shader compilation
  104360. * @param mesh defines the mesh that will use this material
  104361. * @param options defines additional options for compiling the shaders
  104362. * @returns a promise that resolves when the compilation completes
  104363. */
  104364. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  104365. private static readonly _AllDirtyCallBack;
  104366. private static readonly _ImageProcessingDirtyCallBack;
  104367. private static readonly _TextureDirtyCallBack;
  104368. private static readonly _FresnelDirtyCallBack;
  104369. private static readonly _MiscDirtyCallBack;
  104370. private static readonly _LightsDirtyCallBack;
  104371. private static readonly _AttributeDirtyCallBack;
  104372. private static _FresnelAndMiscDirtyCallBack;
  104373. private static _TextureAndMiscDirtyCallBack;
  104374. private static readonly _DirtyCallbackArray;
  104375. private static readonly _RunDirtyCallBacks;
  104376. /**
  104377. * Marks a define in the material to indicate that it needs to be re-computed
  104378. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  104379. */
  104380. markAsDirty(flag: number): void;
  104381. /**
  104382. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  104383. * @param func defines a function which checks material defines against the submeshes
  104384. */
  104385. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  104386. /**
  104387. * Indicates that the scene should check if the rendering now needs a prepass
  104388. */
  104389. protected _markScenePrePassDirty(): void;
  104390. /**
  104391. * Indicates that we need to re-calculated for all submeshes
  104392. */
  104393. protected _markAllSubMeshesAsAllDirty(): void;
  104394. /**
  104395. * Indicates that image processing needs to be re-calculated for all submeshes
  104396. */
  104397. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  104398. /**
  104399. * Indicates that textures need to be re-calculated for all submeshes
  104400. */
  104401. protected _markAllSubMeshesAsTexturesDirty(): void;
  104402. /**
  104403. * Indicates that fresnel needs to be re-calculated for all submeshes
  104404. */
  104405. protected _markAllSubMeshesAsFresnelDirty(): void;
  104406. /**
  104407. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  104408. */
  104409. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  104410. /**
  104411. * Indicates that lights need to be re-calculated for all submeshes
  104412. */
  104413. protected _markAllSubMeshesAsLightsDirty(): void;
  104414. /**
  104415. * Indicates that attributes need to be re-calculated for all submeshes
  104416. */
  104417. protected _markAllSubMeshesAsAttributesDirty(): void;
  104418. /**
  104419. * Indicates that misc needs to be re-calculated for all submeshes
  104420. */
  104421. protected _markAllSubMeshesAsMiscDirty(): void;
  104422. /**
  104423. * Indicates that textures and misc need to be re-calculated for all submeshes
  104424. */
  104425. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  104426. /**
  104427. * Sets the required values to the prepass renderer.
  104428. * @param prePassRenderer defines the prepass renderer to setup.
  104429. * @returns true if the pre pass is needed.
  104430. */
  104431. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  104432. /**
  104433. * Disposes the material
  104434. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  104435. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  104436. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  104437. */
  104438. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  104439. /** @hidden */
  104440. private releaseVertexArrayObject;
  104441. /**
  104442. * Serializes this material
  104443. * @returns the serialized material object
  104444. */
  104445. serialize(): any;
  104446. /**
  104447. * Creates a material from parsed material data
  104448. * @param parsedMaterial defines parsed material data
  104449. * @param scene defines the hosting scene
  104450. * @param rootUrl defines the root URL to use to load textures
  104451. * @returns a new material
  104452. */
  104453. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  104454. }
  104455. }
  104456. declare module BABYLON {
  104457. /**
  104458. * A multi-material is used to apply different materials to different parts of the same object without the need of
  104459. * separate meshes. This can be use to improve performances.
  104460. * @see https://doc.babylonjs.com/how_to/multi_materials
  104461. */
  104462. export class MultiMaterial extends Material {
  104463. private _subMaterials;
  104464. /**
  104465. * Gets or Sets the list of Materials used within the multi material.
  104466. * They need to be ordered according to the submeshes order in the associated mesh
  104467. */
  104468. get subMaterials(): Nullable<Material>[];
  104469. set subMaterials(value: Nullable<Material>[]);
  104470. /**
  104471. * Function used to align with Node.getChildren()
  104472. * @returns the list of Materials used within the multi material
  104473. */
  104474. getChildren(): Nullable<Material>[];
  104475. /**
  104476. * Instantiates a new Multi Material
  104477. * A multi-material is used to apply different materials to different parts of the same object without the need of
  104478. * separate meshes. This can be use to improve performances.
  104479. * @see https://doc.babylonjs.com/how_to/multi_materials
  104480. * @param name Define the name in the scene
  104481. * @param scene Define the scene the material belongs to
  104482. */
  104483. constructor(name: string, scene: Scene);
  104484. private _hookArray;
  104485. /**
  104486. * Get one of the submaterial by its index in the submaterials array
  104487. * @param index The index to look the sub material at
  104488. * @returns The Material if the index has been defined
  104489. */
  104490. getSubMaterial(index: number): Nullable<Material>;
  104491. /**
  104492. * Get the list of active textures for the whole sub materials list.
  104493. * @returns All the textures that will be used during the rendering
  104494. */
  104495. getActiveTextures(): BaseTexture[];
  104496. /**
  104497. * Gets the current class name of the material e.g. "MultiMaterial"
  104498. * Mainly use in serialization.
  104499. * @returns the class name
  104500. */
  104501. getClassName(): string;
  104502. /**
  104503. * Checks if the material is ready to render the requested sub mesh
  104504. * @param mesh Define the mesh the submesh belongs to
  104505. * @param subMesh Define the sub mesh to look readyness for
  104506. * @param useInstances Define whether or not the material is used with instances
  104507. * @returns true if ready, otherwise false
  104508. */
  104509. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  104510. /**
  104511. * Clones the current material and its related sub materials
  104512. * @param name Define the name of the newly cloned material
  104513. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  104514. * @returns the cloned material
  104515. */
  104516. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  104517. /**
  104518. * Serializes the materials into a JSON representation.
  104519. * @returns the JSON representation
  104520. */
  104521. serialize(): any;
  104522. /**
  104523. * Dispose the material and release its associated resources
  104524. * @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)
  104525. * @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)
  104526. * @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)
  104527. */
  104528. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  104529. /**
  104530. * Creates a MultiMaterial from parsed MultiMaterial data.
  104531. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  104532. * @param scene defines the hosting scene
  104533. * @returns a new MultiMaterial
  104534. */
  104535. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  104536. }
  104537. }
  104538. declare module BABYLON {
  104539. /**
  104540. * Defines a subdivision inside a mesh
  104541. */
  104542. export class SubMesh implements ICullable {
  104543. /** the material index to use */
  104544. materialIndex: number;
  104545. /** vertex index start */
  104546. verticesStart: number;
  104547. /** vertices count */
  104548. verticesCount: number;
  104549. /** index start */
  104550. indexStart: number;
  104551. /** indices count */
  104552. indexCount: number;
  104553. /** @hidden */
  104554. _materialDefines: Nullable<MaterialDefines>;
  104555. /** @hidden */
  104556. _materialEffect: Nullable<Effect>;
  104557. /** @hidden */
  104558. _effectOverride: Nullable<Effect>;
  104559. /**
  104560. * Gets material defines used by the effect associated to the sub mesh
  104561. */
  104562. get materialDefines(): Nullable<MaterialDefines>;
  104563. /**
  104564. * Sets material defines used by the effect associated to the sub mesh
  104565. */
  104566. set materialDefines(defines: Nullable<MaterialDefines>);
  104567. /**
  104568. * Gets associated effect
  104569. */
  104570. get effect(): Nullable<Effect>;
  104571. /**
  104572. * Sets associated effect (effect used to render this submesh)
  104573. * @param effect defines the effect to associate with
  104574. * @param defines defines the set of defines used to compile this effect
  104575. */
  104576. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  104577. /** @hidden */
  104578. _linesIndexCount: number;
  104579. private _mesh;
  104580. private _renderingMesh;
  104581. private _boundingInfo;
  104582. private _linesIndexBuffer;
  104583. /** @hidden */
  104584. _lastColliderWorldVertices: Nullable<Vector3[]>;
  104585. /** @hidden */
  104586. _trianglePlanes: Plane[];
  104587. /** @hidden */
  104588. _lastColliderTransformMatrix: Nullable<Matrix>;
  104589. /** @hidden */
  104590. _renderId: number;
  104591. /** @hidden */
  104592. _alphaIndex: number;
  104593. /** @hidden */
  104594. _distanceToCamera: number;
  104595. /** @hidden */
  104596. _id: number;
  104597. private _currentMaterial;
  104598. /**
  104599. * Add a new submesh to a mesh
  104600. * @param materialIndex defines the material index to use
  104601. * @param verticesStart defines vertex index start
  104602. * @param verticesCount defines vertices count
  104603. * @param indexStart defines index start
  104604. * @param indexCount defines indices count
  104605. * @param mesh defines the parent mesh
  104606. * @param renderingMesh defines an optional rendering mesh
  104607. * @param createBoundingBox defines if bounding box should be created for this submesh
  104608. * @returns the new submesh
  104609. */
  104610. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  104611. /**
  104612. * Creates a new submesh
  104613. * @param materialIndex defines the material index to use
  104614. * @param verticesStart defines vertex index start
  104615. * @param verticesCount defines vertices count
  104616. * @param indexStart defines index start
  104617. * @param indexCount defines indices count
  104618. * @param mesh defines the parent mesh
  104619. * @param renderingMesh defines an optional rendering mesh
  104620. * @param createBoundingBox defines if bounding box should be created for this submesh
  104621. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  104622. */
  104623. constructor(
  104624. /** the material index to use */
  104625. materialIndex: number,
  104626. /** vertex index start */
  104627. verticesStart: number,
  104628. /** vertices count */
  104629. verticesCount: number,
  104630. /** index start */
  104631. indexStart: number,
  104632. /** indices count */
  104633. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  104634. /**
  104635. * Returns true if this submesh covers the entire parent mesh
  104636. * @ignorenaming
  104637. */
  104638. get IsGlobal(): boolean;
  104639. /**
  104640. * Returns the submesh BoudingInfo object
  104641. * @returns current bounding info (or mesh's one if the submesh is global)
  104642. */
  104643. getBoundingInfo(): BoundingInfo;
  104644. /**
  104645. * Sets the submesh BoundingInfo
  104646. * @param boundingInfo defines the new bounding info to use
  104647. * @returns the SubMesh
  104648. */
  104649. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  104650. /**
  104651. * Returns the mesh of the current submesh
  104652. * @return the parent mesh
  104653. */
  104654. getMesh(): AbstractMesh;
  104655. /**
  104656. * Returns the rendering mesh of the submesh
  104657. * @returns the rendering mesh (could be different from parent mesh)
  104658. */
  104659. getRenderingMesh(): Mesh;
  104660. /**
  104661. * Returns the replacement mesh of the submesh
  104662. * @returns the replacement mesh (could be different from parent mesh)
  104663. */
  104664. getReplacementMesh(): Nullable<AbstractMesh>;
  104665. /**
  104666. * Returns the effective mesh of the submesh
  104667. * @returns the effective mesh (could be different from parent mesh)
  104668. */
  104669. getEffectiveMesh(): AbstractMesh;
  104670. /**
  104671. * Returns the submesh material
  104672. * @returns null or the current material
  104673. */
  104674. getMaterial(): Nullable<Material>;
  104675. private _IsMultiMaterial;
  104676. /**
  104677. * Sets a new updated BoundingInfo object to the submesh
  104678. * @param data defines an optional position array to use to determine the bounding info
  104679. * @returns the SubMesh
  104680. */
  104681. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  104682. /** @hidden */
  104683. _checkCollision(collider: Collider): boolean;
  104684. /**
  104685. * Updates the submesh BoundingInfo
  104686. * @param world defines the world matrix to use to update the bounding info
  104687. * @returns the submesh
  104688. */
  104689. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  104690. /**
  104691. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  104692. * @param frustumPlanes defines the frustum planes
  104693. * @returns true if the submesh is intersecting with the frustum
  104694. */
  104695. isInFrustum(frustumPlanes: Plane[]): boolean;
  104696. /**
  104697. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  104698. * @param frustumPlanes defines the frustum planes
  104699. * @returns true if the submesh is inside the frustum
  104700. */
  104701. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  104702. /**
  104703. * Renders the submesh
  104704. * @param enableAlphaMode defines if alpha needs to be used
  104705. * @returns the submesh
  104706. */
  104707. render(enableAlphaMode: boolean): SubMesh;
  104708. /**
  104709. * @hidden
  104710. */
  104711. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  104712. /**
  104713. * Checks if the submesh intersects with a ray
  104714. * @param ray defines the ray to test
  104715. * @returns true is the passed ray intersects the submesh bounding box
  104716. */
  104717. canIntersects(ray: Ray): boolean;
  104718. /**
  104719. * Intersects current submesh with a ray
  104720. * @param ray defines the ray to test
  104721. * @param positions defines mesh's positions array
  104722. * @param indices defines mesh's indices array
  104723. * @param fastCheck defines if the first intersection will be used (and not the closest)
  104724. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  104725. * @returns intersection info or null if no intersection
  104726. */
  104727. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  104728. /** @hidden */
  104729. private _intersectLines;
  104730. /** @hidden */
  104731. private _intersectUnIndexedLines;
  104732. /** @hidden */
  104733. private _intersectTriangles;
  104734. /** @hidden */
  104735. private _intersectUnIndexedTriangles;
  104736. /** @hidden */
  104737. _rebuild(): void;
  104738. /**
  104739. * Creates a new submesh from the passed mesh
  104740. * @param newMesh defines the new hosting mesh
  104741. * @param newRenderingMesh defines an optional rendering mesh
  104742. * @returns the new submesh
  104743. */
  104744. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  104745. /**
  104746. * Release associated resources
  104747. */
  104748. dispose(): void;
  104749. /**
  104750. * Gets the class name
  104751. * @returns the string "SubMesh".
  104752. */
  104753. getClassName(): string;
  104754. /**
  104755. * Creates a new submesh from indices data
  104756. * @param materialIndex the index of the main mesh material
  104757. * @param startIndex the index where to start the copy in the mesh indices array
  104758. * @param indexCount the number of indices to copy then from the startIndex
  104759. * @param mesh the main mesh to create the submesh from
  104760. * @param renderingMesh the optional rendering mesh
  104761. * @returns a new submesh
  104762. */
  104763. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  104764. }
  104765. }
  104766. declare module BABYLON {
  104767. /**
  104768. * Class used to represent data loading progression
  104769. */
  104770. export class SceneLoaderFlags {
  104771. private static _ForceFullSceneLoadingForIncremental;
  104772. private static _ShowLoadingScreen;
  104773. private static _CleanBoneMatrixWeights;
  104774. private static _loggingLevel;
  104775. /**
  104776. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  104777. */
  104778. static get ForceFullSceneLoadingForIncremental(): boolean;
  104779. static set ForceFullSceneLoadingForIncremental(value: boolean);
  104780. /**
  104781. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  104782. */
  104783. static get ShowLoadingScreen(): boolean;
  104784. static set ShowLoadingScreen(value: boolean);
  104785. /**
  104786. * Defines the current logging level (while loading the scene)
  104787. * @ignorenaming
  104788. */
  104789. static get loggingLevel(): number;
  104790. static set loggingLevel(value: number);
  104791. /**
  104792. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  104793. */
  104794. static get CleanBoneMatrixWeights(): boolean;
  104795. static set CleanBoneMatrixWeights(value: boolean);
  104796. }
  104797. }
  104798. declare module BABYLON {
  104799. /**
  104800. * Class used to store geometry data (vertex buffers + index buffer)
  104801. */
  104802. export class Geometry implements IGetSetVerticesData {
  104803. /**
  104804. * Gets or sets the ID of the geometry
  104805. */
  104806. id: string;
  104807. /**
  104808. * Gets or sets the unique ID of the geometry
  104809. */
  104810. uniqueId: number;
  104811. /**
  104812. * Gets the delay loading state of the geometry (none by default which means not delayed)
  104813. */
  104814. delayLoadState: number;
  104815. /**
  104816. * Gets the file containing the data to load when running in delay load state
  104817. */
  104818. delayLoadingFile: Nullable<string>;
  104819. /**
  104820. * Callback called when the geometry is updated
  104821. */
  104822. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  104823. private _scene;
  104824. private _engine;
  104825. private _meshes;
  104826. private _totalVertices;
  104827. /** @hidden */
  104828. _indices: IndicesArray;
  104829. /** @hidden */
  104830. _vertexBuffers: {
  104831. [key: string]: VertexBuffer;
  104832. };
  104833. private _isDisposed;
  104834. private _extend;
  104835. private _boundingBias;
  104836. /** @hidden */
  104837. _delayInfo: Array<string>;
  104838. private _indexBuffer;
  104839. private _indexBufferIsUpdatable;
  104840. /** @hidden */
  104841. _boundingInfo: Nullable<BoundingInfo>;
  104842. /** @hidden */
  104843. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  104844. /** @hidden */
  104845. _softwareSkinningFrameId: number;
  104846. private _vertexArrayObjects;
  104847. private _updatable;
  104848. /** @hidden */
  104849. _positions: Nullable<Vector3[]>;
  104850. /**
  104851. * 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
  104852. */
  104853. get boundingBias(): Vector2;
  104854. /**
  104855. * 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
  104856. */
  104857. set boundingBias(value: Vector2);
  104858. /**
  104859. * Static function used to attach a new empty geometry to a mesh
  104860. * @param mesh defines the mesh to attach the geometry to
  104861. * @returns the new Geometry
  104862. */
  104863. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  104864. /** Get the list of meshes using this geometry */
  104865. get meshes(): Mesh[];
  104866. /**
  104867. * 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
  104868. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  104869. */
  104870. useBoundingInfoFromGeometry: boolean;
  104871. /**
  104872. * Creates a new geometry
  104873. * @param id defines the unique ID
  104874. * @param scene defines the hosting scene
  104875. * @param vertexData defines the VertexData used to get geometry data
  104876. * @param updatable defines if geometry must be updatable (false by default)
  104877. * @param mesh defines the mesh that will be associated with the geometry
  104878. */
  104879. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  104880. /**
  104881. * Gets the current extend of the geometry
  104882. */
  104883. get extend(): {
  104884. minimum: Vector3;
  104885. maximum: Vector3;
  104886. };
  104887. /**
  104888. * Gets the hosting scene
  104889. * @returns the hosting Scene
  104890. */
  104891. getScene(): Scene;
  104892. /**
  104893. * Gets the hosting engine
  104894. * @returns the hosting Engine
  104895. */
  104896. getEngine(): Engine;
  104897. /**
  104898. * Defines if the geometry is ready to use
  104899. * @returns true if the geometry is ready to be used
  104900. */
  104901. isReady(): boolean;
  104902. /**
  104903. * Gets a value indicating that the geometry should not be serialized
  104904. */
  104905. get doNotSerialize(): boolean;
  104906. /** @hidden */
  104907. _rebuild(): void;
  104908. /**
  104909. * Affects all geometry data in one call
  104910. * @param vertexData defines the geometry data
  104911. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  104912. */
  104913. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  104914. /**
  104915. * Set specific vertex data
  104916. * @param kind defines the data kind (Position, normal, etc...)
  104917. * @param data defines the vertex data to use
  104918. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  104919. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  104920. */
  104921. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  104922. /**
  104923. * Removes a specific vertex data
  104924. * @param kind defines the data kind (Position, normal, etc...)
  104925. */
  104926. removeVerticesData(kind: string): void;
  104927. /**
  104928. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  104929. * @param buffer defines the vertex buffer to use
  104930. * @param totalVertices defines the total number of vertices for position kind (could be null)
  104931. */
  104932. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  104933. /**
  104934. * Update a specific vertex buffer
  104935. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  104936. * It will do nothing if the buffer is not updatable
  104937. * @param kind defines the data kind (Position, normal, etc...)
  104938. * @param data defines the data to use
  104939. * @param offset defines the offset in the target buffer where to store the data
  104940. * @param useBytes set to true if the offset is in bytes
  104941. */
  104942. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  104943. /**
  104944. * Update a specific vertex buffer
  104945. * This function will create a new buffer if the current one is not updatable
  104946. * @param kind defines the data kind (Position, normal, etc...)
  104947. * @param data defines the data to use
  104948. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  104949. */
  104950. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  104951. private _updateBoundingInfo;
  104952. /** @hidden */
  104953. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  104954. /**
  104955. * Gets total number of vertices
  104956. * @returns the total number of vertices
  104957. */
  104958. getTotalVertices(): number;
  104959. /**
  104960. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  104961. * @param kind defines the data kind (Position, normal, etc...)
  104962. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  104963. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  104964. * @returns a float array containing vertex data
  104965. */
  104966. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  104967. /**
  104968. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  104969. * @param kind defines the data kind (Position, normal, etc...)
  104970. * @returns true if the vertex buffer with the specified kind is updatable
  104971. */
  104972. isVertexBufferUpdatable(kind: string): boolean;
  104973. /**
  104974. * Gets a specific vertex buffer
  104975. * @param kind defines the data kind (Position, normal, etc...)
  104976. * @returns a VertexBuffer
  104977. */
  104978. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  104979. /**
  104980. * Returns all vertex buffers
  104981. * @return an object holding all vertex buffers indexed by kind
  104982. */
  104983. getVertexBuffers(): Nullable<{
  104984. [key: string]: VertexBuffer;
  104985. }>;
  104986. /**
  104987. * Gets a boolean indicating if specific vertex buffer is present
  104988. * @param kind defines the data kind (Position, normal, etc...)
  104989. * @returns true if data is present
  104990. */
  104991. isVerticesDataPresent(kind: string): boolean;
  104992. /**
  104993. * Gets a list of all attached data kinds (Position, normal, etc...)
  104994. * @returns a list of string containing all kinds
  104995. */
  104996. getVerticesDataKinds(): string[];
  104997. /**
  104998. * Update index buffer
  104999. * @param indices defines the indices to store in the index buffer
  105000. * @param offset defines the offset in the target buffer where to store the data
  105001. * @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)
  105002. */
  105003. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  105004. /**
  105005. * Creates a new index buffer
  105006. * @param indices defines the indices to store in the index buffer
  105007. * @param totalVertices defines the total number of vertices (could be null)
  105008. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  105009. */
  105010. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  105011. /**
  105012. * Return the total number of indices
  105013. * @returns the total number of indices
  105014. */
  105015. getTotalIndices(): number;
  105016. /**
  105017. * Gets the index buffer array
  105018. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  105019. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  105020. * @returns the index buffer array
  105021. */
  105022. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  105023. /**
  105024. * Gets the index buffer
  105025. * @return the index buffer
  105026. */
  105027. getIndexBuffer(): Nullable<DataBuffer>;
  105028. /** @hidden */
  105029. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  105030. /**
  105031. * Release the associated resources for a specific mesh
  105032. * @param mesh defines the source mesh
  105033. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  105034. */
  105035. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  105036. /**
  105037. * Apply current geometry to a given mesh
  105038. * @param mesh defines the mesh to apply geometry to
  105039. */
  105040. applyToMesh(mesh: Mesh): void;
  105041. private _updateExtend;
  105042. private _applyToMesh;
  105043. private notifyUpdate;
  105044. /**
  105045. * Load the geometry if it was flagged as delay loaded
  105046. * @param scene defines the hosting scene
  105047. * @param onLoaded defines a callback called when the geometry is loaded
  105048. */
  105049. load(scene: Scene, onLoaded?: () => void): void;
  105050. private _queueLoad;
  105051. /**
  105052. * Invert the geometry to move from a right handed system to a left handed one.
  105053. */
  105054. toLeftHanded(): void;
  105055. /** @hidden */
  105056. _resetPointsArrayCache(): void;
  105057. /** @hidden */
  105058. _generatePointsArray(): boolean;
  105059. /**
  105060. * Gets a value indicating if the geometry is disposed
  105061. * @returns true if the geometry was disposed
  105062. */
  105063. isDisposed(): boolean;
  105064. private _disposeVertexArrayObjects;
  105065. /**
  105066. * Free all associated resources
  105067. */
  105068. dispose(): void;
  105069. /**
  105070. * Clone the current geometry into a new geometry
  105071. * @param id defines the unique ID of the new geometry
  105072. * @returns a new geometry object
  105073. */
  105074. copy(id: string): Geometry;
  105075. /**
  105076. * Serialize the current geometry info (and not the vertices data) into a JSON object
  105077. * @return a JSON representation of the current geometry data (without the vertices data)
  105078. */
  105079. serialize(): any;
  105080. private toNumberArray;
  105081. /**
  105082. * Serialize all vertices data into a JSON oject
  105083. * @returns a JSON representation of the current geometry data
  105084. */
  105085. serializeVerticeData(): any;
  105086. /**
  105087. * Extracts a clone of a mesh geometry
  105088. * @param mesh defines the source mesh
  105089. * @param id defines the unique ID of the new geometry object
  105090. * @returns the new geometry object
  105091. */
  105092. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  105093. /**
  105094. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  105095. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  105096. * Be aware Math.random() could cause collisions, but:
  105097. * "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"
  105098. * @returns a string containing a new GUID
  105099. */
  105100. static RandomId(): string;
  105101. /** @hidden */
  105102. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  105103. private static _CleanMatricesWeights;
  105104. /**
  105105. * Create a new geometry from persisted data (Using .babylon file format)
  105106. * @param parsedVertexData defines the persisted data
  105107. * @param scene defines the hosting scene
  105108. * @param rootUrl defines the root url to use to load assets (like delayed data)
  105109. * @returns the new geometry object
  105110. */
  105111. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  105112. }
  105113. }
  105114. declare module BABYLON {
  105115. /**
  105116. * Define an interface for all classes that will get and set the data on vertices
  105117. */
  105118. export interface IGetSetVerticesData {
  105119. /**
  105120. * Gets a boolean indicating if specific vertex data is present
  105121. * @param kind defines the vertex data kind to use
  105122. * @returns true is data kind is present
  105123. */
  105124. isVerticesDataPresent(kind: string): boolean;
  105125. /**
  105126. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  105127. * @param kind defines the data kind (Position, normal, etc...)
  105128. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  105129. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  105130. * @returns a float array containing vertex data
  105131. */
  105132. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  105133. /**
  105134. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  105135. * @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.
  105136. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  105137. * @returns the indices array or an empty array if the mesh has no geometry
  105138. */
  105139. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  105140. /**
  105141. * Set specific vertex data
  105142. * @param kind defines the data kind (Position, normal, etc...)
  105143. * @param data defines the vertex data to use
  105144. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  105145. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  105146. */
  105147. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  105148. /**
  105149. * Update a specific associated vertex buffer
  105150. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  105151. * - VertexBuffer.PositionKind
  105152. * - VertexBuffer.UVKind
  105153. * - VertexBuffer.UV2Kind
  105154. * - VertexBuffer.UV3Kind
  105155. * - VertexBuffer.UV4Kind
  105156. * - VertexBuffer.UV5Kind
  105157. * - VertexBuffer.UV6Kind
  105158. * - VertexBuffer.ColorKind
  105159. * - VertexBuffer.MatricesIndicesKind
  105160. * - VertexBuffer.MatricesIndicesExtraKind
  105161. * - VertexBuffer.MatricesWeightsKind
  105162. * - VertexBuffer.MatricesWeightsExtraKind
  105163. * @param data defines the data source
  105164. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  105165. * @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)
  105166. */
  105167. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  105168. /**
  105169. * Creates a new index buffer
  105170. * @param indices defines the indices to store in the index buffer
  105171. * @param totalVertices defines the total number of vertices (could be null)
  105172. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  105173. */
  105174. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  105175. }
  105176. /**
  105177. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  105178. */
  105179. export class VertexData {
  105180. /**
  105181. * Mesh side orientation : usually the external or front surface
  105182. */
  105183. static readonly FRONTSIDE: number;
  105184. /**
  105185. * Mesh side orientation : usually the internal or back surface
  105186. */
  105187. static readonly BACKSIDE: number;
  105188. /**
  105189. * Mesh side orientation : both internal and external or front and back surfaces
  105190. */
  105191. static readonly DOUBLESIDE: number;
  105192. /**
  105193. * Mesh side orientation : by default, `FRONTSIDE`
  105194. */
  105195. static readonly DEFAULTSIDE: number;
  105196. /**
  105197. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  105198. */
  105199. positions: Nullable<FloatArray>;
  105200. /**
  105201. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  105202. */
  105203. normals: Nullable<FloatArray>;
  105204. /**
  105205. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  105206. */
  105207. tangents: Nullable<FloatArray>;
  105208. /**
  105209. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  105210. */
  105211. uvs: Nullable<FloatArray>;
  105212. /**
  105213. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  105214. */
  105215. uvs2: Nullable<FloatArray>;
  105216. /**
  105217. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  105218. */
  105219. uvs3: Nullable<FloatArray>;
  105220. /**
  105221. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  105222. */
  105223. uvs4: Nullable<FloatArray>;
  105224. /**
  105225. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  105226. */
  105227. uvs5: Nullable<FloatArray>;
  105228. /**
  105229. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  105230. */
  105231. uvs6: Nullable<FloatArray>;
  105232. /**
  105233. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  105234. */
  105235. colors: Nullable<FloatArray>;
  105236. /**
  105237. * 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).
  105238. */
  105239. matricesIndices: Nullable<FloatArray>;
  105240. /**
  105241. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  105242. */
  105243. matricesWeights: Nullable<FloatArray>;
  105244. /**
  105245. * An array extending the number of possible indices
  105246. */
  105247. matricesIndicesExtra: Nullable<FloatArray>;
  105248. /**
  105249. * An array extending the number of possible weights when the number of indices is extended
  105250. */
  105251. matricesWeightsExtra: Nullable<FloatArray>;
  105252. /**
  105253. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  105254. */
  105255. indices: Nullable<IndicesArray>;
  105256. /**
  105257. * Uses the passed data array to set the set the values for the specified kind of data
  105258. * @param data a linear array of floating numbers
  105259. * @param kind the type of data that is being set, eg positions, colors etc
  105260. */
  105261. set(data: FloatArray, kind: string): void;
  105262. /**
  105263. * Associates the vertexData to the passed Mesh.
  105264. * Sets it as updatable or not (default `false`)
  105265. * @param mesh the mesh the vertexData is applied to
  105266. * @param updatable when used and having the value true allows new data to update the vertexData
  105267. * @returns the VertexData
  105268. */
  105269. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  105270. /**
  105271. * Associates the vertexData to the passed Geometry.
  105272. * Sets it as updatable or not (default `false`)
  105273. * @param geometry the geometry the vertexData is applied to
  105274. * @param updatable when used and having the value true allows new data to update the vertexData
  105275. * @returns VertexData
  105276. */
  105277. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  105278. /**
  105279. * Updates the associated mesh
  105280. * @param mesh the mesh to be updated
  105281. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  105282. * @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
  105283. * @returns VertexData
  105284. */
  105285. updateMesh(mesh: Mesh): VertexData;
  105286. /**
  105287. * Updates the associated geometry
  105288. * @param geometry the geometry to be updated
  105289. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  105290. * @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
  105291. * @returns VertexData.
  105292. */
  105293. updateGeometry(geometry: Geometry): VertexData;
  105294. private _applyTo;
  105295. private _update;
  105296. /**
  105297. * Transforms each position and each normal of the vertexData according to the passed Matrix
  105298. * @param matrix the transforming matrix
  105299. * @returns the VertexData
  105300. */
  105301. transform(matrix: Matrix): VertexData;
  105302. /**
  105303. * Merges the passed VertexData into the current one
  105304. * @param other the VertexData to be merged into the current one
  105305. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  105306. * @returns the modified VertexData
  105307. */
  105308. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  105309. private _mergeElement;
  105310. private _validate;
  105311. /**
  105312. * Serializes the VertexData
  105313. * @returns a serialized object
  105314. */
  105315. serialize(): any;
  105316. /**
  105317. * Extracts the vertexData from a mesh
  105318. * @param mesh the mesh from which to extract the VertexData
  105319. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  105320. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  105321. * @returns the object VertexData associated to the passed mesh
  105322. */
  105323. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  105324. /**
  105325. * Extracts the vertexData from the geometry
  105326. * @param geometry the geometry from which to extract the VertexData
  105327. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  105328. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  105329. * @returns the object VertexData associated to the passed mesh
  105330. */
  105331. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  105332. private static _ExtractFrom;
  105333. /**
  105334. * Creates the VertexData for a Ribbon
  105335. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  105336. * * pathArray array of paths, each of which an array of successive Vector3
  105337. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  105338. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  105339. * * 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
  105340. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105341. * * 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)
  105342. * * 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)
  105343. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  105344. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  105345. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  105346. * @returns the VertexData of the ribbon
  105347. */
  105348. static CreateRibbon(options: {
  105349. pathArray: Vector3[][];
  105350. closeArray?: boolean;
  105351. closePath?: boolean;
  105352. offset?: number;
  105353. sideOrientation?: number;
  105354. frontUVs?: Vector4;
  105355. backUVs?: Vector4;
  105356. invertUV?: boolean;
  105357. uvs?: Vector2[];
  105358. colors?: Color4[];
  105359. }): VertexData;
  105360. /**
  105361. * Creates the VertexData for a box
  105362. * @param options an object used to set the following optional parameters for the box, required but can be empty
  105363. * * size sets the width, height and depth of the box to the value of size, optional default 1
  105364. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  105365. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  105366. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  105367. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  105368. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  105369. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105370. * * 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)
  105371. * * 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)
  105372. * @returns the VertexData of the box
  105373. */
  105374. static CreateBox(options: {
  105375. size?: number;
  105376. width?: number;
  105377. height?: number;
  105378. depth?: number;
  105379. faceUV?: Vector4[];
  105380. faceColors?: Color4[];
  105381. sideOrientation?: number;
  105382. frontUVs?: Vector4;
  105383. backUVs?: Vector4;
  105384. }): VertexData;
  105385. /**
  105386. * Creates the VertexData for a tiled box
  105387. * @param options an object used to set the following optional parameters for the box, required but can be empty
  105388. * * faceTiles sets the pattern, tile size and number of tiles for a face
  105389. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  105390. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  105391. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105392. * @returns the VertexData of the box
  105393. */
  105394. static CreateTiledBox(options: {
  105395. pattern?: number;
  105396. width?: number;
  105397. height?: number;
  105398. depth?: number;
  105399. tileSize?: number;
  105400. tileWidth?: number;
  105401. tileHeight?: number;
  105402. alignHorizontal?: number;
  105403. alignVertical?: number;
  105404. faceUV?: Vector4[];
  105405. faceColors?: Color4[];
  105406. sideOrientation?: number;
  105407. }): VertexData;
  105408. /**
  105409. * Creates the VertexData for a tiled plane
  105410. * @param options an object used to set the following optional parameters for the box, required but can be empty
  105411. * * pattern a limited pattern arrangement depending on the number
  105412. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  105413. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  105414. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  105415. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105416. * * 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)
  105417. * * 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)
  105418. * @returns the VertexData of the tiled plane
  105419. */
  105420. static CreateTiledPlane(options: {
  105421. pattern?: number;
  105422. tileSize?: number;
  105423. tileWidth?: number;
  105424. tileHeight?: number;
  105425. size?: number;
  105426. width?: number;
  105427. height?: number;
  105428. alignHorizontal?: number;
  105429. alignVertical?: number;
  105430. sideOrientation?: number;
  105431. frontUVs?: Vector4;
  105432. backUVs?: Vector4;
  105433. }): VertexData;
  105434. /**
  105435. * Creates the VertexData for an ellipsoid, defaults to a sphere
  105436. * @param options an object used to set the following optional parameters for the box, required but can be empty
  105437. * * segments sets the number of horizontal strips optional, default 32
  105438. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  105439. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  105440. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  105441. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  105442. * * 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
  105443. * * 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
  105444. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105445. * * 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)
  105446. * * 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)
  105447. * @returns the VertexData of the ellipsoid
  105448. */
  105449. static CreateSphere(options: {
  105450. segments?: number;
  105451. diameter?: number;
  105452. diameterX?: number;
  105453. diameterY?: number;
  105454. diameterZ?: number;
  105455. arc?: number;
  105456. slice?: number;
  105457. sideOrientation?: number;
  105458. frontUVs?: Vector4;
  105459. backUVs?: Vector4;
  105460. }): VertexData;
  105461. /**
  105462. * Creates the VertexData for a cylinder, cone or prism
  105463. * @param options an object used to set the following optional parameters for the box, required but can be empty
  105464. * * height sets the height (y direction) of the cylinder, optional, default 2
  105465. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  105466. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  105467. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  105468. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  105469. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  105470. * * 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
  105471. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  105472. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  105473. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  105474. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  105475. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105476. * * 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)
  105477. * * 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)
  105478. * @returns the VertexData of the cylinder, cone or prism
  105479. */
  105480. static CreateCylinder(options: {
  105481. height?: number;
  105482. diameterTop?: number;
  105483. diameterBottom?: number;
  105484. diameter?: number;
  105485. tessellation?: number;
  105486. subdivisions?: number;
  105487. arc?: number;
  105488. faceColors?: Color4[];
  105489. faceUV?: Vector4[];
  105490. hasRings?: boolean;
  105491. enclose?: boolean;
  105492. sideOrientation?: number;
  105493. frontUVs?: Vector4;
  105494. backUVs?: Vector4;
  105495. }): VertexData;
  105496. /**
  105497. * Creates the VertexData for a torus
  105498. * @param options an object used to set the following optional parameters for the box, required but can be empty
  105499. * * diameter the diameter of the torus, optional default 1
  105500. * * thickness the diameter of the tube forming the torus, optional default 0.5
  105501. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  105502. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105503. * * 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)
  105504. * * 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)
  105505. * @returns the VertexData of the torus
  105506. */
  105507. static CreateTorus(options: {
  105508. diameter?: number;
  105509. thickness?: number;
  105510. tessellation?: number;
  105511. sideOrientation?: number;
  105512. frontUVs?: Vector4;
  105513. backUVs?: Vector4;
  105514. }): VertexData;
  105515. /**
  105516. * Creates the VertexData of the LineSystem
  105517. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  105518. * - lines an array of lines, each line being an array of successive Vector3
  105519. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  105520. * @returns the VertexData of the LineSystem
  105521. */
  105522. static CreateLineSystem(options: {
  105523. lines: Vector3[][];
  105524. colors?: Nullable<Color4[][]>;
  105525. }): VertexData;
  105526. /**
  105527. * Create the VertexData for a DashedLines
  105528. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  105529. * - points an array successive Vector3
  105530. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  105531. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  105532. * - dashNb the intended total number of dashes, optional, default 200
  105533. * @returns the VertexData for the DashedLines
  105534. */
  105535. static CreateDashedLines(options: {
  105536. points: Vector3[];
  105537. dashSize?: number;
  105538. gapSize?: number;
  105539. dashNb?: number;
  105540. }): VertexData;
  105541. /**
  105542. * Creates the VertexData for a Ground
  105543. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  105544. * - width the width (x direction) of the ground, optional, default 1
  105545. * - height the height (z direction) of the ground, optional, default 1
  105546. * - subdivisions the number of subdivisions per side, optional, default 1
  105547. * @returns the VertexData of the Ground
  105548. */
  105549. static CreateGround(options: {
  105550. width?: number;
  105551. height?: number;
  105552. subdivisions?: number;
  105553. subdivisionsX?: number;
  105554. subdivisionsY?: number;
  105555. }): VertexData;
  105556. /**
  105557. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  105558. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  105559. * * xmin the ground minimum X coordinate, optional, default -1
  105560. * * zmin the ground minimum Z coordinate, optional, default -1
  105561. * * xmax the ground maximum X coordinate, optional, default 1
  105562. * * zmax the ground maximum Z coordinate, optional, default 1
  105563. * * 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}
  105564. * * 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}
  105565. * @returns the VertexData of the TiledGround
  105566. */
  105567. static CreateTiledGround(options: {
  105568. xmin: number;
  105569. zmin: number;
  105570. xmax: number;
  105571. zmax: number;
  105572. subdivisions?: {
  105573. w: number;
  105574. h: number;
  105575. };
  105576. precision?: {
  105577. w: number;
  105578. h: number;
  105579. };
  105580. }): VertexData;
  105581. /**
  105582. * Creates the VertexData of the Ground designed from a heightmap
  105583. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  105584. * * width the width (x direction) of the ground
  105585. * * height the height (z direction) of the ground
  105586. * * subdivisions the number of subdivisions per side
  105587. * * minHeight the minimum altitude on the ground, optional, default 0
  105588. * * maxHeight the maximum altitude on the ground, optional default 1
  105589. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  105590. * * buffer the array holding the image color data
  105591. * * bufferWidth the width of image
  105592. * * bufferHeight the height of image
  105593. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  105594. * @returns the VertexData of the Ground designed from a heightmap
  105595. */
  105596. static CreateGroundFromHeightMap(options: {
  105597. width: number;
  105598. height: number;
  105599. subdivisions: number;
  105600. minHeight: number;
  105601. maxHeight: number;
  105602. colorFilter: Color3;
  105603. buffer: Uint8Array;
  105604. bufferWidth: number;
  105605. bufferHeight: number;
  105606. alphaFilter: number;
  105607. }): VertexData;
  105608. /**
  105609. * Creates the VertexData for a Plane
  105610. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  105611. * * size sets the width and height of the plane to the value of size, optional default 1
  105612. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  105613. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  105614. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105615. * * 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)
  105616. * * 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)
  105617. * @returns the VertexData of the box
  105618. */
  105619. static CreatePlane(options: {
  105620. size?: number;
  105621. width?: number;
  105622. height?: number;
  105623. sideOrientation?: number;
  105624. frontUVs?: Vector4;
  105625. backUVs?: Vector4;
  105626. }): VertexData;
  105627. /**
  105628. * Creates the VertexData of the Disc or regular Polygon
  105629. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  105630. * * radius the radius of the disc, optional default 0.5
  105631. * * tessellation the number of polygon sides, optional, default 64
  105632. * * 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
  105633. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105634. * * 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)
  105635. * * 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)
  105636. * @returns the VertexData of the box
  105637. */
  105638. static CreateDisc(options: {
  105639. radius?: number;
  105640. tessellation?: number;
  105641. arc?: number;
  105642. sideOrientation?: number;
  105643. frontUVs?: Vector4;
  105644. backUVs?: Vector4;
  105645. }): VertexData;
  105646. /**
  105647. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  105648. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  105649. * @param polygon a mesh built from polygonTriangulation.build()
  105650. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105651. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  105652. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  105653. * @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)
  105654. * @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)
  105655. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  105656. * @returns the VertexData of the Polygon
  105657. */
  105658. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  105659. /**
  105660. * Creates the VertexData of the IcoSphere
  105661. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  105662. * * radius the radius of the IcoSphere, optional default 1
  105663. * * radiusX allows stretching in the x direction, optional, default radius
  105664. * * radiusY allows stretching in the y direction, optional, default radius
  105665. * * radiusZ allows stretching in the z direction, optional, default radius
  105666. * * flat when true creates a flat shaded mesh, optional, default true
  105667. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  105668. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105669. * * 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)
  105670. * * 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)
  105671. * @returns the VertexData of the IcoSphere
  105672. */
  105673. static CreateIcoSphere(options: {
  105674. radius?: number;
  105675. radiusX?: number;
  105676. radiusY?: number;
  105677. radiusZ?: number;
  105678. flat?: boolean;
  105679. subdivisions?: number;
  105680. sideOrientation?: number;
  105681. frontUVs?: Vector4;
  105682. backUVs?: Vector4;
  105683. }): VertexData;
  105684. /**
  105685. * Creates the VertexData for a Polyhedron
  105686. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  105687. * * type provided types are:
  105688. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  105689. * * 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)
  105690. * * size the size of the IcoSphere, optional default 1
  105691. * * sizeX allows stretching in the x direction, optional, default size
  105692. * * sizeY allows stretching in the y direction, optional, default size
  105693. * * sizeZ allows stretching in the z direction, optional, default size
  105694. * * 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
  105695. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  105696. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  105697. * * flat when true creates a flat shaded mesh, optional, default true
  105698. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  105699. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105700. * * 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)
  105701. * * 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)
  105702. * @returns the VertexData of the Polyhedron
  105703. */
  105704. static CreatePolyhedron(options: {
  105705. type?: number;
  105706. size?: number;
  105707. sizeX?: number;
  105708. sizeY?: number;
  105709. sizeZ?: number;
  105710. custom?: any;
  105711. faceUV?: Vector4[];
  105712. faceColors?: Color4[];
  105713. flat?: boolean;
  105714. sideOrientation?: number;
  105715. frontUVs?: Vector4;
  105716. backUVs?: Vector4;
  105717. }): VertexData;
  105718. /**
  105719. * Creates the VertexData for a TorusKnot
  105720. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  105721. * * radius the radius of the torus knot, optional, default 2
  105722. * * tube the thickness of the tube, optional, default 0.5
  105723. * * radialSegments the number of sides on each tube segments, optional, default 32
  105724. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  105725. * * p the number of windings around the z axis, optional, default 2
  105726. * * q the number of windings around the x axis, optional, default 3
  105727. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105728. * * 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)
  105729. * * 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)
  105730. * @returns the VertexData of the Torus Knot
  105731. */
  105732. static CreateTorusKnot(options: {
  105733. radius?: number;
  105734. tube?: number;
  105735. radialSegments?: number;
  105736. tubularSegments?: number;
  105737. p?: number;
  105738. q?: number;
  105739. sideOrientation?: number;
  105740. frontUVs?: Vector4;
  105741. backUVs?: Vector4;
  105742. }): VertexData;
  105743. /**
  105744. * Compute normals for given positions and indices
  105745. * @param positions an array of vertex positions, [...., x, y, z, ......]
  105746. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  105747. * @param normals an array of vertex normals, [...., x, y, z, ......]
  105748. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  105749. * * facetNormals : optional array of facet normals (vector3)
  105750. * * facetPositions : optional array of facet positions (vector3)
  105751. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  105752. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  105753. * * bInfo : optional bounding info, required for facetPartitioning computation
  105754. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  105755. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  105756. * * useRightHandedSystem: optional boolean to for right handed system computation
  105757. * * depthSort : optional boolean to enable the facet depth sort computation
  105758. * * distanceTo : optional Vector3 to compute the facet depth from this location
  105759. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  105760. */
  105761. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  105762. facetNormals?: any;
  105763. facetPositions?: any;
  105764. facetPartitioning?: any;
  105765. ratio?: number;
  105766. bInfo?: any;
  105767. bbSize?: Vector3;
  105768. subDiv?: any;
  105769. useRightHandedSystem?: boolean;
  105770. depthSort?: boolean;
  105771. distanceTo?: Vector3;
  105772. depthSortedFacets?: any;
  105773. }): void;
  105774. /** @hidden */
  105775. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  105776. /**
  105777. * Applies VertexData created from the imported parameters to the geometry
  105778. * @param parsedVertexData the parsed data from an imported file
  105779. * @param geometry the geometry to apply the VertexData to
  105780. */
  105781. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  105782. }
  105783. }
  105784. declare module BABYLON {
  105785. /**
  105786. * Defines a target to use with MorphTargetManager
  105787. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  105788. */
  105789. export class MorphTarget implements IAnimatable {
  105790. /** defines the name of the target */
  105791. name: string;
  105792. /**
  105793. * Gets or sets the list of animations
  105794. */
  105795. animations: Animation[];
  105796. private _scene;
  105797. private _positions;
  105798. private _normals;
  105799. private _tangents;
  105800. private _uvs;
  105801. private _influence;
  105802. private _uniqueId;
  105803. /**
  105804. * Observable raised when the influence changes
  105805. */
  105806. onInfluenceChanged: Observable<boolean>;
  105807. /** @hidden */
  105808. _onDataLayoutChanged: Observable<void>;
  105809. /**
  105810. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  105811. */
  105812. get influence(): number;
  105813. set influence(influence: number);
  105814. /**
  105815. * Gets or sets the id of the morph Target
  105816. */
  105817. id: string;
  105818. private _animationPropertiesOverride;
  105819. /**
  105820. * Gets or sets the animation properties override
  105821. */
  105822. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  105823. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  105824. /**
  105825. * Creates a new MorphTarget
  105826. * @param name defines the name of the target
  105827. * @param influence defines the influence to use
  105828. * @param scene defines the scene the morphtarget belongs to
  105829. */
  105830. constructor(
  105831. /** defines the name of the target */
  105832. name: string, influence?: number, scene?: Nullable<Scene>);
  105833. /**
  105834. * Gets the unique ID of this manager
  105835. */
  105836. get uniqueId(): number;
  105837. /**
  105838. * Gets a boolean defining if the target contains position data
  105839. */
  105840. get hasPositions(): boolean;
  105841. /**
  105842. * Gets a boolean defining if the target contains normal data
  105843. */
  105844. get hasNormals(): boolean;
  105845. /**
  105846. * Gets a boolean defining if the target contains tangent data
  105847. */
  105848. get hasTangents(): boolean;
  105849. /**
  105850. * Gets a boolean defining if the target contains texture coordinates data
  105851. */
  105852. get hasUVs(): boolean;
  105853. /**
  105854. * Affects position data to this target
  105855. * @param data defines the position data to use
  105856. */
  105857. setPositions(data: Nullable<FloatArray>): void;
  105858. /**
  105859. * Gets the position data stored in this target
  105860. * @returns a FloatArray containing the position data (or null if not present)
  105861. */
  105862. getPositions(): Nullable<FloatArray>;
  105863. /**
  105864. * Affects normal data to this target
  105865. * @param data defines the normal data to use
  105866. */
  105867. setNormals(data: Nullable<FloatArray>): void;
  105868. /**
  105869. * Gets the normal data stored in this target
  105870. * @returns a FloatArray containing the normal data (or null if not present)
  105871. */
  105872. getNormals(): Nullable<FloatArray>;
  105873. /**
  105874. * Affects tangent data to this target
  105875. * @param data defines the tangent data to use
  105876. */
  105877. setTangents(data: Nullable<FloatArray>): void;
  105878. /**
  105879. * Gets the tangent data stored in this target
  105880. * @returns a FloatArray containing the tangent data (or null if not present)
  105881. */
  105882. getTangents(): Nullable<FloatArray>;
  105883. /**
  105884. * Affects texture coordinates data to this target
  105885. * @param data defines the texture coordinates data to use
  105886. */
  105887. setUVs(data: Nullable<FloatArray>): void;
  105888. /**
  105889. * Gets the texture coordinates data stored in this target
  105890. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  105891. */
  105892. getUVs(): Nullable<FloatArray>;
  105893. /**
  105894. * Clone the current target
  105895. * @returns a new MorphTarget
  105896. */
  105897. clone(): MorphTarget;
  105898. /**
  105899. * Serializes the current target into a Serialization object
  105900. * @returns the serialized object
  105901. */
  105902. serialize(): any;
  105903. /**
  105904. * Returns the string "MorphTarget"
  105905. * @returns "MorphTarget"
  105906. */
  105907. getClassName(): string;
  105908. /**
  105909. * Creates a new target from serialized data
  105910. * @param serializationObject defines the serialized data to use
  105911. * @returns a new MorphTarget
  105912. */
  105913. static Parse(serializationObject: any): MorphTarget;
  105914. /**
  105915. * Creates a MorphTarget from mesh data
  105916. * @param mesh defines the source mesh
  105917. * @param name defines the name to use for the new target
  105918. * @param influence defines the influence to attach to the target
  105919. * @returns a new MorphTarget
  105920. */
  105921. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  105922. }
  105923. }
  105924. declare module BABYLON {
  105925. /**
  105926. * This class is used to deform meshes using morphing between different targets
  105927. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  105928. */
  105929. export class MorphTargetManager {
  105930. private _targets;
  105931. private _targetInfluenceChangedObservers;
  105932. private _targetDataLayoutChangedObservers;
  105933. private _activeTargets;
  105934. private _scene;
  105935. private _influences;
  105936. private _supportsNormals;
  105937. private _supportsTangents;
  105938. private _supportsUVs;
  105939. private _vertexCount;
  105940. private _uniqueId;
  105941. private _tempInfluences;
  105942. /**
  105943. * Gets or sets a boolean indicating if normals must be morphed
  105944. */
  105945. enableNormalMorphing: boolean;
  105946. /**
  105947. * Gets or sets a boolean indicating if tangents must be morphed
  105948. */
  105949. enableTangentMorphing: boolean;
  105950. /**
  105951. * Gets or sets a boolean indicating if UV must be morphed
  105952. */
  105953. enableUVMorphing: boolean;
  105954. /**
  105955. * Creates a new MorphTargetManager
  105956. * @param scene defines the current scene
  105957. */
  105958. constructor(scene?: Nullable<Scene>);
  105959. /**
  105960. * Gets the unique ID of this manager
  105961. */
  105962. get uniqueId(): number;
  105963. /**
  105964. * Gets the number of vertices handled by this manager
  105965. */
  105966. get vertexCount(): number;
  105967. /**
  105968. * Gets a boolean indicating if this manager supports morphing of normals
  105969. */
  105970. get supportsNormals(): boolean;
  105971. /**
  105972. * Gets a boolean indicating if this manager supports morphing of tangents
  105973. */
  105974. get supportsTangents(): boolean;
  105975. /**
  105976. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  105977. */
  105978. get supportsUVs(): boolean;
  105979. /**
  105980. * Gets the number of targets stored in this manager
  105981. */
  105982. get numTargets(): number;
  105983. /**
  105984. * Gets the number of influencers (ie. the number of targets with influences > 0)
  105985. */
  105986. get numInfluencers(): number;
  105987. /**
  105988. * Gets the list of influences (one per target)
  105989. */
  105990. get influences(): Float32Array;
  105991. /**
  105992. * Gets the active target at specified index. An active target is a target with an influence > 0
  105993. * @param index defines the index to check
  105994. * @returns the requested target
  105995. */
  105996. getActiveTarget(index: number): MorphTarget;
  105997. /**
  105998. * Gets the target at specified index
  105999. * @param index defines the index to check
  106000. * @returns the requested target
  106001. */
  106002. getTarget(index: number): MorphTarget;
  106003. /**
  106004. * Add a new target to this manager
  106005. * @param target defines the target to add
  106006. */
  106007. addTarget(target: MorphTarget): void;
  106008. /**
  106009. * Removes a target from the manager
  106010. * @param target defines the target to remove
  106011. */
  106012. removeTarget(target: MorphTarget): void;
  106013. /**
  106014. * Clone the current manager
  106015. * @returns a new MorphTargetManager
  106016. */
  106017. clone(): MorphTargetManager;
  106018. /**
  106019. * Serializes the current manager into a Serialization object
  106020. * @returns the serialized object
  106021. */
  106022. serialize(): any;
  106023. private _syncActiveTargets;
  106024. /**
  106025. * Syncrhonize the targets with all the meshes using this morph target manager
  106026. */
  106027. synchronize(): void;
  106028. /**
  106029. * Creates a new MorphTargetManager from serialized data
  106030. * @param serializationObject defines the serialized data
  106031. * @param scene defines the hosting scene
  106032. * @returns the new MorphTargetManager
  106033. */
  106034. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  106035. }
  106036. }
  106037. declare module BABYLON {
  106038. /**
  106039. * Class used to represent a specific level of detail of a mesh
  106040. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  106041. */
  106042. export class MeshLODLevel {
  106043. /** Defines the distance where this level should start being displayed */
  106044. distance: number;
  106045. /** Defines the mesh to use to render this level */
  106046. mesh: Nullable<Mesh>;
  106047. /**
  106048. * Creates a new LOD level
  106049. * @param distance defines the distance where this level should star being displayed
  106050. * @param mesh defines the mesh to use to render this level
  106051. */
  106052. constructor(
  106053. /** Defines the distance where this level should start being displayed */
  106054. distance: number,
  106055. /** Defines the mesh to use to render this level */
  106056. mesh: Nullable<Mesh>);
  106057. }
  106058. }
  106059. declare module BABYLON {
  106060. /**
  106061. * Helper class used to generate a canvas to manipulate images
  106062. */
  106063. export class CanvasGenerator {
  106064. /**
  106065. * Create a new canvas (or offscreen canvas depending on the context)
  106066. * @param width defines the expected width
  106067. * @param height defines the expected height
  106068. * @return a new canvas or offscreen canvas
  106069. */
  106070. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  106071. }
  106072. }
  106073. declare module BABYLON {
  106074. /**
  106075. * Mesh representing the gorund
  106076. */
  106077. export class GroundMesh extends Mesh {
  106078. /** If octree should be generated */
  106079. generateOctree: boolean;
  106080. private _heightQuads;
  106081. /** @hidden */
  106082. _subdivisionsX: number;
  106083. /** @hidden */
  106084. _subdivisionsY: number;
  106085. /** @hidden */
  106086. _width: number;
  106087. /** @hidden */
  106088. _height: number;
  106089. /** @hidden */
  106090. _minX: number;
  106091. /** @hidden */
  106092. _maxX: number;
  106093. /** @hidden */
  106094. _minZ: number;
  106095. /** @hidden */
  106096. _maxZ: number;
  106097. constructor(name: string, scene: Scene);
  106098. /**
  106099. * "GroundMesh"
  106100. * @returns "GroundMesh"
  106101. */
  106102. getClassName(): string;
  106103. /**
  106104. * The minimum of x and y subdivisions
  106105. */
  106106. get subdivisions(): number;
  106107. /**
  106108. * X subdivisions
  106109. */
  106110. get subdivisionsX(): number;
  106111. /**
  106112. * Y subdivisions
  106113. */
  106114. get subdivisionsY(): number;
  106115. /**
  106116. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  106117. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  106118. * @param chunksCount the number of subdivisions for x and y
  106119. * @param octreeBlocksSize (Default: 32)
  106120. */
  106121. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  106122. /**
  106123. * Returns a height (y) value in the Worl system :
  106124. * the ground altitude at the coordinates (x, z) expressed in the World system.
  106125. * @param x x coordinate
  106126. * @param z z coordinate
  106127. * @returns the ground y position if (x, z) are outside the ground surface.
  106128. */
  106129. getHeightAtCoordinates(x: number, z: number): number;
  106130. /**
  106131. * Returns a normalized vector (Vector3) orthogonal to the ground
  106132. * at the ground coordinates (x, z) expressed in the World system.
  106133. * @param x x coordinate
  106134. * @param z z coordinate
  106135. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  106136. */
  106137. getNormalAtCoordinates(x: number, z: number): Vector3;
  106138. /**
  106139. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  106140. * at the ground coordinates (x, z) expressed in the World system.
  106141. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  106142. * @param x x coordinate
  106143. * @param z z coordinate
  106144. * @param ref vector to store the result
  106145. * @returns the GroundMesh.
  106146. */
  106147. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  106148. /**
  106149. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  106150. * if the ground has been updated.
  106151. * This can be used in the render loop.
  106152. * @returns the GroundMesh.
  106153. */
  106154. updateCoordinateHeights(): GroundMesh;
  106155. private _getFacetAt;
  106156. private _initHeightQuads;
  106157. private _computeHeightQuads;
  106158. /**
  106159. * Serializes this ground mesh
  106160. * @param serializationObject object to write serialization to
  106161. */
  106162. serialize(serializationObject: any): void;
  106163. /**
  106164. * Parses a serialized ground mesh
  106165. * @param parsedMesh the serialized mesh
  106166. * @param scene the scene to create the ground mesh in
  106167. * @returns the created ground mesh
  106168. */
  106169. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  106170. }
  106171. }
  106172. declare module BABYLON {
  106173. /**
  106174. * Interface for Physics-Joint data
  106175. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106176. */
  106177. export interface PhysicsJointData {
  106178. /**
  106179. * The main pivot of the joint
  106180. */
  106181. mainPivot?: Vector3;
  106182. /**
  106183. * The connected pivot of the joint
  106184. */
  106185. connectedPivot?: Vector3;
  106186. /**
  106187. * The main axis of the joint
  106188. */
  106189. mainAxis?: Vector3;
  106190. /**
  106191. * The connected axis of the joint
  106192. */
  106193. connectedAxis?: Vector3;
  106194. /**
  106195. * The collision of the joint
  106196. */
  106197. collision?: boolean;
  106198. /**
  106199. * Native Oimo/Cannon/Energy data
  106200. */
  106201. nativeParams?: any;
  106202. }
  106203. /**
  106204. * This is a holder class for the physics joint created by the physics plugin
  106205. * It holds a set of functions to control the underlying joint
  106206. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106207. */
  106208. export class PhysicsJoint {
  106209. /**
  106210. * The type of the physics joint
  106211. */
  106212. type: number;
  106213. /**
  106214. * The data for the physics joint
  106215. */
  106216. jointData: PhysicsJointData;
  106217. private _physicsJoint;
  106218. protected _physicsPlugin: IPhysicsEnginePlugin;
  106219. /**
  106220. * Initializes the physics joint
  106221. * @param type The type of the physics joint
  106222. * @param jointData The data for the physics joint
  106223. */
  106224. constructor(
  106225. /**
  106226. * The type of the physics joint
  106227. */
  106228. type: number,
  106229. /**
  106230. * The data for the physics joint
  106231. */
  106232. jointData: PhysicsJointData);
  106233. /**
  106234. * Gets the physics joint
  106235. */
  106236. get physicsJoint(): any;
  106237. /**
  106238. * Sets the physics joint
  106239. */
  106240. set physicsJoint(newJoint: any);
  106241. /**
  106242. * Sets the physics plugin
  106243. */
  106244. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  106245. /**
  106246. * Execute a function that is physics-plugin specific.
  106247. * @param {Function} func the function that will be executed.
  106248. * It accepts two parameters: the physics world and the physics joint
  106249. */
  106250. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  106251. /**
  106252. * Distance-Joint type
  106253. */
  106254. static DistanceJoint: number;
  106255. /**
  106256. * Hinge-Joint type
  106257. */
  106258. static HingeJoint: number;
  106259. /**
  106260. * Ball-and-Socket joint type
  106261. */
  106262. static BallAndSocketJoint: number;
  106263. /**
  106264. * Wheel-Joint type
  106265. */
  106266. static WheelJoint: number;
  106267. /**
  106268. * Slider-Joint type
  106269. */
  106270. static SliderJoint: number;
  106271. /**
  106272. * Prismatic-Joint type
  106273. */
  106274. static PrismaticJoint: number;
  106275. /**
  106276. * Universal-Joint type
  106277. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  106278. */
  106279. static UniversalJoint: number;
  106280. /**
  106281. * Hinge-Joint 2 type
  106282. */
  106283. static Hinge2Joint: number;
  106284. /**
  106285. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  106286. */
  106287. static PointToPointJoint: number;
  106288. /**
  106289. * Spring-Joint type
  106290. */
  106291. static SpringJoint: number;
  106292. /**
  106293. * Lock-Joint type
  106294. */
  106295. static LockJoint: number;
  106296. }
  106297. /**
  106298. * A class representing a physics distance joint
  106299. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106300. */
  106301. export class DistanceJoint extends PhysicsJoint {
  106302. /**
  106303. *
  106304. * @param jointData The data for the Distance-Joint
  106305. */
  106306. constructor(jointData: DistanceJointData);
  106307. /**
  106308. * Update the predefined distance.
  106309. * @param maxDistance The maximum preferred distance
  106310. * @param minDistance The minimum preferred distance
  106311. */
  106312. updateDistance(maxDistance: number, minDistance?: number): void;
  106313. }
  106314. /**
  106315. * Represents a Motor-Enabled Joint
  106316. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106317. */
  106318. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  106319. /**
  106320. * Initializes the Motor-Enabled Joint
  106321. * @param type The type of the joint
  106322. * @param jointData The physica joint data for the joint
  106323. */
  106324. constructor(type: number, jointData: PhysicsJointData);
  106325. /**
  106326. * Set the motor values.
  106327. * Attention, this function is plugin specific. Engines won't react 100% the same.
  106328. * @param force the force to apply
  106329. * @param maxForce max force for this motor.
  106330. */
  106331. setMotor(force?: number, maxForce?: number): void;
  106332. /**
  106333. * Set the motor's limits.
  106334. * Attention, this function is plugin specific. Engines won't react 100% the same.
  106335. * @param upperLimit The upper limit of the motor
  106336. * @param lowerLimit The lower limit of the motor
  106337. */
  106338. setLimit(upperLimit: number, lowerLimit?: number): void;
  106339. }
  106340. /**
  106341. * This class represents a single physics Hinge-Joint
  106342. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106343. */
  106344. export class HingeJoint extends MotorEnabledJoint {
  106345. /**
  106346. * Initializes the Hinge-Joint
  106347. * @param jointData The joint data for the Hinge-Joint
  106348. */
  106349. constructor(jointData: PhysicsJointData);
  106350. /**
  106351. * Set the motor values.
  106352. * Attention, this function is plugin specific. Engines won't react 100% the same.
  106353. * @param {number} force the force to apply
  106354. * @param {number} maxForce max force for this motor.
  106355. */
  106356. setMotor(force?: number, maxForce?: number): void;
  106357. /**
  106358. * Set the motor's limits.
  106359. * Attention, this function is plugin specific. Engines won't react 100% the same.
  106360. * @param upperLimit The upper limit of the motor
  106361. * @param lowerLimit The lower limit of the motor
  106362. */
  106363. setLimit(upperLimit: number, lowerLimit?: number): void;
  106364. }
  106365. /**
  106366. * This class represents a dual hinge physics joint (same as wheel joint)
  106367. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106368. */
  106369. export class Hinge2Joint extends MotorEnabledJoint {
  106370. /**
  106371. * Initializes the Hinge2-Joint
  106372. * @param jointData The joint data for the Hinge2-Joint
  106373. */
  106374. constructor(jointData: PhysicsJointData);
  106375. /**
  106376. * Set the motor values.
  106377. * Attention, this function is plugin specific. Engines won't react 100% the same.
  106378. * @param {number} targetSpeed the speed the motor is to reach
  106379. * @param {number} maxForce max force for this motor.
  106380. * @param {motorIndex} the motor's index, 0 or 1.
  106381. */
  106382. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  106383. /**
  106384. * Set the motor limits.
  106385. * Attention, this function is plugin specific. Engines won't react 100% the same.
  106386. * @param {number} upperLimit the upper limit
  106387. * @param {number} lowerLimit lower limit
  106388. * @param {motorIndex} the motor's index, 0 or 1.
  106389. */
  106390. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  106391. }
  106392. /**
  106393. * Interface for a motor enabled joint
  106394. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106395. */
  106396. export interface IMotorEnabledJoint {
  106397. /**
  106398. * Physics joint
  106399. */
  106400. physicsJoint: any;
  106401. /**
  106402. * Sets the motor of the motor-enabled joint
  106403. * @param force The force of the motor
  106404. * @param maxForce The maximum force of the motor
  106405. * @param motorIndex The index of the motor
  106406. */
  106407. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  106408. /**
  106409. * Sets the limit of the motor
  106410. * @param upperLimit The upper limit of the motor
  106411. * @param lowerLimit The lower limit of the motor
  106412. * @param motorIndex The index of the motor
  106413. */
  106414. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  106415. }
  106416. /**
  106417. * Joint data for a Distance-Joint
  106418. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106419. */
  106420. export interface DistanceJointData extends PhysicsJointData {
  106421. /**
  106422. * Max distance the 2 joint objects can be apart
  106423. */
  106424. maxDistance: number;
  106425. }
  106426. /**
  106427. * Joint data from a spring joint
  106428. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106429. */
  106430. export interface SpringJointData extends PhysicsJointData {
  106431. /**
  106432. * Length of the spring
  106433. */
  106434. length: number;
  106435. /**
  106436. * Stiffness of the spring
  106437. */
  106438. stiffness: number;
  106439. /**
  106440. * Damping of the spring
  106441. */
  106442. damping: number;
  106443. /** this callback will be called when applying the force to the impostors. */
  106444. forceApplicationCallback: () => void;
  106445. }
  106446. }
  106447. declare module BABYLON {
  106448. /**
  106449. * Holds the data for the raycast result
  106450. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106451. */
  106452. export class PhysicsRaycastResult {
  106453. private _hasHit;
  106454. private _hitDistance;
  106455. private _hitNormalWorld;
  106456. private _hitPointWorld;
  106457. private _rayFromWorld;
  106458. private _rayToWorld;
  106459. /**
  106460. * Gets if there was a hit
  106461. */
  106462. get hasHit(): boolean;
  106463. /**
  106464. * Gets the distance from the hit
  106465. */
  106466. get hitDistance(): number;
  106467. /**
  106468. * Gets the hit normal/direction in the world
  106469. */
  106470. get hitNormalWorld(): Vector3;
  106471. /**
  106472. * Gets the hit point in the world
  106473. */
  106474. get hitPointWorld(): Vector3;
  106475. /**
  106476. * Gets the ray "start point" of the ray in the world
  106477. */
  106478. get rayFromWorld(): Vector3;
  106479. /**
  106480. * Gets the ray "end point" of the ray in the world
  106481. */
  106482. get rayToWorld(): Vector3;
  106483. /**
  106484. * Sets the hit data (normal & point in world space)
  106485. * @param hitNormalWorld defines the normal in world space
  106486. * @param hitPointWorld defines the point in world space
  106487. */
  106488. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  106489. /**
  106490. * Sets the distance from the start point to the hit point
  106491. * @param distance
  106492. */
  106493. setHitDistance(distance: number): void;
  106494. /**
  106495. * Calculates the distance manually
  106496. */
  106497. calculateHitDistance(): void;
  106498. /**
  106499. * Resets all the values to default
  106500. * @param from The from point on world space
  106501. * @param to The to point on world space
  106502. */
  106503. reset(from?: Vector3, to?: Vector3): void;
  106504. }
  106505. /**
  106506. * Interface for the size containing width and height
  106507. */
  106508. interface IXYZ {
  106509. /**
  106510. * X
  106511. */
  106512. x: number;
  106513. /**
  106514. * Y
  106515. */
  106516. y: number;
  106517. /**
  106518. * Z
  106519. */
  106520. z: number;
  106521. }
  106522. }
  106523. declare module BABYLON {
  106524. /**
  106525. * Interface used to describe a physics joint
  106526. */
  106527. export interface PhysicsImpostorJoint {
  106528. /** Defines the main impostor to which the joint is linked */
  106529. mainImpostor: PhysicsImpostor;
  106530. /** Defines the impostor that is connected to the main impostor using this joint */
  106531. connectedImpostor: PhysicsImpostor;
  106532. /** Defines the joint itself */
  106533. joint: PhysicsJoint;
  106534. }
  106535. /** @hidden */
  106536. export interface IPhysicsEnginePlugin {
  106537. world: any;
  106538. name: string;
  106539. setGravity(gravity: Vector3): void;
  106540. setTimeStep(timeStep: number): void;
  106541. getTimeStep(): number;
  106542. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  106543. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  106544. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  106545. generatePhysicsBody(impostor: PhysicsImpostor): void;
  106546. removePhysicsBody(impostor: PhysicsImpostor): void;
  106547. generateJoint(joint: PhysicsImpostorJoint): void;
  106548. removeJoint(joint: PhysicsImpostorJoint): void;
  106549. isSupported(): boolean;
  106550. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  106551. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  106552. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  106553. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  106554. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  106555. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  106556. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  106557. getBodyMass(impostor: PhysicsImpostor): number;
  106558. getBodyFriction(impostor: PhysicsImpostor): number;
  106559. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  106560. getBodyRestitution(impostor: PhysicsImpostor): number;
  106561. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  106562. getBodyPressure?(impostor: PhysicsImpostor): number;
  106563. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  106564. getBodyStiffness?(impostor: PhysicsImpostor): number;
  106565. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  106566. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  106567. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  106568. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  106569. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  106570. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  106571. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  106572. sleepBody(impostor: PhysicsImpostor): void;
  106573. wakeUpBody(impostor: PhysicsImpostor): void;
  106574. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  106575. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  106576. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  106577. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  106578. getRadius(impostor: PhysicsImpostor): number;
  106579. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  106580. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  106581. dispose(): void;
  106582. }
  106583. /**
  106584. * Interface used to define a physics engine
  106585. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106586. */
  106587. export interface IPhysicsEngine {
  106588. /**
  106589. * Gets the gravity vector used by the simulation
  106590. */
  106591. gravity: Vector3;
  106592. /**
  106593. * Sets the gravity vector used by the simulation
  106594. * @param gravity defines the gravity vector to use
  106595. */
  106596. setGravity(gravity: Vector3): void;
  106597. /**
  106598. * Set the time step of the physics engine.
  106599. * Default is 1/60.
  106600. * To slow it down, enter 1/600 for example.
  106601. * To speed it up, 1/30
  106602. * @param newTimeStep the new timestep to apply to this world.
  106603. */
  106604. setTimeStep(newTimeStep: number): void;
  106605. /**
  106606. * Get the time step of the physics engine.
  106607. * @returns the current time step
  106608. */
  106609. getTimeStep(): number;
  106610. /**
  106611. * Set the sub time step of the physics engine.
  106612. * Default is 0 meaning there is no sub steps
  106613. * To increase physics resolution precision, set a small value (like 1 ms)
  106614. * @param subTimeStep defines the new sub timestep used for physics resolution.
  106615. */
  106616. setSubTimeStep(subTimeStep: number): void;
  106617. /**
  106618. * Get the sub time step of the physics engine.
  106619. * @returns the current sub time step
  106620. */
  106621. getSubTimeStep(): number;
  106622. /**
  106623. * Release all resources
  106624. */
  106625. dispose(): void;
  106626. /**
  106627. * Gets the name of the current physics plugin
  106628. * @returns the name of the plugin
  106629. */
  106630. getPhysicsPluginName(): string;
  106631. /**
  106632. * Adding a new impostor for the impostor tracking.
  106633. * This will be done by the impostor itself.
  106634. * @param impostor the impostor to add
  106635. */
  106636. addImpostor(impostor: PhysicsImpostor): void;
  106637. /**
  106638. * Remove an impostor from the engine.
  106639. * This impostor and its mesh will not longer be updated by the physics engine.
  106640. * @param impostor the impostor to remove
  106641. */
  106642. removeImpostor(impostor: PhysicsImpostor): void;
  106643. /**
  106644. * Add a joint to the physics engine
  106645. * @param mainImpostor defines the main impostor to which the joint is added.
  106646. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  106647. * @param joint defines the joint that will connect both impostors.
  106648. */
  106649. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  106650. /**
  106651. * Removes a joint from the simulation
  106652. * @param mainImpostor defines the impostor used with the joint
  106653. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  106654. * @param joint defines the joint to remove
  106655. */
  106656. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  106657. /**
  106658. * Gets the current plugin used to run the simulation
  106659. * @returns current plugin
  106660. */
  106661. getPhysicsPlugin(): IPhysicsEnginePlugin;
  106662. /**
  106663. * Gets the list of physic impostors
  106664. * @returns an array of PhysicsImpostor
  106665. */
  106666. getImpostors(): Array<PhysicsImpostor>;
  106667. /**
  106668. * Gets the impostor for a physics enabled object
  106669. * @param object defines the object impersonated by the impostor
  106670. * @returns the PhysicsImpostor or null if not found
  106671. */
  106672. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  106673. /**
  106674. * Gets the impostor for a physics body object
  106675. * @param body defines physics body used by the impostor
  106676. * @returns the PhysicsImpostor or null if not found
  106677. */
  106678. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  106679. /**
  106680. * Does a raycast in the physics world
  106681. * @param from when should the ray start?
  106682. * @param to when should the ray end?
  106683. * @returns PhysicsRaycastResult
  106684. */
  106685. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  106686. /**
  106687. * Called by the scene. No need to call it.
  106688. * @param delta defines the timespam between frames
  106689. */
  106690. _step(delta: number): void;
  106691. }
  106692. }
  106693. declare module BABYLON {
  106694. /**
  106695. * The interface for the physics imposter parameters
  106696. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106697. */
  106698. export interface PhysicsImpostorParameters {
  106699. /**
  106700. * The mass of the physics imposter
  106701. */
  106702. mass: number;
  106703. /**
  106704. * The friction of the physics imposter
  106705. */
  106706. friction?: number;
  106707. /**
  106708. * The coefficient of restitution of the physics imposter
  106709. */
  106710. restitution?: number;
  106711. /**
  106712. * The native options of the physics imposter
  106713. */
  106714. nativeOptions?: any;
  106715. /**
  106716. * Specifies if the parent should be ignored
  106717. */
  106718. ignoreParent?: boolean;
  106719. /**
  106720. * Specifies if bi-directional transformations should be disabled
  106721. */
  106722. disableBidirectionalTransformation?: boolean;
  106723. /**
  106724. * The pressure inside the physics imposter, soft object only
  106725. */
  106726. pressure?: number;
  106727. /**
  106728. * The stiffness the physics imposter, soft object only
  106729. */
  106730. stiffness?: number;
  106731. /**
  106732. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  106733. */
  106734. velocityIterations?: number;
  106735. /**
  106736. * The number of iterations used in maintaining consistent vertex positions, soft object only
  106737. */
  106738. positionIterations?: number;
  106739. /**
  106740. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  106741. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  106742. * Add to fix multiple points
  106743. */
  106744. fixedPoints?: number;
  106745. /**
  106746. * The collision margin around a soft object
  106747. */
  106748. margin?: number;
  106749. /**
  106750. * The collision margin around a soft object
  106751. */
  106752. damping?: number;
  106753. /**
  106754. * The path for a rope based on an extrusion
  106755. */
  106756. path?: any;
  106757. /**
  106758. * The shape of an extrusion used for a rope based on an extrusion
  106759. */
  106760. shape?: any;
  106761. }
  106762. /**
  106763. * Interface for a physics-enabled object
  106764. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106765. */
  106766. export interface IPhysicsEnabledObject {
  106767. /**
  106768. * The position of the physics-enabled object
  106769. */
  106770. position: Vector3;
  106771. /**
  106772. * The rotation of the physics-enabled object
  106773. */
  106774. rotationQuaternion: Nullable<Quaternion>;
  106775. /**
  106776. * The scale of the physics-enabled object
  106777. */
  106778. scaling: Vector3;
  106779. /**
  106780. * The rotation of the physics-enabled object
  106781. */
  106782. rotation?: Vector3;
  106783. /**
  106784. * The parent of the physics-enabled object
  106785. */
  106786. parent?: any;
  106787. /**
  106788. * The bounding info of the physics-enabled object
  106789. * @returns The bounding info of the physics-enabled object
  106790. */
  106791. getBoundingInfo(): BoundingInfo;
  106792. /**
  106793. * Computes the world matrix
  106794. * @param force Specifies if the world matrix should be computed by force
  106795. * @returns A world matrix
  106796. */
  106797. computeWorldMatrix(force: boolean): Matrix;
  106798. /**
  106799. * Gets the world matrix
  106800. * @returns A world matrix
  106801. */
  106802. getWorldMatrix?(): Matrix;
  106803. /**
  106804. * Gets the child meshes
  106805. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  106806. * @returns An array of abstract meshes
  106807. */
  106808. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  106809. /**
  106810. * Gets the vertex data
  106811. * @param kind The type of vertex data
  106812. * @returns A nullable array of numbers, or a float32 array
  106813. */
  106814. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  106815. /**
  106816. * Gets the indices from the mesh
  106817. * @returns A nullable array of index arrays
  106818. */
  106819. getIndices?(): Nullable<IndicesArray>;
  106820. /**
  106821. * Gets the scene from the mesh
  106822. * @returns the indices array or null
  106823. */
  106824. getScene?(): Scene;
  106825. /**
  106826. * Gets the absolute position from the mesh
  106827. * @returns the absolute position
  106828. */
  106829. getAbsolutePosition(): Vector3;
  106830. /**
  106831. * Gets the absolute pivot point from the mesh
  106832. * @returns the absolute pivot point
  106833. */
  106834. getAbsolutePivotPoint(): Vector3;
  106835. /**
  106836. * Rotates the mesh
  106837. * @param axis The axis of rotation
  106838. * @param amount The amount of rotation
  106839. * @param space The space of the rotation
  106840. * @returns The rotation transform node
  106841. */
  106842. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  106843. /**
  106844. * Translates the mesh
  106845. * @param axis The axis of translation
  106846. * @param distance The distance of translation
  106847. * @param space The space of the translation
  106848. * @returns The transform node
  106849. */
  106850. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  106851. /**
  106852. * Sets the absolute position of the mesh
  106853. * @param absolutePosition The absolute position of the mesh
  106854. * @returns The transform node
  106855. */
  106856. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  106857. /**
  106858. * Gets the class name of the mesh
  106859. * @returns The class name
  106860. */
  106861. getClassName(): string;
  106862. }
  106863. /**
  106864. * Represents a physics imposter
  106865. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106866. */
  106867. export class PhysicsImpostor {
  106868. /**
  106869. * The physics-enabled object used as the physics imposter
  106870. */
  106871. object: IPhysicsEnabledObject;
  106872. /**
  106873. * The type of the physics imposter
  106874. */
  106875. type: number;
  106876. private _options;
  106877. private _scene?;
  106878. /**
  106879. * The default object size of the imposter
  106880. */
  106881. static DEFAULT_OBJECT_SIZE: Vector3;
  106882. /**
  106883. * The identity quaternion of the imposter
  106884. */
  106885. static IDENTITY_QUATERNION: Quaternion;
  106886. /** @hidden */
  106887. _pluginData: any;
  106888. private _physicsEngine;
  106889. private _physicsBody;
  106890. private _bodyUpdateRequired;
  106891. private _onBeforePhysicsStepCallbacks;
  106892. private _onAfterPhysicsStepCallbacks;
  106893. /** @hidden */
  106894. _onPhysicsCollideCallbacks: Array<{
  106895. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  106896. otherImpostors: Array<PhysicsImpostor>;
  106897. }>;
  106898. private _deltaPosition;
  106899. private _deltaRotation;
  106900. private _deltaRotationConjugated;
  106901. /** @hidden */
  106902. _isFromLine: boolean;
  106903. private _parent;
  106904. private _isDisposed;
  106905. private static _tmpVecs;
  106906. private static _tmpQuat;
  106907. /**
  106908. * Specifies if the physics imposter is disposed
  106909. */
  106910. get isDisposed(): boolean;
  106911. /**
  106912. * Gets the mass of the physics imposter
  106913. */
  106914. get mass(): number;
  106915. set mass(value: number);
  106916. /**
  106917. * Gets the coefficient of friction
  106918. */
  106919. get friction(): number;
  106920. /**
  106921. * Sets the coefficient of friction
  106922. */
  106923. set friction(value: number);
  106924. /**
  106925. * Gets the coefficient of restitution
  106926. */
  106927. get restitution(): number;
  106928. /**
  106929. * Sets the coefficient of restitution
  106930. */
  106931. set restitution(value: number);
  106932. /**
  106933. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  106934. */
  106935. get pressure(): number;
  106936. /**
  106937. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  106938. */
  106939. set pressure(value: number);
  106940. /**
  106941. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  106942. */
  106943. get stiffness(): number;
  106944. /**
  106945. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  106946. */
  106947. set stiffness(value: number);
  106948. /**
  106949. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  106950. */
  106951. get velocityIterations(): number;
  106952. /**
  106953. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  106954. */
  106955. set velocityIterations(value: number);
  106956. /**
  106957. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  106958. */
  106959. get positionIterations(): number;
  106960. /**
  106961. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  106962. */
  106963. set positionIterations(value: number);
  106964. /**
  106965. * The unique id of the physics imposter
  106966. * set by the physics engine when adding this impostor to the array
  106967. */
  106968. uniqueId: number;
  106969. /**
  106970. * @hidden
  106971. */
  106972. soft: boolean;
  106973. /**
  106974. * @hidden
  106975. */
  106976. segments: number;
  106977. private _joints;
  106978. /**
  106979. * Initializes the physics imposter
  106980. * @param object The physics-enabled object used as the physics imposter
  106981. * @param type The type of the physics imposter
  106982. * @param _options The options for the physics imposter
  106983. * @param _scene The Babylon scene
  106984. */
  106985. constructor(
  106986. /**
  106987. * The physics-enabled object used as the physics imposter
  106988. */
  106989. object: IPhysicsEnabledObject,
  106990. /**
  106991. * The type of the physics imposter
  106992. */
  106993. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  106994. /**
  106995. * This function will completly initialize this impostor.
  106996. * It will create a new body - but only if this mesh has no parent.
  106997. * If it has, this impostor will not be used other than to define the impostor
  106998. * of the child mesh.
  106999. * @hidden
  107000. */
  107001. _init(): void;
  107002. private _getPhysicsParent;
  107003. /**
  107004. * Should a new body be generated.
  107005. * @returns boolean specifying if body initialization is required
  107006. */
  107007. isBodyInitRequired(): boolean;
  107008. /**
  107009. * Sets the updated scaling
  107010. * @param updated Specifies if the scaling is updated
  107011. */
  107012. setScalingUpdated(): void;
  107013. /**
  107014. * Force a regeneration of this or the parent's impostor's body.
  107015. * Use under cautious - This will remove all joints already implemented.
  107016. */
  107017. forceUpdate(): void;
  107018. /**
  107019. * Gets the body that holds this impostor. Either its own, or its parent.
  107020. */
  107021. get physicsBody(): any;
  107022. /**
  107023. * Get the parent of the physics imposter
  107024. * @returns Physics imposter or null
  107025. */
  107026. get parent(): Nullable<PhysicsImpostor>;
  107027. /**
  107028. * Sets the parent of the physics imposter
  107029. */
  107030. set parent(value: Nullable<PhysicsImpostor>);
  107031. /**
  107032. * Set the physics body. Used mainly by the physics engine/plugin
  107033. */
  107034. set physicsBody(physicsBody: any);
  107035. /**
  107036. * Resets the update flags
  107037. */
  107038. resetUpdateFlags(): void;
  107039. /**
  107040. * Gets the object extend size
  107041. * @returns the object extend size
  107042. */
  107043. getObjectExtendSize(): Vector3;
  107044. /**
  107045. * Gets the object center
  107046. * @returns The object center
  107047. */
  107048. getObjectCenter(): Vector3;
  107049. /**
  107050. * Get a specific parameter from the options parameters
  107051. * @param paramName The object parameter name
  107052. * @returns The object parameter
  107053. */
  107054. getParam(paramName: string): any;
  107055. /**
  107056. * Sets a specific parameter in the options given to the physics plugin
  107057. * @param paramName The parameter name
  107058. * @param value The value of the parameter
  107059. */
  107060. setParam(paramName: string, value: number): void;
  107061. /**
  107062. * Specifically change the body's mass option. Won't recreate the physics body object
  107063. * @param mass The mass of the physics imposter
  107064. */
  107065. setMass(mass: number): void;
  107066. /**
  107067. * Gets the linear velocity
  107068. * @returns linear velocity or null
  107069. */
  107070. getLinearVelocity(): Nullable<Vector3>;
  107071. /**
  107072. * Sets the linear velocity
  107073. * @param velocity linear velocity or null
  107074. */
  107075. setLinearVelocity(velocity: Nullable<Vector3>): void;
  107076. /**
  107077. * Gets the angular velocity
  107078. * @returns angular velocity or null
  107079. */
  107080. getAngularVelocity(): Nullable<Vector3>;
  107081. /**
  107082. * Sets the angular velocity
  107083. * @param velocity The velocity or null
  107084. */
  107085. setAngularVelocity(velocity: Nullable<Vector3>): void;
  107086. /**
  107087. * Execute a function with the physics plugin native code
  107088. * Provide a function the will have two variables - the world object and the physics body object
  107089. * @param func The function to execute with the physics plugin native code
  107090. */
  107091. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  107092. /**
  107093. * Register a function that will be executed before the physics world is stepping forward
  107094. * @param func The function to execute before the physics world is stepped forward
  107095. */
  107096. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  107097. /**
  107098. * Unregister a function that will be executed before the physics world is stepping forward
  107099. * @param func The function to execute before the physics world is stepped forward
  107100. */
  107101. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  107102. /**
  107103. * Register a function that will be executed after the physics step
  107104. * @param func The function to execute after physics step
  107105. */
  107106. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  107107. /**
  107108. * Unregisters a function that will be executed after the physics step
  107109. * @param func The function to execute after physics step
  107110. */
  107111. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  107112. /**
  107113. * register a function that will be executed when this impostor collides against a different body
  107114. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  107115. * @param func Callback that is executed on collision
  107116. */
  107117. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  107118. /**
  107119. * Unregisters the physics imposter on contact
  107120. * @param collideAgainst The physics object to collide against
  107121. * @param func Callback to execute on collision
  107122. */
  107123. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  107124. private _tmpQuat;
  107125. private _tmpQuat2;
  107126. /**
  107127. * Get the parent rotation
  107128. * @returns The parent rotation
  107129. */
  107130. getParentsRotation(): Quaternion;
  107131. /**
  107132. * this function is executed by the physics engine.
  107133. */
  107134. beforeStep: () => void;
  107135. /**
  107136. * this function is executed by the physics engine
  107137. */
  107138. afterStep: () => void;
  107139. /**
  107140. * Legacy collision detection event support
  107141. */
  107142. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  107143. /**
  107144. * event and body object due to cannon's event-based architecture.
  107145. */
  107146. onCollide: (e: {
  107147. body: any;
  107148. }) => void;
  107149. /**
  107150. * Apply a force
  107151. * @param force The force to apply
  107152. * @param contactPoint The contact point for the force
  107153. * @returns The physics imposter
  107154. */
  107155. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  107156. /**
  107157. * Apply an impulse
  107158. * @param force The impulse force
  107159. * @param contactPoint The contact point for the impulse force
  107160. * @returns The physics imposter
  107161. */
  107162. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  107163. /**
  107164. * A help function to create a joint
  107165. * @param otherImpostor A physics imposter used to create a joint
  107166. * @param jointType The type of joint
  107167. * @param jointData The data for the joint
  107168. * @returns The physics imposter
  107169. */
  107170. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  107171. /**
  107172. * Add a joint to this impostor with a different impostor
  107173. * @param otherImpostor A physics imposter used to add a joint
  107174. * @param joint The joint to add
  107175. * @returns The physics imposter
  107176. */
  107177. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  107178. /**
  107179. * Add an anchor to a cloth impostor
  107180. * @param otherImpostor rigid impostor to anchor to
  107181. * @param width ratio across width from 0 to 1
  107182. * @param height ratio up height from 0 to 1
  107183. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  107184. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  107185. * @returns impostor the soft imposter
  107186. */
  107187. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  107188. /**
  107189. * Add a hook to a rope impostor
  107190. * @param otherImpostor rigid impostor to anchor to
  107191. * @param length ratio across rope from 0 to 1
  107192. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  107193. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  107194. * @returns impostor the rope imposter
  107195. */
  107196. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  107197. /**
  107198. * Will keep this body still, in a sleep mode.
  107199. * @returns the physics imposter
  107200. */
  107201. sleep(): PhysicsImpostor;
  107202. /**
  107203. * Wake the body up.
  107204. * @returns The physics imposter
  107205. */
  107206. wakeUp(): PhysicsImpostor;
  107207. /**
  107208. * Clones the physics imposter
  107209. * @param newObject The physics imposter clones to this physics-enabled object
  107210. * @returns A nullable physics imposter
  107211. */
  107212. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  107213. /**
  107214. * Disposes the physics imposter
  107215. */
  107216. dispose(): void;
  107217. /**
  107218. * Sets the delta position
  107219. * @param position The delta position amount
  107220. */
  107221. setDeltaPosition(position: Vector3): void;
  107222. /**
  107223. * Sets the delta rotation
  107224. * @param rotation The delta rotation amount
  107225. */
  107226. setDeltaRotation(rotation: Quaternion): void;
  107227. /**
  107228. * Gets the box size of the physics imposter and stores the result in the input parameter
  107229. * @param result Stores the box size
  107230. * @returns The physics imposter
  107231. */
  107232. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  107233. /**
  107234. * Gets the radius of the physics imposter
  107235. * @returns Radius of the physics imposter
  107236. */
  107237. getRadius(): number;
  107238. /**
  107239. * Sync a bone with this impostor
  107240. * @param bone The bone to sync to the impostor.
  107241. * @param boneMesh The mesh that the bone is influencing.
  107242. * @param jointPivot The pivot of the joint / bone in local space.
  107243. * @param distToJoint Optional distance from the impostor to the joint.
  107244. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  107245. */
  107246. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  107247. /**
  107248. * Sync impostor to a bone
  107249. * @param bone The bone that the impostor will be synced to.
  107250. * @param boneMesh The mesh that the bone is influencing.
  107251. * @param jointPivot The pivot of the joint / bone in local space.
  107252. * @param distToJoint Optional distance from the impostor to the joint.
  107253. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  107254. * @param boneAxis Optional vector3 axis the bone is aligned with
  107255. */
  107256. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  107257. /**
  107258. * No-Imposter type
  107259. */
  107260. static NoImpostor: number;
  107261. /**
  107262. * Sphere-Imposter type
  107263. */
  107264. static SphereImpostor: number;
  107265. /**
  107266. * Box-Imposter type
  107267. */
  107268. static BoxImpostor: number;
  107269. /**
  107270. * Plane-Imposter type
  107271. */
  107272. static PlaneImpostor: number;
  107273. /**
  107274. * Mesh-imposter type
  107275. */
  107276. static MeshImpostor: number;
  107277. /**
  107278. * Capsule-Impostor type (Ammo.js plugin only)
  107279. */
  107280. static CapsuleImpostor: number;
  107281. /**
  107282. * Cylinder-Imposter type
  107283. */
  107284. static CylinderImpostor: number;
  107285. /**
  107286. * Particle-Imposter type
  107287. */
  107288. static ParticleImpostor: number;
  107289. /**
  107290. * Heightmap-Imposter type
  107291. */
  107292. static HeightmapImpostor: number;
  107293. /**
  107294. * ConvexHull-Impostor type (Ammo.js plugin only)
  107295. */
  107296. static ConvexHullImpostor: number;
  107297. /**
  107298. * Custom-Imposter type (Ammo.js plugin only)
  107299. */
  107300. static CustomImpostor: number;
  107301. /**
  107302. * Rope-Imposter type
  107303. */
  107304. static RopeImpostor: number;
  107305. /**
  107306. * Cloth-Imposter type
  107307. */
  107308. static ClothImpostor: number;
  107309. /**
  107310. * Softbody-Imposter type
  107311. */
  107312. static SoftbodyImpostor: number;
  107313. }
  107314. }
  107315. declare module BABYLON {
  107316. /**
  107317. * @hidden
  107318. **/
  107319. export class _CreationDataStorage {
  107320. closePath?: boolean;
  107321. closeArray?: boolean;
  107322. idx: number[];
  107323. dashSize: number;
  107324. gapSize: number;
  107325. path3D: Path3D;
  107326. pathArray: Vector3[][];
  107327. arc: number;
  107328. radius: number;
  107329. cap: number;
  107330. tessellation: number;
  107331. }
  107332. /**
  107333. * @hidden
  107334. **/
  107335. class _InstanceDataStorage {
  107336. visibleInstances: any;
  107337. batchCache: _InstancesBatch;
  107338. instancesBufferSize: number;
  107339. instancesBuffer: Nullable<Buffer>;
  107340. instancesData: Float32Array;
  107341. overridenInstanceCount: number;
  107342. isFrozen: boolean;
  107343. previousBatch: Nullable<_InstancesBatch>;
  107344. hardwareInstancedRendering: boolean;
  107345. sideOrientation: number;
  107346. manualUpdate: boolean;
  107347. }
  107348. /**
  107349. * @hidden
  107350. **/
  107351. export class _InstancesBatch {
  107352. mustReturn: boolean;
  107353. visibleInstances: Nullable<InstancedMesh[]>[];
  107354. renderSelf: boolean[];
  107355. hardwareInstancedRendering: boolean[];
  107356. }
  107357. /**
  107358. * @hidden
  107359. **/
  107360. class _ThinInstanceDataStorage {
  107361. instancesCount: number;
  107362. matrixBuffer: Nullable<Buffer>;
  107363. matrixBufferSize: number;
  107364. matrixData: Nullable<Float32Array>;
  107365. boundingVectors: Array<Vector3>;
  107366. worldMatrices: Nullable<Matrix[]>;
  107367. }
  107368. /**
  107369. * Class used to represent renderable models
  107370. */
  107371. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  107372. /**
  107373. * Mesh side orientation : usually the external or front surface
  107374. */
  107375. static readonly FRONTSIDE: number;
  107376. /**
  107377. * Mesh side orientation : usually the internal or back surface
  107378. */
  107379. static readonly BACKSIDE: number;
  107380. /**
  107381. * Mesh side orientation : both internal and external or front and back surfaces
  107382. */
  107383. static readonly DOUBLESIDE: number;
  107384. /**
  107385. * Mesh side orientation : by default, `FRONTSIDE`
  107386. */
  107387. static readonly DEFAULTSIDE: number;
  107388. /**
  107389. * Mesh cap setting : no cap
  107390. */
  107391. static readonly NO_CAP: number;
  107392. /**
  107393. * Mesh cap setting : one cap at the beginning of the mesh
  107394. */
  107395. static readonly CAP_START: number;
  107396. /**
  107397. * Mesh cap setting : one cap at the end of the mesh
  107398. */
  107399. static readonly CAP_END: number;
  107400. /**
  107401. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  107402. */
  107403. static readonly CAP_ALL: number;
  107404. /**
  107405. * Mesh pattern setting : no flip or rotate
  107406. */
  107407. static readonly NO_FLIP: number;
  107408. /**
  107409. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  107410. */
  107411. static readonly FLIP_TILE: number;
  107412. /**
  107413. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  107414. */
  107415. static readonly ROTATE_TILE: number;
  107416. /**
  107417. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  107418. */
  107419. static readonly FLIP_ROW: number;
  107420. /**
  107421. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  107422. */
  107423. static readonly ROTATE_ROW: number;
  107424. /**
  107425. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  107426. */
  107427. static readonly FLIP_N_ROTATE_TILE: number;
  107428. /**
  107429. * Mesh pattern setting : rotate pattern and rotate
  107430. */
  107431. static readonly FLIP_N_ROTATE_ROW: number;
  107432. /**
  107433. * Mesh tile positioning : part tiles same on left/right or top/bottom
  107434. */
  107435. static readonly CENTER: number;
  107436. /**
  107437. * Mesh tile positioning : part tiles on left
  107438. */
  107439. static readonly LEFT: number;
  107440. /**
  107441. * Mesh tile positioning : part tiles on right
  107442. */
  107443. static readonly RIGHT: number;
  107444. /**
  107445. * Mesh tile positioning : part tiles on top
  107446. */
  107447. static readonly TOP: number;
  107448. /**
  107449. * Mesh tile positioning : part tiles on bottom
  107450. */
  107451. static readonly BOTTOM: number;
  107452. /**
  107453. * Gets the default side orientation.
  107454. * @param orientation the orientation to value to attempt to get
  107455. * @returns the default orientation
  107456. * @hidden
  107457. */
  107458. static _GetDefaultSideOrientation(orientation?: number): number;
  107459. private _internalMeshDataInfo;
  107460. get computeBonesUsingShaders(): boolean;
  107461. set computeBonesUsingShaders(value: boolean);
  107462. /**
  107463. * An event triggered before rendering the mesh
  107464. */
  107465. get onBeforeRenderObservable(): Observable<Mesh>;
  107466. /**
  107467. * An event triggered before binding the mesh
  107468. */
  107469. get onBeforeBindObservable(): Observable<Mesh>;
  107470. /**
  107471. * An event triggered after rendering the mesh
  107472. */
  107473. get onAfterRenderObservable(): Observable<Mesh>;
  107474. /**
  107475. * An event triggered before drawing the mesh
  107476. */
  107477. get onBeforeDrawObservable(): Observable<Mesh>;
  107478. private _onBeforeDrawObserver;
  107479. /**
  107480. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  107481. */
  107482. set onBeforeDraw(callback: () => void);
  107483. get hasInstances(): boolean;
  107484. get hasThinInstances(): boolean;
  107485. /**
  107486. * Gets the delay loading state of the mesh (when delay loading is turned on)
  107487. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  107488. */
  107489. delayLoadState: number;
  107490. /**
  107491. * Gets the list of instances created from this mesh
  107492. * it is not supposed to be modified manually.
  107493. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  107494. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  107495. */
  107496. instances: InstancedMesh[];
  107497. /**
  107498. * Gets the file containing delay loading data for this mesh
  107499. */
  107500. delayLoadingFile: string;
  107501. /** @hidden */
  107502. _binaryInfo: any;
  107503. /**
  107504. * User defined function used to change how LOD level selection is done
  107505. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  107506. */
  107507. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  107508. /**
  107509. * Gets or sets the morph target manager
  107510. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  107511. */
  107512. get morphTargetManager(): Nullable<MorphTargetManager>;
  107513. set morphTargetManager(value: Nullable<MorphTargetManager>);
  107514. /** @hidden */
  107515. _creationDataStorage: Nullable<_CreationDataStorage>;
  107516. /** @hidden */
  107517. _geometry: Nullable<Geometry>;
  107518. /** @hidden */
  107519. _delayInfo: Array<string>;
  107520. /** @hidden */
  107521. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  107522. /** @hidden */
  107523. _instanceDataStorage: _InstanceDataStorage;
  107524. /** @hidden */
  107525. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  107526. private _effectiveMaterial;
  107527. /** @hidden */
  107528. _shouldGenerateFlatShading: boolean;
  107529. /** @hidden */
  107530. _originalBuilderSideOrientation: number;
  107531. /**
  107532. * Use this property to change the original side orientation defined at construction time
  107533. */
  107534. overrideMaterialSideOrientation: Nullable<number>;
  107535. /**
  107536. * Gets the source mesh (the one used to clone this one from)
  107537. */
  107538. get source(): Nullable<Mesh>;
  107539. /**
  107540. * Gets or sets a boolean indicating that this mesh does not use index buffer
  107541. */
  107542. get isUnIndexed(): boolean;
  107543. set isUnIndexed(value: boolean);
  107544. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  107545. get worldMatrixInstancedBuffer(): Float32Array;
  107546. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  107547. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  107548. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  107549. /**
  107550. * @constructor
  107551. * @param name The value used by scene.getMeshByName() to do a lookup.
  107552. * @param scene The scene to add this mesh to.
  107553. * @param parent The parent of this mesh, if it has one
  107554. * @param source An optional Mesh from which geometry is shared, cloned.
  107555. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  107556. * When false, achieved by calling a clone(), also passing False.
  107557. * This will make creation of children, recursive.
  107558. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  107559. */
  107560. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  107561. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  107562. doNotInstantiate: boolean;
  107563. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  107564. /**
  107565. * Gets the class name
  107566. * @returns the string "Mesh".
  107567. */
  107568. getClassName(): string;
  107569. /** @hidden */
  107570. get _isMesh(): boolean;
  107571. /**
  107572. * Returns a description of this mesh
  107573. * @param fullDetails define if full details about this mesh must be used
  107574. * @returns a descriptive string representing this mesh
  107575. */
  107576. toString(fullDetails?: boolean): string;
  107577. /** @hidden */
  107578. _unBindEffect(): void;
  107579. /**
  107580. * Gets a boolean indicating if this mesh has LOD
  107581. */
  107582. get hasLODLevels(): boolean;
  107583. /**
  107584. * Gets the list of MeshLODLevel associated with the current mesh
  107585. * @returns an array of MeshLODLevel
  107586. */
  107587. getLODLevels(): MeshLODLevel[];
  107588. private _sortLODLevels;
  107589. /**
  107590. * Add a mesh as LOD level triggered at the given distance.
  107591. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  107592. * @param distance The distance from the center of the object to show this level
  107593. * @param mesh The mesh to be added as LOD level (can be null)
  107594. * @return This mesh (for chaining)
  107595. */
  107596. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  107597. /**
  107598. * Returns the LOD level mesh at the passed distance or null if not found.
  107599. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  107600. * @param distance The distance from the center of the object to show this level
  107601. * @returns a Mesh or `null`
  107602. */
  107603. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  107604. /**
  107605. * Remove a mesh from the LOD array
  107606. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  107607. * @param mesh defines the mesh to be removed
  107608. * @return This mesh (for chaining)
  107609. */
  107610. removeLODLevel(mesh: Mesh): Mesh;
  107611. /**
  107612. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  107613. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  107614. * @param camera defines the camera to use to compute distance
  107615. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  107616. * @return This mesh (for chaining)
  107617. */
  107618. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  107619. /**
  107620. * Gets the mesh internal Geometry object
  107621. */
  107622. get geometry(): Nullable<Geometry>;
  107623. /**
  107624. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  107625. * @returns the total number of vertices
  107626. */
  107627. getTotalVertices(): number;
  107628. /**
  107629. * Returns the content of an associated vertex buffer
  107630. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  107631. * - VertexBuffer.PositionKind
  107632. * - VertexBuffer.UVKind
  107633. * - VertexBuffer.UV2Kind
  107634. * - VertexBuffer.UV3Kind
  107635. * - VertexBuffer.UV4Kind
  107636. * - VertexBuffer.UV5Kind
  107637. * - VertexBuffer.UV6Kind
  107638. * - VertexBuffer.ColorKind
  107639. * - VertexBuffer.MatricesIndicesKind
  107640. * - VertexBuffer.MatricesIndicesExtraKind
  107641. * - VertexBuffer.MatricesWeightsKind
  107642. * - VertexBuffer.MatricesWeightsExtraKind
  107643. * @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
  107644. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  107645. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  107646. */
  107647. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  107648. /**
  107649. * Returns the mesh VertexBuffer object from the requested `kind`
  107650. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  107651. * - VertexBuffer.PositionKind
  107652. * - VertexBuffer.NormalKind
  107653. * - VertexBuffer.UVKind
  107654. * - VertexBuffer.UV2Kind
  107655. * - VertexBuffer.UV3Kind
  107656. * - VertexBuffer.UV4Kind
  107657. * - VertexBuffer.UV5Kind
  107658. * - VertexBuffer.UV6Kind
  107659. * - VertexBuffer.ColorKind
  107660. * - VertexBuffer.MatricesIndicesKind
  107661. * - VertexBuffer.MatricesIndicesExtraKind
  107662. * - VertexBuffer.MatricesWeightsKind
  107663. * - VertexBuffer.MatricesWeightsExtraKind
  107664. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  107665. */
  107666. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  107667. /**
  107668. * Tests if a specific vertex buffer is associated with this mesh
  107669. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  107670. * - VertexBuffer.PositionKind
  107671. * - VertexBuffer.NormalKind
  107672. * - VertexBuffer.UVKind
  107673. * - VertexBuffer.UV2Kind
  107674. * - VertexBuffer.UV3Kind
  107675. * - VertexBuffer.UV4Kind
  107676. * - VertexBuffer.UV5Kind
  107677. * - VertexBuffer.UV6Kind
  107678. * - VertexBuffer.ColorKind
  107679. * - VertexBuffer.MatricesIndicesKind
  107680. * - VertexBuffer.MatricesIndicesExtraKind
  107681. * - VertexBuffer.MatricesWeightsKind
  107682. * - VertexBuffer.MatricesWeightsExtraKind
  107683. * @returns a boolean
  107684. */
  107685. isVerticesDataPresent(kind: string): boolean;
  107686. /**
  107687. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  107688. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  107689. * - VertexBuffer.PositionKind
  107690. * - VertexBuffer.UVKind
  107691. * - VertexBuffer.UV2Kind
  107692. * - VertexBuffer.UV3Kind
  107693. * - VertexBuffer.UV4Kind
  107694. * - VertexBuffer.UV5Kind
  107695. * - VertexBuffer.UV6Kind
  107696. * - VertexBuffer.ColorKind
  107697. * - VertexBuffer.MatricesIndicesKind
  107698. * - VertexBuffer.MatricesIndicesExtraKind
  107699. * - VertexBuffer.MatricesWeightsKind
  107700. * - VertexBuffer.MatricesWeightsExtraKind
  107701. * @returns a boolean
  107702. */
  107703. isVertexBufferUpdatable(kind: string): boolean;
  107704. /**
  107705. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  107706. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  107707. * - VertexBuffer.PositionKind
  107708. * - VertexBuffer.NormalKind
  107709. * - VertexBuffer.UVKind
  107710. * - VertexBuffer.UV2Kind
  107711. * - VertexBuffer.UV3Kind
  107712. * - VertexBuffer.UV4Kind
  107713. * - VertexBuffer.UV5Kind
  107714. * - VertexBuffer.UV6Kind
  107715. * - VertexBuffer.ColorKind
  107716. * - VertexBuffer.MatricesIndicesKind
  107717. * - VertexBuffer.MatricesIndicesExtraKind
  107718. * - VertexBuffer.MatricesWeightsKind
  107719. * - VertexBuffer.MatricesWeightsExtraKind
  107720. * @returns an array of strings
  107721. */
  107722. getVerticesDataKinds(): string[];
  107723. /**
  107724. * Returns a positive integer : the total number of indices in this mesh geometry.
  107725. * @returns the numner of indices or zero if the mesh has no geometry.
  107726. */
  107727. getTotalIndices(): number;
  107728. /**
  107729. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  107730. * @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.
  107731. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  107732. * @returns the indices array or an empty array if the mesh has no geometry
  107733. */
  107734. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  107735. get isBlocked(): boolean;
  107736. /**
  107737. * Determine if the current mesh is ready to be rendered
  107738. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  107739. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  107740. * @returns true if all associated assets are ready (material, textures, shaders)
  107741. */
  107742. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  107743. /**
  107744. * 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.
  107745. */
  107746. get areNormalsFrozen(): boolean;
  107747. /**
  107748. * 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.
  107749. * @returns the current mesh
  107750. */
  107751. freezeNormals(): Mesh;
  107752. /**
  107753. * 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
  107754. * @returns the current mesh
  107755. */
  107756. unfreezeNormals(): Mesh;
  107757. /**
  107758. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  107759. */
  107760. set overridenInstanceCount(count: number);
  107761. /** @hidden */
  107762. _preActivate(): Mesh;
  107763. /** @hidden */
  107764. _preActivateForIntermediateRendering(renderId: number): Mesh;
  107765. /** @hidden */
  107766. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  107767. protected _afterComputeWorldMatrix(): void;
  107768. /** @hidden */
  107769. _postActivate(): void;
  107770. /**
  107771. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  107772. * This means the mesh underlying bounding box and sphere are recomputed.
  107773. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  107774. * @returns the current mesh
  107775. */
  107776. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  107777. /** @hidden */
  107778. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  107779. /**
  107780. * This function will subdivide the mesh into multiple submeshes
  107781. * @param count defines the expected number of submeshes
  107782. */
  107783. subdivide(count: number): void;
  107784. /**
  107785. * Copy a FloatArray into a specific associated vertex buffer
  107786. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  107787. * - VertexBuffer.PositionKind
  107788. * - VertexBuffer.UVKind
  107789. * - VertexBuffer.UV2Kind
  107790. * - VertexBuffer.UV3Kind
  107791. * - VertexBuffer.UV4Kind
  107792. * - VertexBuffer.UV5Kind
  107793. * - VertexBuffer.UV6Kind
  107794. * - VertexBuffer.ColorKind
  107795. * - VertexBuffer.MatricesIndicesKind
  107796. * - VertexBuffer.MatricesIndicesExtraKind
  107797. * - VertexBuffer.MatricesWeightsKind
  107798. * - VertexBuffer.MatricesWeightsExtraKind
  107799. * @param data defines the data source
  107800. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  107801. * @param stride defines the data stride size (can be null)
  107802. * @returns the current mesh
  107803. */
  107804. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  107805. /**
  107806. * Delete a vertex buffer associated with this mesh
  107807. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  107808. * - VertexBuffer.PositionKind
  107809. * - VertexBuffer.UVKind
  107810. * - VertexBuffer.UV2Kind
  107811. * - VertexBuffer.UV3Kind
  107812. * - VertexBuffer.UV4Kind
  107813. * - VertexBuffer.UV5Kind
  107814. * - VertexBuffer.UV6Kind
  107815. * - VertexBuffer.ColorKind
  107816. * - VertexBuffer.MatricesIndicesKind
  107817. * - VertexBuffer.MatricesIndicesExtraKind
  107818. * - VertexBuffer.MatricesWeightsKind
  107819. * - VertexBuffer.MatricesWeightsExtraKind
  107820. */
  107821. removeVerticesData(kind: string): void;
  107822. /**
  107823. * Flags an associated vertex buffer as updatable
  107824. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  107825. * - VertexBuffer.PositionKind
  107826. * - VertexBuffer.UVKind
  107827. * - VertexBuffer.UV2Kind
  107828. * - VertexBuffer.UV3Kind
  107829. * - VertexBuffer.UV4Kind
  107830. * - VertexBuffer.UV5Kind
  107831. * - VertexBuffer.UV6Kind
  107832. * - VertexBuffer.ColorKind
  107833. * - VertexBuffer.MatricesIndicesKind
  107834. * - VertexBuffer.MatricesIndicesExtraKind
  107835. * - VertexBuffer.MatricesWeightsKind
  107836. * - VertexBuffer.MatricesWeightsExtraKind
  107837. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  107838. */
  107839. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  107840. /**
  107841. * Sets the mesh global Vertex Buffer
  107842. * @param buffer defines the buffer to use
  107843. * @returns the current mesh
  107844. */
  107845. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  107846. /**
  107847. * Update a specific associated vertex buffer
  107848. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  107849. * - VertexBuffer.PositionKind
  107850. * - VertexBuffer.UVKind
  107851. * - VertexBuffer.UV2Kind
  107852. * - VertexBuffer.UV3Kind
  107853. * - VertexBuffer.UV4Kind
  107854. * - VertexBuffer.UV5Kind
  107855. * - VertexBuffer.UV6Kind
  107856. * - VertexBuffer.ColorKind
  107857. * - VertexBuffer.MatricesIndicesKind
  107858. * - VertexBuffer.MatricesIndicesExtraKind
  107859. * - VertexBuffer.MatricesWeightsKind
  107860. * - VertexBuffer.MatricesWeightsExtraKind
  107861. * @param data defines the data source
  107862. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  107863. * @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)
  107864. * @returns the current mesh
  107865. */
  107866. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  107867. /**
  107868. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  107869. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  107870. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  107871. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  107872. * @returns the current mesh
  107873. */
  107874. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  107875. /**
  107876. * Creates a un-shared specific occurence of the geometry for the mesh.
  107877. * @returns the current mesh
  107878. */
  107879. makeGeometryUnique(): Mesh;
  107880. /**
  107881. * Set the index buffer of this mesh
  107882. * @param indices defines the source data
  107883. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  107884. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  107885. * @returns the current mesh
  107886. */
  107887. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  107888. /**
  107889. * Update the current index buffer
  107890. * @param indices defines the source data
  107891. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  107892. * @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)
  107893. * @returns the current mesh
  107894. */
  107895. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  107896. /**
  107897. * Invert the geometry to move from a right handed system to a left handed one.
  107898. * @returns the current mesh
  107899. */
  107900. toLeftHanded(): Mesh;
  107901. /** @hidden */
  107902. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  107903. /** @hidden */
  107904. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  107905. /**
  107906. * Registers for this mesh a javascript function called just before the rendering process
  107907. * @param func defines the function to call before rendering this mesh
  107908. * @returns the current mesh
  107909. */
  107910. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  107911. /**
  107912. * Disposes a previously registered javascript function called before the rendering
  107913. * @param func defines the function to remove
  107914. * @returns the current mesh
  107915. */
  107916. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  107917. /**
  107918. * Registers for this mesh a javascript function called just after the rendering is complete
  107919. * @param func defines the function to call after rendering this mesh
  107920. * @returns the current mesh
  107921. */
  107922. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  107923. /**
  107924. * Disposes a previously registered javascript function called after the rendering.
  107925. * @param func defines the function to remove
  107926. * @returns the current mesh
  107927. */
  107928. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  107929. /** @hidden */
  107930. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  107931. /** @hidden */
  107932. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  107933. /** @hidden */
  107934. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  107935. /** @hidden */
  107936. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  107937. /** @hidden */
  107938. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  107939. /** @hidden */
  107940. _rebuild(): void;
  107941. /** @hidden */
  107942. _freeze(): void;
  107943. /** @hidden */
  107944. _unFreeze(): void;
  107945. /**
  107946. * 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
  107947. * @param subMesh defines the subMesh to render
  107948. * @param enableAlphaMode defines if alpha mode can be changed
  107949. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  107950. * @returns the current mesh
  107951. */
  107952. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  107953. private _onBeforeDraw;
  107954. /**
  107955. * Renormalize the mesh and patch it up if there are no weights
  107956. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  107957. * However in the case of zero weights then we set just a single influence to 1.
  107958. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  107959. */
  107960. cleanMatrixWeights(): void;
  107961. private normalizeSkinFourWeights;
  107962. private normalizeSkinWeightsAndExtra;
  107963. /**
  107964. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  107965. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  107966. * the user know there was an issue with importing the mesh
  107967. * @returns a validation object with skinned, valid and report string
  107968. */
  107969. validateSkinning(): {
  107970. skinned: boolean;
  107971. valid: boolean;
  107972. report: string;
  107973. };
  107974. /** @hidden */
  107975. _checkDelayState(): Mesh;
  107976. private _queueLoad;
  107977. /**
  107978. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  107979. * A mesh is in the frustum if its bounding box intersects the frustum
  107980. * @param frustumPlanes defines the frustum to test
  107981. * @returns true if the mesh is in the frustum planes
  107982. */
  107983. isInFrustum(frustumPlanes: Plane[]): boolean;
  107984. /**
  107985. * Sets the mesh material by the material or multiMaterial `id` property
  107986. * @param id is a string identifying the material or the multiMaterial
  107987. * @returns the current mesh
  107988. */
  107989. setMaterialByID(id: string): Mesh;
  107990. /**
  107991. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  107992. * @returns an array of IAnimatable
  107993. */
  107994. getAnimatables(): IAnimatable[];
  107995. /**
  107996. * Modifies the mesh geometry according to the passed transformation matrix.
  107997. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  107998. * The mesh normals are modified using the same transformation.
  107999. * Note that, under the hood, this method sets a new VertexBuffer each call.
  108000. * @param transform defines the transform matrix to use
  108001. * @see https://doc.babylonjs.com/resources/baking_transformations
  108002. * @returns the current mesh
  108003. */
  108004. bakeTransformIntoVertices(transform: Matrix): Mesh;
  108005. /**
  108006. * Modifies the mesh geometry according to its own current World Matrix.
  108007. * The mesh World Matrix is then reset.
  108008. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  108009. * Note that, under the hood, this method sets a new VertexBuffer each call.
  108010. * @see https://doc.babylonjs.com/resources/baking_transformations
  108011. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  108012. * @returns the current mesh
  108013. */
  108014. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  108015. /** @hidden */
  108016. get _positions(): Nullable<Vector3[]>;
  108017. /** @hidden */
  108018. _resetPointsArrayCache(): Mesh;
  108019. /** @hidden */
  108020. _generatePointsArray(): boolean;
  108021. /**
  108022. * Returns a new Mesh object generated from the current mesh properties.
  108023. * This method must not get confused with createInstance()
  108024. * @param name is a string, the name given to the new mesh
  108025. * @param newParent can be any Node object (default `null`)
  108026. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  108027. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  108028. * @returns a new mesh
  108029. */
  108030. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  108031. /**
  108032. * Releases resources associated with this mesh.
  108033. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  108034. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  108035. */
  108036. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  108037. /** @hidden */
  108038. _disposeInstanceSpecificData(): void;
  108039. /** @hidden */
  108040. _disposeThinInstanceSpecificData(): void;
  108041. /**
  108042. * Modifies the mesh geometry according to a displacement map.
  108043. * 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.
  108044. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  108045. * @param url is a string, the URL from the image file is to be downloaded.
  108046. * @param minHeight is the lower limit of the displacement.
  108047. * @param maxHeight is the upper limit of the displacement.
  108048. * @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.
  108049. * @param uvOffset is an optional vector2 used to offset UV.
  108050. * @param uvScale is an optional vector2 used to scale UV.
  108051. * @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.
  108052. * @returns the Mesh.
  108053. */
  108054. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  108055. /**
  108056. * Modifies the mesh geometry according to a displacementMap buffer.
  108057. * 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.
  108058. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  108059. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  108060. * @param heightMapWidth is the width of the buffer image.
  108061. * @param heightMapHeight is the height of the buffer image.
  108062. * @param minHeight is the lower limit of the displacement.
  108063. * @param maxHeight is the upper limit of the displacement.
  108064. * @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.
  108065. * @param uvOffset is an optional vector2 used to offset UV.
  108066. * @param uvScale is an optional vector2 used to scale UV.
  108067. * @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.
  108068. * @returns the Mesh.
  108069. */
  108070. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  108071. /**
  108072. * Modify the mesh to get a flat shading rendering.
  108073. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  108074. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  108075. * @returns current mesh
  108076. */
  108077. convertToFlatShadedMesh(): Mesh;
  108078. /**
  108079. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  108080. * In other words, more vertices, no more indices and a single bigger VBO.
  108081. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  108082. * @returns current mesh
  108083. */
  108084. convertToUnIndexedMesh(): Mesh;
  108085. /**
  108086. * Inverses facet orientations.
  108087. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  108088. * @param flipNormals will also inverts the normals
  108089. * @returns current mesh
  108090. */
  108091. flipFaces(flipNormals?: boolean): Mesh;
  108092. /**
  108093. * Increase the number of facets and hence vertices in a mesh
  108094. * Vertex normals are interpolated from existing vertex normals
  108095. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  108096. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  108097. */
  108098. increaseVertices(numberPerEdge: number): void;
  108099. /**
  108100. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  108101. * This will undo any application of covertToFlatShadedMesh
  108102. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  108103. */
  108104. forceSharedVertices(): void;
  108105. /** @hidden */
  108106. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  108107. /** @hidden */
  108108. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  108109. /**
  108110. * Creates a new InstancedMesh object from the mesh model.
  108111. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  108112. * @param name defines the name of the new instance
  108113. * @returns a new InstancedMesh
  108114. */
  108115. createInstance(name: string): InstancedMesh;
  108116. /**
  108117. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  108118. * After this call, all the mesh instances have the same submeshes than the current mesh.
  108119. * @returns the current mesh
  108120. */
  108121. synchronizeInstances(): Mesh;
  108122. /**
  108123. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  108124. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  108125. * This should be used together with the simplification to avoid disappearing triangles.
  108126. * @param successCallback an optional success callback to be called after the optimization finished.
  108127. * @returns the current mesh
  108128. */
  108129. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  108130. /**
  108131. * Serialize current mesh
  108132. * @param serializationObject defines the object which will receive the serialization data
  108133. */
  108134. serialize(serializationObject: any): void;
  108135. /** @hidden */
  108136. _syncGeometryWithMorphTargetManager(): void;
  108137. /** @hidden */
  108138. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  108139. /**
  108140. * Returns a new Mesh object parsed from the source provided.
  108141. * @param parsedMesh is the source
  108142. * @param scene defines the hosting scene
  108143. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  108144. * @returns a new Mesh
  108145. */
  108146. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  108147. /**
  108148. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  108149. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108150. * @param name defines the name of the mesh to create
  108151. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  108152. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  108153. * @param closePath creates a seam between the first and the last points of each path of the path array
  108154. * @param offset is taken in account only if the `pathArray` is containing a single path
  108155. * @param scene defines the hosting scene
  108156. * @param updatable defines if the mesh must be flagged as updatable
  108157. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108158. * @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)
  108159. * @returns a new Mesh
  108160. */
  108161. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  108162. /**
  108163. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  108164. * @param name defines the name of the mesh to create
  108165. * @param radius sets the radius size (float) of the polygon (default 0.5)
  108166. * @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
  108167. * @param scene defines the hosting scene
  108168. * @param updatable defines if the mesh must be flagged as updatable
  108169. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108170. * @returns a new Mesh
  108171. */
  108172. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  108173. /**
  108174. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  108175. * @param name defines the name of the mesh to create
  108176. * @param size sets the size (float) of each box side (default 1)
  108177. * @param scene defines the hosting scene
  108178. * @param updatable defines if the mesh must be flagged as updatable
  108179. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108180. * @returns a new Mesh
  108181. */
  108182. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  108183. /**
  108184. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  108185. * @param name defines the name of the mesh to create
  108186. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  108187. * @param diameter sets the diameter size (float) of the sphere (default 1)
  108188. * @param scene defines the hosting scene
  108189. * @param updatable defines if the mesh must be flagged as updatable
  108190. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108191. * @returns a new Mesh
  108192. */
  108193. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  108194. /**
  108195. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  108196. * @param name defines the name of the mesh to create
  108197. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  108198. * @param diameter sets the diameter size (float) of the sphere (default 1)
  108199. * @param scene defines the hosting scene
  108200. * @returns a new Mesh
  108201. */
  108202. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  108203. /**
  108204. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  108205. * @param name defines the name of the mesh to create
  108206. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  108207. * @param diameterTop set the top cap diameter (floats, default 1)
  108208. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  108209. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  108210. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  108211. * @param scene defines the hosting scene
  108212. * @param updatable defines if the mesh must be flagged as updatable
  108213. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108214. * @returns a new Mesh
  108215. */
  108216. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  108217. /**
  108218. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  108219. * @param name defines the name of the mesh to create
  108220. * @param diameter sets the diameter size (float) of the torus (default 1)
  108221. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  108222. * @param tessellation sets the number of torus sides (postive integer, default 16)
  108223. * @param scene defines the hosting scene
  108224. * @param updatable defines if the mesh must be flagged as updatable
  108225. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108226. * @returns a new Mesh
  108227. */
  108228. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  108229. /**
  108230. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  108231. * @param name defines the name of the mesh to create
  108232. * @param radius sets the global radius size (float) of the torus knot (default 2)
  108233. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  108234. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  108235. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  108236. * @param p the number of windings on X axis (positive integers, default 2)
  108237. * @param q the number of windings on Y axis (positive integers, default 3)
  108238. * @param scene defines the hosting scene
  108239. * @param updatable defines if the mesh must be flagged as updatable
  108240. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108241. * @returns a new Mesh
  108242. */
  108243. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  108244. /**
  108245. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  108246. * @param name defines the name of the mesh to create
  108247. * @param points is an array successive Vector3
  108248. * @param scene defines the hosting scene
  108249. * @param updatable defines if the mesh must be flagged as updatable
  108250. * @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).
  108251. * @returns a new Mesh
  108252. */
  108253. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  108254. /**
  108255. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  108256. * @param name defines the name of the mesh to create
  108257. * @param points is an array successive Vector3
  108258. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  108259. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  108260. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  108261. * @param scene defines the hosting scene
  108262. * @param updatable defines if the mesh must be flagged as updatable
  108263. * @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)
  108264. * @returns a new Mesh
  108265. */
  108266. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  108267. /**
  108268. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  108269. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  108270. * 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.
  108271. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  108272. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108273. * Remember you can only change the shape positions, not their number when updating a polygon.
  108274. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  108275. * @param name defines the name of the mesh to create
  108276. * @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
  108277. * @param scene defines the hosting scene
  108278. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  108279. * @param updatable defines if the mesh must be flagged as updatable
  108280. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108281. * @param earcutInjection can be used to inject your own earcut reference
  108282. * @returns a new Mesh
  108283. */
  108284. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  108285. /**
  108286. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  108287. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  108288. * @param name defines the name of the mesh to create
  108289. * @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
  108290. * @param depth defines the height of extrusion
  108291. * @param scene defines the hosting scene
  108292. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  108293. * @param updatable defines if the mesh must be flagged as updatable
  108294. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108295. * @param earcutInjection can be used to inject your own earcut reference
  108296. * @returns a new Mesh
  108297. */
  108298. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  108299. /**
  108300. * Creates an extruded shape mesh.
  108301. * 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
  108302. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108303. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  108304. * @param name defines the name of the mesh to create
  108305. * @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
  108306. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  108307. * @param scale is the value to scale the shape
  108308. * @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
  108309. * @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
  108310. * @param scene defines the hosting scene
  108311. * @param updatable defines if the mesh must be flagged as updatable
  108312. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108313. * @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)
  108314. * @returns a new Mesh
  108315. */
  108316. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  108317. /**
  108318. * Creates an custom extruded shape mesh.
  108319. * The custom extrusion is a parametric shape.
  108320. * It has no predefined shape. Its final shape will depend on the input parameters.
  108321. * Please consider using the same method from the MeshBuilder class instead
  108322. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  108323. * @param name defines the name of the mesh to create
  108324. * @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
  108325. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  108326. * @param scaleFunction is a custom Javascript function called on each path point
  108327. * @param rotationFunction is a custom Javascript function called on each path point
  108328. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  108329. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  108330. * @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
  108331. * @param scene defines the hosting scene
  108332. * @param updatable defines if the mesh must be flagged as updatable
  108333. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108334. * @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)
  108335. * @returns a new Mesh
  108336. */
  108337. 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;
  108338. /**
  108339. * Creates lathe mesh.
  108340. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  108341. * Please consider using the same method from the MeshBuilder class instead
  108342. * @param name defines the name of the mesh to create
  108343. * @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
  108344. * @param radius is the radius value of the lathe
  108345. * @param tessellation is the side number of the lathe.
  108346. * @param scene defines the hosting scene
  108347. * @param updatable defines if the mesh must be flagged as updatable
  108348. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108349. * @returns a new Mesh
  108350. */
  108351. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  108352. /**
  108353. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  108354. * @param name defines the name of the mesh to create
  108355. * @param size sets the size (float) of both sides of the plane at once (default 1)
  108356. * @param scene defines the hosting scene
  108357. * @param updatable defines if the mesh must be flagged as updatable
  108358. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108359. * @returns a new Mesh
  108360. */
  108361. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  108362. /**
  108363. * Creates a ground mesh.
  108364. * Please consider using the same method from the MeshBuilder class instead
  108365. * @param name defines the name of the mesh to create
  108366. * @param width set the width of the ground
  108367. * @param height set the height of the ground
  108368. * @param subdivisions sets the number of subdivisions per side
  108369. * @param scene defines the hosting scene
  108370. * @param updatable defines if the mesh must be flagged as updatable
  108371. * @returns a new Mesh
  108372. */
  108373. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  108374. /**
  108375. * Creates a tiled ground mesh.
  108376. * Please consider using the same method from the MeshBuilder class instead
  108377. * @param name defines the name of the mesh to create
  108378. * @param xmin set the ground minimum X coordinate
  108379. * @param zmin set the ground minimum Y coordinate
  108380. * @param xmax set the ground maximum X coordinate
  108381. * @param zmax set the ground maximum Z coordinate
  108382. * @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
  108383. * @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
  108384. * @param scene defines the hosting scene
  108385. * @param updatable defines if the mesh must be flagged as updatable
  108386. * @returns a new Mesh
  108387. */
  108388. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  108389. w: number;
  108390. h: number;
  108391. }, precision: {
  108392. w: number;
  108393. h: number;
  108394. }, scene: Scene, updatable?: boolean): Mesh;
  108395. /**
  108396. * Creates a ground mesh from a height map.
  108397. * Please consider using the same method from the MeshBuilder class instead
  108398. * @see https://doc.babylonjs.com/babylon101/height_map
  108399. * @param name defines the name of the mesh to create
  108400. * @param url sets the URL of the height map image resource
  108401. * @param width set the ground width size
  108402. * @param height set the ground height size
  108403. * @param subdivisions sets the number of subdivision per side
  108404. * @param minHeight is the minimum altitude on the ground
  108405. * @param maxHeight is the maximum altitude on the ground
  108406. * @param scene defines the hosting scene
  108407. * @param updatable defines if the mesh must be flagged as updatable
  108408. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  108409. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  108410. * @returns a new Mesh
  108411. */
  108412. 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;
  108413. /**
  108414. * Creates a tube mesh.
  108415. * The tube is a parametric shape.
  108416. * It has no predefined shape. Its final shape will depend on the input parameters.
  108417. * Please consider using the same method from the MeshBuilder class instead
  108418. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108419. * @param name defines the name of the mesh to create
  108420. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  108421. * @param radius sets the tube radius size
  108422. * @param tessellation is the number of sides on the tubular surface
  108423. * @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
  108424. * @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
  108425. * @param scene defines the hosting scene
  108426. * @param updatable defines if the mesh must be flagged as updatable
  108427. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108428. * @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)
  108429. * @returns a new Mesh
  108430. */
  108431. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  108432. (i: number, distance: number): number;
  108433. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  108434. /**
  108435. * Creates a polyhedron mesh.
  108436. * Please consider using the same method from the MeshBuilder class instead.
  108437. * * 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
  108438. * * The parameter `size` (positive float, default 1) sets the polygon size
  108439. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  108440. * * 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`
  108441. * * 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
  108442. * * 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)`)
  108443. * * 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
  108444. * * 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
  108445. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  108446. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108447. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108448. * @param name defines the name of the mesh to create
  108449. * @param options defines the options used to create the mesh
  108450. * @param scene defines the hosting scene
  108451. * @returns a new Mesh
  108452. */
  108453. static CreatePolyhedron(name: string, options: {
  108454. type?: number;
  108455. size?: number;
  108456. sizeX?: number;
  108457. sizeY?: number;
  108458. sizeZ?: number;
  108459. custom?: any;
  108460. faceUV?: Vector4[];
  108461. faceColors?: Color4[];
  108462. updatable?: boolean;
  108463. sideOrientation?: number;
  108464. }, scene: Scene): Mesh;
  108465. /**
  108466. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  108467. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  108468. * * 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`)
  108469. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  108470. * * 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
  108471. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  108472. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108473. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108474. * @param name defines the name of the mesh
  108475. * @param options defines the options used to create the mesh
  108476. * @param scene defines the hosting scene
  108477. * @returns a new Mesh
  108478. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  108479. */
  108480. static CreateIcoSphere(name: string, options: {
  108481. radius?: number;
  108482. flat?: boolean;
  108483. subdivisions?: number;
  108484. sideOrientation?: number;
  108485. updatable?: boolean;
  108486. }, scene: Scene): Mesh;
  108487. /**
  108488. * Creates a decal mesh.
  108489. * Please consider using the same method from the MeshBuilder class instead.
  108490. * A decal is a mesh usually applied as a model onto the surface of another mesh
  108491. * @param name defines the name of the mesh
  108492. * @param sourceMesh defines the mesh receiving the decal
  108493. * @param position sets the position of the decal in world coordinates
  108494. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  108495. * @param size sets the decal scaling
  108496. * @param angle sets the angle to rotate the decal
  108497. * @returns a new Mesh
  108498. */
  108499. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  108500. /**
  108501. * Prepare internal position array for software CPU skinning
  108502. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  108503. */
  108504. setPositionsForCPUSkinning(): Float32Array;
  108505. /**
  108506. * Prepare internal normal array for software CPU skinning
  108507. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  108508. */
  108509. setNormalsForCPUSkinning(): Float32Array;
  108510. /**
  108511. * Updates the vertex buffer by applying transformation from the bones
  108512. * @param skeleton defines the skeleton to apply to current mesh
  108513. * @returns the current mesh
  108514. */
  108515. applySkeleton(skeleton: Skeleton): Mesh;
  108516. /**
  108517. * 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
  108518. * @param meshes defines the list of meshes to scan
  108519. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  108520. */
  108521. static MinMax(meshes: AbstractMesh[]): {
  108522. min: Vector3;
  108523. max: Vector3;
  108524. };
  108525. /**
  108526. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  108527. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  108528. * @returns a vector3
  108529. */
  108530. static Center(meshesOrMinMaxVector: {
  108531. min: Vector3;
  108532. max: Vector3;
  108533. } | AbstractMesh[]): Vector3;
  108534. /**
  108535. * Merge the array of meshes into a single mesh for performance reasons.
  108536. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  108537. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  108538. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  108539. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  108540. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  108541. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  108542. * @returns a new mesh
  108543. */
  108544. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  108545. /** @hidden */
  108546. addInstance(instance: InstancedMesh): void;
  108547. /** @hidden */
  108548. removeInstance(instance: InstancedMesh): void;
  108549. }
  108550. }
  108551. declare module BABYLON {
  108552. /**
  108553. * This is the base class of all the camera used in the application.
  108554. * @see https://doc.babylonjs.com/features/cameras
  108555. */
  108556. export class Camera extends Node {
  108557. /** @hidden */
  108558. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  108559. /**
  108560. * This is the default projection mode used by the cameras.
  108561. * It helps recreating a feeling of perspective and better appreciate depth.
  108562. * This is the best way to simulate real life cameras.
  108563. */
  108564. static readonly PERSPECTIVE_CAMERA: number;
  108565. /**
  108566. * This helps creating camera with an orthographic mode.
  108567. * 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.
  108568. */
  108569. static readonly ORTHOGRAPHIC_CAMERA: number;
  108570. /**
  108571. * This is the default FOV mode for perspective cameras.
  108572. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  108573. */
  108574. static readonly FOVMODE_VERTICAL_FIXED: number;
  108575. /**
  108576. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  108577. */
  108578. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  108579. /**
  108580. * This specifies ther is no need for a camera rig.
  108581. * Basically only one eye is rendered corresponding to the camera.
  108582. */
  108583. static readonly RIG_MODE_NONE: number;
  108584. /**
  108585. * Simulates a camera Rig with one blue eye and one red eye.
  108586. * This can be use with 3d blue and red glasses.
  108587. */
  108588. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  108589. /**
  108590. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  108591. */
  108592. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  108593. /**
  108594. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  108595. */
  108596. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  108597. /**
  108598. * Defines that both eyes of the camera will be rendered over under each other.
  108599. */
  108600. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  108601. /**
  108602. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  108603. */
  108604. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  108605. /**
  108606. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  108607. */
  108608. static readonly RIG_MODE_VR: number;
  108609. /**
  108610. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  108611. */
  108612. static readonly RIG_MODE_WEBVR: number;
  108613. /**
  108614. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  108615. */
  108616. static readonly RIG_MODE_CUSTOM: number;
  108617. /**
  108618. * Defines if by default attaching controls should prevent the default javascript event to continue.
  108619. */
  108620. static ForceAttachControlToAlwaysPreventDefault: boolean;
  108621. /**
  108622. * Define the input manager associated with the camera.
  108623. */
  108624. inputs: CameraInputsManager<Camera>;
  108625. /** @hidden */
  108626. _position: Vector3;
  108627. /**
  108628. * Define the current local position of the camera in the scene
  108629. */
  108630. get position(): Vector3;
  108631. set position(newPosition: Vector3);
  108632. /**
  108633. * The vector the camera should consider as up.
  108634. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  108635. */
  108636. upVector: Vector3;
  108637. /**
  108638. * Define the current limit on the left side for an orthographic camera
  108639. * In scene unit
  108640. */
  108641. orthoLeft: Nullable<number>;
  108642. /**
  108643. * Define the current limit on the right side for an orthographic camera
  108644. * In scene unit
  108645. */
  108646. orthoRight: Nullable<number>;
  108647. /**
  108648. * Define the current limit on the bottom side for an orthographic camera
  108649. * In scene unit
  108650. */
  108651. orthoBottom: Nullable<number>;
  108652. /**
  108653. * Define the current limit on the top side for an orthographic camera
  108654. * In scene unit
  108655. */
  108656. orthoTop: Nullable<number>;
  108657. /**
  108658. * Field Of View is set in Radians. (default is 0.8)
  108659. */
  108660. fov: number;
  108661. /**
  108662. * Define the minimum distance the camera can see from.
  108663. * This is important to note that the depth buffer are not infinite and the closer it starts
  108664. * the more your scene might encounter depth fighting issue.
  108665. */
  108666. minZ: number;
  108667. /**
  108668. * Define the maximum distance the camera can see to.
  108669. * This is important to note that the depth buffer are not infinite and the further it end
  108670. * the more your scene might encounter depth fighting issue.
  108671. */
  108672. maxZ: number;
  108673. /**
  108674. * Define the default inertia of the camera.
  108675. * This helps giving a smooth feeling to the camera movement.
  108676. */
  108677. inertia: number;
  108678. /**
  108679. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  108680. */
  108681. mode: number;
  108682. /**
  108683. * Define whether the camera is intermediate.
  108684. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  108685. */
  108686. isIntermediate: boolean;
  108687. /**
  108688. * Define the viewport of the camera.
  108689. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  108690. */
  108691. viewport: Viewport;
  108692. /**
  108693. * Restricts the camera to viewing objects with the same layerMask.
  108694. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  108695. */
  108696. layerMask: number;
  108697. /**
  108698. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  108699. */
  108700. fovMode: number;
  108701. /**
  108702. * Rig mode of the camera.
  108703. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  108704. * This is normally controlled byt the camera themselves as internal use.
  108705. */
  108706. cameraRigMode: number;
  108707. /**
  108708. * Defines the distance between both "eyes" in case of a RIG
  108709. */
  108710. interaxialDistance: number;
  108711. /**
  108712. * Defines if stereoscopic rendering is done side by side or over under.
  108713. */
  108714. isStereoscopicSideBySide: boolean;
  108715. /**
  108716. * 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
  108717. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  108718. * else in the scene. (Eg. security camera)
  108719. *
  108720. * 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)
  108721. */
  108722. customRenderTargets: RenderTargetTexture[];
  108723. /**
  108724. * When set, the camera will render to this render target instead of the default canvas
  108725. *
  108726. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  108727. */
  108728. outputRenderTarget: Nullable<RenderTargetTexture>;
  108729. /**
  108730. * Observable triggered when the camera view matrix has changed.
  108731. */
  108732. onViewMatrixChangedObservable: Observable<Camera>;
  108733. /**
  108734. * Observable triggered when the camera Projection matrix has changed.
  108735. */
  108736. onProjectionMatrixChangedObservable: Observable<Camera>;
  108737. /**
  108738. * Observable triggered when the inputs have been processed.
  108739. */
  108740. onAfterCheckInputsObservable: Observable<Camera>;
  108741. /**
  108742. * Observable triggered when reset has been called and applied to the camera.
  108743. */
  108744. onRestoreStateObservable: Observable<Camera>;
  108745. /**
  108746. * Is this camera a part of a rig system?
  108747. */
  108748. isRigCamera: boolean;
  108749. /**
  108750. * If isRigCamera set to true this will be set with the parent camera.
  108751. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  108752. */
  108753. rigParent?: Camera;
  108754. /** @hidden */
  108755. _cameraRigParams: any;
  108756. /** @hidden */
  108757. _rigCameras: Camera[];
  108758. /** @hidden */
  108759. _rigPostProcess: Nullable<PostProcess>;
  108760. protected _webvrViewMatrix: Matrix;
  108761. /** @hidden */
  108762. _skipRendering: boolean;
  108763. /** @hidden */
  108764. _projectionMatrix: Matrix;
  108765. /** @hidden */
  108766. _postProcesses: Nullable<PostProcess>[];
  108767. /** @hidden */
  108768. _activeMeshes: SmartArray<AbstractMesh>;
  108769. protected _globalPosition: Vector3;
  108770. /** @hidden */
  108771. _computedViewMatrix: Matrix;
  108772. private _doNotComputeProjectionMatrix;
  108773. private _transformMatrix;
  108774. private _frustumPlanes;
  108775. private _refreshFrustumPlanes;
  108776. private _storedFov;
  108777. private _stateStored;
  108778. /**
  108779. * Instantiates a new camera object.
  108780. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  108781. * @see https://doc.babylonjs.com/features/cameras
  108782. * @param name Defines the name of the camera in the scene
  108783. * @param position Defines the position of the camera
  108784. * @param scene Defines the scene the camera belongs too
  108785. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  108786. */
  108787. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  108788. /**
  108789. * Store current camera state (fov, position, etc..)
  108790. * @returns the camera
  108791. */
  108792. storeState(): Camera;
  108793. /**
  108794. * Restores the camera state values if it has been stored. You must call storeState() first
  108795. */
  108796. protected _restoreStateValues(): boolean;
  108797. /**
  108798. * Restored camera state. You must call storeState() first.
  108799. * @returns true if restored and false otherwise
  108800. */
  108801. restoreState(): boolean;
  108802. /**
  108803. * Gets the class name of the camera.
  108804. * @returns the class name
  108805. */
  108806. getClassName(): string;
  108807. /** @hidden */
  108808. readonly _isCamera: boolean;
  108809. /**
  108810. * Gets a string representation of the camera useful for debug purpose.
  108811. * @param fullDetails Defines that a more verboe level of logging is required
  108812. * @returns the string representation
  108813. */
  108814. toString(fullDetails?: boolean): string;
  108815. /**
  108816. * Gets the current world space position of the camera.
  108817. */
  108818. get globalPosition(): Vector3;
  108819. /**
  108820. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  108821. * @returns the active meshe list
  108822. */
  108823. getActiveMeshes(): SmartArray<AbstractMesh>;
  108824. /**
  108825. * Check whether a mesh is part of the current active mesh list of the camera
  108826. * @param mesh Defines the mesh to check
  108827. * @returns true if active, false otherwise
  108828. */
  108829. isActiveMesh(mesh: Mesh): boolean;
  108830. /**
  108831. * Is this camera ready to be used/rendered
  108832. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  108833. * @return true if the camera is ready
  108834. */
  108835. isReady(completeCheck?: boolean): boolean;
  108836. /** @hidden */
  108837. _initCache(): void;
  108838. /** @hidden */
  108839. _updateCache(ignoreParentClass?: boolean): void;
  108840. /** @hidden */
  108841. _isSynchronized(): boolean;
  108842. /** @hidden */
  108843. _isSynchronizedViewMatrix(): boolean;
  108844. /** @hidden */
  108845. _isSynchronizedProjectionMatrix(): boolean;
  108846. /**
  108847. * Attach the input controls to a specific dom element to get the input from.
  108848. * @param element Defines the element the controls should be listened from
  108849. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108850. */
  108851. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108852. /**
  108853. * Detach the current controls from the specified dom element.
  108854. * @param element Defines the element to stop listening the inputs from
  108855. */
  108856. detachControl(element: HTMLElement): void;
  108857. /**
  108858. * Update the camera state according to the different inputs gathered during the frame.
  108859. */
  108860. update(): void;
  108861. /** @hidden */
  108862. _checkInputs(): void;
  108863. /** @hidden */
  108864. get rigCameras(): Camera[];
  108865. /**
  108866. * Gets the post process used by the rig cameras
  108867. */
  108868. get rigPostProcess(): Nullable<PostProcess>;
  108869. /**
  108870. * Internal, gets the first post proces.
  108871. * @returns the first post process to be run on this camera.
  108872. */
  108873. _getFirstPostProcess(): Nullable<PostProcess>;
  108874. private _cascadePostProcessesToRigCams;
  108875. /**
  108876. * Attach a post process to the camera.
  108877. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  108878. * @param postProcess The post process to attach to the camera
  108879. * @param insertAt The position of the post process in case several of them are in use in the scene
  108880. * @returns the position the post process has been inserted at
  108881. */
  108882. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  108883. /**
  108884. * Detach a post process to the camera.
  108885. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  108886. * @param postProcess The post process to detach from the camera
  108887. */
  108888. detachPostProcess(postProcess: PostProcess): void;
  108889. /**
  108890. * Gets the current world matrix of the camera
  108891. */
  108892. getWorldMatrix(): Matrix;
  108893. /** @hidden */
  108894. _getViewMatrix(): Matrix;
  108895. /**
  108896. * Gets the current view matrix of the camera.
  108897. * @param force forces the camera to recompute the matrix without looking at the cached state
  108898. * @returns the view matrix
  108899. */
  108900. getViewMatrix(force?: boolean): Matrix;
  108901. /**
  108902. * Freeze the projection matrix.
  108903. * It will prevent the cache check of the camera projection compute and can speed up perf
  108904. * if no parameter of the camera are meant to change
  108905. * @param projection Defines manually a projection if necessary
  108906. */
  108907. freezeProjectionMatrix(projection?: Matrix): void;
  108908. /**
  108909. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  108910. */
  108911. unfreezeProjectionMatrix(): void;
  108912. /**
  108913. * Gets the current projection matrix of the camera.
  108914. * @param force forces the camera to recompute the matrix without looking at the cached state
  108915. * @returns the projection matrix
  108916. */
  108917. getProjectionMatrix(force?: boolean): Matrix;
  108918. /**
  108919. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  108920. * @returns a Matrix
  108921. */
  108922. getTransformationMatrix(): Matrix;
  108923. private _updateFrustumPlanes;
  108924. /**
  108925. * Checks if a cullable object (mesh...) is in the camera frustum
  108926. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  108927. * @param target The object to check
  108928. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  108929. * @returns true if the object is in frustum otherwise false
  108930. */
  108931. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  108932. /**
  108933. * Checks if a cullable object (mesh...) is in the camera frustum
  108934. * Unlike isInFrustum this cheks the full bounding box
  108935. * @param target The object to check
  108936. * @returns true if the object is in frustum otherwise false
  108937. */
  108938. isCompletelyInFrustum(target: ICullable): boolean;
  108939. /**
  108940. * Gets a ray in the forward direction from the camera.
  108941. * @param length Defines the length of the ray to create
  108942. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  108943. * @param origin Defines the start point of the ray which defaults to the camera position
  108944. * @returns the forward ray
  108945. */
  108946. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  108947. /**
  108948. * Gets a ray in the forward direction from the camera.
  108949. * @param refRay the ray to (re)use when setting the values
  108950. * @param length Defines the length of the ray to create
  108951. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  108952. * @param origin Defines the start point of the ray which defaults to the camera position
  108953. * @returns the forward ray
  108954. */
  108955. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  108956. /**
  108957. * Releases resources associated with this node.
  108958. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  108959. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  108960. */
  108961. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  108962. /** @hidden */
  108963. _isLeftCamera: boolean;
  108964. /**
  108965. * Gets the left camera of a rig setup in case of Rigged Camera
  108966. */
  108967. get isLeftCamera(): boolean;
  108968. /** @hidden */
  108969. _isRightCamera: boolean;
  108970. /**
  108971. * Gets the right camera of a rig setup in case of Rigged Camera
  108972. */
  108973. get isRightCamera(): boolean;
  108974. /**
  108975. * Gets the left camera of a rig setup in case of Rigged Camera
  108976. */
  108977. get leftCamera(): Nullable<FreeCamera>;
  108978. /**
  108979. * Gets the right camera of a rig setup in case of Rigged Camera
  108980. */
  108981. get rightCamera(): Nullable<FreeCamera>;
  108982. /**
  108983. * Gets the left camera target of a rig setup in case of Rigged Camera
  108984. * @returns the target position
  108985. */
  108986. getLeftTarget(): Nullable<Vector3>;
  108987. /**
  108988. * Gets the right camera target of a rig setup in case of Rigged Camera
  108989. * @returns the target position
  108990. */
  108991. getRightTarget(): Nullable<Vector3>;
  108992. /**
  108993. * @hidden
  108994. */
  108995. setCameraRigMode(mode: number, rigParams: any): void;
  108996. /** @hidden */
  108997. static _setStereoscopicRigMode(camera: Camera): void;
  108998. /** @hidden */
  108999. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  109000. /** @hidden */
  109001. static _setVRRigMode(camera: Camera, rigParams: any): void;
  109002. /** @hidden */
  109003. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  109004. /** @hidden */
  109005. _getVRProjectionMatrix(): Matrix;
  109006. protected _updateCameraRotationMatrix(): void;
  109007. protected _updateWebVRCameraRotationMatrix(): void;
  109008. /**
  109009. * This function MUST be overwritten by the different WebVR cameras available.
  109010. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  109011. * @hidden
  109012. */
  109013. _getWebVRProjectionMatrix(): Matrix;
  109014. /**
  109015. * This function MUST be overwritten by the different WebVR cameras available.
  109016. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  109017. * @hidden
  109018. */
  109019. _getWebVRViewMatrix(): Matrix;
  109020. /** @hidden */
  109021. setCameraRigParameter(name: string, value: any): void;
  109022. /**
  109023. * needs to be overridden by children so sub has required properties to be copied
  109024. * @hidden
  109025. */
  109026. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  109027. /**
  109028. * May need to be overridden by children
  109029. * @hidden
  109030. */
  109031. _updateRigCameras(): void;
  109032. /** @hidden */
  109033. _setupInputs(): void;
  109034. /**
  109035. * Serialiaze the camera setup to a json represention
  109036. * @returns the JSON representation
  109037. */
  109038. serialize(): any;
  109039. /**
  109040. * Clones the current camera.
  109041. * @param name The cloned camera name
  109042. * @returns the cloned camera
  109043. */
  109044. clone(name: string): Camera;
  109045. /**
  109046. * Gets the direction of the camera relative to a given local axis.
  109047. * @param localAxis Defines the reference axis to provide a relative direction.
  109048. * @return the direction
  109049. */
  109050. getDirection(localAxis: Vector3): Vector3;
  109051. /**
  109052. * Returns the current camera absolute rotation
  109053. */
  109054. get absoluteRotation(): Quaternion;
  109055. /**
  109056. * Gets the direction of the camera relative to a given local axis into a passed vector.
  109057. * @param localAxis Defines the reference axis to provide a relative direction.
  109058. * @param result Defines the vector to store the result in
  109059. */
  109060. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  109061. /**
  109062. * Gets a camera constructor for a given camera type
  109063. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  109064. * @param name The name of the camera the result will be able to instantiate
  109065. * @param scene The scene the result will construct the camera in
  109066. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  109067. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  109068. * @returns a factory method to construc the camera
  109069. */
  109070. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  109071. /**
  109072. * Compute the world matrix of the camera.
  109073. * @returns the camera world matrix
  109074. */
  109075. computeWorldMatrix(): Matrix;
  109076. /**
  109077. * Parse a JSON and creates the camera from the parsed information
  109078. * @param parsedCamera The JSON to parse
  109079. * @param scene The scene to instantiate the camera in
  109080. * @returns the newly constructed camera
  109081. */
  109082. static Parse(parsedCamera: any, scene: Scene): Camera;
  109083. }
  109084. }
  109085. declare module BABYLON {
  109086. /**
  109087. * Class containing static functions to help procedurally build meshes
  109088. */
  109089. export class DiscBuilder {
  109090. /**
  109091. * Creates a plane polygonal mesh. By default, this is a disc
  109092. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  109093. * * 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
  109094. * * 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
  109095. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109096. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109097. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109098. * @param name defines the name of the mesh
  109099. * @param options defines the options used to create the mesh
  109100. * @param scene defines the hosting scene
  109101. * @returns the plane polygonal mesh
  109102. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  109103. */
  109104. static CreateDisc(name: string, options: {
  109105. radius?: number;
  109106. tessellation?: number;
  109107. arc?: number;
  109108. updatable?: boolean;
  109109. sideOrientation?: number;
  109110. frontUVs?: Vector4;
  109111. backUVs?: Vector4;
  109112. }, scene?: Nullable<Scene>): Mesh;
  109113. }
  109114. }
  109115. declare module BABYLON {
  109116. /**
  109117. * Options to be used when creating a FresnelParameters.
  109118. */
  109119. export type IFresnelParametersCreationOptions = {
  109120. /**
  109121. * Define the color used on edges (grazing angle)
  109122. */
  109123. leftColor?: Color3;
  109124. /**
  109125. * Define the color used on center
  109126. */
  109127. rightColor?: Color3;
  109128. /**
  109129. * Define bias applied to computed fresnel term
  109130. */
  109131. bias?: number;
  109132. /**
  109133. * Defined the power exponent applied to fresnel term
  109134. */
  109135. power?: number;
  109136. /**
  109137. * Define if the fresnel effect is enable or not.
  109138. */
  109139. isEnabled?: boolean;
  109140. };
  109141. /**
  109142. * Serialized format for FresnelParameters.
  109143. */
  109144. export type IFresnelParametersSerialized = {
  109145. /**
  109146. * Define the color used on edges (grazing angle) [as an array]
  109147. */
  109148. leftColor: number[];
  109149. /**
  109150. * Define the color used on center [as an array]
  109151. */
  109152. rightColor: number[];
  109153. /**
  109154. * Define bias applied to computed fresnel term
  109155. */
  109156. bias: number;
  109157. /**
  109158. * Defined the power exponent applied to fresnel term
  109159. */
  109160. power?: number;
  109161. /**
  109162. * Define if the fresnel effect is enable or not.
  109163. */
  109164. isEnabled: boolean;
  109165. };
  109166. /**
  109167. * This represents all the required information to add a fresnel effect on a material:
  109168. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109169. */
  109170. export class FresnelParameters {
  109171. private _isEnabled;
  109172. /**
  109173. * Define if the fresnel effect is enable or not.
  109174. */
  109175. get isEnabled(): boolean;
  109176. set isEnabled(value: boolean);
  109177. /**
  109178. * Define the color used on edges (grazing angle)
  109179. */
  109180. leftColor: Color3;
  109181. /**
  109182. * Define the color used on center
  109183. */
  109184. rightColor: Color3;
  109185. /**
  109186. * Define bias applied to computed fresnel term
  109187. */
  109188. bias: number;
  109189. /**
  109190. * Defined the power exponent applied to fresnel term
  109191. */
  109192. power: number;
  109193. /**
  109194. * Creates a new FresnelParameters object.
  109195. *
  109196. * @param options provide your own settings to optionally to override defaults
  109197. */
  109198. constructor(options?: IFresnelParametersCreationOptions);
  109199. /**
  109200. * Clones the current fresnel and its valuues
  109201. * @returns a clone fresnel configuration
  109202. */
  109203. clone(): FresnelParameters;
  109204. /**
  109205. * Determines equality between FresnelParameters objects
  109206. * @param otherFresnelParameters defines the second operand
  109207. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  109208. */
  109209. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  109210. /**
  109211. * Serializes the current fresnel parameters to a JSON representation.
  109212. * @return the JSON serialization
  109213. */
  109214. serialize(): IFresnelParametersSerialized;
  109215. /**
  109216. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  109217. * @param parsedFresnelParameters Define the JSON representation
  109218. * @returns the parsed parameters
  109219. */
  109220. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  109221. }
  109222. }
  109223. declare module BABYLON {
  109224. /**
  109225. * This groups all the flags used to control the materials channel.
  109226. */
  109227. export class MaterialFlags {
  109228. private static _DiffuseTextureEnabled;
  109229. /**
  109230. * Are diffuse textures enabled in the application.
  109231. */
  109232. static get DiffuseTextureEnabled(): boolean;
  109233. static set DiffuseTextureEnabled(value: boolean);
  109234. private static _DetailTextureEnabled;
  109235. /**
  109236. * Are detail textures enabled in the application.
  109237. */
  109238. static get DetailTextureEnabled(): boolean;
  109239. static set DetailTextureEnabled(value: boolean);
  109240. private static _AmbientTextureEnabled;
  109241. /**
  109242. * Are ambient textures enabled in the application.
  109243. */
  109244. static get AmbientTextureEnabled(): boolean;
  109245. static set AmbientTextureEnabled(value: boolean);
  109246. private static _OpacityTextureEnabled;
  109247. /**
  109248. * Are opacity textures enabled in the application.
  109249. */
  109250. static get OpacityTextureEnabled(): boolean;
  109251. static set OpacityTextureEnabled(value: boolean);
  109252. private static _ReflectionTextureEnabled;
  109253. /**
  109254. * Are reflection textures enabled in the application.
  109255. */
  109256. static get ReflectionTextureEnabled(): boolean;
  109257. static set ReflectionTextureEnabled(value: boolean);
  109258. private static _EmissiveTextureEnabled;
  109259. /**
  109260. * Are emissive textures enabled in the application.
  109261. */
  109262. static get EmissiveTextureEnabled(): boolean;
  109263. static set EmissiveTextureEnabled(value: boolean);
  109264. private static _SpecularTextureEnabled;
  109265. /**
  109266. * Are specular textures enabled in the application.
  109267. */
  109268. static get SpecularTextureEnabled(): boolean;
  109269. static set SpecularTextureEnabled(value: boolean);
  109270. private static _BumpTextureEnabled;
  109271. /**
  109272. * Are bump textures enabled in the application.
  109273. */
  109274. static get BumpTextureEnabled(): boolean;
  109275. static set BumpTextureEnabled(value: boolean);
  109276. private static _LightmapTextureEnabled;
  109277. /**
  109278. * Are lightmap textures enabled in the application.
  109279. */
  109280. static get LightmapTextureEnabled(): boolean;
  109281. static set LightmapTextureEnabled(value: boolean);
  109282. private static _RefractionTextureEnabled;
  109283. /**
  109284. * Are refraction textures enabled in the application.
  109285. */
  109286. static get RefractionTextureEnabled(): boolean;
  109287. static set RefractionTextureEnabled(value: boolean);
  109288. private static _ColorGradingTextureEnabled;
  109289. /**
  109290. * Are color grading textures enabled in the application.
  109291. */
  109292. static get ColorGradingTextureEnabled(): boolean;
  109293. static set ColorGradingTextureEnabled(value: boolean);
  109294. private static _FresnelEnabled;
  109295. /**
  109296. * Are fresnels enabled in the application.
  109297. */
  109298. static get FresnelEnabled(): boolean;
  109299. static set FresnelEnabled(value: boolean);
  109300. private static _ClearCoatTextureEnabled;
  109301. /**
  109302. * Are clear coat textures enabled in the application.
  109303. */
  109304. static get ClearCoatTextureEnabled(): boolean;
  109305. static set ClearCoatTextureEnabled(value: boolean);
  109306. private static _ClearCoatBumpTextureEnabled;
  109307. /**
  109308. * Are clear coat bump textures enabled in the application.
  109309. */
  109310. static get ClearCoatBumpTextureEnabled(): boolean;
  109311. static set ClearCoatBumpTextureEnabled(value: boolean);
  109312. private static _ClearCoatTintTextureEnabled;
  109313. /**
  109314. * Are clear coat tint textures enabled in the application.
  109315. */
  109316. static get ClearCoatTintTextureEnabled(): boolean;
  109317. static set ClearCoatTintTextureEnabled(value: boolean);
  109318. private static _SheenTextureEnabled;
  109319. /**
  109320. * Are sheen textures enabled in the application.
  109321. */
  109322. static get SheenTextureEnabled(): boolean;
  109323. static set SheenTextureEnabled(value: boolean);
  109324. private static _AnisotropicTextureEnabled;
  109325. /**
  109326. * Are anisotropic textures enabled in the application.
  109327. */
  109328. static get AnisotropicTextureEnabled(): boolean;
  109329. static set AnisotropicTextureEnabled(value: boolean);
  109330. private static _ThicknessTextureEnabled;
  109331. /**
  109332. * Are thickness textures enabled in the application.
  109333. */
  109334. static get ThicknessTextureEnabled(): boolean;
  109335. static set ThicknessTextureEnabled(value: boolean);
  109336. }
  109337. }
  109338. declare module BABYLON {
  109339. /** @hidden */
  109340. export var defaultFragmentDeclaration: {
  109341. name: string;
  109342. shader: string;
  109343. };
  109344. }
  109345. declare module BABYLON {
  109346. /** @hidden */
  109347. export var defaultUboDeclaration: {
  109348. name: string;
  109349. shader: string;
  109350. };
  109351. }
  109352. declare module BABYLON {
  109353. /** @hidden */
  109354. export var prePassDeclaration: {
  109355. name: string;
  109356. shader: string;
  109357. };
  109358. }
  109359. declare module BABYLON {
  109360. /** @hidden */
  109361. export var lightFragmentDeclaration: {
  109362. name: string;
  109363. shader: string;
  109364. };
  109365. }
  109366. declare module BABYLON {
  109367. /** @hidden */
  109368. export var lightUboDeclaration: {
  109369. name: string;
  109370. shader: string;
  109371. };
  109372. }
  109373. declare module BABYLON {
  109374. /** @hidden */
  109375. export var lightsFragmentFunctions: {
  109376. name: string;
  109377. shader: string;
  109378. };
  109379. }
  109380. declare module BABYLON {
  109381. /** @hidden */
  109382. export var shadowsFragmentFunctions: {
  109383. name: string;
  109384. shader: string;
  109385. };
  109386. }
  109387. declare module BABYLON {
  109388. /** @hidden */
  109389. export var fresnelFunction: {
  109390. name: string;
  109391. shader: string;
  109392. };
  109393. }
  109394. declare module BABYLON {
  109395. /** @hidden */
  109396. export var bumpFragmentMainFunctions: {
  109397. name: string;
  109398. shader: string;
  109399. };
  109400. }
  109401. declare module BABYLON {
  109402. /** @hidden */
  109403. export var bumpFragmentFunctions: {
  109404. name: string;
  109405. shader: string;
  109406. };
  109407. }
  109408. declare module BABYLON {
  109409. /** @hidden */
  109410. export var logDepthDeclaration: {
  109411. name: string;
  109412. shader: string;
  109413. };
  109414. }
  109415. declare module BABYLON {
  109416. /** @hidden */
  109417. export var bumpFragment: {
  109418. name: string;
  109419. shader: string;
  109420. };
  109421. }
  109422. declare module BABYLON {
  109423. /** @hidden */
  109424. export var depthPrePass: {
  109425. name: string;
  109426. shader: string;
  109427. };
  109428. }
  109429. declare module BABYLON {
  109430. /** @hidden */
  109431. export var lightFragment: {
  109432. name: string;
  109433. shader: string;
  109434. };
  109435. }
  109436. declare module BABYLON {
  109437. /** @hidden */
  109438. export var logDepthFragment: {
  109439. name: string;
  109440. shader: string;
  109441. };
  109442. }
  109443. declare module BABYLON {
  109444. /** @hidden */
  109445. export var defaultPixelShader: {
  109446. name: string;
  109447. shader: string;
  109448. };
  109449. }
  109450. declare module BABYLON {
  109451. /** @hidden */
  109452. export var defaultVertexDeclaration: {
  109453. name: string;
  109454. shader: string;
  109455. };
  109456. }
  109457. declare module BABYLON {
  109458. /** @hidden */
  109459. export var bumpVertexDeclaration: {
  109460. name: string;
  109461. shader: string;
  109462. };
  109463. }
  109464. declare module BABYLON {
  109465. /** @hidden */
  109466. export var bumpVertex: {
  109467. name: string;
  109468. shader: string;
  109469. };
  109470. }
  109471. declare module BABYLON {
  109472. /** @hidden */
  109473. export var fogVertex: {
  109474. name: string;
  109475. shader: string;
  109476. };
  109477. }
  109478. declare module BABYLON {
  109479. /** @hidden */
  109480. export var shadowsVertex: {
  109481. name: string;
  109482. shader: string;
  109483. };
  109484. }
  109485. declare module BABYLON {
  109486. /** @hidden */
  109487. export var pointCloudVertex: {
  109488. name: string;
  109489. shader: string;
  109490. };
  109491. }
  109492. declare module BABYLON {
  109493. /** @hidden */
  109494. export var logDepthVertex: {
  109495. name: string;
  109496. shader: string;
  109497. };
  109498. }
  109499. declare module BABYLON {
  109500. /** @hidden */
  109501. export var defaultVertexShader: {
  109502. name: string;
  109503. shader: string;
  109504. };
  109505. }
  109506. declare module BABYLON {
  109507. /**
  109508. * @hidden
  109509. */
  109510. export interface IMaterialDetailMapDefines {
  109511. DETAIL: boolean;
  109512. DETAILDIRECTUV: number;
  109513. DETAIL_NORMALBLENDMETHOD: number;
  109514. /** @hidden */
  109515. _areTexturesDirty: boolean;
  109516. }
  109517. /**
  109518. * Define the code related to the detail map parameters of a material
  109519. *
  109520. * Inspired from:
  109521. * 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
  109522. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  109523. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  109524. */
  109525. export class DetailMapConfiguration {
  109526. private _texture;
  109527. /**
  109528. * The detail texture of the material.
  109529. */
  109530. texture: Nullable<BaseTexture>;
  109531. /**
  109532. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  109533. * Bigger values mean stronger blending
  109534. */
  109535. diffuseBlendLevel: number;
  109536. /**
  109537. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  109538. * Bigger values mean stronger blending. Only used with PBR materials
  109539. */
  109540. roughnessBlendLevel: number;
  109541. /**
  109542. * Defines how strong the bump effect from the detail map is
  109543. * Bigger values mean stronger effect
  109544. */
  109545. bumpLevel: number;
  109546. private _normalBlendMethod;
  109547. /**
  109548. * The method used to blend the bump and detail normals together
  109549. */
  109550. normalBlendMethod: number;
  109551. private _isEnabled;
  109552. /**
  109553. * Enable or disable the detail map on this material
  109554. */
  109555. isEnabled: boolean;
  109556. /** @hidden */
  109557. private _internalMarkAllSubMeshesAsTexturesDirty;
  109558. /** @hidden */
  109559. _markAllSubMeshesAsTexturesDirty(): void;
  109560. /**
  109561. * Instantiate a new detail map
  109562. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  109563. */
  109564. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  109565. /**
  109566. * Gets whether the submesh is ready to be used or not.
  109567. * @param defines the list of "defines" to update.
  109568. * @param scene defines the scene the material belongs to.
  109569. * @returns - boolean indicating that the submesh is ready or not.
  109570. */
  109571. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  109572. /**
  109573. * Update the defines for detail map usage
  109574. * @param defines the list of "defines" to update.
  109575. * @param scene defines the scene the material belongs to.
  109576. */
  109577. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  109578. /**
  109579. * Binds the material data.
  109580. * @param uniformBuffer defines the Uniform buffer to fill in.
  109581. * @param scene defines the scene the material belongs to.
  109582. * @param isFrozen defines whether the material is frozen or not.
  109583. */
  109584. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  109585. /**
  109586. * Checks to see if a texture is used in the material.
  109587. * @param texture - Base texture to use.
  109588. * @returns - Boolean specifying if a texture is used in the material.
  109589. */
  109590. hasTexture(texture: BaseTexture): boolean;
  109591. /**
  109592. * Returns an array of the actively used textures.
  109593. * @param activeTextures Array of BaseTextures
  109594. */
  109595. getActiveTextures(activeTextures: BaseTexture[]): void;
  109596. /**
  109597. * Returns the animatable textures.
  109598. * @param animatables Array of animatable textures.
  109599. */
  109600. getAnimatables(animatables: IAnimatable[]): void;
  109601. /**
  109602. * Disposes the resources of the material.
  109603. * @param forceDisposeTextures - Forces the disposal of all textures.
  109604. */
  109605. dispose(forceDisposeTextures?: boolean): void;
  109606. /**
  109607. * Get the current class name useful for serialization or dynamic coding.
  109608. * @returns "DetailMap"
  109609. */
  109610. getClassName(): string;
  109611. /**
  109612. * Add the required uniforms to the current list.
  109613. * @param uniforms defines the current uniform list.
  109614. */
  109615. static AddUniforms(uniforms: string[]): void;
  109616. /**
  109617. * Add the required samplers to the current list.
  109618. * @param samplers defines the current sampler list.
  109619. */
  109620. static AddSamplers(samplers: string[]): void;
  109621. /**
  109622. * Add the required uniforms to the current buffer.
  109623. * @param uniformBuffer defines the current uniform buffer.
  109624. */
  109625. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  109626. /**
  109627. * Makes a duplicate of the current instance into another one.
  109628. * @param detailMap define the instance where to copy the info
  109629. */
  109630. copyTo(detailMap: DetailMapConfiguration): void;
  109631. /**
  109632. * Serializes this detail map instance
  109633. * @returns - An object with the serialized instance.
  109634. */
  109635. serialize(): any;
  109636. /**
  109637. * Parses a detail map setting from a serialized object.
  109638. * @param source - Serialized object.
  109639. * @param scene Defines the scene we are parsing for
  109640. * @param rootUrl Defines the rootUrl to load from
  109641. */
  109642. parse(source: any, scene: Scene, rootUrl: string): void;
  109643. }
  109644. }
  109645. declare module BABYLON {
  109646. /** @hidden */
  109647. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  109648. MAINUV1: boolean;
  109649. MAINUV2: boolean;
  109650. DIFFUSE: boolean;
  109651. DIFFUSEDIRECTUV: number;
  109652. DETAIL: boolean;
  109653. DETAILDIRECTUV: number;
  109654. DETAIL_NORMALBLENDMETHOD: number;
  109655. AMBIENT: boolean;
  109656. AMBIENTDIRECTUV: number;
  109657. OPACITY: boolean;
  109658. OPACITYDIRECTUV: number;
  109659. OPACITYRGB: boolean;
  109660. REFLECTION: boolean;
  109661. EMISSIVE: boolean;
  109662. EMISSIVEDIRECTUV: number;
  109663. SPECULAR: boolean;
  109664. SPECULARDIRECTUV: number;
  109665. BUMP: boolean;
  109666. BUMPDIRECTUV: number;
  109667. PARALLAX: boolean;
  109668. PARALLAXOCCLUSION: boolean;
  109669. SPECULAROVERALPHA: boolean;
  109670. CLIPPLANE: boolean;
  109671. CLIPPLANE2: boolean;
  109672. CLIPPLANE3: boolean;
  109673. CLIPPLANE4: boolean;
  109674. CLIPPLANE5: boolean;
  109675. CLIPPLANE6: boolean;
  109676. ALPHATEST: boolean;
  109677. DEPTHPREPASS: boolean;
  109678. ALPHAFROMDIFFUSE: boolean;
  109679. POINTSIZE: boolean;
  109680. FOG: boolean;
  109681. SPECULARTERM: boolean;
  109682. DIFFUSEFRESNEL: boolean;
  109683. OPACITYFRESNEL: boolean;
  109684. REFLECTIONFRESNEL: boolean;
  109685. REFRACTIONFRESNEL: boolean;
  109686. EMISSIVEFRESNEL: boolean;
  109687. FRESNEL: boolean;
  109688. NORMAL: boolean;
  109689. UV1: boolean;
  109690. UV2: boolean;
  109691. VERTEXCOLOR: boolean;
  109692. VERTEXALPHA: boolean;
  109693. NUM_BONE_INFLUENCERS: number;
  109694. BonesPerMesh: number;
  109695. BONETEXTURE: boolean;
  109696. INSTANCES: boolean;
  109697. THIN_INSTANCES: boolean;
  109698. GLOSSINESS: boolean;
  109699. ROUGHNESS: boolean;
  109700. EMISSIVEASILLUMINATION: boolean;
  109701. LINKEMISSIVEWITHDIFFUSE: boolean;
  109702. REFLECTIONFRESNELFROMSPECULAR: boolean;
  109703. LIGHTMAP: boolean;
  109704. LIGHTMAPDIRECTUV: number;
  109705. OBJECTSPACE_NORMALMAP: boolean;
  109706. USELIGHTMAPASSHADOWMAP: boolean;
  109707. REFLECTIONMAP_3D: boolean;
  109708. REFLECTIONMAP_SPHERICAL: boolean;
  109709. REFLECTIONMAP_PLANAR: boolean;
  109710. REFLECTIONMAP_CUBIC: boolean;
  109711. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  109712. REFLECTIONMAP_PROJECTION: boolean;
  109713. REFLECTIONMAP_SKYBOX: boolean;
  109714. REFLECTIONMAP_EXPLICIT: boolean;
  109715. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  109716. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  109717. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  109718. INVERTCUBICMAP: boolean;
  109719. LOGARITHMICDEPTH: boolean;
  109720. REFRACTION: boolean;
  109721. REFRACTIONMAP_3D: boolean;
  109722. REFLECTIONOVERALPHA: boolean;
  109723. TWOSIDEDLIGHTING: boolean;
  109724. SHADOWFLOAT: boolean;
  109725. MORPHTARGETS: boolean;
  109726. MORPHTARGETS_NORMAL: boolean;
  109727. MORPHTARGETS_TANGENT: boolean;
  109728. MORPHTARGETS_UV: boolean;
  109729. NUM_MORPH_INFLUENCERS: number;
  109730. NONUNIFORMSCALING: boolean;
  109731. PREMULTIPLYALPHA: boolean;
  109732. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  109733. ALPHABLEND: boolean;
  109734. PREPASS: boolean;
  109735. SCENE_MRT_COUNT: number;
  109736. RGBDLIGHTMAP: boolean;
  109737. RGBDREFLECTION: boolean;
  109738. RGBDREFRACTION: boolean;
  109739. IMAGEPROCESSING: boolean;
  109740. VIGNETTE: boolean;
  109741. VIGNETTEBLENDMODEMULTIPLY: boolean;
  109742. VIGNETTEBLENDMODEOPAQUE: boolean;
  109743. TONEMAPPING: boolean;
  109744. TONEMAPPING_ACES: boolean;
  109745. CONTRAST: boolean;
  109746. COLORCURVES: boolean;
  109747. COLORGRADING: boolean;
  109748. COLORGRADING3D: boolean;
  109749. SAMPLER3DGREENDEPTH: boolean;
  109750. SAMPLER3DBGRMAP: boolean;
  109751. IMAGEPROCESSINGPOSTPROCESS: boolean;
  109752. MULTIVIEW: boolean;
  109753. /**
  109754. * If the reflection texture on this material is in linear color space
  109755. * @hidden
  109756. */
  109757. IS_REFLECTION_LINEAR: boolean;
  109758. /**
  109759. * If the refraction texture on this material is in linear color space
  109760. * @hidden
  109761. */
  109762. IS_REFRACTION_LINEAR: boolean;
  109763. EXPOSURE: boolean;
  109764. constructor();
  109765. setReflectionMode(modeToEnable: string): void;
  109766. }
  109767. /**
  109768. * This is the default material used in Babylon. It is the best trade off between quality
  109769. * and performances.
  109770. * @see https://doc.babylonjs.com/babylon101/materials
  109771. */
  109772. export class StandardMaterial extends PushMaterial {
  109773. private _diffuseTexture;
  109774. /**
  109775. * The basic texture of the material as viewed under a light.
  109776. */
  109777. diffuseTexture: Nullable<BaseTexture>;
  109778. private _ambientTexture;
  109779. /**
  109780. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  109781. */
  109782. ambientTexture: Nullable<BaseTexture>;
  109783. private _opacityTexture;
  109784. /**
  109785. * Define the transparency of the material from a texture.
  109786. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  109787. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  109788. */
  109789. opacityTexture: Nullable<BaseTexture>;
  109790. private _reflectionTexture;
  109791. /**
  109792. * Define the texture used to display the reflection.
  109793. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  109794. */
  109795. reflectionTexture: Nullable<BaseTexture>;
  109796. private _emissiveTexture;
  109797. /**
  109798. * Define texture of the material as if self lit.
  109799. * This will be mixed in the final result even in the absence of light.
  109800. */
  109801. emissiveTexture: Nullable<BaseTexture>;
  109802. private _specularTexture;
  109803. /**
  109804. * Define how the color and intensity of the highlight given by the light in the material.
  109805. */
  109806. specularTexture: Nullable<BaseTexture>;
  109807. private _bumpTexture;
  109808. /**
  109809. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  109810. * 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.
  109811. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  109812. */
  109813. bumpTexture: Nullable<BaseTexture>;
  109814. private _lightmapTexture;
  109815. /**
  109816. * Complex lighting can be computationally expensive to compute at runtime.
  109817. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  109818. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  109819. */
  109820. lightmapTexture: Nullable<BaseTexture>;
  109821. private _refractionTexture;
  109822. /**
  109823. * Define the texture used to display the refraction.
  109824. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  109825. */
  109826. refractionTexture: Nullable<BaseTexture>;
  109827. /**
  109828. * The color of the material lit by the environmental background lighting.
  109829. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  109830. */
  109831. ambientColor: Color3;
  109832. /**
  109833. * The basic color of the material as viewed under a light.
  109834. */
  109835. diffuseColor: Color3;
  109836. /**
  109837. * Define how the color and intensity of the highlight given by the light in the material.
  109838. */
  109839. specularColor: Color3;
  109840. /**
  109841. * Define the color of the material as if self lit.
  109842. * This will be mixed in the final result even in the absence of light.
  109843. */
  109844. emissiveColor: Color3;
  109845. /**
  109846. * Defines how sharp are the highlights in the material.
  109847. * The bigger the value the sharper giving a more glossy feeling to the result.
  109848. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  109849. */
  109850. specularPower: number;
  109851. private _useAlphaFromDiffuseTexture;
  109852. /**
  109853. * Does the transparency come from the diffuse texture alpha channel.
  109854. */
  109855. useAlphaFromDiffuseTexture: boolean;
  109856. private _useEmissiveAsIllumination;
  109857. /**
  109858. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  109859. */
  109860. useEmissiveAsIllumination: boolean;
  109861. private _linkEmissiveWithDiffuse;
  109862. /**
  109863. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  109864. * the emissive level when the final color is close to one.
  109865. */
  109866. linkEmissiveWithDiffuse: boolean;
  109867. private _useSpecularOverAlpha;
  109868. /**
  109869. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  109870. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  109871. */
  109872. useSpecularOverAlpha: boolean;
  109873. private _useReflectionOverAlpha;
  109874. /**
  109875. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  109876. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  109877. */
  109878. useReflectionOverAlpha: boolean;
  109879. private _disableLighting;
  109880. /**
  109881. * Does lights from the scene impacts this material.
  109882. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  109883. */
  109884. disableLighting: boolean;
  109885. private _useObjectSpaceNormalMap;
  109886. /**
  109887. * Allows using an object space normal map (instead of tangent space).
  109888. */
  109889. useObjectSpaceNormalMap: boolean;
  109890. private _useParallax;
  109891. /**
  109892. * Is parallax enabled or not.
  109893. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  109894. */
  109895. useParallax: boolean;
  109896. private _useParallaxOcclusion;
  109897. /**
  109898. * Is parallax occlusion enabled or not.
  109899. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  109900. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  109901. */
  109902. useParallaxOcclusion: boolean;
  109903. /**
  109904. * 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.
  109905. */
  109906. parallaxScaleBias: number;
  109907. private _roughness;
  109908. /**
  109909. * Helps to define how blurry the reflections should appears in the material.
  109910. */
  109911. roughness: number;
  109912. /**
  109913. * In case of refraction, define the value of the index of refraction.
  109914. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  109915. */
  109916. indexOfRefraction: number;
  109917. /**
  109918. * Invert the refraction texture alongside the y axis.
  109919. * It can be useful with procedural textures or probe for instance.
  109920. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  109921. */
  109922. invertRefractionY: boolean;
  109923. /**
  109924. * Defines the alpha limits in alpha test mode.
  109925. */
  109926. alphaCutOff: number;
  109927. private _useLightmapAsShadowmap;
  109928. /**
  109929. * In case of light mapping, define whether the map contains light or shadow informations.
  109930. */
  109931. useLightmapAsShadowmap: boolean;
  109932. private _diffuseFresnelParameters;
  109933. /**
  109934. * Define the diffuse fresnel parameters of the material.
  109935. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109936. */
  109937. diffuseFresnelParameters: FresnelParameters;
  109938. private _opacityFresnelParameters;
  109939. /**
  109940. * Define the opacity fresnel parameters of the material.
  109941. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109942. */
  109943. opacityFresnelParameters: FresnelParameters;
  109944. private _reflectionFresnelParameters;
  109945. /**
  109946. * Define the reflection fresnel parameters of the material.
  109947. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109948. */
  109949. reflectionFresnelParameters: FresnelParameters;
  109950. private _refractionFresnelParameters;
  109951. /**
  109952. * Define the refraction fresnel parameters of the material.
  109953. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109954. */
  109955. refractionFresnelParameters: FresnelParameters;
  109956. private _emissiveFresnelParameters;
  109957. /**
  109958. * Define the emissive fresnel parameters of the material.
  109959. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109960. */
  109961. emissiveFresnelParameters: FresnelParameters;
  109962. private _useReflectionFresnelFromSpecular;
  109963. /**
  109964. * If true automatically deducts the fresnels values from the material specularity.
  109965. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109966. */
  109967. useReflectionFresnelFromSpecular: boolean;
  109968. private _useGlossinessFromSpecularMapAlpha;
  109969. /**
  109970. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  109971. */
  109972. useGlossinessFromSpecularMapAlpha: boolean;
  109973. private _maxSimultaneousLights;
  109974. /**
  109975. * Defines the maximum number of lights that can be used in the material
  109976. */
  109977. maxSimultaneousLights: number;
  109978. private _invertNormalMapX;
  109979. /**
  109980. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  109981. */
  109982. invertNormalMapX: boolean;
  109983. private _invertNormalMapY;
  109984. /**
  109985. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  109986. */
  109987. invertNormalMapY: boolean;
  109988. private _twoSidedLighting;
  109989. /**
  109990. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  109991. */
  109992. twoSidedLighting: boolean;
  109993. /**
  109994. * Default configuration related to image processing available in the standard Material.
  109995. */
  109996. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  109997. /**
  109998. * Gets the image processing configuration used either in this material.
  109999. */
  110000. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  110001. /**
  110002. * Sets the Default image processing configuration used either in the this material.
  110003. *
  110004. * If sets to null, the scene one is in use.
  110005. */
  110006. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  110007. /**
  110008. * Keep track of the image processing observer to allow dispose and replace.
  110009. */
  110010. private _imageProcessingObserver;
  110011. /**
  110012. * Attaches a new image processing configuration to the Standard Material.
  110013. * @param configuration
  110014. */
  110015. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  110016. /**
  110017. * Gets wether the color curves effect is enabled.
  110018. */
  110019. get cameraColorCurvesEnabled(): boolean;
  110020. /**
  110021. * Sets wether the color curves effect is enabled.
  110022. */
  110023. set cameraColorCurvesEnabled(value: boolean);
  110024. /**
  110025. * Gets wether the color grading effect is enabled.
  110026. */
  110027. get cameraColorGradingEnabled(): boolean;
  110028. /**
  110029. * Gets wether the color grading effect is enabled.
  110030. */
  110031. set cameraColorGradingEnabled(value: boolean);
  110032. /**
  110033. * Gets wether tonemapping is enabled or not.
  110034. */
  110035. get cameraToneMappingEnabled(): boolean;
  110036. /**
  110037. * Sets wether tonemapping is enabled or not
  110038. */
  110039. set cameraToneMappingEnabled(value: boolean);
  110040. /**
  110041. * The camera exposure used on this material.
  110042. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  110043. * This corresponds to a photographic exposure.
  110044. */
  110045. get cameraExposure(): number;
  110046. /**
  110047. * The camera exposure used on this material.
  110048. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  110049. * This corresponds to a photographic exposure.
  110050. */
  110051. set cameraExposure(value: number);
  110052. /**
  110053. * Gets The camera contrast used on this material.
  110054. */
  110055. get cameraContrast(): number;
  110056. /**
  110057. * Sets The camera contrast used on this material.
  110058. */
  110059. set cameraContrast(value: number);
  110060. /**
  110061. * Gets the Color Grading 2D Lookup Texture.
  110062. */
  110063. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  110064. /**
  110065. * Sets the Color Grading 2D Lookup Texture.
  110066. */
  110067. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  110068. /**
  110069. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  110070. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  110071. * 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;
  110072. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  110073. */
  110074. get cameraColorCurves(): Nullable<ColorCurves>;
  110075. /**
  110076. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  110077. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  110078. * 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;
  110079. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  110080. */
  110081. set cameraColorCurves(value: Nullable<ColorCurves>);
  110082. /**
  110083. * Can this material render to several textures at once
  110084. */
  110085. get canRenderToMRT(): boolean;
  110086. /**
  110087. * Defines the detail map parameters for the material.
  110088. */
  110089. readonly detailMap: DetailMapConfiguration;
  110090. protected _renderTargets: SmartArray<RenderTargetTexture>;
  110091. protected _worldViewProjectionMatrix: Matrix;
  110092. protected _globalAmbientColor: Color3;
  110093. protected _useLogarithmicDepth: boolean;
  110094. protected _rebuildInParallel: boolean;
  110095. /**
  110096. * Instantiates a new standard material.
  110097. * This is the default material used in Babylon. It is the best trade off between quality
  110098. * and performances.
  110099. * @see https://doc.babylonjs.com/babylon101/materials
  110100. * @param name Define the name of the material in the scene
  110101. * @param scene Define the scene the material belong to
  110102. */
  110103. constructor(name: string, scene: Scene);
  110104. /**
  110105. * Gets a boolean indicating that current material needs to register RTT
  110106. */
  110107. get hasRenderTargetTextures(): boolean;
  110108. /**
  110109. * Gets the current class name of the material e.g. "StandardMaterial"
  110110. * Mainly use in serialization.
  110111. * @returns the class name
  110112. */
  110113. getClassName(): string;
  110114. /**
  110115. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  110116. * You can try switching to logarithmic depth.
  110117. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  110118. */
  110119. get useLogarithmicDepth(): boolean;
  110120. set useLogarithmicDepth(value: boolean);
  110121. /**
  110122. * Specifies if the material will require alpha blending
  110123. * @returns a boolean specifying if alpha blending is needed
  110124. */
  110125. needAlphaBlending(): boolean;
  110126. /**
  110127. * Specifies if this material should be rendered in alpha test mode
  110128. * @returns a boolean specifying if an alpha test is needed.
  110129. */
  110130. needAlphaTesting(): boolean;
  110131. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  110132. /**
  110133. * Get the texture used for alpha test purpose.
  110134. * @returns the diffuse texture in case of the standard material.
  110135. */
  110136. getAlphaTestTexture(): Nullable<BaseTexture>;
  110137. /**
  110138. * Get if the submesh is ready to be used and all its information available.
  110139. * Child classes can use it to update shaders
  110140. * @param mesh defines the mesh to check
  110141. * @param subMesh defines which submesh to check
  110142. * @param useInstances specifies that instances should be used
  110143. * @returns a boolean indicating that the submesh is ready or not
  110144. */
  110145. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  110146. /**
  110147. * Builds the material UBO layouts.
  110148. * Used internally during the effect preparation.
  110149. */
  110150. buildUniformLayout(): void;
  110151. /**
  110152. * Unbinds the material from the mesh
  110153. */
  110154. unbind(): void;
  110155. /**
  110156. * Binds the submesh to this material by preparing the effect and shader to draw
  110157. * @param world defines the world transformation matrix
  110158. * @param mesh defines the mesh containing the submesh
  110159. * @param subMesh defines the submesh to bind the material to
  110160. */
  110161. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  110162. /**
  110163. * Get the list of animatables in the material.
  110164. * @returns the list of animatables object used in the material
  110165. */
  110166. getAnimatables(): IAnimatable[];
  110167. /**
  110168. * Gets the active textures from the material
  110169. * @returns an array of textures
  110170. */
  110171. getActiveTextures(): BaseTexture[];
  110172. /**
  110173. * Specifies if the material uses a texture
  110174. * @param texture defines the texture to check against the material
  110175. * @returns a boolean specifying if the material uses the texture
  110176. */
  110177. hasTexture(texture: BaseTexture): boolean;
  110178. /**
  110179. * Disposes the material
  110180. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  110181. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  110182. */
  110183. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  110184. /**
  110185. * Makes a duplicate of the material, and gives it a new name
  110186. * @param name defines the new name for the duplicated material
  110187. * @returns the cloned material
  110188. */
  110189. clone(name: string): StandardMaterial;
  110190. /**
  110191. * Serializes this material in a JSON representation
  110192. * @returns the serialized material object
  110193. */
  110194. serialize(): any;
  110195. /**
  110196. * Creates a standard material from parsed material data
  110197. * @param source defines the JSON representation of the material
  110198. * @param scene defines the hosting scene
  110199. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  110200. * @returns a new standard material
  110201. */
  110202. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  110203. /**
  110204. * Are diffuse textures enabled in the application.
  110205. */
  110206. static get DiffuseTextureEnabled(): boolean;
  110207. static set DiffuseTextureEnabled(value: boolean);
  110208. /**
  110209. * Are detail textures enabled in the application.
  110210. */
  110211. static get DetailTextureEnabled(): boolean;
  110212. static set DetailTextureEnabled(value: boolean);
  110213. /**
  110214. * Are ambient textures enabled in the application.
  110215. */
  110216. static get AmbientTextureEnabled(): boolean;
  110217. static set AmbientTextureEnabled(value: boolean);
  110218. /**
  110219. * Are opacity textures enabled in the application.
  110220. */
  110221. static get OpacityTextureEnabled(): boolean;
  110222. static set OpacityTextureEnabled(value: boolean);
  110223. /**
  110224. * Are reflection textures enabled in the application.
  110225. */
  110226. static get ReflectionTextureEnabled(): boolean;
  110227. static set ReflectionTextureEnabled(value: boolean);
  110228. /**
  110229. * Are emissive textures enabled in the application.
  110230. */
  110231. static get EmissiveTextureEnabled(): boolean;
  110232. static set EmissiveTextureEnabled(value: boolean);
  110233. /**
  110234. * Are specular textures enabled in the application.
  110235. */
  110236. static get SpecularTextureEnabled(): boolean;
  110237. static set SpecularTextureEnabled(value: boolean);
  110238. /**
  110239. * Are bump textures enabled in the application.
  110240. */
  110241. static get BumpTextureEnabled(): boolean;
  110242. static set BumpTextureEnabled(value: boolean);
  110243. /**
  110244. * Are lightmap textures enabled in the application.
  110245. */
  110246. static get LightmapTextureEnabled(): boolean;
  110247. static set LightmapTextureEnabled(value: boolean);
  110248. /**
  110249. * Are refraction textures enabled in the application.
  110250. */
  110251. static get RefractionTextureEnabled(): boolean;
  110252. static set RefractionTextureEnabled(value: boolean);
  110253. /**
  110254. * Are color grading textures enabled in the application.
  110255. */
  110256. static get ColorGradingTextureEnabled(): boolean;
  110257. static set ColorGradingTextureEnabled(value: boolean);
  110258. /**
  110259. * Are fresnels enabled in the application.
  110260. */
  110261. static get FresnelEnabled(): boolean;
  110262. static set FresnelEnabled(value: boolean);
  110263. }
  110264. }
  110265. declare module BABYLON {
  110266. /**
  110267. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  110268. *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.
  110269. * The SPS is also a particle system. It provides some methods to manage the particles.
  110270. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  110271. *
  110272. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  110273. */
  110274. export class SolidParticleSystem implements IDisposable {
  110275. /**
  110276. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  110277. * Example : var p = SPS.particles[i];
  110278. */
  110279. particles: SolidParticle[];
  110280. /**
  110281. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  110282. */
  110283. nbParticles: number;
  110284. /**
  110285. * If the particles must ever face the camera (default false). Useful for planar particles.
  110286. */
  110287. billboard: boolean;
  110288. /**
  110289. * Recompute normals when adding a shape
  110290. */
  110291. recomputeNormals: boolean;
  110292. /**
  110293. * This a counter ofr your own usage. It's not set by any SPS functions.
  110294. */
  110295. counter: number;
  110296. /**
  110297. * The SPS name. This name is also given to the underlying mesh.
  110298. */
  110299. name: string;
  110300. /**
  110301. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  110302. */
  110303. mesh: Mesh;
  110304. /**
  110305. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  110306. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  110307. */
  110308. vars: any;
  110309. /**
  110310. * This array is populated when the SPS is set as 'pickable'.
  110311. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  110312. * Each element of this array is an object `{idx: int, faceId: int}`.
  110313. * `idx` is the picked particle index in the `SPS.particles` array
  110314. * `faceId` is the picked face index counted within this particle.
  110315. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  110316. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  110317. * Use the method SPS.pickedParticle(pickingInfo) instead.
  110318. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  110319. */
  110320. pickedParticles: {
  110321. idx: number;
  110322. faceId: number;
  110323. }[];
  110324. /**
  110325. * This array is populated when the SPS is set as 'pickable'
  110326. * Each key of this array is a submesh index.
  110327. * Each element of this array is a second array defined like this :
  110328. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  110329. * Each element of this second array is an object `{idx: int, faceId: int}`.
  110330. * `idx` is the picked particle index in the `SPS.particles` array
  110331. * `faceId` is the picked face index counted within this particle.
  110332. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  110333. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  110334. */
  110335. pickedBySubMesh: {
  110336. idx: number;
  110337. faceId: number;
  110338. }[][];
  110339. /**
  110340. * This array is populated when `enableDepthSort` is set to true.
  110341. * Each element of this array is an instance of the class DepthSortedParticle.
  110342. */
  110343. depthSortedParticles: DepthSortedParticle[];
  110344. /**
  110345. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  110346. * @hidden
  110347. */
  110348. _bSphereOnly: boolean;
  110349. /**
  110350. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  110351. * @hidden
  110352. */
  110353. _bSphereRadiusFactor: number;
  110354. private _scene;
  110355. private _positions;
  110356. private _indices;
  110357. private _normals;
  110358. private _colors;
  110359. private _uvs;
  110360. private _indices32;
  110361. private _positions32;
  110362. private _normals32;
  110363. private _fixedNormal32;
  110364. private _colors32;
  110365. private _uvs32;
  110366. private _index;
  110367. private _updatable;
  110368. private _pickable;
  110369. private _isVisibilityBoxLocked;
  110370. private _alwaysVisible;
  110371. private _depthSort;
  110372. private _expandable;
  110373. private _shapeCounter;
  110374. private _copy;
  110375. private _color;
  110376. private _computeParticleColor;
  110377. private _computeParticleTexture;
  110378. private _computeParticleRotation;
  110379. private _computeParticleVertex;
  110380. private _computeBoundingBox;
  110381. private _depthSortParticles;
  110382. private _camera;
  110383. private _mustUnrotateFixedNormals;
  110384. private _particlesIntersect;
  110385. private _needs32Bits;
  110386. private _isNotBuilt;
  110387. private _lastParticleId;
  110388. private _idxOfId;
  110389. private _multimaterialEnabled;
  110390. private _useModelMaterial;
  110391. private _indicesByMaterial;
  110392. private _materialIndexes;
  110393. private _depthSortFunction;
  110394. private _materialSortFunction;
  110395. private _materials;
  110396. private _multimaterial;
  110397. private _materialIndexesById;
  110398. private _defaultMaterial;
  110399. private _autoUpdateSubMeshes;
  110400. private _tmpVertex;
  110401. /**
  110402. * Creates a SPS (Solid Particle System) object.
  110403. * @param name (String) is the SPS name, this will be the underlying mesh name.
  110404. * @param scene (Scene) is the scene in which the SPS is added.
  110405. * @param options defines the options of the sps e.g.
  110406. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  110407. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  110408. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  110409. * * 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.
  110410. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  110411. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  110412. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  110413. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  110414. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  110415. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  110416. */
  110417. constructor(name: string, scene: Scene, options?: {
  110418. updatable?: boolean;
  110419. isPickable?: boolean;
  110420. enableDepthSort?: boolean;
  110421. particleIntersection?: boolean;
  110422. boundingSphereOnly?: boolean;
  110423. bSphereRadiusFactor?: number;
  110424. expandable?: boolean;
  110425. useModelMaterial?: boolean;
  110426. enableMultiMaterial?: boolean;
  110427. });
  110428. /**
  110429. * Builds the SPS underlying mesh. Returns a standard Mesh.
  110430. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  110431. * @returns the created mesh
  110432. */
  110433. buildMesh(): Mesh;
  110434. /**
  110435. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  110436. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  110437. * Thus the particles generated from `digest()` have their property `position` set yet.
  110438. * @param mesh ( Mesh ) is the mesh to be digested
  110439. * @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
  110440. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  110441. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  110442. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  110443. * @returns the current SPS
  110444. */
  110445. digest(mesh: Mesh, options?: {
  110446. facetNb?: number;
  110447. number?: number;
  110448. delta?: number;
  110449. storage?: [];
  110450. }): SolidParticleSystem;
  110451. /**
  110452. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  110453. * @hidden
  110454. */
  110455. private _unrotateFixedNormals;
  110456. /**
  110457. * Resets the temporary working copy particle
  110458. * @hidden
  110459. */
  110460. private _resetCopy;
  110461. /**
  110462. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  110463. * @param p the current index in the positions array to be updated
  110464. * @param ind the current index in the indices array
  110465. * @param shape a Vector3 array, the shape geometry
  110466. * @param positions the positions array to be updated
  110467. * @param meshInd the shape indices array
  110468. * @param indices the indices array to be updated
  110469. * @param meshUV the shape uv array
  110470. * @param uvs the uv array to be updated
  110471. * @param meshCol the shape color array
  110472. * @param colors the color array to be updated
  110473. * @param meshNor the shape normals array
  110474. * @param normals the normals array to be updated
  110475. * @param idx the particle index
  110476. * @param idxInShape the particle index in its shape
  110477. * @param options the addShape() method passed options
  110478. * @model the particle model
  110479. * @hidden
  110480. */
  110481. private _meshBuilder;
  110482. /**
  110483. * Returns a shape Vector3 array from positions float array
  110484. * @param positions float array
  110485. * @returns a vector3 array
  110486. * @hidden
  110487. */
  110488. private _posToShape;
  110489. /**
  110490. * Returns a shapeUV array from a float uvs (array deep copy)
  110491. * @param uvs as a float array
  110492. * @returns a shapeUV array
  110493. * @hidden
  110494. */
  110495. private _uvsToShapeUV;
  110496. /**
  110497. * Adds a new particle object in the particles array
  110498. * @param idx particle index in particles array
  110499. * @param id particle id
  110500. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  110501. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  110502. * @param model particle ModelShape object
  110503. * @param shapeId model shape identifier
  110504. * @param idxInShape index of the particle in the current model
  110505. * @param bInfo model bounding info object
  110506. * @param storage target storage array, if any
  110507. * @hidden
  110508. */
  110509. private _addParticle;
  110510. /**
  110511. * Adds some particles to the SPS from the model shape. Returns the shape id.
  110512. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  110513. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  110514. * @param nb (positive integer) the number of particles to be created from this model
  110515. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  110516. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  110517. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  110518. * @returns the number of shapes in the system
  110519. */
  110520. addShape(mesh: Mesh, nb: number, options?: {
  110521. positionFunction?: any;
  110522. vertexFunction?: any;
  110523. storage?: [];
  110524. }): number;
  110525. /**
  110526. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  110527. * @hidden
  110528. */
  110529. private _rebuildParticle;
  110530. /**
  110531. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  110532. * @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.
  110533. * @returns the SPS.
  110534. */
  110535. rebuildMesh(reset?: boolean): SolidParticleSystem;
  110536. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  110537. * Returns an array with the removed particles.
  110538. * 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.
  110539. * The SPS can't be empty so at least one particle needs to remain in place.
  110540. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  110541. * @param start index of the first particle to remove
  110542. * @param end index of the last particle to remove (included)
  110543. * @returns an array populated with the removed particles
  110544. */
  110545. removeParticles(start: number, end: number): SolidParticle[];
  110546. /**
  110547. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  110548. * @param solidParticleArray an array populated with Solid Particles objects
  110549. * @returns the SPS
  110550. */
  110551. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  110552. /**
  110553. * Creates a new particle and modifies the SPS mesh geometry :
  110554. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  110555. * - calls _addParticle() to populate the particle array
  110556. * factorized code from addShape() and insertParticlesFromArray()
  110557. * @param idx particle index in the particles array
  110558. * @param i particle index in its shape
  110559. * @param modelShape particle ModelShape object
  110560. * @param shape shape vertex array
  110561. * @param meshInd shape indices array
  110562. * @param meshUV shape uv array
  110563. * @param meshCol shape color array
  110564. * @param meshNor shape normals array
  110565. * @param bbInfo shape bounding info
  110566. * @param storage target particle storage
  110567. * @options addShape() passed options
  110568. * @hidden
  110569. */
  110570. private _insertNewParticle;
  110571. /**
  110572. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  110573. * This method calls `updateParticle()` for each particle of the SPS.
  110574. * For an animated SPS, it is usually called within the render loop.
  110575. * 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.
  110576. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  110577. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  110578. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  110579. * @returns the SPS.
  110580. */
  110581. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  110582. /**
  110583. * Disposes the SPS.
  110584. */
  110585. dispose(): void;
  110586. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  110587. * idx is the particle index in the SPS
  110588. * faceId is the picked face index counted within this particle.
  110589. * Returns null if the pickInfo can't identify a picked particle.
  110590. * @param pickingInfo (PickingInfo object)
  110591. * @returns {idx: number, faceId: number} or null
  110592. */
  110593. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  110594. idx: number;
  110595. faceId: number;
  110596. }>;
  110597. /**
  110598. * Returns a SolidParticle object from its identifier : particle.id
  110599. * @param id (integer) the particle Id
  110600. * @returns the searched particle or null if not found in the SPS.
  110601. */
  110602. getParticleById(id: number): Nullable<SolidParticle>;
  110603. /**
  110604. * Returns a new array populated with the particles having the passed shapeId.
  110605. * @param shapeId (integer) the shape identifier
  110606. * @returns a new solid particle array
  110607. */
  110608. getParticlesByShapeId(shapeId: number): SolidParticle[];
  110609. /**
  110610. * Populates the passed array "ref" with the particles having the passed shapeId.
  110611. * @param shapeId the shape identifier
  110612. * @returns the SPS
  110613. * @param ref
  110614. */
  110615. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  110616. /**
  110617. * Computes the required SubMeshes according the materials assigned to the particles.
  110618. * @returns the solid particle system.
  110619. * Does nothing if called before the SPS mesh is built.
  110620. */
  110621. computeSubMeshes(): SolidParticleSystem;
  110622. /**
  110623. * Sorts the solid particles by material when MultiMaterial is enabled.
  110624. * Updates the indices32 array.
  110625. * Updates the indicesByMaterial array.
  110626. * Updates the mesh indices array.
  110627. * @returns the SPS
  110628. * @hidden
  110629. */
  110630. private _sortParticlesByMaterial;
  110631. /**
  110632. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  110633. * @hidden
  110634. */
  110635. private _setMaterialIndexesById;
  110636. /**
  110637. * Returns an array with unique values of Materials from the passed array
  110638. * @param array the material array to be checked and filtered
  110639. * @hidden
  110640. */
  110641. private _filterUniqueMaterialId;
  110642. /**
  110643. * Sets a new Standard Material as _defaultMaterial if not already set.
  110644. * @hidden
  110645. */
  110646. private _setDefaultMaterial;
  110647. /**
  110648. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  110649. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  110650. * @returns the SPS.
  110651. */
  110652. refreshVisibleSize(): SolidParticleSystem;
  110653. /**
  110654. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  110655. * @param size the size (float) of the visibility box
  110656. * note : this doesn't lock the SPS mesh bounding box.
  110657. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  110658. */
  110659. setVisibilityBox(size: number): void;
  110660. /**
  110661. * Gets whether the SPS as always visible or not
  110662. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  110663. */
  110664. get isAlwaysVisible(): boolean;
  110665. /**
  110666. * Sets the SPS as always visible or not
  110667. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  110668. */
  110669. set isAlwaysVisible(val: boolean);
  110670. /**
  110671. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  110672. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  110673. */
  110674. set isVisibilityBoxLocked(val: boolean);
  110675. /**
  110676. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  110677. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  110678. */
  110679. get isVisibilityBoxLocked(): boolean;
  110680. /**
  110681. * Tells to `setParticles()` to compute the particle rotations or not.
  110682. * Default value : true. The SPS is faster when it's set to false.
  110683. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  110684. */
  110685. set computeParticleRotation(val: boolean);
  110686. /**
  110687. * Tells to `setParticles()` to compute the particle colors or not.
  110688. * Default value : true. The SPS is faster when it's set to false.
  110689. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  110690. */
  110691. set computeParticleColor(val: boolean);
  110692. set computeParticleTexture(val: boolean);
  110693. /**
  110694. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  110695. * Default value : false. The SPS is faster when it's set to false.
  110696. * Note : the particle custom vertex positions aren't stored values.
  110697. */
  110698. set computeParticleVertex(val: boolean);
  110699. /**
  110700. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  110701. */
  110702. set computeBoundingBox(val: boolean);
  110703. /**
  110704. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  110705. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  110706. * Default : `true`
  110707. */
  110708. set depthSortParticles(val: boolean);
  110709. /**
  110710. * Gets if `setParticles()` computes the particle rotations or not.
  110711. * Default value : true. The SPS is faster when it's set to false.
  110712. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  110713. */
  110714. get computeParticleRotation(): boolean;
  110715. /**
  110716. * Gets if `setParticles()` computes the particle colors or not.
  110717. * Default value : true. The SPS is faster when it's set to false.
  110718. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  110719. */
  110720. get computeParticleColor(): boolean;
  110721. /**
  110722. * Gets if `setParticles()` computes the particle textures or not.
  110723. * Default value : true. The SPS is faster when it's set to false.
  110724. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  110725. */
  110726. get computeParticleTexture(): boolean;
  110727. /**
  110728. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  110729. * Default value : false. The SPS is faster when it's set to false.
  110730. * Note : the particle custom vertex positions aren't stored values.
  110731. */
  110732. get computeParticleVertex(): boolean;
  110733. /**
  110734. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  110735. */
  110736. get computeBoundingBox(): boolean;
  110737. /**
  110738. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  110739. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  110740. * Default : `true`
  110741. */
  110742. get depthSortParticles(): boolean;
  110743. /**
  110744. * Gets if the SPS is created as expandable at construction time.
  110745. * Default : `false`
  110746. */
  110747. get expandable(): boolean;
  110748. /**
  110749. * Gets if the SPS supports the Multi Materials
  110750. */
  110751. get multimaterialEnabled(): boolean;
  110752. /**
  110753. * Gets if the SPS uses the model materials for its own multimaterial.
  110754. */
  110755. get useModelMaterial(): boolean;
  110756. /**
  110757. * The SPS used material array.
  110758. */
  110759. get materials(): Material[];
  110760. /**
  110761. * Sets the SPS MultiMaterial from the passed materials.
  110762. * Note : the passed array is internally copied and not used then by reference.
  110763. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  110764. */
  110765. setMultiMaterial(materials: Material[]): void;
  110766. /**
  110767. * The SPS computed multimaterial object
  110768. */
  110769. get multimaterial(): MultiMaterial;
  110770. set multimaterial(mm: MultiMaterial);
  110771. /**
  110772. * If the subMeshes must be updated on the next call to setParticles()
  110773. */
  110774. get autoUpdateSubMeshes(): boolean;
  110775. set autoUpdateSubMeshes(val: boolean);
  110776. /**
  110777. * This function does nothing. It may be overwritten to set all the particle first values.
  110778. * The SPS doesn't call this function, you may have to call it by your own.
  110779. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  110780. */
  110781. initParticles(): void;
  110782. /**
  110783. * This function does nothing. It may be overwritten to recycle a particle.
  110784. * The SPS doesn't call this function, you may have to call it by your own.
  110785. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  110786. * @param particle The particle to recycle
  110787. * @returns the recycled particle
  110788. */
  110789. recycleParticle(particle: SolidParticle): SolidParticle;
  110790. /**
  110791. * Updates a particle : this function should be overwritten by the user.
  110792. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  110793. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  110794. * @example : just set a particle position or velocity and recycle conditions
  110795. * @param particle The particle to update
  110796. * @returns the updated particle
  110797. */
  110798. updateParticle(particle: SolidParticle): SolidParticle;
  110799. /**
  110800. * Updates a vertex of a particle : it can be overwritten by the user.
  110801. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  110802. * @param particle the current particle
  110803. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  110804. * @param pt the index of the current vertex in the particle shape
  110805. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  110806. * @example : just set a vertex particle position or color
  110807. * @returns the sps
  110808. */
  110809. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  110810. /**
  110811. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  110812. * This does nothing and may be overwritten by the user.
  110813. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  110814. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  110815. * @param update the boolean update value actually passed to setParticles()
  110816. */
  110817. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  110818. /**
  110819. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  110820. * This will be passed three parameters.
  110821. * This does nothing and may be overwritten by the user.
  110822. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  110823. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  110824. * @param update the boolean update value actually passed to setParticles()
  110825. */
  110826. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  110827. }
  110828. }
  110829. declare module BABYLON {
  110830. /**
  110831. * Represents one particle of a solid particle system.
  110832. */
  110833. export class SolidParticle {
  110834. /**
  110835. * particle global index
  110836. */
  110837. idx: number;
  110838. /**
  110839. * particle identifier
  110840. */
  110841. id: number;
  110842. /**
  110843. * The color of the particle
  110844. */
  110845. color: Nullable<Color4>;
  110846. /**
  110847. * The world space position of the particle.
  110848. */
  110849. position: Vector3;
  110850. /**
  110851. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  110852. */
  110853. rotation: Vector3;
  110854. /**
  110855. * The world space rotation quaternion of the particle.
  110856. */
  110857. rotationQuaternion: Nullable<Quaternion>;
  110858. /**
  110859. * The scaling of the particle.
  110860. */
  110861. scaling: Vector3;
  110862. /**
  110863. * The uvs of the particle.
  110864. */
  110865. uvs: Vector4;
  110866. /**
  110867. * The current speed of the particle.
  110868. */
  110869. velocity: Vector3;
  110870. /**
  110871. * The pivot point in the particle local space.
  110872. */
  110873. pivot: Vector3;
  110874. /**
  110875. * Must the particle be translated from its pivot point in its local space ?
  110876. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  110877. * Default : false
  110878. */
  110879. translateFromPivot: boolean;
  110880. /**
  110881. * Is the particle active or not ?
  110882. */
  110883. alive: boolean;
  110884. /**
  110885. * Is the particle visible or not ?
  110886. */
  110887. isVisible: boolean;
  110888. /**
  110889. * Index of this particle in the global "positions" array (Internal use)
  110890. * @hidden
  110891. */
  110892. _pos: number;
  110893. /**
  110894. * @hidden Index of this particle in the global "indices" array (Internal use)
  110895. */
  110896. _ind: number;
  110897. /**
  110898. * @hidden ModelShape of this particle (Internal use)
  110899. */
  110900. _model: ModelShape;
  110901. /**
  110902. * ModelShape id of this particle
  110903. */
  110904. shapeId: number;
  110905. /**
  110906. * Index of the particle in its shape id
  110907. */
  110908. idxInShape: number;
  110909. /**
  110910. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  110911. */
  110912. _modelBoundingInfo: BoundingInfo;
  110913. /**
  110914. * @hidden Particle BoundingInfo object (Internal use)
  110915. */
  110916. _boundingInfo: BoundingInfo;
  110917. /**
  110918. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  110919. */
  110920. _sps: SolidParticleSystem;
  110921. /**
  110922. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  110923. */
  110924. _stillInvisible: boolean;
  110925. /**
  110926. * @hidden Last computed particle rotation matrix
  110927. */
  110928. _rotationMatrix: number[];
  110929. /**
  110930. * Parent particle Id, if any.
  110931. * Default null.
  110932. */
  110933. parentId: Nullable<number>;
  110934. /**
  110935. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  110936. */
  110937. materialIndex: Nullable<number>;
  110938. /**
  110939. * Custom object or properties.
  110940. */
  110941. props: Nullable<any>;
  110942. /**
  110943. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  110944. * The possible values are :
  110945. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  110946. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  110947. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  110948. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  110949. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  110950. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  110951. * */
  110952. cullingStrategy: number;
  110953. /**
  110954. * @hidden Internal global position in the SPS.
  110955. */
  110956. _globalPosition: Vector3;
  110957. /**
  110958. * Creates a Solid Particle object.
  110959. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  110960. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  110961. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  110962. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  110963. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  110964. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  110965. * @param shapeId (integer) is the model shape identifier in the SPS.
  110966. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  110967. * @param sps defines the sps it is associated to
  110968. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  110969. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  110970. */
  110971. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  110972. /**
  110973. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  110974. * @param target the particle target
  110975. * @returns the current particle
  110976. */
  110977. copyToRef(target: SolidParticle): SolidParticle;
  110978. /**
  110979. * Legacy support, changed scale to scaling
  110980. */
  110981. get scale(): Vector3;
  110982. /**
  110983. * Legacy support, changed scale to scaling
  110984. */
  110985. set scale(scale: Vector3);
  110986. /**
  110987. * Legacy support, changed quaternion to rotationQuaternion
  110988. */
  110989. get quaternion(): Nullable<Quaternion>;
  110990. /**
  110991. * Legacy support, changed quaternion to rotationQuaternion
  110992. */
  110993. set quaternion(q: Nullable<Quaternion>);
  110994. /**
  110995. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  110996. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  110997. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  110998. * @returns true if it intersects
  110999. */
  111000. intersectsMesh(target: Mesh | SolidParticle): boolean;
  111001. /**
  111002. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  111003. * A particle is in the frustum if its bounding box intersects the frustum
  111004. * @param frustumPlanes defines the frustum to test
  111005. * @returns true if the particle is in the frustum planes
  111006. */
  111007. isInFrustum(frustumPlanes: Plane[]): boolean;
  111008. /**
  111009. * get the rotation matrix of the particle
  111010. * @hidden
  111011. */
  111012. getRotationMatrix(m: Matrix): void;
  111013. }
  111014. /**
  111015. * Represents the shape of the model used by one particle of a solid particle system.
  111016. * SPS internal tool, don't use it manually.
  111017. */
  111018. export class ModelShape {
  111019. /**
  111020. * The shape id
  111021. * @hidden
  111022. */
  111023. shapeID: number;
  111024. /**
  111025. * flat array of model positions (internal use)
  111026. * @hidden
  111027. */
  111028. _shape: Vector3[];
  111029. /**
  111030. * flat array of model UVs (internal use)
  111031. * @hidden
  111032. */
  111033. _shapeUV: number[];
  111034. /**
  111035. * color array of the model
  111036. * @hidden
  111037. */
  111038. _shapeColors: number[];
  111039. /**
  111040. * indices array of the model
  111041. * @hidden
  111042. */
  111043. _indices: number[];
  111044. /**
  111045. * normals array of the model
  111046. * @hidden
  111047. */
  111048. _normals: number[];
  111049. /**
  111050. * length of the shape in the model indices array (internal use)
  111051. * @hidden
  111052. */
  111053. _indicesLength: number;
  111054. /**
  111055. * Custom position function (internal use)
  111056. * @hidden
  111057. */
  111058. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  111059. /**
  111060. * Custom vertex function (internal use)
  111061. * @hidden
  111062. */
  111063. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  111064. /**
  111065. * Model material (internal use)
  111066. * @hidden
  111067. */
  111068. _material: Nullable<Material>;
  111069. /**
  111070. * 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.
  111071. * SPS internal tool, don't use it manually.
  111072. * @hidden
  111073. */
  111074. 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>);
  111075. }
  111076. /**
  111077. * Represents a Depth Sorted Particle in the solid particle system.
  111078. * @hidden
  111079. */
  111080. export class DepthSortedParticle {
  111081. /**
  111082. * Particle index
  111083. */
  111084. idx: number;
  111085. /**
  111086. * Index of the particle in the "indices" array
  111087. */
  111088. ind: number;
  111089. /**
  111090. * Length of the particle shape in the "indices" array
  111091. */
  111092. indicesLength: number;
  111093. /**
  111094. * Squared distance from the particle to the camera
  111095. */
  111096. sqDistance: number;
  111097. /**
  111098. * Material index when used with MultiMaterials
  111099. */
  111100. materialIndex: number;
  111101. /**
  111102. * Creates a new sorted particle
  111103. * @param materialIndex
  111104. */
  111105. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  111106. }
  111107. /**
  111108. * Represents a solid particle vertex
  111109. */
  111110. export class SolidParticleVertex {
  111111. /**
  111112. * Vertex position
  111113. */
  111114. position: Vector3;
  111115. /**
  111116. * Vertex color
  111117. */
  111118. color: Color4;
  111119. /**
  111120. * Vertex UV
  111121. */
  111122. uv: Vector2;
  111123. /**
  111124. * Creates a new solid particle vertex
  111125. */
  111126. constructor();
  111127. /** Vertex x coordinate */
  111128. get x(): number;
  111129. set x(val: number);
  111130. /** Vertex y coordinate */
  111131. get y(): number;
  111132. set y(val: number);
  111133. /** Vertex z coordinate */
  111134. get z(): number;
  111135. set z(val: number);
  111136. }
  111137. }
  111138. declare module BABYLON {
  111139. /**
  111140. * @hidden
  111141. */
  111142. export class _MeshCollisionData {
  111143. _checkCollisions: boolean;
  111144. _collisionMask: number;
  111145. _collisionGroup: number;
  111146. _surroundingMeshes: Nullable<AbstractMesh[]>;
  111147. _collider: Nullable<Collider>;
  111148. _oldPositionForCollisions: Vector3;
  111149. _diffPositionForCollisions: Vector3;
  111150. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  111151. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  111152. }
  111153. }
  111154. declare module BABYLON {
  111155. /** @hidden */
  111156. class _FacetDataStorage {
  111157. facetPositions: Vector3[];
  111158. facetNormals: Vector3[];
  111159. facetPartitioning: number[][];
  111160. facetNb: number;
  111161. partitioningSubdivisions: number;
  111162. partitioningBBoxRatio: number;
  111163. facetDataEnabled: boolean;
  111164. facetParameters: any;
  111165. bbSize: Vector3;
  111166. subDiv: {
  111167. max: number;
  111168. X: number;
  111169. Y: number;
  111170. Z: number;
  111171. };
  111172. facetDepthSort: boolean;
  111173. facetDepthSortEnabled: boolean;
  111174. depthSortedIndices: IndicesArray;
  111175. depthSortedFacets: {
  111176. ind: number;
  111177. sqDistance: number;
  111178. }[];
  111179. facetDepthSortFunction: (f1: {
  111180. ind: number;
  111181. sqDistance: number;
  111182. }, f2: {
  111183. ind: number;
  111184. sqDistance: number;
  111185. }) => number;
  111186. facetDepthSortFrom: Vector3;
  111187. facetDepthSortOrigin: Vector3;
  111188. invertedMatrix: Matrix;
  111189. }
  111190. /**
  111191. * @hidden
  111192. **/
  111193. class _InternalAbstractMeshDataInfo {
  111194. _hasVertexAlpha: boolean;
  111195. _useVertexColors: boolean;
  111196. _numBoneInfluencers: number;
  111197. _applyFog: boolean;
  111198. _receiveShadows: boolean;
  111199. _facetData: _FacetDataStorage;
  111200. _visibility: number;
  111201. _skeleton: Nullable<Skeleton>;
  111202. _layerMask: number;
  111203. _computeBonesUsingShaders: boolean;
  111204. _isActive: boolean;
  111205. _onlyForInstances: boolean;
  111206. _isActiveIntermediate: boolean;
  111207. _onlyForInstancesIntermediate: boolean;
  111208. _actAsRegularMesh: boolean;
  111209. }
  111210. /**
  111211. * Class used to store all common mesh properties
  111212. */
  111213. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  111214. /** No occlusion */
  111215. static OCCLUSION_TYPE_NONE: number;
  111216. /** Occlusion set to optimisitic */
  111217. static OCCLUSION_TYPE_OPTIMISTIC: number;
  111218. /** Occlusion set to strict */
  111219. static OCCLUSION_TYPE_STRICT: number;
  111220. /** Use an accurante occlusion algorithm */
  111221. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  111222. /** Use a conservative occlusion algorithm */
  111223. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  111224. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  111225. * Test order :
  111226. * Is the bounding sphere outside the frustum ?
  111227. * If not, are the bounding box vertices outside the frustum ?
  111228. * It not, then the cullable object is in the frustum.
  111229. */
  111230. static readonly CULLINGSTRATEGY_STANDARD: number;
  111231. /** Culling strategy : Bounding Sphere Only.
  111232. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  111233. * It's also less accurate than the standard because some not visible objects can still be selected.
  111234. * Test : is the bounding sphere outside the frustum ?
  111235. * If not, then the cullable object is in the frustum.
  111236. */
  111237. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  111238. /** Culling strategy : Optimistic Inclusion.
  111239. * This in an inclusion test first, then the standard exclusion test.
  111240. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  111241. * 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.
  111242. * Anyway, it's as accurate as the standard strategy.
  111243. * Test :
  111244. * Is the cullable object bounding sphere center in the frustum ?
  111245. * If not, apply the default culling strategy.
  111246. */
  111247. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  111248. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  111249. * This in an inclusion test first, then the bounding sphere only exclusion test.
  111250. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  111251. * 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.
  111252. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  111253. * Test :
  111254. * Is the cullable object bounding sphere center in the frustum ?
  111255. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  111256. */
  111257. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  111258. /**
  111259. * No billboard
  111260. */
  111261. static get BILLBOARDMODE_NONE(): number;
  111262. /** Billboard on X axis */
  111263. static get BILLBOARDMODE_X(): number;
  111264. /** Billboard on Y axis */
  111265. static get BILLBOARDMODE_Y(): number;
  111266. /** Billboard on Z axis */
  111267. static get BILLBOARDMODE_Z(): number;
  111268. /** Billboard on all axes */
  111269. static get BILLBOARDMODE_ALL(): number;
  111270. /** Billboard on using position instead of orientation */
  111271. static get BILLBOARDMODE_USE_POSITION(): number;
  111272. /** @hidden */
  111273. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  111274. /**
  111275. * The culling strategy to use to check whether the mesh must be rendered or not.
  111276. * This value can be changed at any time and will be used on the next render mesh selection.
  111277. * The possible values are :
  111278. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  111279. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  111280. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  111281. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  111282. * Please read each static variable documentation to get details about the culling process.
  111283. * */
  111284. cullingStrategy: number;
  111285. /**
  111286. * Gets the number of facets in the mesh
  111287. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  111288. */
  111289. get facetNb(): number;
  111290. /**
  111291. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  111292. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  111293. */
  111294. get partitioningSubdivisions(): number;
  111295. set partitioningSubdivisions(nb: number);
  111296. /**
  111297. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  111298. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  111299. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  111300. */
  111301. get partitioningBBoxRatio(): number;
  111302. set partitioningBBoxRatio(ratio: number);
  111303. /**
  111304. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  111305. * Works only for updatable meshes.
  111306. * Doesn't work with multi-materials
  111307. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  111308. */
  111309. get mustDepthSortFacets(): boolean;
  111310. set mustDepthSortFacets(sort: boolean);
  111311. /**
  111312. * The location (Vector3) where the facet depth sort must be computed from.
  111313. * By default, the active camera position.
  111314. * Used only when facet depth sort is enabled
  111315. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  111316. */
  111317. get facetDepthSortFrom(): Vector3;
  111318. set facetDepthSortFrom(location: Vector3);
  111319. /**
  111320. * gets a boolean indicating if facetData is enabled
  111321. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  111322. */
  111323. get isFacetDataEnabled(): boolean;
  111324. /** @hidden */
  111325. _updateNonUniformScalingState(value: boolean): boolean;
  111326. /**
  111327. * An event triggered when this mesh collides with another one
  111328. */
  111329. onCollideObservable: Observable<AbstractMesh>;
  111330. /** Set a function to call when this mesh collides with another one */
  111331. set onCollide(callback: () => void);
  111332. /**
  111333. * An event triggered when the collision's position changes
  111334. */
  111335. onCollisionPositionChangeObservable: Observable<Vector3>;
  111336. /** Set a function to call when the collision's position changes */
  111337. set onCollisionPositionChange(callback: () => void);
  111338. /**
  111339. * An event triggered when material is changed
  111340. */
  111341. onMaterialChangedObservable: Observable<AbstractMesh>;
  111342. /**
  111343. * Gets or sets the orientation for POV movement & rotation
  111344. */
  111345. definedFacingForward: boolean;
  111346. /** @hidden */
  111347. _occlusionQuery: Nullable<WebGLQuery>;
  111348. /** @hidden */
  111349. _renderingGroup: Nullable<RenderingGroup>;
  111350. /**
  111351. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  111352. */
  111353. get visibility(): number;
  111354. /**
  111355. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  111356. */
  111357. set visibility(value: number);
  111358. /** Gets or sets the alpha index used to sort transparent meshes
  111359. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  111360. */
  111361. alphaIndex: number;
  111362. /**
  111363. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  111364. */
  111365. isVisible: boolean;
  111366. /**
  111367. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  111368. */
  111369. isPickable: boolean;
  111370. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  111371. showSubMeshesBoundingBox: boolean;
  111372. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  111373. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111374. */
  111375. isBlocker: boolean;
  111376. /**
  111377. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  111378. */
  111379. enablePointerMoveEvents: boolean;
  111380. /**
  111381. * Specifies the rendering group id for this mesh (0 by default)
  111382. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  111383. */
  111384. renderingGroupId: number;
  111385. private _material;
  111386. /** Gets or sets current material */
  111387. get material(): Nullable<Material>;
  111388. set material(value: Nullable<Material>);
  111389. /**
  111390. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  111391. * @see https://doc.babylonjs.com/babylon101/shadows
  111392. */
  111393. get receiveShadows(): boolean;
  111394. set receiveShadows(value: boolean);
  111395. /** Defines color to use when rendering outline */
  111396. outlineColor: Color3;
  111397. /** Define width to use when rendering outline */
  111398. outlineWidth: number;
  111399. /** Defines color to use when rendering overlay */
  111400. overlayColor: Color3;
  111401. /** Defines alpha to use when rendering overlay */
  111402. overlayAlpha: number;
  111403. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  111404. get hasVertexAlpha(): boolean;
  111405. set hasVertexAlpha(value: boolean);
  111406. /** 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) */
  111407. get useVertexColors(): boolean;
  111408. set useVertexColors(value: boolean);
  111409. /**
  111410. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  111411. */
  111412. get computeBonesUsingShaders(): boolean;
  111413. set computeBonesUsingShaders(value: boolean);
  111414. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  111415. get numBoneInfluencers(): number;
  111416. set numBoneInfluencers(value: number);
  111417. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  111418. get applyFog(): boolean;
  111419. set applyFog(value: boolean);
  111420. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  111421. useOctreeForRenderingSelection: boolean;
  111422. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  111423. useOctreeForPicking: boolean;
  111424. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  111425. useOctreeForCollisions: boolean;
  111426. /**
  111427. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  111428. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  111429. */
  111430. get layerMask(): number;
  111431. set layerMask(value: number);
  111432. /**
  111433. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  111434. */
  111435. alwaysSelectAsActiveMesh: boolean;
  111436. /**
  111437. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  111438. */
  111439. doNotSyncBoundingInfo: boolean;
  111440. /**
  111441. * Gets or sets the current action manager
  111442. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  111443. */
  111444. actionManager: Nullable<AbstractActionManager>;
  111445. private _meshCollisionData;
  111446. /**
  111447. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  111448. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  111449. */
  111450. ellipsoid: Vector3;
  111451. /**
  111452. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  111453. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  111454. */
  111455. ellipsoidOffset: Vector3;
  111456. /**
  111457. * Gets or sets a collision mask used to mask collisions (default is -1).
  111458. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  111459. */
  111460. get collisionMask(): number;
  111461. set collisionMask(mask: number);
  111462. /**
  111463. * Gets or sets the current collision group mask (-1 by default).
  111464. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  111465. */
  111466. get collisionGroup(): number;
  111467. set collisionGroup(mask: number);
  111468. /**
  111469. * Gets or sets current surrounding meshes (null by default).
  111470. *
  111471. * By default collision detection is tested against every mesh in the scene.
  111472. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  111473. * meshes will be tested for the collision.
  111474. *
  111475. * Note: if set to an empty array no collision will happen when this mesh is moved.
  111476. */
  111477. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  111478. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  111479. /**
  111480. * Defines edge width used when edgesRenderer is enabled
  111481. * @see https://www.babylonjs-playground.com/#10OJSG#13
  111482. */
  111483. edgesWidth: number;
  111484. /**
  111485. * Defines edge color used when edgesRenderer is enabled
  111486. * @see https://www.babylonjs-playground.com/#10OJSG#13
  111487. */
  111488. edgesColor: Color4;
  111489. /** @hidden */
  111490. _edgesRenderer: Nullable<IEdgesRenderer>;
  111491. /** @hidden */
  111492. _masterMesh: Nullable<AbstractMesh>;
  111493. /** @hidden */
  111494. _boundingInfo: Nullable<BoundingInfo>;
  111495. /** @hidden */
  111496. _renderId: number;
  111497. /**
  111498. * Gets or sets the list of subMeshes
  111499. * @see https://doc.babylonjs.com/how_to/multi_materials
  111500. */
  111501. subMeshes: SubMesh[];
  111502. /** @hidden */
  111503. _intersectionsInProgress: AbstractMesh[];
  111504. /** @hidden */
  111505. _unIndexed: boolean;
  111506. /** @hidden */
  111507. _lightSources: Light[];
  111508. /** Gets the list of lights affecting that mesh */
  111509. get lightSources(): Light[];
  111510. /** @hidden */
  111511. get _positions(): Nullable<Vector3[]>;
  111512. /** @hidden */
  111513. _waitingData: {
  111514. lods: Nullable<any>;
  111515. actions: Nullable<any>;
  111516. freezeWorldMatrix: Nullable<boolean>;
  111517. };
  111518. /** @hidden */
  111519. _bonesTransformMatrices: Nullable<Float32Array>;
  111520. /** @hidden */
  111521. _transformMatrixTexture: Nullable<RawTexture>;
  111522. /**
  111523. * Gets or sets a skeleton to apply skining transformations
  111524. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  111525. */
  111526. set skeleton(value: Nullable<Skeleton>);
  111527. get skeleton(): Nullable<Skeleton>;
  111528. /**
  111529. * An event triggered when the mesh is rebuilt.
  111530. */
  111531. onRebuildObservable: Observable<AbstractMesh>;
  111532. /**
  111533. * Creates a new AbstractMesh
  111534. * @param name defines the name of the mesh
  111535. * @param scene defines the hosting scene
  111536. */
  111537. constructor(name: string, scene?: Nullable<Scene>);
  111538. /**
  111539. * Returns the string "AbstractMesh"
  111540. * @returns "AbstractMesh"
  111541. */
  111542. getClassName(): string;
  111543. /**
  111544. * Gets a string representation of the current mesh
  111545. * @param fullDetails defines a boolean indicating if full details must be included
  111546. * @returns a string representation of the current mesh
  111547. */
  111548. toString(fullDetails?: boolean): string;
  111549. /**
  111550. * @hidden
  111551. */
  111552. protected _getEffectiveParent(): Nullable<Node>;
  111553. /** @hidden */
  111554. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  111555. /** @hidden */
  111556. _rebuild(): void;
  111557. /** @hidden */
  111558. _resyncLightSources(): void;
  111559. /** @hidden */
  111560. _resyncLightSource(light: Light): void;
  111561. /** @hidden */
  111562. _unBindEffect(): void;
  111563. /** @hidden */
  111564. _removeLightSource(light: Light, dispose: boolean): void;
  111565. private _markSubMeshesAsDirty;
  111566. /** @hidden */
  111567. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  111568. /** @hidden */
  111569. _markSubMeshesAsAttributesDirty(): void;
  111570. /** @hidden */
  111571. _markSubMeshesAsMiscDirty(): void;
  111572. /**
  111573. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  111574. */
  111575. get scaling(): Vector3;
  111576. set scaling(newScaling: Vector3);
  111577. /**
  111578. * Returns true if the mesh is blocked. Implemented by child classes
  111579. */
  111580. get isBlocked(): boolean;
  111581. /**
  111582. * Returns the mesh itself by default. Implemented by child classes
  111583. * @param camera defines the camera to use to pick the right LOD level
  111584. * @returns the currentAbstractMesh
  111585. */
  111586. getLOD(camera: Camera): Nullable<AbstractMesh>;
  111587. /**
  111588. * Returns 0 by default. Implemented by child classes
  111589. * @returns an integer
  111590. */
  111591. getTotalVertices(): number;
  111592. /**
  111593. * Returns a positive integer : the total number of indices in this mesh geometry.
  111594. * @returns the numner of indices or zero if the mesh has no geometry.
  111595. */
  111596. getTotalIndices(): number;
  111597. /**
  111598. * Returns null by default. Implemented by child classes
  111599. * @returns null
  111600. */
  111601. getIndices(): Nullable<IndicesArray>;
  111602. /**
  111603. * Returns the array of the requested vertex data kind. Implemented by child classes
  111604. * @param kind defines the vertex data kind to use
  111605. * @returns null
  111606. */
  111607. getVerticesData(kind: string): Nullable<FloatArray>;
  111608. /**
  111609. * Sets the vertex data of the mesh geometry for the requested `kind`.
  111610. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  111611. * Note that a new underlying VertexBuffer object is created each call.
  111612. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  111613. * @param kind defines vertex data kind:
  111614. * * VertexBuffer.PositionKind
  111615. * * VertexBuffer.UVKind
  111616. * * VertexBuffer.UV2Kind
  111617. * * VertexBuffer.UV3Kind
  111618. * * VertexBuffer.UV4Kind
  111619. * * VertexBuffer.UV5Kind
  111620. * * VertexBuffer.UV6Kind
  111621. * * VertexBuffer.ColorKind
  111622. * * VertexBuffer.MatricesIndicesKind
  111623. * * VertexBuffer.MatricesIndicesExtraKind
  111624. * * VertexBuffer.MatricesWeightsKind
  111625. * * VertexBuffer.MatricesWeightsExtraKind
  111626. * @param data defines the data source
  111627. * @param updatable defines if the data must be flagged as updatable (or static)
  111628. * @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
  111629. * @returns the current mesh
  111630. */
  111631. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  111632. /**
  111633. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  111634. * If the mesh has no geometry, it is simply returned as it is.
  111635. * @param kind defines vertex data kind:
  111636. * * VertexBuffer.PositionKind
  111637. * * VertexBuffer.UVKind
  111638. * * VertexBuffer.UV2Kind
  111639. * * VertexBuffer.UV3Kind
  111640. * * VertexBuffer.UV4Kind
  111641. * * VertexBuffer.UV5Kind
  111642. * * VertexBuffer.UV6Kind
  111643. * * VertexBuffer.ColorKind
  111644. * * VertexBuffer.MatricesIndicesKind
  111645. * * VertexBuffer.MatricesIndicesExtraKind
  111646. * * VertexBuffer.MatricesWeightsKind
  111647. * * VertexBuffer.MatricesWeightsExtraKind
  111648. * @param data defines the data source
  111649. * @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
  111650. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  111651. * @returns the current mesh
  111652. */
  111653. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  111654. /**
  111655. * Sets the mesh indices,
  111656. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  111657. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  111658. * @param totalVertices Defines the total number of vertices
  111659. * @returns the current mesh
  111660. */
  111661. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  111662. /**
  111663. * Gets a boolean indicating if specific vertex data is present
  111664. * @param kind defines the vertex data kind to use
  111665. * @returns true is data kind is present
  111666. */
  111667. isVerticesDataPresent(kind: string): boolean;
  111668. /**
  111669. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  111670. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  111671. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  111672. * @returns a BoundingInfo
  111673. */
  111674. getBoundingInfo(): BoundingInfo;
  111675. /**
  111676. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  111677. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  111678. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  111679. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  111680. * @returns the current mesh
  111681. */
  111682. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  111683. /**
  111684. * Overwrite the current bounding info
  111685. * @param boundingInfo defines the new bounding info
  111686. * @returns the current mesh
  111687. */
  111688. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  111689. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  111690. get useBones(): boolean;
  111691. /** @hidden */
  111692. _preActivate(): void;
  111693. /** @hidden */
  111694. _preActivateForIntermediateRendering(renderId: number): void;
  111695. /** @hidden */
  111696. _activate(renderId: number, intermediateRendering: boolean): boolean;
  111697. /** @hidden */
  111698. _postActivate(): void;
  111699. /** @hidden */
  111700. _freeze(): void;
  111701. /** @hidden */
  111702. _unFreeze(): void;
  111703. /**
  111704. * Gets the current world matrix
  111705. * @returns a Matrix
  111706. */
  111707. getWorldMatrix(): Matrix;
  111708. /** @hidden */
  111709. _getWorldMatrixDeterminant(): number;
  111710. /**
  111711. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  111712. */
  111713. get isAnInstance(): boolean;
  111714. /**
  111715. * Gets a boolean indicating if this mesh has instances
  111716. */
  111717. get hasInstances(): boolean;
  111718. /**
  111719. * Gets a boolean indicating if this mesh has thin instances
  111720. */
  111721. get hasThinInstances(): boolean;
  111722. /**
  111723. * Perform relative position change from the point of view of behind the front of the mesh.
  111724. * This is performed taking into account the meshes current rotation, so you do not have to care.
  111725. * Supports definition of mesh facing forward or backward
  111726. * @param amountRight defines the distance on the right axis
  111727. * @param amountUp defines the distance on the up axis
  111728. * @param amountForward defines the distance on the forward axis
  111729. * @returns the current mesh
  111730. */
  111731. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  111732. /**
  111733. * Calculate relative position change from the point of view of behind the front of the mesh.
  111734. * This is performed taking into account the meshes current rotation, so you do not have to care.
  111735. * Supports definition of mesh facing forward or backward
  111736. * @param amountRight defines the distance on the right axis
  111737. * @param amountUp defines the distance on the up axis
  111738. * @param amountForward defines the distance on the forward axis
  111739. * @returns the new displacement vector
  111740. */
  111741. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  111742. /**
  111743. * Perform relative rotation change from the point of view of behind the front of the mesh.
  111744. * Supports definition of mesh facing forward or backward
  111745. * @param flipBack defines the flip
  111746. * @param twirlClockwise defines the twirl
  111747. * @param tiltRight defines the tilt
  111748. * @returns the current mesh
  111749. */
  111750. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  111751. /**
  111752. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  111753. * Supports definition of mesh facing forward or backward.
  111754. * @param flipBack defines the flip
  111755. * @param twirlClockwise defines the twirl
  111756. * @param tiltRight defines the tilt
  111757. * @returns the new rotation vector
  111758. */
  111759. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  111760. /**
  111761. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  111762. * This means the mesh underlying bounding box and sphere are recomputed.
  111763. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  111764. * @returns the current mesh
  111765. */
  111766. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  111767. /** @hidden */
  111768. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  111769. /** @hidden */
  111770. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  111771. /** @hidden */
  111772. _updateBoundingInfo(): AbstractMesh;
  111773. /** @hidden */
  111774. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  111775. /** @hidden */
  111776. protected _afterComputeWorldMatrix(): void;
  111777. /** @hidden */
  111778. get _effectiveMesh(): AbstractMesh;
  111779. /**
  111780. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  111781. * A mesh is in the frustum if its bounding box intersects the frustum
  111782. * @param frustumPlanes defines the frustum to test
  111783. * @returns true if the mesh is in the frustum planes
  111784. */
  111785. isInFrustum(frustumPlanes: Plane[]): boolean;
  111786. /**
  111787. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  111788. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  111789. * @param frustumPlanes defines the frustum to test
  111790. * @returns true if the mesh is completely in the frustum planes
  111791. */
  111792. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  111793. /**
  111794. * True if the mesh intersects another mesh or a SolidParticle object
  111795. * @param mesh defines a target mesh or SolidParticle to test
  111796. * @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)
  111797. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  111798. * @returns true if there is an intersection
  111799. */
  111800. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  111801. /**
  111802. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  111803. * @param point defines the point to test
  111804. * @returns true if there is an intersection
  111805. */
  111806. intersectsPoint(point: Vector3): boolean;
  111807. /**
  111808. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  111809. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  111810. */
  111811. get checkCollisions(): boolean;
  111812. set checkCollisions(collisionEnabled: boolean);
  111813. /**
  111814. * Gets Collider object used to compute collisions (not physics)
  111815. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  111816. */
  111817. get collider(): Nullable<Collider>;
  111818. /**
  111819. * Move the mesh using collision engine
  111820. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  111821. * @param displacement defines the requested displacement vector
  111822. * @returns the current mesh
  111823. */
  111824. moveWithCollisions(displacement: Vector3): AbstractMesh;
  111825. private _onCollisionPositionChange;
  111826. /** @hidden */
  111827. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  111828. /** @hidden */
  111829. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  111830. /** @hidden */
  111831. _checkCollision(collider: Collider): AbstractMesh;
  111832. /** @hidden */
  111833. _generatePointsArray(): boolean;
  111834. /**
  111835. * Checks if the passed Ray intersects with the mesh
  111836. * @param ray defines the ray to use
  111837. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  111838. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  111839. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  111840. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  111841. * @returns the picking info
  111842. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  111843. */
  111844. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  111845. /**
  111846. * Clones the current mesh
  111847. * @param name defines the mesh name
  111848. * @param newParent defines the new mesh parent
  111849. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  111850. * @returns the new mesh
  111851. */
  111852. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  111853. /**
  111854. * Disposes all the submeshes of the current meshnp
  111855. * @returns the current mesh
  111856. */
  111857. releaseSubMeshes(): AbstractMesh;
  111858. /**
  111859. * Releases resources associated with this abstract mesh.
  111860. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  111861. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  111862. */
  111863. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  111864. /**
  111865. * Adds the passed mesh as a child to the current mesh
  111866. * @param mesh defines the child mesh
  111867. * @returns the current mesh
  111868. */
  111869. addChild(mesh: AbstractMesh): AbstractMesh;
  111870. /**
  111871. * Removes the passed mesh from the current mesh children list
  111872. * @param mesh defines the child mesh
  111873. * @returns the current mesh
  111874. */
  111875. removeChild(mesh: AbstractMesh): AbstractMesh;
  111876. /** @hidden */
  111877. private _initFacetData;
  111878. /**
  111879. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  111880. * This method can be called within the render loop.
  111881. * 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
  111882. * @returns the current mesh
  111883. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111884. */
  111885. updateFacetData(): AbstractMesh;
  111886. /**
  111887. * Returns the facetLocalNormals array.
  111888. * The normals are expressed in the mesh local spac
  111889. * @returns an array of Vector3
  111890. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111891. */
  111892. getFacetLocalNormals(): Vector3[];
  111893. /**
  111894. * Returns the facetLocalPositions array.
  111895. * The facet positions are expressed in the mesh local space
  111896. * @returns an array of Vector3
  111897. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111898. */
  111899. getFacetLocalPositions(): Vector3[];
  111900. /**
  111901. * Returns the facetLocalPartioning array
  111902. * @returns an array of array of numbers
  111903. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111904. */
  111905. getFacetLocalPartitioning(): number[][];
  111906. /**
  111907. * Returns the i-th facet position in the world system.
  111908. * This method allocates a new Vector3 per call
  111909. * @param i defines the facet index
  111910. * @returns a new Vector3
  111911. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111912. */
  111913. getFacetPosition(i: number): Vector3;
  111914. /**
  111915. * Sets the reference Vector3 with the i-th facet position in the world system
  111916. * @param i defines the facet index
  111917. * @param ref defines the target vector
  111918. * @returns the current mesh
  111919. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111920. */
  111921. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  111922. /**
  111923. * Returns the i-th facet normal in the world system.
  111924. * This method allocates a new Vector3 per call
  111925. * @param i defines the facet index
  111926. * @returns a new Vector3
  111927. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111928. */
  111929. getFacetNormal(i: number): Vector3;
  111930. /**
  111931. * Sets the reference Vector3 with the i-th facet normal in the world system
  111932. * @param i defines the facet index
  111933. * @param ref defines the target vector
  111934. * @returns the current mesh
  111935. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111936. */
  111937. getFacetNormalToRef(i: number, ref: Vector3): this;
  111938. /**
  111939. * 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)
  111940. * @param x defines x coordinate
  111941. * @param y defines y coordinate
  111942. * @param z defines z coordinate
  111943. * @returns the array of facet indexes
  111944. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111945. */
  111946. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  111947. /**
  111948. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  111949. * @param projected sets as the (x,y,z) world projection on the facet
  111950. * @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
  111951. * @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
  111952. * @param x defines x coordinate
  111953. * @param y defines y coordinate
  111954. * @param z defines z coordinate
  111955. * @returns the face index if found (or null instead)
  111956. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111957. */
  111958. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  111959. /**
  111960. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  111961. * @param projected sets as the (x,y,z) local projection on the facet
  111962. * @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
  111963. * @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
  111964. * @param x defines x coordinate
  111965. * @param y defines y coordinate
  111966. * @param z defines z coordinate
  111967. * @returns the face index if found (or null instead)
  111968. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111969. */
  111970. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  111971. /**
  111972. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  111973. * @returns the parameters
  111974. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111975. */
  111976. getFacetDataParameters(): any;
  111977. /**
  111978. * Disables the feature FacetData and frees the related memory
  111979. * @returns the current mesh
  111980. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111981. */
  111982. disableFacetData(): AbstractMesh;
  111983. /**
  111984. * Updates the AbstractMesh indices array
  111985. * @param indices defines the data source
  111986. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  111987. * @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)
  111988. * @returns the current mesh
  111989. */
  111990. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  111991. /**
  111992. * Creates new normals data for the mesh
  111993. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  111994. * @returns the current mesh
  111995. */
  111996. createNormals(updatable: boolean): AbstractMesh;
  111997. /**
  111998. * Align the mesh with a normal
  111999. * @param normal defines the normal to use
  112000. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  112001. * @returns the current mesh
  112002. */
  112003. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  112004. /** @hidden */
  112005. _checkOcclusionQuery(): boolean;
  112006. /**
  112007. * Disables the mesh edge rendering mode
  112008. * @returns the currentAbstractMesh
  112009. */
  112010. disableEdgesRendering(): AbstractMesh;
  112011. /**
  112012. * Enables the edge rendering mode on the mesh.
  112013. * This mode makes the mesh edges visible
  112014. * @param epsilon defines the maximal distance between two angles to detect a face
  112015. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  112016. * @returns the currentAbstractMesh
  112017. * @see https://www.babylonjs-playground.com/#19O9TU#0
  112018. */
  112019. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  112020. /**
  112021. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  112022. * @returns an array of particle systems in the scene that use the mesh as an emitter
  112023. */
  112024. getConnectedParticleSystems(): IParticleSystem[];
  112025. }
  112026. }
  112027. declare module BABYLON {
  112028. /**
  112029. * Interface used to define ActionEvent
  112030. */
  112031. export interface IActionEvent {
  112032. /** The mesh or sprite that triggered the action */
  112033. source: any;
  112034. /** The X mouse cursor position at the time of the event */
  112035. pointerX: number;
  112036. /** The Y mouse cursor position at the time of the event */
  112037. pointerY: number;
  112038. /** The mesh that is currently pointed at (can be null) */
  112039. meshUnderPointer: Nullable<AbstractMesh>;
  112040. /** the original (browser) event that triggered the ActionEvent */
  112041. sourceEvent?: any;
  112042. /** additional data for the event */
  112043. additionalData?: any;
  112044. }
  112045. /**
  112046. * ActionEvent is the event being sent when an action is triggered.
  112047. */
  112048. export class ActionEvent implements IActionEvent {
  112049. /** The mesh or sprite that triggered the action */
  112050. source: any;
  112051. /** The X mouse cursor position at the time of the event */
  112052. pointerX: number;
  112053. /** The Y mouse cursor position at the time of the event */
  112054. pointerY: number;
  112055. /** The mesh that is currently pointed at (can be null) */
  112056. meshUnderPointer: Nullable<AbstractMesh>;
  112057. /** the original (browser) event that triggered the ActionEvent */
  112058. sourceEvent?: any;
  112059. /** additional data for the event */
  112060. additionalData?: any;
  112061. /**
  112062. * Creates a new ActionEvent
  112063. * @param source The mesh or sprite that triggered the action
  112064. * @param pointerX The X mouse cursor position at the time of the event
  112065. * @param pointerY The Y mouse cursor position at the time of the event
  112066. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  112067. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  112068. * @param additionalData additional data for the event
  112069. */
  112070. constructor(
  112071. /** The mesh or sprite that triggered the action */
  112072. source: any,
  112073. /** The X mouse cursor position at the time of the event */
  112074. pointerX: number,
  112075. /** The Y mouse cursor position at the time of the event */
  112076. pointerY: number,
  112077. /** The mesh that is currently pointed at (can be null) */
  112078. meshUnderPointer: Nullable<AbstractMesh>,
  112079. /** the original (browser) event that triggered the ActionEvent */
  112080. sourceEvent?: any,
  112081. /** additional data for the event */
  112082. additionalData?: any);
  112083. /**
  112084. * Helper function to auto-create an ActionEvent from a source mesh.
  112085. * @param source The source mesh that triggered the event
  112086. * @param evt The original (browser) event
  112087. * @param additionalData additional data for the event
  112088. * @returns the new ActionEvent
  112089. */
  112090. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  112091. /**
  112092. * Helper function to auto-create an ActionEvent from a source sprite
  112093. * @param source The source sprite that triggered the event
  112094. * @param scene Scene associated with the sprite
  112095. * @param evt The original (browser) event
  112096. * @param additionalData additional data for the event
  112097. * @returns the new ActionEvent
  112098. */
  112099. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  112100. /**
  112101. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  112102. * @param scene the scene where the event occurred
  112103. * @param evt The original (browser) event
  112104. * @returns the new ActionEvent
  112105. */
  112106. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  112107. /**
  112108. * Helper function to auto-create an ActionEvent from a primitive
  112109. * @param prim defines the target primitive
  112110. * @param pointerPos defines the pointer position
  112111. * @param evt The original (browser) event
  112112. * @param additionalData additional data for the event
  112113. * @returns the new ActionEvent
  112114. */
  112115. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  112116. }
  112117. }
  112118. declare module BABYLON {
  112119. /**
  112120. * Abstract class used to decouple action Manager from scene and meshes.
  112121. * Do not instantiate.
  112122. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  112123. */
  112124. export abstract class AbstractActionManager implements IDisposable {
  112125. /** Gets the list of active triggers */
  112126. static Triggers: {
  112127. [key: string]: number;
  112128. };
  112129. /** Gets the cursor to use when hovering items */
  112130. hoverCursor: string;
  112131. /** Gets the list of actions */
  112132. actions: IAction[];
  112133. /**
  112134. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  112135. */
  112136. isRecursive: boolean;
  112137. /**
  112138. * Releases all associated resources
  112139. */
  112140. abstract dispose(): void;
  112141. /**
  112142. * Does this action manager has pointer triggers
  112143. */
  112144. abstract get hasPointerTriggers(): boolean;
  112145. /**
  112146. * Does this action manager has pick triggers
  112147. */
  112148. abstract get hasPickTriggers(): boolean;
  112149. /**
  112150. * Process a specific trigger
  112151. * @param trigger defines the trigger to process
  112152. * @param evt defines the event details to be processed
  112153. */
  112154. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  112155. /**
  112156. * Does this action manager handles actions of any of the given triggers
  112157. * @param triggers defines the triggers to be tested
  112158. * @return a boolean indicating whether one (or more) of the triggers is handled
  112159. */
  112160. abstract hasSpecificTriggers(triggers: number[]): boolean;
  112161. /**
  112162. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  112163. * speed.
  112164. * @param triggerA defines the trigger to be tested
  112165. * @param triggerB defines the trigger to be tested
  112166. * @return a boolean indicating whether one (or more) of the triggers is handled
  112167. */
  112168. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  112169. /**
  112170. * Does this action manager handles actions of a given trigger
  112171. * @param trigger defines the trigger to be tested
  112172. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  112173. * @return whether the trigger is handled
  112174. */
  112175. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  112176. /**
  112177. * Serialize this manager to a JSON object
  112178. * @param name defines the property name to store this manager
  112179. * @returns a JSON representation of this manager
  112180. */
  112181. abstract serialize(name: string): any;
  112182. /**
  112183. * Registers an action to this action manager
  112184. * @param action defines the action to be registered
  112185. * @return the action amended (prepared) after registration
  112186. */
  112187. abstract registerAction(action: IAction): Nullable<IAction>;
  112188. /**
  112189. * Unregisters an action to this action manager
  112190. * @param action defines the action to be unregistered
  112191. * @return a boolean indicating whether the action has been unregistered
  112192. */
  112193. abstract unregisterAction(action: IAction): Boolean;
  112194. /**
  112195. * Does exist one action manager with at least one trigger
  112196. **/
  112197. static get HasTriggers(): boolean;
  112198. /**
  112199. * Does exist one action manager with at least one pick trigger
  112200. **/
  112201. static get HasPickTriggers(): boolean;
  112202. /**
  112203. * Does exist one action manager that handles actions of a given trigger
  112204. * @param trigger defines the trigger to be tested
  112205. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  112206. **/
  112207. static HasSpecificTrigger(trigger: number): boolean;
  112208. }
  112209. }
  112210. declare module BABYLON {
  112211. /**
  112212. * Defines how a node can be built from a string name.
  112213. */
  112214. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  112215. /**
  112216. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  112217. */
  112218. export class Node implements IBehaviorAware<Node> {
  112219. /** @hidden */
  112220. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  112221. private static _NodeConstructors;
  112222. /**
  112223. * Add a new node constructor
  112224. * @param type defines the type name of the node to construct
  112225. * @param constructorFunc defines the constructor function
  112226. */
  112227. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  112228. /**
  112229. * Returns a node constructor based on type name
  112230. * @param type defines the type name
  112231. * @param name defines the new node name
  112232. * @param scene defines the hosting scene
  112233. * @param options defines optional options to transmit to constructors
  112234. * @returns the new constructor or null
  112235. */
  112236. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  112237. /**
  112238. * Gets or sets the name of the node
  112239. */
  112240. name: string;
  112241. /**
  112242. * Gets or sets the id of the node
  112243. */
  112244. id: string;
  112245. /**
  112246. * Gets or sets the unique id of the node
  112247. */
  112248. uniqueId: number;
  112249. /**
  112250. * Gets or sets a string used to store user defined state for the node
  112251. */
  112252. state: string;
  112253. /**
  112254. * Gets or sets an object used to store user defined information for the node
  112255. */
  112256. metadata: any;
  112257. /**
  112258. * For internal use only. Please do not use.
  112259. */
  112260. reservedDataStore: any;
  112261. /**
  112262. * List of inspectable custom properties (used by the Inspector)
  112263. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  112264. */
  112265. inspectableCustomProperties: IInspectable[];
  112266. private _doNotSerialize;
  112267. /**
  112268. * Gets or sets a boolean used to define if the node must be serialized
  112269. */
  112270. get doNotSerialize(): boolean;
  112271. set doNotSerialize(value: boolean);
  112272. /** @hidden */
  112273. _isDisposed: boolean;
  112274. /**
  112275. * Gets a list of Animations associated with the node
  112276. */
  112277. animations: Animation[];
  112278. protected _ranges: {
  112279. [name: string]: Nullable<AnimationRange>;
  112280. };
  112281. /**
  112282. * Callback raised when the node is ready to be used
  112283. */
  112284. onReady: Nullable<(node: Node) => void>;
  112285. private _isEnabled;
  112286. private _isParentEnabled;
  112287. private _isReady;
  112288. /** @hidden */
  112289. _currentRenderId: number;
  112290. private _parentUpdateId;
  112291. /** @hidden */
  112292. _childUpdateId: number;
  112293. /** @hidden */
  112294. _waitingParentId: Nullable<string>;
  112295. /** @hidden */
  112296. _scene: Scene;
  112297. /** @hidden */
  112298. _cache: any;
  112299. private _parentNode;
  112300. private _children;
  112301. /** @hidden */
  112302. _worldMatrix: Matrix;
  112303. /** @hidden */
  112304. _worldMatrixDeterminant: number;
  112305. /** @hidden */
  112306. _worldMatrixDeterminantIsDirty: boolean;
  112307. /** @hidden */
  112308. private _sceneRootNodesIndex;
  112309. /**
  112310. * Gets a boolean indicating if the node has been disposed
  112311. * @returns true if the node was disposed
  112312. */
  112313. isDisposed(): boolean;
  112314. /**
  112315. * Gets or sets the parent of the node (without keeping the current position in the scene)
  112316. * @see https://doc.babylonjs.com/how_to/parenting
  112317. */
  112318. set parent(parent: Nullable<Node>);
  112319. get parent(): Nullable<Node>;
  112320. /** @hidden */
  112321. _addToSceneRootNodes(): void;
  112322. /** @hidden */
  112323. _removeFromSceneRootNodes(): void;
  112324. private _animationPropertiesOverride;
  112325. /**
  112326. * Gets or sets the animation properties override
  112327. */
  112328. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  112329. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  112330. /**
  112331. * Gets a string identifying the name of the class
  112332. * @returns "Node" string
  112333. */
  112334. getClassName(): string;
  112335. /** @hidden */
  112336. readonly _isNode: boolean;
  112337. /**
  112338. * An event triggered when the mesh is disposed
  112339. */
  112340. onDisposeObservable: Observable<Node>;
  112341. private _onDisposeObserver;
  112342. /**
  112343. * Sets a callback that will be raised when the node will be disposed
  112344. */
  112345. set onDispose(callback: () => void);
  112346. /**
  112347. * Creates a new Node
  112348. * @param name the name and id to be given to this node
  112349. * @param scene the scene this node will be added to
  112350. */
  112351. constructor(name: string, scene?: Nullable<Scene>);
  112352. /**
  112353. * Gets the scene of the node
  112354. * @returns a scene
  112355. */
  112356. getScene(): Scene;
  112357. /**
  112358. * Gets the engine of the node
  112359. * @returns a Engine
  112360. */
  112361. getEngine(): Engine;
  112362. private _behaviors;
  112363. /**
  112364. * Attach a behavior to the node
  112365. * @see https://doc.babylonjs.com/features/behaviour
  112366. * @param behavior defines the behavior to attach
  112367. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  112368. * @returns the current Node
  112369. */
  112370. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  112371. /**
  112372. * Remove an attached behavior
  112373. * @see https://doc.babylonjs.com/features/behaviour
  112374. * @param behavior defines the behavior to attach
  112375. * @returns the current Node
  112376. */
  112377. removeBehavior(behavior: Behavior<Node>): Node;
  112378. /**
  112379. * Gets the list of attached behaviors
  112380. * @see https://doc.babylonjs.com/features/behaviour
  112381. */
  112382. get behaviors(): Behavior<Node>[];
  112383. /**
  112384. * Gets an attached behavior by name
  112385. * @param name defines the name of the behavior to look for
  112386. * @see https://doc.babylonjs.com/features/behaviour
  112387. * @returns null if behavior was not found else the requested behavior
  112388. */
  112389. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  112390. /**
  112391. * Returns the latest update of the World matrix
  112392. * @returns a Matrix
  112393. */
  112394. getWorldMatrix(): Matrix;
  112395. /** @hidden */
  112396. _getWorldMatrixDeterminant(): number;
  112397. /**
  112398. * Returns directly the latest state of the mesh World matrix.
  112399. * A Matrix is returned.
  112400. */
  112401. get worldMatrixFromCache(): Matrix;
  112402. /** @hidden */
  112403. _initCache(): void;
  112404. /** @hidden */
  112405. updateCache(force?: boolean): void;
  112406. /** @hidden */
  112407. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  112408. /** @hidden */
  112409. _updateCache(ignoreParentClass?: boolean): void;
  112410. /** @hidden */
  112411. _isSynchronized(): boolean;
  112412. /** @hidden */
  112413. _markSyncedWithParent(): void;
  112414. /** @hidden */
  112415. isSynchronizedWithParent(): boolean;
  112416. /** @hidden */
  112417. isSynchronized(): boolean;
  112418. /**
  112419. * Is this node ready to be used/rendered
  112420. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  112421. * @return true if the node is ready
  112422. */
  112423. isReady(completeCheck?: boolean): boolean;
  112424. /**
  112425. * Is this node enabled?
  112426. * 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
  112427. * @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
  112428. * @return whether this node (and its parent) is enabled
  112429. */
  112430. isEnabled(checkAncestors?: boolean): boolean;
  112431. /** @hidden */
  112432. protected _syncParentEnabledState(): void;
  112433. /**
  112434. * Set the enabled state of this node
  112435. * @param value defines the new enabled state
  112436. */
  112437. setEnabled(value: boolean): void;
  112438. /**
  112439. * Is this node a descendant of the given node?
  112440. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  112441. * @param ancestor defines the parent node to inspect
  112442. * @returns a boolean indicating if this node is a descendant of the given node
  112443. */
  112444. isDescendantOf(ancestor: Node): boolean;
  112445. /** @hidden */
  112446. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  112447. /**
  112448. * Will return all nodes that have this node as ascendant
  112449. * @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
  112450. * @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
  112451. * @return all children nodes of all types
  112452. */
  112453. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  112454. /**
  112455. * Get all child-meshes of this node
  112456. * @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)
  112457. * @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
  112458. * @returns an array of AbstractMesh
  112459. */
  112460. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  112461. /**
  112462. * Get all direct children of this node
  112463. * @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
  112464. * @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)
  112465. * @returns an array of Node
  112466. */
  112467. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  112468. /** @hidden */
  112469. _setReady(state: boolean): void;
  112470. /**
  112471. * Get an animation by name
  112472. * @param name defines the name of the animation to look for
  112473. * @returns null if not found else the requested animation
  112474. */
  112475. getAnimationByName(name: string): Nullable<Animation>;
  112476. /**
  112477. * Creates an animation range for this node
  112478. * @param name defines the name of the range
  112479. * @param from defines the starting key
  112480. * @param to defines the end key
  112481. */
  112482. createAnimationRange(name: string, from: number, to: number): void;
  112483. /**
  112484. * Delete a specific animation range
  112485. * @param name defines the name of the range to delete
  112486. * @param deleteFrames defines if animation frames from the range must be deleted as well
  112487. */
  112488. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  112489. /**
  112490. * Get an animation range by name
  112491. * @param name defines the name of the animation range to look for
  112492. * @returns null if not found else the requested animation range
  112493. */
  112494. getAnimationRange(name: string): Nullable<AnimationRange>;
  112495. /**
  112496. * Gets the list of all animation ranges defined on this node
  112497. * @returns an array
  112498. */
  112499. getAnimationRanges(): Nullable<AnimationRange>[];
  112500. /**
  112501. * Will start the animation sequence
  112502. * @param name defines the range frames for animation sequence
  112503. * @param loop defines if the animation should loop (false by default)
  112504. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  112505. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  112506. * @returns the object created for this animation. If range does not exist, it will return null
  112507. */
  112508. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  112509. /**
  112510. * Serialize animation ranges into a JSON compatible object
  112511. * @returns serialization object
  112512. */
  112513. serializeAnimationRanges(): any;
  112514. /**
  112515. * Computes the world matrix of the node
  112516. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  112517. * @returns the world matrix
  112518. */
  112519. computeWorldMatrix(force?: boolean): Matrix;
  112520. /**
  112521. * Releases resources associated with this node.
  112522. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  112523. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  112524. */
  112525. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  112526. /**
  112527. * Parse animation range data from a serialization object and store them into a given node
  112528. * @param node defines where to store the animation ranges
  112529. * @param parsedNode defines the serialization object to read data from
  112530. * @param scene defines the hosting scene
  112531. */
  112532. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  112533. /**
  112534. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  112535. * @param includeDescendants Include bounding info from descendants as well (true by default)
  112536. * @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
  112537. * @returns the new bounding vectors
  112538. */
  112539. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  112540. min: Vector3;
  112541. max: Vector3;
  112542. };
  112543. }
  112544. }
  112545. declare module BABYLON {
  112546. /**
  112547. * @hidden
  112548. */
  112549. export class _IAnimationState {
  112550. key: number;
  112551. repeatCount: number;
  112552. workValue?: any;
  112553. loopMode?: number;
  112554. offsetValue?: any;
  112555. highLimitValue?: any;
  112556. }
  112557. /**
  112558. * Class used to store any kind of animation
  112559. */
  112560. export class Animation {
  112561. /**Name of the animation */
  112562. name: string;
  112563. /**Property to animate */
  112564. targetProperty: string;
  112565. /**The frames per second of the animation */
  112566. framePerSecond: number;
  112567. /**The data type of the animation */
  112568. dataType: number;
  112569. /**The loop mode of the animation */
  112570. loopMode?: number | undefined;
  112571. /**Specifies if blending should be enabled */
  112572. enableBlending?: boolean | undefined;
  112573. /**
  112574. * Use matrix interpolation instead of using direct key value when animating matrices
  112575. */
  112576. static AllowMatricesInterpolation: boolean;
  112577. /**
  112578. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  112579. */
  112580. static AllowMatrixDecomposeForInterpolation: boolean;
  112581. /** Define the Url to load snippets */
  112582. static SnippetUrl: string;
  112583. /** Snippet ID if the animation was created from the snippet server */
  112584. snippetId: string;
  112585. /**
  112586. * Stores the key frames of the animation
  112587. */
  112588. private _keys;
  112589. /**
  112590. * Stores the easing function of the animation
  112591. */
  112592. private _easingFunction;
  112593. /**
  112594. * @hidden Internal use only
  112595. */
  112596. _runtimeAnimations: RuntimeAnimation[];
  112597. /**
  112598. * The set of event that will be linked to this animation
  112599. */
  112600. private _events;
  112601. /**
  112602. * Stores an array of target property paths
  112603. */
  112604. targetPropertyPath: string[];
  112605. /**
  112606. * Stores the blending speed of the animation
  112607. */
  112608. blendingSpeed: number;
  112609. /**
  112610. * Stores the animation ranges for the animation
  112611. */
  112612. private _ranges;
  112613. /**
  112614. * @hidden Internal use
  112615. */
  112616. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  112617. /**
  112618. * Sets up an animation
  112619. * @param property The property to animate
  112620. * @param animationType The animation type to apply
  112621. * @param framePerSecond The frames per second of the animation
  112622. * @param easingFunction The easing function used in the animation
  112623. * @returns The created animation
  112624. */
  112625. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  112626. /**
  112627. * Create and start an animation on a node
  112628. * @param name defines the name of the global animation that will be run on all nodes
  112629. * @param node defines the root node where the animation will take place
  112630. * @param targetProperty defines property to animate
  112631. * @param framePerSecond defines the number of frame per second yo use
  112632. * @param totalFrame defines the number of frames in total
  112633. * @param from defines the initial value
  112634. * @param to defines the final value
  112635. * @param loopMode defines which loop mode you want to use (off by default)
  112636. * @param easingFunction defines the easing function to use (linear by default)
  112637. * @param onAnimationEnd defines the callback to call when animation end
  112638. * @returns the animatable created for this animation
  112639. */
  112640. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  112641. /**
  112642. * Create and start an animation on a node and its descendants
  112643. * @param name defines the name of the global animation that will be run on all nodes
  112644. * @param node defines the root node where the animation will take place
  112645. * @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
  112646. * @param targetProperty defines property to animate
  112647. * @param framePerSecond defines the number of frame per second to use
  112648. * @param totalFrame defines the number of frames in total
  112649. * @param from defines the initial value
  112650. * @param to defines the final value
  112651. * @param loopMode defines which loop mode you want to use (off by default)
  112652. * @param easingFunction defines the easing function to use (linear by default)
  112653. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  112654. * @returns the list of animatables created for all nodes
  112655. * @example https://www.babylonjs-playground.com/#MH0VLI
  112656. */
  112657. 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[]>;
  112658. /**
  112659. * Creates a new animation, merges it with the existing animations and starts it
  112660. * @param name Name of the animation
  112661. * @param node Node which contains the scene that begins the animations
  112662. * @param targetProperty Specifies which property to animate
  112663. * @param framePerSecond The frames per second of the animation
  112664. * @param totalFrame The total number of frames
  112665. * @param from The frame at the beginning of the animation
  112666. * @param to The frame at the end of the animation
  112667. * @param loopMode Specifies the loop mode of the animation
  112668. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  112669. * @param onAnimationEnd Callback to run once the animation is complete
  112670. * @returns Nullable animation
  112671. */
  112672. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  112673. /**
  112674. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  112675. * @param sourceAnimation defines the Animation containing keyframes to convert
  112676. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  112677. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  112678. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  112679. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  112680. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  112681. */
  112682. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  112683. /**
  112684. * Transition property of an host to the target Value
  112685. * @param property The property to transition
  112686. * @param targetValue The target Value of the property
  112687. * @param host The object where the property to animate belongs
  112688. * @param scene Scene used to run the animation
  112689. * @param frameRate Framerate (in frame/s) to use
  112690. * @param transition The transition type we want to use
  112691. * @param duration The duration of the animation, in milliseconds
  112692. * @param onAnimationEnd Callback trigger at the end of the animation
  112693. * @returns Nullable animation
  112694. */
  112695. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  112696. /**
  112697. * Return the array of runtime animations currently using this animation
  112698. */
  112699. get runtimeAnimations(): RuntimeAnimation[];
  112700. /**
  112701. * Specifies if any of the runtime animations are currently running
  112702. */
  112703. get hasRunningRuntimeAnimations(): boolean;
  112704. /**
  112705. * Initializes the animation
  112706. * @param name Name of the animation
  112707. * @param targetProperty Property to animate
  112708. * @param framePerSecond The frames per second of the animation
  112709. * @param dataType The data type of the animation
  112710. * @param loopMode The loop mode of the animation
  112711. * @param enableBlending Specifies if blending should be enabled
  112712. */
  112713. constructor(
  112714. /**Name of the animation */
  112715. name: string,
  112716. /**Property to animate */
  112717. targetProperty: string,
  112718. /**The frames per second of the animation */
  112719. framePerSecond: number,
  112720. /**The data type of the animation */
  112721. dataType: number,
  112722. /**The loop mode of the animation */
  112723. loopMode?: number | undefined,
  112724. /**Specifies if blending should be enabled */
  112725. enableBlending?: boolean | undefined);
  112726. /**
  112727. * Converts the animation to a string
  112728. * @param fullDetails support for multiple levels of logging within scene loading
  112729. * @returns String form of the animation
  112730. */
  112731. toString(fullDetails?: boolean): string;
  112732. /**
  112733. * Add an event to this animation
  112734. * @param event Event to add
  112735. */
  112736. addEvent(event: AnimationEvent): void;
  112737. /**
  112738. * Remove all events found at the given frame
  112739. * @param frame The frame to remove events from
  112740. */
  112741. removeEvents(frame: number): void;
  112742. /**
  112743. * Retrieves all the events from the animation
  112744. * @returns Events from the animation
  112745. */
  112746. getEvents(): AnimationEvent[];
  112747. /**
  112748. * Creates an animation range
  112749. * @param name Name of the animation range
  112750. * @param from Starting frame of the animation range
  112751. * @param to Ending frame of the animation
  112752. */
  112753. createRange(name: string, from: number, to: number): void;
  112754. /**
  112755. * Deletes an animation range by name
  112756. * @param name Name of the animation range to delete
  112757. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  112758. */
  112759. deleteRange(name: string, deleteFrames?: boolean): void;
  112760. /**
  112761. * Gets the animation range by name, or null if not defined
  112762. * @param name Name of the animation range
  112763. * @returns Nullable animation range
  112764. */
  112765. getRange(name: string): Nullable<AnimationRange>;
  112766. /**
  112767. * Gets the key frames from the animation
  112768. * @returns The key frames of the animation
  112769. */
  112770. getKeys(): Array<IAnimationKey>;
  112771. /**
  112772. * Gets the highest frame rate of the animation
  112773. * @returns Highest frame rate of the animation
  112774. */
  112775. getHighestFrame(): number;
  112776. /**
  112777. * Gets the easing function of the animation
  112778. * @returns Easing function of the animation
  112779. */
  112780. getEasingFunction(): IEasingFunction;
  112781. /**
  112782. * Sets the easing function of the animation
  112783. * @param easingFunction A custom mathematical formula for animation
  112784. */
  112785. setEasingFunction(easingFunction: EasingFunction): void;
  112786. /**
  112787. * Interpolates a scalar linearly
  112788. * @param startValue Start value of the animation curve
  112789. * @param endValue End value of the animation curve
  112790. * @param gradient Scalar amount to interpolate
  112791. * @returns Interpolated scalar value
  112792. */
  112793. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  112794. /**
  112795. * Interpolates a scalar cubically
  112796. * @param startValue Start value of the animation curve
  112797. * @param outTangent End tangent of the animation
  112798. * @param endValue End value of the animation curve
  112799. * @param inTangent Start tangent of the animation curve
  112800. * @param gradient Scalar amount to interpolate
  112801. * @returns Interpolated scalar value
  112802. */
  112803. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  112804. /**
  112805. * Interpolates a quaternion using a spherical linear interpolation
  112806. * @param startValue Start value of the animation curve
  112807. * @param endValue End value of the animation curve
  112808. * @param gradient Scalar amount to interpolate
  112809. * @returns Interpolated quaternion value
  112810. */
  112811. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  112812. /**
  112813. * Interpolates a quaternion cubically
  112814. * @param startValue Start value of the animation curve
  112815. * @param outTangent End tangent of the animation curve
  112816. * @param endValue End value of the animation curve
  112817. * @param inTangent Start tangent of the animation curve
  112818. * @param gradient Scalar amount to interpolate
  112819. * @returns Interpolated quaternion value
  112820. */
  112821. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  112822. /**
  112823. * Interpolates a Vector3 linearl
  112824. * @param startValue Start value of the animation curve
  112825. * @param endValue End value of the animation curve
  112826. * @param gradient Scalar amount to interpolate
  112827. * @returns Interpolated scalar value
  112828. */
  112829. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  112830. /**
  112831. * Interpolates a Vector3 cubically
  112832. * @param startValue Start value of the animation curve
  112833. * @param outTangent End tangent of the animation
  112834. * @param endValue End value of the animation curve
  112835. * @param inTangent Start tangent of the animation curve
  112836. * @param gradient Scalar amount to interpolate
  112837. * @returns InterpolatedVector3 value
  112838. */
  112839. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  112840. /**
  112841. * Interpolates a Vector2 linearly
  112842. * @param startValue Start value of the animation curve
  112843. * @param endValue End value of the animation curve
  112844. * @param gradient Scalar amount to interpolate
  112845. * @returns Interpolated Vector2 value
  112846. */
  112847. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  112848. /**
  112849. * Interpolates a Vector2 cubically
  112850. * @param startValue Start value of the animation curve
  112851. * @param outTangent End tangent of the animation
  112852. * @param endValue End value of the animation curve
  112853. * @param inTangent Start tangent of the animation curve
  112854. * @param gradient Scalar amount to interpolate
  112855. * @returns Interpolated Vector2 value
  112856. */
  112857. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  112858. /**
  112859. * Interpolates a size linearly
  112860. * @param startValue Start value of the animation curve
  112861. * @param endValue End value of the animation curve
  112862. * @param gradient Scalar amount to interpolate
  112863. * @returns Interpolated Size value
  112864. */
  112865. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  112866. /**
  112867. * Interpolates a Color3 linearly
  112868. * @param startValue Start value of the animation curve
  112869. * @param endValue End value of the animation curve
  112870. * @param gradient Scalar amount to interpolate
  112871. * @returns Interpolated Color3 value
  112872. */
  112873. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  112874. /**
  112875. * Interpolates a Color4 linearly
  112876. * @param startValue Start value of the animation curve
  112877. * @param endValue End value of the animation curve
  112878. * @param gradient Scalar amount to interpolate
  112879. * @returns Interpolated Color3 value
  112880. */
  112881. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  112882. /**
  112883. * @hidden Internal use only
  112884. */
  112885. _getKeyValue(value: any): any;
  112886. /**
  112887. * @hidden Internal use only
  112888. */
  112889. _interpolate(currentFrame: number, state: _IAnimationState): any;
  112890. /**
  112891. * Defines the function to use to interpolate matrices
  112892. * @param startValue defines the start matrix
  112893. * @param endValue defines the end matrix
  112894. * @param gradient defines the gradient between both matrices
  112895. * @param result defines an optional target matrix where to store the interpolation
  112896. * @returns the interpolated matrix
  112897. */
  112898. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  112899. /**
  112900. * Makes a copy of the animation
  112901. * @returns Cloned animation
  112902. */
  112903. clone(): Animation;
  112904. /**
  112905. * Sets the key frames of the animation
  112906. * @param values The animation key frames to set
  112907. */
  112908. setKeys(values: Array<IAnimationKey>): void;
  112909. /**
  112910. * Serializes the animation to an object
  112911. * @returns Serialized object
  112912. */
  112913. serialize(): any;
  112914. /**
  112915. * Float animation type
  112916. */
  112917. static readonly ANIMATIONTYPE_FLOAT: number;
  112918. /**
  112919. * Vector3 animation type
  112920. */
  112921. static readonly ANIMATIONTYPE_VECTOR3: number;
  112922. /**
  112923. * Quaternion animation type
  112924. */
  112925. static readonly ANIMATIONTYPE_QUATERNION: number;
  112926. /**
  112927. * Matrix animation type
  112928. */
  112929. static readonly ANIMATIONTYPE_MATRIX: number;
  112930. /**
  112931. * Color3 animation type
  112932. */
  112933. static readonly ANIMATIONTYPE_COLOR3: number;
  112934. /**
  112935. * Color3 animation type
  112936. */
  112937. static readonly ANIMATIONTYPE_COLOR4: number;
  112938. /**
  112939. * Vector2 animation type
  112940. */
  112941. static readonly ANIMATIONTYPE_VECTOR2: number;
  112942. /**
  112943. * Size animation type
  112944. */
  112945. static readonly ANIMATIONTYPE_SIZE: number;
  112946. /**
  112947. * Relative Loop Mode
  112948. */
  112949. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  112950. /**
  112951. * Cycle Loop Mode
  112952. */
  112953. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  112954. /**
  112955. * Constant Loop Mode
  112956. */
  112957. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  112958. /** @hidden */
  112959. static _UniversalLerp(left: any, right: any, amount: number): any;
  112960. /**
  112961. * Parses an animation object and creates an animation
  112962. * @param parsedAnimation Parsed animation object
  112963. * @returns Animation object
  112964. */
  112965. static Parse(parsedAnimation: any): Animation;
  112966. /**
  112967. * Appends the serialized animations from the source animations
  112968. * @param source Source containing the animations
  112969. * @param destination Target to store the animations
  112970. */
  112971. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  112972. /**
  112973. * Creates a new animation or an array of animations from a snippet saved in a remote file
  112974. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  112975. * @param url defines the url to load from
  112976. * @returns a promise that will resolve to the new animation or an array of animations
  112977. */
  112978. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  112979. /**
  112980. * Creates an animation or an array of animations from a snippet saved by the Inspector
  112981. * @param snippetId defines the snippet to load
  112982. * @returns a promise that will resolve to the new animation or a new array of animations
  112983. */
  112984. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  112985. }
  112986. }
  112987. declare module BABYLON {
  112988. /**
  112989. * Interface containing an array of animations
  112990. */
  112991. export interface IAnimatable {
  112992. /**
  112993. * Array of animations
  112994. */
  112995. animations: Nullable<Array<Animation>>;
  112996. }
  112997. }
  112998. declare module BABYLON {
  112999. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  113000. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113001. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113002. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113003. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113004. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113005. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113006. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113007. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113008. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113009. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113010. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113011. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113012. /**
  113013. * Decorator used to define property that can be serialized as reference to a camera
  113014. * @param sourceName defines the name of the property to decorate
  113015. */
  113016. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113017. /**
  113018. * Class used to help serialization objects
  113019. */
  113020. export class SerializationHelper {
  113021. /** @hidden */
  113022. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  113023. /** @hidden */
  113024. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  113025. /** @hidden */
  113026. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  113027. /** @hidden */
  113028. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  113029. /**
  113030. * Appends the serialized animations from the source animations
  113031. * @param source Source containing the animations
  113032. * @param destination Target to store the animations
  113033. */
  113034. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  113035. /**
  113036. * Static function used to serialized a specific entity
  113037. * @param entity defines the entity to serialize
  113038. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  113039. * @returns a JSON compatible object representing the serialization of the entity
  113040. */
  113041. static Serialize<T>(entity: T, serializationObject?: any): any;
  113042. /**
  113043. * Creates a new entity from a serialization data object
  113044. * @param creationFunction defines a function used to instanciated the new entity
  113045. * @param source defines the source serialization data
  113046. * @param scene defines the hosting scene
  113047. * @param rootUrl defines the root url for resources
  113048. * @returns a new entity
  113049. */
  113050. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  113051. /**
  113052. * Clones an object
  113053. * @param creationFunction defines the function used to instanciate the new object
  113054. * @param source defines the source object
  113055. * @returns the cloned object
  113056. */
  113057. static Clone<T>(creationFunction: () => T, source: T): T;
  113058. /**
  113059. * Instanciates a new object based on a source one (some data will be shared between both object)
  113060. * @param creationFunction defines the function used to instanciate the new object
  113061. * @param source defines the source object
  113062. * @returns the new object
  113063. */
  113064. static Instanciate<T>(creationFunction: () => T, source: T): T;
  113065. }
  113066. }
  113067. declare module BABYLON {
  113068. /**
  113069. * Base class of all the textures in babylon.
  113070. * It groups all the common properties the materials, post process, lights... might need
  113071. * in order to make a correct use of the texture.
  113072. */
  113073. export class BaseTexture implements IAnimatable {
  113074. /**
  113075. * Default anisotropic filtering level for the application.
  113076. * It is set to 4 as a good tradeoff between perf and quality.
  113077. */
  113078. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  113079. /**
  113080. * Gets or sets the unique id of the texture
  113081. */
  113082. uniqueId: number;
  113083. /**
  113084. * Define the name of the texture.
  113085. */
  113086. name: string;
  113087. /**
  113088. * Gets or sets an object used to store user defined information.
  113089. */
  113090. metadata: any;
  113091. /**
  113092. * For internal use only. Please do not use.
  113093. */
  113094. reservedDataStore: any;
  113095. private _hasAlpha;
  113096. /**
  113097. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  113098. */
  113099. set hasAlpha(value: boolean);
  113100. get hasAlpha(): boolean;
  113101. /**
  113102. * Defines if the alpha value should be determined via the rgb values.
  113103. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  113104. */
  113105. getAlphaFromRGB: boolean;
  113106. /**
  113107. * Intensity or strength of the texture.
  113108. * It is commonly used by materials to fine tune the intensity of the texture
  113109. */
  113110. level: number;
  113111. /**
  113112. * Define the UV chanel to use starting from 0 and defaulting to 0.
  113113. * This is part of the texture as textures usually maps to one uv set.
  113114. */
  113115. coordinatesIndex: number;
  113116. private _coordinatesMode;
  113117. /**
  113118. * How a texture is mapped.
  113119. *
  113120. * | Value | Type | Description |
  113121. * | ----- | ----------------------------------- | ----------- |
  113122. * | 0 | EXPLICIT_MODE | |
  113123. * | 1 | SPHERICAL_MODE | |
  113124. * | 2 | PLANAR_MODE | |
  113125. * | 3 | CUBIC_MODE | |
  113126. * | 4 | PROJECTION_MODE | |
  113127. * | 5 | SKYBOX_MODE | |
  113128. * | 6 | INVCUBIC_MODE | |
  113129. * | 7 | EQUIRECTANGULAR_MODE | |
  113130. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  113131. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  113132. */
  113133. set coordinatesMode(value: number);
  113134. get coordinatesMode(): number;
  113135. /**
  113136. * | Value | Type | Description |
  113137. * | ----- | ------------------ | ----------- |
  113138. * | 0 | CLAMP_ADDRESSMODE | |
  113139. * | 1 | WRAP_ADDRESSMODE | |
  113140. * | 2 | MIRROR_ADDRESSMODE | |
  113141. */
  113142. wrapU: number;
  113143. /**
  113144. * | Value | Type | Description |
  113145. * | ----- | ------------------ | ----------- |
  113146. * | 0 | CLAMP_ADDRESSMODE | |
  113147. * | 1 | WRAP_ADDRESSMODE | |
  113148. * | 2 | MIRROR_ADDRESSMODE | |
  113149. */
  113150. wrapV: number;
  113151. /**
  113152. * | Value | Type | Description |
  113153. * | ----- | ------------------ | ----------- |
  113154. * | 0 | CLAMP_ADDRESSMODE | |
  113155. * | 1 | WRAP_ADDRESSMODE | |
  113156. * | 2 | MIRROR_ADDRESSMODE | |
  113157. */
  113158. wrapR: number;
  113159. /**
  113160. * With compliant hardware and browser (supporting anisotropic filtering)
  113161. * this defines the level of anisotropic filtering in the texture.
  113162. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  113163. */
  113164. anisotropicFilteringLevel: number;
  113165. /**
  113166. * Define if the texture is a cube texture or if false a 2d texture.
  113167. */
  113168. get isCube(): boolean;
  113169. set isCube(value: boolean);
  113170. /**
  113171. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  113172. */
  113173. get is3D(): boolean;
  113174. set is3D(value: boolean);
  113175. /**
  113176. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  113177. */
  113178. get is2DArray(): boolean;
  113179. set is2DArray(value: boolean);
  113180. /**
  113181. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  113182. * HDR texture are usually stored in linear space.
  113183. * This only impacts the PBR and Background materials
  113184. */
  113185. gammaSpace: boolean;
  113186. /**
  113187. * Gets or sets whether or not the texture contains RGBD data.
  113188. */
  113189. get isRGBD(): boolean;
  113190. set isRGBD(value: boolean);
  113191. /**
  113192. * Is Z inverted in the texture (useful in a cube texture).
  113193. */
  113194. invertZ: boolean;
  113195. /**
  113196. * Are mip maps generated for this texture or not.
  113197. */
  113198. get noMipmap(): boolean;
  113199. /**
  113200. * @hidden
  113201. */
  113202. lodLevelInAlpha: boolean;
  113203. /**
  113204. * With prefiltered texture, defined the offset used during the prefiltering steps.
  113205. */
  113206. get lodGenerationOffset(): number;
  113207. set lodGenerationOffset(value: number);
  113208. /**
  113209. * With prefiltered texture, defined the scale used during the prefiltering steps.
  113210. */
  113211. get lodGenerationScale(): number;
  113212. set lodGenerationScale(value: number);
  113213. /**
  113214. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  113215. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  113216. * average roughness values.
  113217. */
  113218. get linearSpecularLOD(): boolean;
  113219. set linearSpecularLOD(value: boolean);
  113220. /**
  113221. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  113222. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  113223. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  113224. */
  113225. get irradianceTexture(): Nullable<BaseTexture>;
  113226. set irradianceTexture(value: Nullable<BaseTexture>);
  113227. /**
  113228. * Define if the texture is a render target.
  113229. */
  113230. isRenderTarget: boolean;
  113231. /**
  113232. * Define the unique id of the texture in the scene.
  113233. */
  113234. get uid(): string;
  113235. /** @hidden */
  113236. _prefiltered: boolean;
  113237. /**
  113238. * Return a string representation of the texture.
  113239. * @returns the texture as a string
  113240. */
  113241. toString(): string;
  113242. /**
  113243. * Get the class name of the texture.
  113244. * @returns "BaseTexture"
  113245. */
  113246. getClassName(): string;
  113247. /**
  113248. * Define the list of animation attached to the texture.
  113249. */
  113250. animations: Animation[];
  113251. /**
  113252. * An event triggered when the texture is disposed.
  113253. */
  113254. onDisposeObservable: Observable<BaseTexture>;
  113255. private _onDisposeObserver;
  113256. /**
  113257. * Callback triggered when the texture has been disposed.
  113258. * Kept for back compatibility, you can use the onDisposeObservable instead.
  113259. */
  113260. set onDispose(callback: () => void);
  113261. /**
  113262. * Define the current state of the loading sequence when in delayed load mode.
  113263. */
  113264. delayLoadState: number;
  113265. protected _scene: Nullable<Scene>;
  113266. protected _engine: Nullable<ThinEngine>;
  113267. /** @hidden */
  113268. _texture: Nullable<InternalTexture>;
  113269. private _uid;
  113270. /**
  113271. * Define if the texture is preventinga material to render or not.
  113272. * If not and the texture is not ready, the engine will use a default black texture instead.
  113273. */
  113274. get isBlocking(): boolean;
  113275. /**
  113276. * Instantiates a new BaseTexture.
  113277. * Base class of all the textures in babylon.
  113278. * It groups all the common properties the materials, post process, lights... might need
  113279. * in order to make a correct use of the texture.
  113280. * @param sceneOrEngine Define the scene or engine the texture blongs to
  113281. */
  113282. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  113283. /**
  113284. * Get the scene the texture belongs to.
  113285. * @returns the scene or null if undefined
  113286. */
  113287. getScene(): Nullable<Scene>;
  113288. /** @hidden */
  113289. protected _getEngine(): Nullable<ThinEngine>;
  113290. /**
  113291. * Get the texture transform matrix used to offset tile the texture for istance.
  113292. * @returns the transformation matrix
  113293. */
  113294. getTextureMatrix(): Matrix;
  113295. /**
  113296. * Get the texture reflection matrix used to rotate/transform the reflection.
  113297. * @returns the reflection matrix
  113298. */
  113299. getReflectionTextureMatrix(): Matrix;
  113300. /**
  113301. * Get the underlying lower level texture from Babylon.
  113302. * @returns the insternal texture
  113303. */
  113304. getInternalTexture(): Nullable<InternalTexture>;
  113305. /**
  113306. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  113307. * @returns true if ready or not blocking
  113308. */
  113309. isReadyOrNotBlocking(): boolean;
  113310. /**
  113311. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  113312. * @returns true if fully ready
  113313. */
  113314. isReady(): boolean;
  113315. private _cachedSize;
  113316. /**
  113317. * Get the size of the texture.
  113318. * @returns the texture size.
  113319. */
  113320. getSize(): ISize;
  113321. /**
  113322. * Get the base size of the texture.
  113323. * It can be different from the size if the texture has been resized for POT for instance
  113324. * @returns the base size
  113325. */
  113326. getBaseSize(): ISize;
  113327. /**
  113328. * Update the sampling mode of the texture.
  113329. * Default is Trilinear mode.
  113330. *
  113331. * | Value | Type | Description |
  113332. * | ----- | ------------------ | ----------- |
  113333. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  113334. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  113335. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  113336. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  113337. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  113338. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  113339. * | 7 | NEAREST_LINEAR | |
  113340. * | 8 | NEAREST_NEAREST | |
  113341. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  113342. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  113343. * | 11 | LINEAR_LINEAR | |
  113344. * | 12 | LINEAR_NEAREST | |
  113345. *
  113346. * > _mag_: magnification filter (close to the viewer)
  113347. * > _min_: minification filter (far from the viewer)
  113348. * > _mip_: filter used between mip map levels
  113349. *@param samplingMode Define the new sampling mode of the texture
  113350. */
  113351. updateSamplingMode(samplingMode: number): void;
  113352. /**
  113353. * Scales the texture if is `canRescale()`
  113354. * @param ratio the resize factor we want to use to rescale
  113355. */
  113356. scale(ratio: number): void;
  113357. /**
  113358. * Get if the texture can rescale.
  113359. */
  113360. get canRescale(): boolean;
  113361. /** @hidden */
  113362. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  113363. /** @hidden */
  113364. _rebuild(): void;
  113365. /**
  113366. * Triggers the load sequence in delayed load mode.
  113367. */
  113368. delayLoad(): void;
  113369. /**
  113370. * Clones the texture.
  113371. * @returns the cloned texture
  113372. */
  113373. clone(): Nullable<BaseTexture>;
  113374. /**
  113375. * Get the texture underlying type (INT, FLOAT...)
  113376. */
  113377. get textureType(): number;
  113378. /**
  113379. * Get the texture underlying format (RGB, RGBA...)
  113380. */
  113381. get textureFormat(): number;
  113382. /**
  113383. * Indicates that textures need to be re-calculated for all materials
  113384. */
  113385. protected _markAllSubMeshesAsTexturesDirty(): void;
  113386. /**
  113387. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  113388. * This will returns an RGBA array buffer containing either in values (0-255) or
  113389. * float values (0-1) depending of the underlying buffer type.
  113390. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  113391. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  113392. * @param buffer defines a user defined buffer to fill with data (can be null)
  113393. * @returns The Array buffer containing the pixels data.
  113394. */
  113395. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  113396. /**
  113397. * Release and destroy the underlying lower level texture aka internalTexture.
  113398. */
  113399. releaseInternalTexture(): void;
  113400. /** @hidden */
  113401. get _lodTextureHigh(): Nullable<BaseTexture>;
  113402. /** @hidden */
  113403. get _lodTextureMid(): Nullable<BaseTexture>;
  113404. /** @hidden */
  113405. get _lodTextureLow(): Nullable<BaseTexture>;
  113406. /**
  113407. * Dispose the texture and release its associated resources.
  113408. */
  113409. dispose(): void;
  113410. /**
  113411. * Serialize the texture into a JSON representation that can be parsed later on.
  113412. * @returns the JSON representation of the texture
  113413. */
  113414. serialize(): any;
  113415. /**
  113416. * Helper function to be called back once a list of texture contains only ready textures.
  113417. * @param textures Define the list of textures to wait for
  113418. * @param callback Define the callback triggered once the entire list will be ready
  113419. */
  113420. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  113421. private static _isScene;
  113422. }
  113423. }
  113424. declare module BABYLON {
  113425. /**
  113426. * Options to be used when creating an effect.
  113427. */
  113428. export interface IEffectCreationOptions {
  113429. /**
  113430. * Atrributes that will be used in the shader.
  113431. */
  113432. attributes: string[];
  113433. /**
  113434. * Uniform varible names that will be set in the shader.
  113435. */
  113436. uniformsNames: string[];
  113437. /**
  113438. * Uniform buffer variable names that will be set in the shader.
  113439. */
  113440. uniformBuffersNames: string[];
  113441. /**
  113442. * Sampler texture variable names that will be set in the shader.
  113443. */
  113444. samplers: string[];
  113445. /**
  113446. * Define statements that will be set in the shader.
  113447. */
  113448. defines: any;
  113449. /**
  113450. * Possible fallbacks for this effect to improve performance when needed.
  113451. */
  113452. fallbacks: Nullable<IEffectFallbacks>;
  113453. /**
  113454. * Callback that will be called when the shader is compiled.
  113455. */
  113456. onCompiled: Nullable<(effect: Effect) => void>;
  113457. /**
  113458. * Callback that will be called if an error occurs during shader compilation.
  113459. */
  113460. onError: Nullable<(effect: Effect, errors: string) => void>;
  113461. /**
  113462. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  113463. */
  113464. indexParameters?: any;
  113465. /**
  113466. * Max number of lights that can be used in the shader.
  113467. */
  113468. maxSimultaneousLights?: number;
  113469. /**
  113470. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  113471. */
  113472. transformFeedbackVaryings?: Nullable<string[]>;
  113473. /**
  113474. * 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
  113475. */
  113476. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  113477. /**
  113478. * Is this effect rendering to several color attachments ?
  113479. */
  113480. multiTarget?: boolean;
  113481. }
  113482. /**
  113483. * Effect containing vertex and fragment shader that can be executed on an object.
  113484. */
  113485. export class Effect implements IDisposable {
  113486. /**
  113487. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  113488. */
  113489. static ShadersRepository: string;
  113490. /**
  113491. * Enable logging of the shader code when a compilation error occurs
  113492. */
  113493. static LogShaderCodeOnCompilationError: boolean;
  113494. /**
  113495. * Name of the effect.
  113496. */
  113497. name: any;
  113498. /**
  113499. * String container all the define statements that should be set on the shader.
  113500. */
  113501. defines: string;
  113502. /**
  113503. * Callback that will be called when the shader is compiled.
  113504. */
  113505. onCompiled: Nullable<(effect: Effect) => void>;
  113506. /**
  113507. * Callback that will be called if an error occurs during shader compilation.
  113508. */
  113509. onError: Nullable<(effect: Effect, errors: string) => void>;
  113510. /**
  113511. * Callback that will be called when effect is bound.
  113512. */
  113513. onBind: Nullable<(effect: Effect) => void>;
  113514. /**
  113515. * Unique ID of the effect.
  113516. */
  113517. uniqueId: number;
  113518. /**
  113519. * Observable that will be called when the shader is compiled.
  113520. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  113521. */
  113522. onCompileObservable: Observable<Effect>;
  113523. /**
  113524. * Observable that will be called if an error occurs during shader compilation.
  113525. */
  113526. onErrorObservable: Observable<Effect>;
  113527. /** @hidden */
  113528. _onBindObservable: Nullable<Observable<Effect>>;
  113529. /**
  113530. * @hidden
  113531. * Specifies if the effect was previously ready
  113532. */
  113533. _wasPreviouslyReady: boolean;
  113534. /**
  113535. * Observable that will be called when effect is bound.
  113536. */
  113537. get onBindObservable(): Observable<Effect>;
  113538. /** @hidden */
  113539. _bonesComputationForcedToCPU: boolean;
  113540. /** @hidden */
  113541. _multiTarget: boolean;
  113542. private static _uniqueIdSeed;
  113543. private _engine;
  113544. private _uniformBuffersNames;
  113545. private _uniformBuffersNamesList;
  113546. private _uniformsNames;
  113547. private _samplerList;
  113548. private _samplers;
  113549. private _isReady;
  113550. private _compilationError;
  113551. private _allFallbacksProcessed;
  113552. private _attributesNames;
  113553. private _attributes;
  113554. private _attributeLocationByName;
  113555. private _uniforms;
  113556. /**
  113557. * Key for the effect.
  113558. * @hidden
  113559. */
  113560. _key: string;
  113561. private _indexParameters;
  113562. private _fallbacks;
  113563. private _vertexSourceCode;
  113564. private _fragmentSourceCode;
  113565. private _vertexSourceCodeOverride;
  113566. private _fragmentSourceCodeOverride;
  113567. private _transformFeedbackVaryings;
  113568. /**
  113569. * Compiled shader to webGL program.
  113570. * @hidden
  113571. */
  113572. _pipelineContext: Nullable<IPipelineContext>;
  113573. private _valueCache;
  113574. private static _baseCache;
  113575. /**
  113576. * Instantiates an effect.
  113577. * An effect can be used to create/manage/execute vertex and fragment shaders.
  113578. * @param baseName Name of the effect.
  113579. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  113580. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  113581. * @param samplers List of sampler variables that will be passed to the shader.
  113582. * @param engine Engine to be used to render the effect
  113583. * @param defines Define statements to be added to the shader.
  113584. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  113585. * @param onCompiled Callback that will be called when the shader is compiled.
  113586. * @param onError Callback that will be called if an error occurs during shader compilation.
  113587. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  113588. */
  113589. 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);
  113590. private _useFinalCode;
  113591. /**
  113592. * Unique key for this effect
  113593. */
  113594. get key(): string;
  113595. /**
  113596. * If the effect has been compiled and prepared.
  113597. * @returns if the effect is compiled and prepared.
  113598. */
  113599. isReady(): boolean;
  113600. private _isReadyInternal;
  113601. /**
  113602. * The engine the effect was initialized with.
  113603. * @returns the engine.
  113604. */
  113605. getEngine(): Engine;
  113606. /**
  113607. * The pipeline context for this effect
  113608. * @returns the associated pipeline context
  113609. */
  113610. getPipelineContext(): Nullable<IPipelineContext>;
  113611. /**
  113612. * The set of names of attribute variables for the shader.
  113613. * @returns An array of attribute names.
  113614. */
  113615. getAttributesNames(): string[];
  113616. /**
  113617. * Returns the attribute at the given index.
  113618. * @param index The index of the attribute.
  113619. * @returns The location of the attribute.
  113620. */
  113621. getAttributeLocation(index: number): number;
  113622. /**
  113623. * Returns the attribute based on the name of the variable.
  113624. * @param name of the attribute to look up.
  113625. * @returns the attribute location.
  113626. */
  113627. getAttributeLocationByName(name: string): number;
  113628. /**
  113629. * The number of attributes.
  113630. * @returns the numnber of attributes.
  113631. */
  113632. getAttributesCount(): number;
  113633. /**
  113634. * Gets the index of a uniform variable.
  113635. * @param uniformName of the uniform to look up.
  113636. * @returns the index.
  113637. */
  113638. getUniformIndex(uniformName: string): number;
  113639. /**
  113640. * Returns the attribute based on the name of the variable.
  113641. * @param uniformName of the uniform to look up.
  113642. * @returns the location of the uniform.
  113643. */
  113644. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  113645. /**
  113646. * Returns an array of sampler variable names
  113647. * @returns The array of sampler variable names.
  113648. */
  113649. getSamplers(): string[];
  113650. /**
  113651. * Returns an array of uniform variable names
  113652. * @returns The array of uniform variable names.
  113653. */
  113654. getUniformNames(): string[];
  113655. /**
  113656. * Returns an array of uniform buffer variable names
  113657. * @returns The array of uniform buffer variable names.
  113658. */
  113659. getUniformBuffersNames(): string[];
  113660. /**
  113661. * Returns the index parameters used to create the effect
  113662. * @returns The index parameters object
  113663. */
  113664. getIndexParameters(): any;
  113665. /**
  113666. * The error from the last compilation.
  113667. * @returns the error string.
  113668. */
  113669. getCompilationError(): string;
  113670. /**
  113671. * Gets a boolean indicating that all fallbacks were used during compilation
  113672. * @returns true if all fallbacks were used
  113673. */
  113674. allFallbacksProcessed(): boolean;
  113675. /**
  113676. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  113677. * @param func The callback to be used.
  113678. */
  113679. executeWhenCompiled(func: (effect: Effect) => void): void;
  113680. private _checkIsReady;
  113681. private _loadShader;
  113682. /**
  113683. * Gets the vertex shader source code of this effect
  113684. */
  113685. get vertexSourceCode(): string;
  113686. /**
  113687. * Gets the fragment shader source code of this effect
  113688. */
  113689. get fragmentSourceCode(): string;
  113690. /**
  113691. * Recompiles the webGL program
  113692. * @param vertexSourceCode The source code for the vertex shader.
  113693. * @param fragmentSourceCode The source code for the fragment shader.
  113694. * @param onCompiled Callback called when completed.
  113695. * @param onError Callback called on error.
  113696. * @hidden
  113697. */
  113698. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  113699. /**
  113700. * Prepares the effect
  113701. * @hidden
  113702. */
  113703. _prepareEffect(): void;
  113704. private _getShaderCodeAndErrorLine;
  113705. private _processCompilationErrors;
  113706. /**
  113707. * Checks if the effect is supported. (Must be called after compilation)
  113708. */
  113709. get isSupported(): boolean;
  113710. /**
  113711. * Binds a texture to the engine to be used as output of the shader.
  113712. * @param channel Name of the output variable.
  113713. * @param texture Texture to bind.
  113714. * @hidden
  113715. */
  113716. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  113717. /**
  113718. * Sets a texture on the engine to be used in the shader.
  113719. * @param channel Name of the sampler variable.
  113720. * @param texture Texture to set.
  113721. */
  113722. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  113723. /**
  113724. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  113725. * @param channel Name of the sampler variable.
  113726. * @param texture Texture to set.
  113727. */
  113728. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  113729. /**
  113730. * Sets an array of textures on the engine to be used in the shader.
  113731. * @param channel Name of the variable.
  113732. * @param textures Textures to set.
  113733. */
  113734. setTextureArray(channel: string, textures: BaseTexture[]): void;
  113735. /**
  113736. * 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)
  113737. * @param channel Name of the sampler variable.
  113738. * @param postProcess Post process to get the input texture from.
  113739. */
  113740. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  113741. /**
  113742. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  113743. * 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)
  113744. * @param channel Name of the sampler variable.
  113745. * @param postProcess Post process to get the output texture from.
  113746. */
  113747. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  113748. /** @hidden */
  113749. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  113750. /** @hidden */
  113751. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  113752. /** @hidden */
  113753. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  113754. /** @hidden */
  113755. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  113756. /**
  113757. * Binds a buffer to a uniform.
  113758. * @param buffer Buffer to bind.
  113759. * @param name Name of the uniform variable to bind to.
  113760. */
  113761. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  113762. /**
  113763. * Binds block to a uniform.
  113764. * @param blockName Name of the block to bind.
  113765. * @param index Index to bind.
  113766. */
  113767. bindUniformBlock(blockName: string, index: number): void;
  113768. /**
  113769. * Sets an interger value on a uniform variable.
  113770. * @param uniformName Name of the variable.
  113771. * @param value Value to be set.
  113772. * @returns this effect.
  113773. */
  113774. setInt(uniformName: string, value: number): Effect;
  113775. /**
  113776. * Sets an int array on a uniform variable.
  113777. * @param uniformName Name of the variable.
  113778. * @param array array to be set.
  113779. * @returns this effect.
  113780. */
  113781. setIntArray(uniformName: string, array: Int32Array): Effect;
  113782. /**
  113783. * 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)
  113784. * @param uniformName Name of the variable.
  113785. * @param array array to be set.
  113786. * @returns this effect.
  113787. */
  113788. setIntArray2(uniformName: string, array: Int32Array): Effect;
  113789. /**
  113790. * 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)
  113791. * @param uniformName Name of the variable.
  113792. * @param array array to be set.
  113793. * @returns this effect.
  113794. */
  113795. setIntArray3(uniformName: string, array: Int32Array): Effect;
  113796. /**
  113797. * 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)
  113798. * @param uniformName Name of the variable.
  113799. * @param array array to be set.
  113800. * @returns this effect.
  113801. */
  113802. setIntArray4(uniformName: string, array: Int32Array): Effect;
  113803. /**
  113804. * Sets an float array on a uniform variable.
  113805. * @param uniformName Name of the variable.
  113806. * @param array array to be set.
  113807. * @returns this effect.
  113808. */
  113809. setFloatArray(uniformName: string, array: Float32Array): Effect;
  113810. /**
  113811. * 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)
  113812. * @param uniformName Name of the variable.
  113813. * @param array array to be set.
  113814. * @returns this effect.
  113815. */
  113816. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  113817. /**
  113818. * 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)
  113819. * @param uniformName Name of the variable.
  113820. * @param array array to be set.
  113821. * @returns this effect.
  113822. */
  113823. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  113824. /**
  113825. * 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)
  113826. * @param uniformName Name of the variable.
  113827. * @param array array to be set.
  113828. * @returns this effect.
  113829. */
  113830. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  113831. /**
  113832. * Sets an array on a uniform variable.
  113833. * @param uniformName Name of the variable.
  113834. * @param array array to be set.
  113835. * @returns this effect.
  113836. */
  113837. setArray(uniformName: string, array: number[]): Effect;
  113838. /**
  113839. * 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)
  113840. * @param uniformName Name of the variable.
  113841. * @param array array to be set.
  113842. * @returns this effect.
  113843. */
  113844. setArray2(uniformName: string, array: number[]): Effect;
  113845. /**
  113846. * 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)
  113847. * @param uniformName Name of the variable.
  113848. * @param array array to be set.
  113849. * @returns this effect.
  113850. */
  113851. setArray3(uniformName: string, array: number[]): Effect;
  113852. /**
  113853. * 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)
  113854. * @param uniformName Name of the variable.
  113855. * @param array array to be set.
  113856. * @returns this effect.
  113857. */
  113858. setArray4(uniformName: string, array: number[]): Effect;
  113859. /**
  113860. * Sets matrices on a uniform variable.
  113861. * @param uniformName Name of the variable.
  113862. * @param matrices matrices to be set.
  113863. * @returns this effect.
  113864. */
  113865. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  113866. /**
  113867. * Sets matrix on a uniform variable.
  113868. * @param uniformName Name of the variable.
  113869. * @param matrix matrix to be set.
  113870. * @returns this effect.
  113871. */
  113872. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  113873. /**
  113874. * 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)
  113875. * @param uniformName Name of the variable.
  113876. * @param matrix matrix to be set.
  113877. * @returns this effect.
  113878. */
  113879. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  113880. /**
  113881. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  113882. * @param uniformName Name of the variable.
  113883. * @param matrix matrix to be set.
  113884. * @returns this effect.
  113885. */
  113886. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  113887. /**
  113888. * Sets a float on a uniform variable.
  113889. * @param uniformName Name of the variable.
  113890. * @param value value to be set.
  113891. * @returns this effect.
  113892. */
  113893. setFloat(uniformName: string, value: number): Effect;
  113894. /**
  113895. * Sets a boolean on a uniform variable.
  113896. * @param uniformName Name of the variable.
  113897. * @param bool value to be set.
  113898. * @returns this effect.
  113899. */
  113900. setBool(uniformName: string, bool: boolean): Effect;
  113901. /**
  113902. * Sets a Vector2 on a uniform variable.
  113903. * @param uniformName Name of the variable.
  113904. * @param vector2 vector2 to be set.
  113905. * @returns this effect.
  113906. */
  113907. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  113908. /**
  113909. * Sets a float2 on a uniform variable.
  113910. * @param uniformName Name of the variable.
  113911. * @param x First float in float2.
  113912. * @param y Second float in float2.
  113913. * @returns this effect.
  113914. */
  113915. setFloat2(uniformName: string, x: number, y: number): Effect;
  113916. /**
  113917. * Sets a Vector3 on a uniform variable.
  113918. * @param uniformName Name of the variable.
  113919. * @param vector3 Value to be set.
  113920. * @returns this effect.
  113921. */
  113922. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  113923. /**
  113924. * Sets a float3 on a uniform variable.
  113925. * @param uniformName Name of the variable.
  113926. * @param x First float in float3.
  113927. * @param y Second float in float3.
  113928. * @param z Third float in float3.
  113929. * @returns this effect.
  113930. */
  113931. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  113932. /**
  113933. * Sets a Vector4 on a uniform variable.
  113934. * @param uniformName Name of the variable.
  113935. * @param vector4 Value to be set.
  113936. * @returns this effect.
  113937. */
  113938. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  113939. /**
  113940. * Sets a float4 on a uniform variable.
  113941. * @param uniformName Name of the variable.
  113942. * @param x First float in float4.
  113943. * @param y Second float in float4.
  113944. * @param z Third float in float4.
  113945. * @param w Fourth float in float4.
  113946. * @returns this effect.
  113947. */
  113948. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  113949. /**
  113950. * Sets a Color3 on a uniform variable.
  113951. * @param uniformName Name of the variable.
  113952. * @param color3 Value to be set.
  113953. * @returns this effect.
  113954. */
  113955. setColor3(uniformName: string, color3: IColor3Like): Effect;
  113956. /**
  113957. * Sets a Color4 on a uniform variable.
  113958. * @param uniformName Name of the variable.
  113959. * @param color3 Value to be set.
  113960. * @param alpha Alpha value to be set.
  113961. * @returns this effect.
  113962. */
  113963. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  113964. /**
  113965. * Sets a Color4 on a uniform variable
  113966. * @param uniformName defines the name of the variable
  113967. * @param color4 defines the value to be set
  113968. * @returns this effect.
  113969. */
  113970. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  113971. /** Release all associated resources */
  113972. dispose(): void;
  113973. /**
  113974. * This function will add a new shader to the shader store
  113975. * @param name the name of the shader
  113976. * @param pixelShader optional pixel shader content
  113977. * @param vertexShader optional vertex shader content
  113978. */
  113979. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  113980. /**
  113981. * Store of each shader (The can be looked up using effect.key)
  113982. */
  113983. static ShadersStore: {
  113984. [key: string]: string;
  113985. };
  113986. /**
  113987. * Store of each included file for a shader (The can be looked up using effect.key)
  113988. */
  113989. static IncludesShadersStore: {
  113990. [key: string]: string;
  113991. };
  113992. /**
  113993. * Resets the cache of effects.
  113994. */
  113995. static ResetCache(): void;
  113996. }
  113997. }
  113998. declare module BABYLON {
  113999. /**
  114000. * Interface used to describe the capabilities of the engine relatively to the current browser
  114001. */
  114002. export interface EngineCapabilities {
  114003. /** Maximum textures units per fragment shader */
  114004. maxTexturesImageUnits: number;
  114005. /** Maximum texture units per vertex shader */
  114006. maxVertexTextureImageUnits: number;
  114007. /** Maximum textures units in the entire pipeline */
  114008. maxCombinedTexturesImageUnits: number;
  114009. /** Maximum texture size */
  114010. maxTextureSize: number;
  114011. /** Maximum texture samples */
  114012. maxSamples?: number;
  114013. /** Maximum cube texture size */
  114014. maxCubemapTextureSize: number;
  114015. /** Maximum render texture size */
  114016. maxRenderTextureSize: number;
  114017. /** Maximum number of vertex attributes */
  114018. maxVertexAttribs: number;
  114019. /** Maximum number of varyings */
  114020. maxVaryingVectors: number;
  114021. /** Maximum number of uniforms per vertex shader */
  114022. maxVertexUniformVectors: number;
  114023. /** Maximum number of uniforms per fragment shader */
  114024. maxFragmentUniformVectors: number;
  114025. /** Defines if standard derivates (dx/dy) are supported */
  114026. standardDerivatives: boolean;
  114027. /** Defines if s3tc texture compression is supported */
  114028. s3tc?: WEBGL_compressed_texture_s3tc;
  114029. /** Defines if pvrtc texture compression is supported */
  114030. pvrtc: any;
  114031. /** Defines if etc1 texture compression is supported */
  114032. etc1: any;
  114033. /** Defines if etc2 texture compression is supported */
  114034. etc2: any;
  114035. /** Defines if astc texture compression is supported */
  114036. astc: any;
  114037. /** Defines if float textures are supported */
  114038. textureFloat: boolean;
  114039. /** Defines if vertex array objects are supported */
  114040. vertexArrayObject: boolean;
  114041. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  114042. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  114043. /** Gets the maximum level of anisotropy supported */
  114044. maxAnisotropy: number;
  114045. /** Defines if instancing is supported */
  114046. instancedArrays: boolean;
  114047. /** Defines if 32 bits indices are supported */
  114048. uintIndices: boolean;
  114049. /** Defines if high precision shaders are supported */
  114050. highPrecisionShaderSupported: boolean;
  114051. /** Defines if depth reading in the fragment shader is supported */
  114052. fragmentDepthSupported: boolean;
  114053. /** Defines if float texture linear filtering is supported*/
  114054. textureFloatLinearFiltering: boolean;
  114055. /** Defines if rendering to float textures is supported */
  114056. textureFloatRender: boolean;
  114057. /** Defines if half float textures are supported*/
  114058. textureHalfFloat: boolean;
  114059. /** Defines if half float texture linear filtering is supported*/
  114060. textureHalfFloatLinearFiltering: boolean;
  114061. /** Defines if rendering to half float textures is supported */
  114062. textureHalfFloatRender: boolean;
  114063. /** Defines if textureLOD shader command is supported */
  114064. textureLOD: boolean;
  114065. /** Defines if draw buffers extension is supported */
  114066. drawBuffersExtension: boolean;
  114067. /** Defines if depth textures are supported */
  114068. depthTextureExtension: boolean;
  114069. /** Defines if float color buffer are supported */
  114070. colorBufferFloat: boolean;
  114071. /** Gets disjoint timer query extension (null if not supported) */
  114072. timerQuery?: EXT_disjoint_timer_query;
  114073. /** Defines if timestamp can be used with timer query */
  114074. canUseTimestampForTimerQuery: boolean;
  114075. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  114076. multiview?: any;
  114077. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  114078. oculusMultiview?: any;
  114079. /** Function used to let the system compiles shaders in background */
  114080. parallelShaderCompile?: {
  114081. COMPLETION_STATUS_KHR: number;
  114082. };
  114083. /** Max number of texture samples for MSAA */
  114084. maxMSAASamples: number;
  114085. /** Defines if the blend min max extension is supported */
  114086. blendMinMax: boolean;
  114087. }
  114088. }
  114089. declare module BABYLON {
  114090. /**
  114091. * @hidden
  114092. **/
  114093. export class DepthCullingState {
  114094. private _isDepthTestDirty;
  114095. private _isDepthMaskDirty;
  114096. private _isDepthFuncDirty;
  114097. private _isCullFaceDirty;
  114098. private _isCullDirty;
  114099. private _isZOffsetDirty;
  114100. private _isFrontFaceDirty;
  114101. private _depthTest;
  114102. private _depthMask;
  114103. private _depthFunc;
  114104. private _cull;
  114105. private _cullFace;
  114106. private _zOffset;
  114107. private _frontFace;
  114108. /**
  114109. * Initializes the state.
  114110. */
  114111. constructor();
  114112. get isDirty(): boolean;
  114113. get zOffset(): number;
  114114. set zOffset(value: number);
  114115. get cullFace(): Nullable<number>;
  114116. set cullFace(value: Nullable<number>);
  114117. get cull(): Nullable<boolean>;
  114118. set cull(value: Nullable<boolean>);
  114119. get depthFunc(): Nullable<number>;
  114120. set depthFunc(value: Nullable<number>);
  114121. get depthMask(): boolean;
  114122. set depthMask(value: boolean);
  114123. get depthTest(): boolean;
  114124. set depthTest(value: boolean);
  114125. get frontFace(): Nullable<number>;
  114126. set frontFace(value: Nullable<number>);
  114127. reset(): void;
  114128. apply(gl: WebGLRenderingContext): void;
  114129. }
  114130. }
  114131. declare module BABYLON {
  114132. /**
  114133. * @hidden
  114134. **/
  114135. export class StencilState {
  114136. /** 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 */
  114137. static readonly ALWAYS: number;
  114138. /** Passed to stencilOperation to specify that stencil value must be kept */
  114139. static readonly KEEP: number;
  114140. /** Passed to stencilOperation to specify that stencil value must be replaced */
  114141. static readonly REPLACE: number;
  114142. private _isStencilTestDirty;
  114143. private _isStencilMaskDirty;
  114144. private _isStencilFuncDirty;
  114145. private _isStencilOpDirty;
  114146. private _stencilTest;
  114147. private _stencilMask;
  114148. private _stencilFunc;
  114149. private _stencilFuncRef;
  114150. private _stencilFuncMask;
  114151. private _stencilOpStencilFail;
  114152. private _stencilOpDepthFail;
  114153. private _stencilOpStencilDepthPass;
  114154. get isDirty(): boolean;
  114155. get stencilFunc(): number;
  114156. set stencilFunc(value: number);
  114157. get stencilFuncRef(): number;
  114158. set stencilFuncRef(value: number);
  114159. get stencilFuncMask(): number;
  114160. set stencilFuncMask(value: number);
  114161. get stencilOpStencilFail(): number;
  114162. set stencilOpStencilFail(value: number);
  114163. get stencilOpDepthFail(): number;
  114164. set stencilOpDepthFail(value: number);
  114165. get stencilOpStencilDepthPass(): number;
  114166. set stencilOpStencilDepthPass(value: number);
  114167. get stencilMask(): number;
  114168. set stencilMask(value: number);
  114169. get stencilTest(): boolean;
  114170. set stencilTest(value: boolean);
  114171. constructor();
  114172. reset(): void;
  114173. apply(gl: WebGLRenderingContext): void;
  114174. }
  114175. }
  114176. declare module BABYLON {
  114177. /**
  114178. * @hidden
  114179. **/
  114180. export class AlphaState {
  114181. private _isAlphaBlendDirty;
  114182. private _isBlendFunctionParametersDirty;
  114183. private _isBlendEquationParametersDirty;
  114184. private _isBlendConstantsDirty;
  114185. private _alphaBlend;
  114186. private _blendFunctionParameters;
  114187. private _blendEquationParameters;
  114188. private _blendConstants;
  114189. /**
  114190. * Initializes the state.
  114191. */
  114192. constructor();
  114193. get isDirty(): boolean;
  114194. get alphaBlend(): boolean;
  114195. set alphaBlend(value: boolean);
  114196. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  114197. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  114198. setAlphaEquationParameters(rgb: number, alpha: number): void;
  114199. reset(): void;
  114200. apply(gl: WebGLRenderingContext): void;
  114201. }
  114202. }
  114203. declare module BABYLON {
  114204. /** @hidden */
  114205. export class WebGL2ShaderProcessor implements IShaderProcessor {
  114206. attributeProcessor(attribute: string): string;
  114207. varyingProcessor(varying: string, isFragment: boolean): string;
  114208. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  114209. }
  114210. }
  114211. declare module BABYLON {
  114212. /**
  114213. * Interface for attribute information associated with buffer instanciation
  114214. */
  114215. export interface InstancingAttributeInfo {
  114216. /**
  114217. * Name of the GLSL attribute
  114218. * if attribute index is not specified, this is used to retrieve the index from the effect
  114219. */
  114220. attributeName: string;
  114221. /**
  114222. * Index/offset of the attribute in the vertex shader
  114223. * if not specified, this will be computes from the name.
  114224. */
  114225. index?: number;
  114226. /**
  114227. * size of the attribute, 1, 2, 3 or 4
  114228. */
  114229. attributeSize: number;
  114230. /**
  114231. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  114232. */
  114233. offset: number;
  114234. /**
  114235. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  114236. * default to 1
  114237. */
  114238. divisor?: number;
  114239. /**
  114240. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  114241. * default is FLOAT
  114242. */
  114243. attributeType?: number;
  114244. /**
  114245. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  114246. */
  114247. normalized?: boolean;
  114248. }
  114249. }
  114250. declare module BABYLON {
  114251. interface ThinEngine {
  114252. /**
  114253. * Update a video texture
  114254. * @param texture defines the texture to update
  114255. * @param video defines the video element to use
  114256. * @param invertY defines if data must be stored with Y axis inverted
  114257. */
  114258. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  114259. }
  114260. }
  114261. declare module BABYLON {
  114262. interface ThinEngine {
  114263. /**
  114264. * Creates a dynamic texture
  114265. * @param width defines the width of the texture
  114266. * @param height defines the height of the texture
  114267. * @param generateMipMaps defines if the engine should generate the mip levels
  114268. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  114269. * @returns the dynamic texture inside an InternalTexture
  114270. */
  114271. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  114272. /**
  114273. * Update the content of a dynamic texture
  114274. * @param texture defines the texture to update
  114275. * @param canvas defines the canvas containing the source
  114276. * @param invertY defines if data must be stored with Y axis inverted
  114277. * @param premulAlpha defines if alpha is stored as premultiplied
  114278. * @param format defines the format of the data
  114279. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  114280. */
  114281. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  114282. }
  114283. }
  114284. declare module BABYLON {
  114285. /**
  114286. * Settings for finer control over video usage
  114287. */
  114288. export interface VideoTextureSettings {
  114289. /**
  114290. * Applies `autoplay` to video, if specified
  114291. */
  114292. autoPlay?: boolean;
  114293. /**
  114294. * Applies `loop` to video, if specified
  114295. */
  114296. loop?: boolean;
  114297. /**
  114298. * Automatically updates internal texture from video at every frame in the render loop
  114299. */
  114300. autoUpdateTexture: boolean;
  114301. /**
  114302. * Image src displayed during the video loading or until the user interacts with the video.
  114303. */
  114304. poster?: string;
  114305. }
  114306. /**
  114307. * If you want to display a video in your scene, this is the special texture for that.
  114308. * This special texture works similar to other textures, with the exception of a few parameters.
  114309. * @see https://doc.babylonjs.com/how_to/video_texture
  114310. */
  114311. export class VideoTexture extends Texture {
  114312. /**
  114313. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  114314. */
  114315. readonly autoUpdateTexture: boolean;
  114316. /**
  114317. * The video instance used by the texture internally
  114318. */
  114319. readonly video: HTMLVideoElement;
  114320. private _onUserActionRequestedObservable;
  114321. /**
  114322. * Event triggerd when a dom action is required by the user to play the video.
  114323. * This happens due to recent changes in browser policies preventing video to auto start.
  114324. */
  114325. get onUserActionRequestedObservable(): Observable<Texture>;
  114326. private _generateMipMaps;
  114327. private _stillImageCaptured;
  114328. private _displayingPosterTexture;
  114329. private _settings;
  114330. private _createInternalTextureOnEvent;
  114331. private _frameId;
  114332. private _currentSrc;
  114333. /**
  114334. * Creates a video texture.
  114335. * If you want to display a video in your scene, this is the special texture for that.
  114336. * This special texture works similar to other textures, with the exception of a few parameters.
  114337. * @see https://doc.babylonjs.com/how_to/video_texture
  114338. * @param name optional name, will detect from video source, if not defined
  114339. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  114340. * @param scene is obviously the current scene.
  114341. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  114342. * @param invertY is false by default but can be used to invert video on Y axis
  114343. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  114344. * @param settings allows finer control over video usage
  114345. */
  114346. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  114347. private _getName;
  114348. private _getVideo;
  114349. private _createInternalTexture;
  114350. private reset;
  114351. /**
  114352. * @hidden Internal method to initiate `update`.
  114353. */
  114354. _rebuild(): void;
  114355. /**
  114356. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  114357. */
  114358. update(): void;
  114359. /**
  114360. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  114361. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  114362. */
  114363. updateTexture(isVisible: boolean): void;
  114364. protected _updateInternalTexture: () => void;
  114365. /**
  114366. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  114367. * @param url New url.
  114368. */
  114369. updateURL(url: string): void;
  114370. /**
  114371. * Clones the texture.
  114372. * @returns the cloned texture
  114373. */
  114374. clone(): VideoTexture;
  114375. /**
  114376. * Dispose the texture and release its associated resources.
  114377. */
  114378. dispose(): void;
  114379. /**
  114380. * Creates a video texture straight from a stream.
  114381. * @param scene Define the scene the texture should be created in
  114382. * @param stream Define the stream the texture should be created from
  114383. * @returns The created video texture as a promise
  114384. */
  114385. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  114386. /**
  114387. * Creates a video texture straight from your WebCam video feed.
  114388. * @param scene Define the scene the texture should be created in
  114389. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  114390. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  114391. * @returns The created video texture as a promise
  114392. */
  114393. static CreateFromWebCamAsync(scene: Scene, constraints: {
  114394. minWidth: number;
  114395. maxWidth: number;
  114396. minHeight: number;
  114397. maxHeight: number;
  114398. deviceId: string;
  114399. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  114400. /**
  114401. * Creates a video texture straight from your WebCam video feed.
  114402. * @param scene Define the scene the texture should be created in
  114403. * @param onReady Define a callback to triggered once the texture will be ready
  114404. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  114405. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  114406. */
  114407. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  114408. minWidth: number;
  114409. maxWidth: number;
  114410. minHeight: number;
  114411. maxHeight: number;
  114412. deviceId: string;
  114413. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  114414. }
  114415. }
  114416. declare module BABYLON {
  114417. /**
  114418. * Defines the interface used by objects working like Scene
  114419. * @hidden
  114420. */
  114421. export interface ISceneLike {
  114422. _addPendingData(data: any): void;
  114423. _removePendingData(data: any): void;
  114424. offlineProvider: IOfflineProvider;
  114425. }
  114426. /** Interface defining initialization parameters for Engine class */
  114427. export interface EngineOptions extends WebGLContextAttributes {
  114428. /**
  114429. * Defines if the engine should no exceed a specified device ratio
  114430. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  114431. */
  114432. limitDeviceRatio?: number;
  114433. /**
  114434. * Defines if webvr should be enabled automatically
  114435. * @see https://doc.babylonjs.com/how_to/webvr_camera
  114436. */
  114437. autoEnableWebVR?: boolean;
  114438. /**
  114439. * Defines if webgl2 should be turned off even if supported
  114440. * @see https://doc.babylonjs.com/features/webgl2
  114441. */
  114442. disableWebGL2Support?: boolean;
  114443. /**
  114444. * Defines if webaudio should be initialized as well
  114445. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  114446. */
  114447. audioEngine?: boolean;
  114448. /**
  114449. * Defines if animations should run using a deterministic lock step
  114450. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  114451. */
  114452. deterministicLockstep?: boolean;
  114453. /** Defines the maximum steps to use with deterministic lock step mode */
  114454. lockstepMaxSteps?: number;
  114455. /** Defines the seconds between each deterministic lock step */
  114456. timeStep?: number;
  114457. /**
  114458. * Defines that engine should ignore context lost events
  114459. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  114460. */
  114461. doNotHandleContextLost?: boolean;
  114462. /**
  114463. * Defines that engine should ignore modifying touch action attribute and style
  114464. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  114465. */
  114466. doNotHandleTouchAction?: boolean;
  114467. /**
  114468. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  114469. */
  114470. useHighPrecisionFloats?: boolean;
  114471. /**
  114472. * Make the canvas XR Compatible for XR sessions
  114473. */
  114474. xrCompatible?: boolean;
  114475. /**
  114476. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  114477. */
  114478. useHighPrecisionMatrix?: boolean;
  114479. }
  114480. /**
  114481. * The base engine class (root of all engines)
  114482. */
  114483. export class ThinEngine {
  114484. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  114485. static ExceptionList: ({
  114486. key: string;
  114487. capture: string;
  114488. captureConstraint: number;
  114489. targets: string[];
  114490. } | {
  114491. key: string;
  114492. capture: null;
  114493. captureConstraint: null;
  114494. targets: string[];
  114495. })[];
  114496. /** @hidden */
  114497. static _TextureLoaders: IInternalTextureLoader[];
  114498. /**
  114499. * Returns the current npm package of the sdk
  114500. */
  114501. static get NpmPackage(): string;
  114502. /**
  114503. * Returns the current version of the framework
  114504. */
  114505. static get Version(): string;
  114506. /**
  114507. * Returns a string describing the current engine
  114508. */
  114509. get description(): string;
  114510. /**
  114511. * Gets or sets the epsilon value used by collision engine
  114512. */
  114513. static CollisionsEpsilon: number;
  114514. /**
  114515. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  114516. */
  114517. static get ShadersRepository(): string;
  114518. static set ShadersRepository(value: string);
  114519. /** @hidden */
  114520. _shaderProcessor: IShaderProcessor;
  114521. /**
  114522. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  114523. */
  114524. forcePOTTextures: boolean;
  114525. /**
  114526. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  114527. */
  114528. isFullscreen: boolean;
  114529. /**
  114530. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  114531. */
  114532. cullBackFaces: boolean;
  114533. /**
  114534. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  114535. */
  114536. renderEvenInBackground: boolean;
  114537. /**
  114538. * Gets or sets a boolean indicating that cache can be kept between frames
  114539. */
  114540. preventCacheWipeBetweenFrames: boolean;
  114541. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  114542. validateShaderPrograms: boolean;
  114543. /**
  114544. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  114545. * This can provide greater z depth for distant objects.
  114546. */
  114547. useReverseDepthBuffer: boolean;
  114548. /**
  114549. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  114550. */
  114551. disableUniformBuffers: boolean;
  114552. /** @hidden */
  114553. _uniformBuffers: UniformBuffer[];
  114554. /**
  114555. * Gets a boolean indicating that the engine supports uniform buffers
  114556. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  114557. */
  114558. get supportsUniformBuffers(): boolean;
  114559. /** @hidden */
  114560. _gl: WebGLRenderingContext;
  114561. /** @hidden */
  114562. _webGLVersion: number;
  114563. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  114564. protected _windowIsBackground: boolean;
  114565. protected _creationOptions: EngineOptions;
  114566. protected _highPrecisionShadersAllowed: boolean;
  114567. /** @hidden */
  114568. get _shouldUseHighPrecisionShader(): boolean;
  114569. /**
  114570. * Gets a boolean indicating that only power of 2 textures are supported
  114571. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  114572. */
  114573. get needPOTTextures(): boolean;
  114574. /** @hidden */
  114575. _badOS: boolean;
  114576. /** @hidden */
  114577. _badDesktopOS: boolean;
  114578. private _hardwareScalingLevel;
  114579. /** @hidden */
  114580. _caps: EngineCapabilities;
  114581. private _isStencilEnable;
  114582. private _glVersion;
  114583. private _glRenderer;
  114584. private _glVendor;
  114585. /** @hidden */
  114586. _videoTextureSupported: boolean;
  114587. protected _renderingQueueLaunched: boolean;
  114588. protected _activeRenderLoops: (() => void)[];
  114589. /**
  114590. * Observable signaled when a context lost event is raised
  114591. */
  114592. onContextLostObservable: Observable<ThinEngine>;
  114593. /**
  114594. * Observable signaled when a context restored event is raised
  114595. */
  114596. onContextRestoredObservable: Observable<ThinEngine>;
  114597. private _onContextLost;
  114598. private _onContextRestored;
  114599. protected _contextWasLost: boolean;
  114600. /** @hidden */
  114601. _doNotHandleContextLost: boolean;
  114602. /**
  114603. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  114604. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  114605. */
  114606. get doNotHandleContextLost(): boolean;
  114607. set doNotHandleContextLost(value: boolean);
  114608. /**
  114609. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  114610. */
  114611. disableVertexArrayObjects: boolean;
  114612. /** @hidden */
  114613. protected _colorWrite: boolean;
  114614. /** @hidden */
  114615. protected _colorWriteChanged: boolean;
  114616. /** @hidden */
  114617. protected _depthCullingState: DepthCullingState;
  114618. /** @hidden */
  114619. protected _stencilState: StencilState;
  114620. /** @hidden */
  114621. _alphaState: AlphaState;
  114622. /** @hidden */
  114623. _alphaMode: number;
  114624. /** @hidden */
  114625. _alphaEquation: number;
  114626. /** @hidden */
  114627. _internalTexturesCache: InternalTexture[];
  114628. /** @hidden */
  114629. protected _activeChannel: number;
  114630. private _currentTextureChannel;
  114631. /** @hidden */
  114632. protected _boundTexturesCache: {
  114633. [key: string]: Nullable<InternalTexture>;
  114634. };
  114635. /** @hidden */
  114636. protected _currentEffect: Nullable<Effect>;
  114637. /** @hidden */
  114638. protected _currentProgram: Nullable<WebGLProgram>;
  114639. private _compiledEffects;
  114640. private _vertexAttribArraysEnabled;
  114641. /** @hidden */
  114642. protected _cachedViewport: Nullable<IViewportLike>;
  114643. private _cachedVertexArrayObject;
  114644. /** @hidden */
  114645. protected _cachedVertexBuffers: any;
  114646. /** @hidden */
  114647. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  114648. /** @hidden */
  114649. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  114650. /** @hidden */
  114651. _currentRenderTarget: Nullable<InternalTexture>;
  114652. private _uintIndicesCurrentlySet;
  114653. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  114654. /** @hidden */
  114655. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  114656. /** @hidden */
  114657. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  114658. private _currentBufferPointers;
  114659. private _currentInstanceLocations;
  114660. private _currentInstanceBuffers;
  114661. private _textureUnits;
  114662. /** @hidden */
  114663. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  114664. /** @hidden */
  114665. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  114666. /** @hidden */
  114667. _boundRenderFunction: any;
  114668. private _vaoRecordInProgress;
  114669. private _mustWipeVertexAttributes;
  114670. private _emptyTexture;
  114671. private _emptyCubeTexture;
  114672. private _emptyTexture3D;
  114673. private _emptyTexture2DArray;
  114674. /** @hidden */
  114675. _frameHandler: number;
  114676. private _nextFreeTextureSlots;
  114677. private _maxSimultaneousTextures;
  114678. private _activeRequests;
  114679. /** @hidden */
  114680. _transformTextureUrl: Nullable<(url: string) => string>;
  114681. protected get _supportsHardwareTextureRescaling(): boolean;
  114682. private _framebufferDimensionsObject;
  114683. /**
  114684. * sets the object from which width and height will be taken from when getting render width and height
  114685. * Will fallback to the gl object
  114686. * @param dimensions the framebuffer width and height that will be used.
  114687. */
  114688. set framebufferDimensionsObject(dimensions: Nullable<{
  114689. framebufferWidth: number;
  114690. framebufferHeight: number;
  114691. }>);
  114692. /**
  114693. * Gets the current viewport
  114694. */
  114695. get currentViewport(): Nullable<IViewportLike>;
  114696. /**
  114697. * Gets the default empty texture
  114698. */
  114699. get emptyTexture(): InternalTexture;
  114700. /**
  114701. * Gets the default empty 3D texture
  114702. */
  114703. get emptyTexture3D(): InternalTexture;
  114704. /**
  114705. * Gets the default empty 2D array texture
  114706. */
  114707. get emptyTexture2DArray(): InternalTexture;
  114708. /**
  114709. * Gets the default empty cube texture
  114710. */
  114711. get emptyCubeTexture(): InternalTexture;
  114712. /**
  114713. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  114714. */
  114715. readonly premultipliedAlpha: boolean;
  114716. /**
  114717. * Observable event triggered before each texture is initialized
  114718. */
  114719. onBeforeTextureInitObservable: Observable<Texture>;
  114720. /**
  114721. * Creates a new engine
  114722. * @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
  114723. * @param antialias defines enable antialiasing (default: false)
  114724. * @param options defines further options to be sent to the getContext() function
  114725. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  114726. */
  114727. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  114728. private _rebuildInternalTextures;
  114729. private _rebuildEffects;
  114730. /**
  114731. * Gets a boolean indicating if all created effects are ready
  114732. * @returns true if all effects are ready
  114733. */
  114734. areAllEffectsReady(): boolean;
  114735. protected _rebuildBuffers(): void;
  114736. protected _initGLContext(): void;
  114737. /**
  114738. * Gets version of the current webGL context
  114739. */
  114740. get webGLVersion(): number;
  114741. /**
  114742. * Gets a string identifying the name of the class
  114743. * @returns "Engine" string
  114744. */
  114745. getClassName(): string;
  114746. /**
  114747. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  114748. */
  114749. get isStencilEnable(): boolean;
  114750. /** @hidden */
  114751. _prepareWorkingCanvas(): void;
  114752. /**
  114753. * Reset the texture cache to empty state
  114754. */
  114755. resetTextureCache(): void;
  114756. /**
  114757. * Gets an object containing information about the current webGL context
  114758. * @returns an object containing the vender, the renderer and the version of the current webGL context
  114759. */
  114760. getGlInfo(): {
  114761. vendor: string;
  114762. renderer: string;
  114763. version: string;
  114764. };
  114765. /**
  114766. * Defines the hardware scaling level.
  114767. * By default the hardware scaling level is computed from the window device ratio.
  114768. * 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.
  114769. * @param level defines the level to use
  114770. */
  114771. setHardwareScalingLevel(level: number): void;
  114772. /**
  114773. * Gets the current hardware scaling level.
  114774. * By default the hardware scaling level is computed from the window device ratio.
  114775. * 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.
  114776. * @returns a number indicating the current hardware scaling level
  114777. */
  114778. getHardwareScalingLevel(): number;
  114779. /**
  114780. * Gets the list of loaded textures
  114781. * @returns an array containing all loaded textures
  114782. */
  114783. getLoadedTexturesCache(): InternalTexture[];
  114784. /**
  114785. * Gets the object containing all engine capabilities
  114786. * @returns the EngineCapabilities object
  114787. */
  114788. getCaps(): EngineCapabilities;
  114789. /**
  114790. * stop executing a render loop function and remove it from the execution array
  114791. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  114792. */
  114793. stopRenderLoop(renderFunction?: () => void): void;
  114794. /** @hidden */
  114795. _renderLoop(): void;
  114796. /**
  114797. * Gets the HTML canvas attached with the current webGL context
  114798. * @returns a HTML canvas
  114799. */
  114800. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  114801. /**
  114802. * Gets host window
  114803. * @returns the host window object
  114804. */
  114805. getHostWindow(): Nullable<Window>;
  114806. /**
  114807. * Gets the current render width
  114808. * @param useScreen defines if screen size must be used (or the current render target if any)
  114809. * @returns a number defining the current render width
  114810. */
  114811. getRenderWidth(useScreen?: boolean): number;
  114812. /**
  114813. * Gets the current render height
  114814. * @param useScreen defines if screen size must be used (or the current render target if any)
  114815. * @returns a number defining the current render height
  114816. */
  114817. getRenderHeight(useScreen?: boolean): number;
  114818. /**
  114819. * Can be used to override the current requestAnimationFrame requester.
  114820. * @hidden
  114821. */
  114822. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  114823. /**
  114824. * Register and execute a render loop. The engine can have more than one render function
  114825. * @param renderFunction defines the function to continuously execute
  114826. */
  114827. runRenderLoop(renderFunction: () => void): void;
  114828. /**
  114829. * Clear the current render buffer or the current render target (if any is set up)
  114830. * @param color defines the color to use
  114831. * @param backBuffer defines if the back buffer must be cleared
  114832. * @param depth defines if the depth buffer must be cleared
  114833. * @param stencil defines if the stencil buffer must be cleared
  114834. */
  114835. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  114836. private _viewportCached;
  114837. /** @hidden */
  114838. _viewport(x: number, y: number, width: number, height: number): void;
  114839. /**
  114840. * Set the WebGL's viewport
  114841. * @param viewport defines the viewport element to be used
  114842. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  114843. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  114844. */
  114845. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  114846. /**
  114847. * Begin a new frame
  114848. */
  114849. beginFrame(): void;
  114850. /**
  114851. * Enf the current frame
  114852. */
  114853. endFrame(): void;
  114854. /**
  114855. * Resize the view according to the canvas' size
  114856. */
  114857. resize(): void;
  114858. /**
  114859. * Force a specific size of the canvas
  114860. * @param width defines the new canvas' width
  114861. * @param height defines the new canvas' height
  114862. * @returns true if the size was changed
  114863. */
  114864. setSize(width: number, height: number): boolean;
  114865. /**
  114866. * Binds the frame buffer to the specified texture.
  114867. * @param texture The texture to render to or null for the default canvas
  114868. * @param faceIndex The face of the texture to render to in case of cube texture
  114869. * @param requiredWidth The width of the target to render to
  114870. * @param requiredHeight The height of the target to render to
  114871. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  114872. * @param lodLevel defines the lod level to bind to the frame buffer
  114873. * @param layer defines the 2d array index to bind to frame buffer to
  114874. */
  114875. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  114876. /** @hidden */
  114877. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  114878. /**
  114879. * Unbind the current render target texture from the webGL context
  114880. * @param texture defines the render target texture to unbind
  114881. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  114882. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  114883. */
  114884. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  114885. /**
  114886. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  114887. */
  114888. flushFramebuffer(): void;
  114889. /**
  114890. * Unbind the current render target and bind the default framebuffer
  114891. */
  114892. restoreDefaultFramebuffer(): void;
  114893. /** @hidden */
  114894. protected _resetVertexBufferBinding(): void;
  114895. /**
  114896. * Creates a vertex buffer
  114897. * @param data the data for the vertex buffer
  114898. * @returns the new WebGL static buffer
  114899. */
  114900. createVertexBuffer(data: DataArray): DataBuffer;
  114901. private _createVertexBuffer;
  114902. /**
  114903. * Creates a dynamic vertex buffer
  114904. * @param data the data for the dynamic vertex buffer
  114905. * @returns the new WebGL dynamic buffer
  114906. */
  114907. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  114908. protected _resetIndexBufferBinding(): void;
  114909. /**
  114910. * Creates a new index buffer
  114911. * @param indices defines the content of the index buffer
  114912. * @param updatable defines if the index buffer must be updatable
  114913. * @returns a new webGL buffer
  114914. */
  114915. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  114916. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  114917. /**
  114918. * Bind a webGL buffer to the webGL context
  114919. * @param buffer defines the buffer to bind
  114920. */
  114921. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  114922. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  114923. private bindBuffer;
  114924. /**
  114925. * update the bound buffer with the given data
  114926. * @param data defines the data to update
  114927. */
  114928. updateArrayBuffer(data: Float32Array): void;
  114929. private _vertexAttribPointer;
  114930. /** @hidden */
  114931. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  114932. private _bindVertexBuffersAttributes;
  114933. /**
  114934. * Records a vertex array object
  114935. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  114936. * @param vertexBuffers defines the list of vertex buffers to store
  114937. * @param indexBuffer defines the index buffer to store
  114938. * @param effect defines the effect to store
  114939. * @returns the new vertex array object
  114940. */
  114941. recordVertexArrayObject(vertexBuffers: {
  114942. [key: string]: VertexBuffer;
  114943. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  114944. /**
  114945. * Bind a specific vertex array object
  114946. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  114947. * @param vertexArrayObject defines the vertex array object to bind
  114948. * @param indexBuffer defines the index buffer to bind
  114949. */
  114950. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  114951. /**
  114952. * Bind webGl buffers directly to the webGL context
  114953. * @param vertexBuffer defines the vertex buffer to bind
  114954. * @param indexBuffer defines the index buffer to bind
  114955. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  114956. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  114957. * @param effect defines the effect associated with the vertex buffer
  114958. */
  114959. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  114960. private _unbindVertexArrayObject;
  114961. /**
  114962. * Bind a list of vertex buffers to the webGL context
  114963. * @param vertexBuffers defines the list of vertex buffers to bind
  114964. * @param indexBuffer defines the index buffer to bind
  114965. * @param effect defines the effect associated with the vertex buffers
  114966. */
  114967. bindBuffers(vertexBuffers: {
  114968. [key: string]: Nullable<VertexBuffer>;
  114969. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  114970. /**
  114971. * Unbind all instance attributes
  114972. */
  114973. unbindInstanceAttributes(): void;
  114974. /**
  114975. * Release and free the memory of a vertex array object
  114976. * @param vao defines the vertex array object to delete
  114977. */
  114978. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  114979. /** @hidden */
  114980. _releaseBuffer(buffer: DataBuffer): boolean;
  114981. protected _deleteBuffer(buffer: DataBuffer): void;
  114982. /**
  114983. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  114984. * @param instancesBuffer defines the webGL buffer to update and bind
  114985. * @param data defines the data to store in the buffer
  114986. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  114987. */
  114988. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  114989. /**
  114990. * Bind the content of a webGL buffer used with instantiation
  114991. * @param instancesBuffer defines the webGL buffer to bind
  114992. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  114993. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  114994. */
  114995. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  114996. /**
  114997. * Disable the instance attribute corresponding to the name in parameter
  114998. * @param name defines the name of the attribute to disable
  114999. */
  115000. disableInstanceAttributeByName(name: string): void;
  115001. /**
  115002. * Disable the instance attribute corresponding to the location in parameter
  115003. * @param attributeLocation defines the attribute location of the attribute to disable
  115004. */
  115005. disableInstanceAttribute(attributeLocation: number): void;
  115006. /**
  115007. * Disable the attribute corresponding to the location in parameter
  115008. * @param attributeLocation defines the attribute location of the attribute to disable
  115009. */
  115010. disableAttributeByIndex(attributeLocation: number): void;
  115011. /**
  115012. * Send a draw order
  115013. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  115014. * @param indexStart defines the starting index
  115015. * @param indexCount defines the number of index to draw
  115016. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  115017. */
  115018. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  115019. /**
  115020. * Draw a list of points
  115021. * @param verticesStart defines the index of first vertex to draw
  115022. * @param verticesCount defines the count of vertices to draw
  115023. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  115024. */
  115025. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  115026. /**
  115027. * Draw a list of unindexed primitives
  115028. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  115029. * @param verticesStart defines the index of first vertex to draw
  115030. * @param verticesCount defines the count of vertices to draw
  115031. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  115032. */
  115033. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  115034. /**
  115035. * Draw a list of indexed primitives
  115036. * @param fillMode defines the primitive to use
  115037. * @param indexStart defines the starting index
  115038. * @param indexCount defines the number of index to draw
  115039. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  115040. */
  115041. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  115042. /**
  115043. * Draw a list of unindexed primitives
  115044. * @param fillMode defines the primitive to use
  115045. * @param verticesStart defines the index of first vertex to draw
  115046. * @param verticesCount defines the count of vertices to draw
  115047. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  115048. */
  115049. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  115050. private _drawMode;
  115051. /** @hidden */
  115052. protected _reportDrawCall(): void;
  115053. /** @hidden */
  115054. _releaseEffect(effect: Effect): void;
  115055. /** @hidden */
  115056. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  115057. /**
  115058. * Create a new effect (used to store vertex/fragment shaders)
  115059. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  115060. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  115061. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  115062. * @param samplers defines an array of string used to represent textures
  115063. * @param defines defines the string containing the defines to use to compile the shaders
  115064. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  115065. * @param onCompiled defines a function to call when the effect creation is successful
  115066. * @param onError defines a function to call when the effect creation has failed
  115067. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  115068. * @returns the new Effect
  115069. */
  115070. 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;
  115071. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  115072. private _compileShader;
  115073. private _compileRawShader;
  115074. /** @hidden */
  115075. _getShaderSource(shader: WebGLShader): Nullable<string>;
  115076. /**
  115077. * Directly creates a webGL program
  115078. * @param pipelineContext defines the pipeline context to attach to
  115079. * @param vertexCode defines the vertex shader code to use
  115080. * @param fragmentCode defines the fragment shader code to use
  115081. * @param context defines the webGL context to use (if not set, the current one will be used)
  115082. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  115083. * @returns the new webGL program
  115084. */
  115085. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  115086. /**
  115087. * Creates a webGL program
  115088. * @param pipelineContext defines the pipeline context to attach to
  115089. * @param vertexCode defines the vertex shader code to use
  115090. * @param fragmentCode defines the fragment shader code to use
  115091. * @param defines defines the string containing the defines to use to compile the shaders
  115092. * @param context defines the webGL context to use (if not set, the current one will be used)
  115093. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  115094. * @returns the new webGL program
  115095. */
  115096. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  115097. /**
  115098. * Creates a new pipeline context
  115099. * @returns the new pipeline
  115100. */
  115101. createPipelineContext(): IPipelineContext;
  115102. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  115103. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  115104. /** @hidden */
  115105. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  115106. /** @hidden */
  115107. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  115108. /** @hidden */
  115109. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  115110. /**
  115111. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  115112. * @param pipelineContext defines the pipeline context to use
  115113. * @param uniformsNames defines the list of uniform names
  115114. * @returns an array of webGL uniform locations
  115115. */
  115116. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  115117. /**
  115118. * Gets the lsit of active attributes for a given webGL program
  115119. * @param pipelineContext defines the pipeline context to use
  115120. * @param attributesNames defines the list of attribute names to get
  115121. * @returns an array of indices indicating the offset of each attribute
  115122. */
  115123. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  115124. /**
  115125. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  115126. * @param effect defines the effect to activate
  115127. */
  115128. enableEffect(effect: Nullable<Effect>): void;
  115129. /**
  115130. * Set the value of an uniform to a number (int)
  115131. * @param uniform defines the webGL uniform location where to store the value
  115132. * @param value defines the int number to store
  115133. */
  115134. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  115135. /**
  115136. * Set the value of an uniform to an array of int32
  115137. * @param uniform defines the webGL uniform location where to store the value
  115138. * @param array defines the array of int32 to store
  115139. */
  115140. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  115141. /**
  115142. * Set the value of an uniform to an array of int32 (stored as vec2)
  115143. * @param uniform defines the webGL uniform location where to store the value
  115144. * @param array defines the array of int32 to store
  115145. */
  115146. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  115147. /**
  115148. * Set the value of an uniform to an array of int32 (stored as vec3)
  115149. * @param uniform defines the webGL uniform location where to store the value
  115150. * @param array defines the array of int32 to store
  115151. */
  115152. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  115153. /**
  115154. * Set the value of an uniform to an array of int32 (stored as vec4)
  115155. * @param uniform defines the webGL uniform location where to store the value
  115156. * @param array defines the array of int32 to store
  115157. */
  115158. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  115159. /**
  115160. * Set the value of an uniform to an array of number
  115161. * @param uniform defines the webGL uniform location where to store the value
  115162. * @param array defines the array of number to store
  115163. */
  115164. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  115165. /**
  115166. * Set the value of an uniform to an array of number (stored as vec2)
  115167. * @param uniform defines the webGL uniform location where to store the value
  115168. * @param array defines the array of number to store
  115169. */
  115170. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  115171. /**
  115172. * Set the value of an uniform to an array of number (stored as vec3)
  115173. * @param uniform defines the webGL uniform location where to store the value
  115174. * @param array defines the array of number to store
  115175. */
  115176. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  115177. /**
  115178. * Set the value of an uniform to an array of number (stored as vec4)
  115179. * @param uniform defines the webGL uniform location where to store the value
  115180. * @param array defines the array of number to store
  115181. */
  115182. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  115183. /**
  115184. * Set the value of an uniform to an array of float32 (stored as matrices)
  115185. * @param uniform defines the webGL uniform location where to store the value
  115186. * @param matrices defines the array of float32 to store
  115187. */
  115188. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  115189. /**
  115190. * Set the value of an uniform to a matrix (3x3)
  115191. * @param uniform defines the webGL uniform location where to store the value
  115192. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  115193. */
  115194. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  115195. /**
  115196. * Set the value of an uniform to a matrix (2x2)
  115197. * @param uniform defines the webGL uniform location where to store the value
  115198. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  115199. */
  115200. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  115201. /**
  115202. * Set the value of an uniform to a number (float)
  115203. * @param uniform defines the webGL uniform location where to store the value
  115204. * @param value defines the float number to store
  115205. */
  115206. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  115207. /**
  115208. * Set the value of an uniform to a vec2
  115209. * @param uniform defines the webGL uniform location where to store the value
  115210. * @param x defines the 1st component of the value
  115211. * @param y defines the 2nd component of the value
  115212. */
  115213. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  115214. /**
  115215. * Set the value of an uniform to a vec3
  115216. * @param uniform defines the webGL uniform location where to store the value
  115217. * @param x defines the 1st component of the value
  115218. * @param y defines the 2nd component of the value
  115219. * @param z defines the 3rd component of the value
  115220. */
  115221. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  115222. /**
  115223. * Set the value of an uniform to a vec4
  115224. * @param uniform defines the webGL uniform location where to store the value
  115225. * @param x defines the 1st component of the value
  115226. * @param y defines the 2nd component of the value
  115227. * @param z defines the 3rd component of the value
  115228. * @param w defines the 4th component of the value
  115229. */
  115230. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  115231. /**
  115232. * Apply all cached states (depth, culling, stencil and alpha)
  115233. */
  115234. applyStates(): void;
  115235. /**
  115236. * Enable or disable color writing
  115237. * @param enable defines the state to set
  115238. */
  115239. setColorWrite(enable: boolean): void;
  115240. /**
  115241. * Gets a boolean indicating if color writing is enabled
  115242. * @returns the current color writing state
  115243. */
  115244. getColorWrite(): boolean;
  115245. /**
  115246. * Gets the depth culling state manager
  115247. */
  115248. get depthCullingState(): DepthCullingState;
  115249. /**
  115250. * Gets the alpha state manager
  115251. */
  115252. get alphaState(): AlphaState;
  115253. /**
  115254. * Gets the stencil state manager
  115255. */
  115256. get stencilState(): StencilState;
  115257. /**
  115258. * Clears the list of texture accessible through engine.
  115259. * This can help preventing texture load conflict due to name collision.
  115260. */
  115261. clearInternalTexturesCache(): void;
  115262. /**
  115263. * Force the entire cache to be cleared
  115264. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  115265. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  115266. */
  115267. wipeCaches(bruteForce?: boolean): void;
  115268. /** @hidden */
  115269. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  115270. min: number;
  115271. mag: number;
  115272. };
  115273. /** @hidden */
  115274. _createTexture(): WebGLTexture;
  115275. /**
  115276. * Usually called from Texture.ts.
  115277. * Passed information to create a WebGLTexture
  115278. * @param url defines a value which contains one of the following:
  115279. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  115280. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  115281. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  115282. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  115283. * @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)
  115284. * @param scene needed for loading to the correct scene
  115285. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  115286. * @param onLoad optional callback to be called upon successful completion
  115287. * @param onError optional callback to be called upon failure
  115288. * @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
  115289. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  115290. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  115291. * @param forcedExtension defines the extension to use to pick the right loader
  115292. * @param mimeType defines an optional mime type
  115293. * @returns a InternalTexture for assignment back into BABYLON.Texture
  115294. */
  115295. 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;
  115296. /**
  115297. * Loads an image as an HTMLImageElement.
  115298. * @param input url string, ArrayBuffer, or Blob to load
  115299. * @param onLoad callback called when the image successfully loads
  115300. * @param onError callback called when the image fails to load
  115301. * @param offlineProvider offline provider for caching
  115302. * @param mimeType optional mime type
  115303. * @returns the HTMLImageElement of the loaded image
  115304. * @hidden
  115305. */
  115306. 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>;
  115307. /**
  115308. * @hidden
  115309. */
  115310. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  115311. private _unpackFlipYCached;
  115312. /**
  115313. * In case you are sharing the context with other applications, it might
  115314. * be interested to not cache the unpack flip y state to ensure a consistent
  115315. * value would be set.
  115316. */
  115317. enableUnpackFlipYCached: boolean;
  115318. /** @hidden */
  115319. _unpackFlipY(value: boolean): void;
  115320. /** @hidden */
  115321. _getUnpackAlignement(): number;
  115322. private _getTextureTarget;
  115323. /**
  115324. * Update the sampling mode of a given texture
  115325. * @param samplingMode defines the required sampling mode
  115326. * @param texture defines the texture to update
  115327. * @param generateMipMaps defines whether to generate mipmaps for the texture
  115328. */
  115329. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  115330. /**
  115331. * Update the sampling mode of a given texture
  115332. * @param texture defines the texture to update
  115333. * @param wrapU defines the texture wrap mode of the u coordinates
  115334. * @param wrapV defines the texture wrap mode of the v coordinates
  115335. * @param wrapR defines the texture wrap mode of the r coordinates
  115336. */
  115337. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  115338. /** @hidden */
  115339. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  115340. width: number;
  115341. height: number;
  115342. layers?: number;
  115343. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  115344. /** @hidden */
  115345. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  115346. /** @hidden */
  115347. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  115348. /**
  115349. * Update a portion of an internal texture
  115350. * @param texture defines the texture to update
  115351. * @param imageData defines the data to store into the texture
  115352. * @param xOffset defines the x coordinates of the update rectangle
  115353. * @param yOffset defines the y coordinates of the update rectangle
  115354. * @param width defines the width of the update rectangle
  115355. * @param height defines the height of the update rectangle
  115356. * @param faceIndex defines the face index if texture is a cube (0 by default)
  115357. * @param lod defines the lod level to update (0 by default)
  115358. */
  115359. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  115360. /** @hidden */
  115361. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  115362. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  115363. private _prepareWebGLTexture;
  115364. /** @hidden */
  115365. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  115366. private _getDepthStencilBuffer;
  115367. /** @hidden */
  115368. _releaseFramebufferObjects(texture: InternalTexture): void;
  115369. /** @hidden */
  115370. _releaseTexture(texture: InternalTexture): void;
  115371. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  115372. protected _setProgram(program: WebGLProgram): void;
  115373. protected _boundUniforms: {
  115374. [key: number]: WebGLUniformLocation;
  115375. };
  115376. /**
  115377. * Binds an effect to the webGL context
  115378. * @param effect defines the effect to bind
  115379. */
  115380. bindSamplers(effect: Effect): void;
  115381. private _activateCurrentTexture;
  115382. /** @hidden */
  115383. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  115384. /** @hidden */
  115385. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  115386. /**
  115387. * Unbind all textures from the webGL context
  115388. */
  115389. unbindAllTextures(): void;
  115390. /**
  115391. * Sets a texture to the according uniform.
  115392. * @param channel The texture channel
  115393. * @param uniform The uniform to set
  115394. * @param texture The texture to apply
  115395. */
  115396. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  115397. private _bindSamplerUniformToChannel;
  115398. private _getTextureWrapMode;
  115399. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  115400. /**
  115401. * Sets an array of texture to the webGL context
  115402. * @param channel defines the channel where the texture array must be set
  115403. * @param uniform defines the associated uniform location
  115404. * @param textures defines the array of textures to bind
  115405. */
  115406. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  115407. /** @hidden */
  115408. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  115409. private _setTextureParameterFloat;
  115410. private _setTextureParameterInteger;
  115411. /**
  115412. * Unbind all vertex attributes from the webGL context
  115413. */
  115414. unbindAllAttributes(): void;
  115415. /**
  115416. * 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
  115417. */
  115418. releaseEffects(): void;
  115419. /**
  115420. * Dispose and release all associated resources
  115421. */
  115422. dispose(): void;
  115423. /**
  115424. * Attach a new callback raised when context lost event is fired
  115425. * @param callback defines the callback to call
  115426. */
  115427. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  115428. /**
  115429. * Attach a new callback raised when context restored event is fired
  115430. * @param callback defines the callback to call
  115431. */
  115432. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  115433. /**
  115434. * Get the current error code of the webGL context
  115435. * @returns the error code
  115436. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  115437. */
  115438. getError(): number;
  115439. private _canRenderToFloatFramebuffer;
  115440. private _canRenderToHalfFloatFramebuffer;
  115441. private _canRenderToFramebuffer;
  115442. /** @hidden */
  115443. _getWebGLTextureType(type: number): number;
  115444. /** @hidden */
  115445. _getInternalFormat(format: number): number;
  115446. /** @hidden */
  115447. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  115448. /** @hidden */
  115449. _getRGBAMultiSampleBufferFormat(type: number): number;
  115450. /** @hidden */
  115451. _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;
  115452. /**
  115453. * Loads a file from a url
  115454. * @param url url to load
  115455. * @param onSuccess callback called when the file successfully loads
  115456. * @param onProgress callback called while file is loading (if the server supports this mode)
  115457. * @param offlineProvider defines the offline provider for caching
  115458. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  115459. * @param onError callback called when the file fails to load
  115460. * @returns a file request object
  115461. * @hidden
  115462. */
  115463. 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;
  115464. /**
  115465. * Reads pixels from the current frame buffer. Please note that this function can be slow
  115466. * @param x defines the x coordinate of the rectangle where pixels must be read
  115467. * @param y defines the y coordinate of the rectangle where pixels must be read
  115468. * @param width defines the width of the rectangle where pixels must be read
  115469. * @param height defines the height of the rectangle where pixels must be read
  115470. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  115471. * @returns a Uint8Array containing RGBA colors
  115472. */
  115473. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  115474. private static _isSupported;
  115475. /**
  115476. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  115477. * @returns true if the engine can be created
  115478. * @ignorenaming
  115479. */
  115480. static isSupported(): boolean;
  115481. /**
  115482. * Find the next highest power of two.
  115483. * @param x Number to start search from.
  115484. * @return Next highest power of two.
  115485. */
  115486. static CeilingPOT(x: number): number;
  115487. /**
  115488. * Find the next lowest power of two.
  115489. * @param x Number to start search from.
  115490. * @return Next lowest power of two.
  115491. */
  115492. static FloorPOT(x: number): number;
  115493. /**
  115494. * Find the nearest power of two.
  115495. * @param x Number to start search from.
  115496. * @return Next nearest power of two.
  115497. */
  115498. static NearestPOT(x: number): number;
  115499. /**
  115500. * Get the closest exponent of two
  115501. * @param value defines the value to approximate
  115502. * @param max defines the maximum value to return
  115503. * @param mode defines how to define the closest value
  115504. * @returns closest exponent of two of the given value
  115505. */
  115506. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  115507. /**
  115508. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  115509. * @param func - the function to be called
  115510. * @param requester - the object that will request the next frame. Falls back to window.
  115511. * @returns frame number
  115512. */
  115513. static QueueNewFrame(func: () => void, requester?: any): number;
  115514. /**
  115515. * Gets host document
  115516. * @returns the host document object
  115517. */
  115518. getHostDocument(): Nullable<Document>;
  115519. }
  115520. }
  115521. declare module BABYLON {
  115522. /**
  115523. * Class representing spherical harmonics coefficients to the 3rd degree
  115524. */
  115525. export class SphericalHarmonics {
  115526. /**
  115527. * Defines whether or not the harmonics have been prescaled for rendering.
  115528. */
  115529. preScaled: boolean;
  115530. /**
  115531. * The l0,0 coefficients of the spherical harmonics
  115532. */
  115533. l00: Vector3;
  115534. /**
  115535. * The l1,-1 coefficients of the spherical harmonics
  115536. */
  115537. l1_1: Vector3;
  115538. /**
  115539. * The l1,0 coefficients of the spherical harmonics
  115540. */
  115541. l10: Vector3;
  115542. /**
  115543. * The l1,1 coefficients of the spherical harmonics
  115544. */
  115545. l11: Vector3;
  115546. /**
  115547. * The l2,-2 coefficients of the spherical harmonics
  115548. */
  115549. l2_2: Vector3;
  115550. /**
  115551. * The l2,-1 coefficients of the spherical harmonics
  115552. */
  115553. l2_1: Vector3;
  115554. /**
  115555. * The l2,0 coefficients of the spherical harmonics
  115556. */
  115557. l20: Vector3;
  115558. /**
  115559. * The l2,1 coefficients of the spherical harmonics
  115560. */
  115561. l21: Vector3;
  115562. /**
  115563. * The l2,2 coefficients of the spherical harmonics
  115564. */
  115565. l22: Vector3;
  115566. /**
  115567. * Adds a light to the spherical harmonics
  115568. * @param direction the direction of the light
  115569. * @param color the color of the light
  115570. * @param deltaSolidAngle the delta solid angle of the light
  115571. */
  115572. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  115573. /**
  115574. * Scales the spherical harmonics by the given amount
  115575. * @param scale the amount to scale
  115576. */
  115577. scaleInPlace(scale: number): void;
  115578. /**
  115579. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  115580. *
  115581. * ```
  115582. * E_lm = A_l * L_lm
  115583. * ```
  115584. *
  115585. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  115586. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  115587. * the scaling factors are given in equation 9.
  115588. */
  115589. convertIncidentRadianceToIrradiance(): void;
  115590. /**
  115591. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  115592. *
  115593. * ```
  115594. * L = (1/pi) * E * rho
  115595. * ```
  115596. *
  115597. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  115598. */
  115599. convertIrradianceToLambertianRadiance(): void;
  115600. /**
  115601. * Integrates the reconstruction coefficients directly in to the SH preventing further
  115602. * required operations at run time.
  115603. *
  115604. * This is simply done by scaling back the SH with Ylm constants parameter.
  115605. * The trigonometric part being applied by the shader at run time.
  115606. */
  115607. preScaleForRendering(): void;
  115608. /**
  115609. * Constructs a spherical harmonics from an array.
  115610. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  115611. * @returns the spherical harmonics
  115612. */
  115613. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  115614. /**
  115615. * Gets the spherical harmonics from polynomial
  115616. * @param polynomial the spherical polynomial
  115617. * @returns the spherical harmonics
  115618. */
  115619. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  115620. }
  115621. /**
  115622. * Class representing spherical polynomial coefficients to the 3rd degree
  115623. */
  115624. export class SphericalPolynomial {
  115625. private _harmonics;
  115626. /**
  115627. * The spherical harmonics used to create the polynomials.
  115628. */
  115629. get preScaledHarmonics(): SphericalHarmonics;
  115630. /**
  115631. * The x coefficients of the spherical polynomial
  115632. */
  115633. x: Vector3;
  115634. /**
  115635. * The y coefficients of the spherical polynomial
  115636. */
  115637. y: Vector3;
  115638. /**
  115639. * The z coefficients of the spherical polynomial
  115640. */
  115641. z: Vector3;
  115642. /**
  115643. * The xx coefficients of the spherical polynomial
  115644. */
  115645. xx: Vector3;
  115646. /**
  115647. * The yy coefficients of the spherical polynomial
  115648. */
  115649. yy: Vector3;
  115650. /**
  115651. * The zz coefficients of the spherical polynomial
  115652. */
  115653. zz: Vector3;
  115654. /**
  115655. * The xy coefficients of the spherical polynomial
  115656. */
  115657. xy: Vector3;
  115658. /**
  115659. * The yz coefficients of the spherical polynomial
  115660. */
  115661. yz: Vector3;
  115662. /**
  115663. * The zx coefficients of the spherical polynomial
  115664. */
  115665. zx: Vector3;
  115666. /**
  115667. * Adds an ambient color to the spherical polynomial
  115668. * @param color the color to add
  115669. */
  115670. addAmbient(color: Color3): void;
  115671. /**
  115672. * Scales the spherical polynomial by the given amount
  115673. * @param scale the amount to scale
  115674. */
  115675. scaleInPlace(scale: number): void;
  115676. /**
  115677. * Gets the spherical polynomial from harmonics
  115678. * @param harmonics the spherical harmonics
  115679. * @returns the spherical polynomial
  115680. */
  115681. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  115682. /**
  115683. * Constructs a spherical polynomial from an array.
  115684. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  115685. * @returns the spherical polynomial
  115686. */
  115687. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  115688. }
  115689. }
  115690. declare module BABYLON {
  115691. /**
  115692. * Defines the source of the internal texture
  115693. */
  115694. export enum InternalTextureSource {
  115695. /**
  115696. * The source of the texture data is unknown
  115697. */
  115698. Unknown = 0,
  115699. /**
  115700. * Texture data comes from an URL
  115701. */
  115702. Url = 1,
  115703. /**
  115704. * Texture data is only used for temporary storage
  115705. */
  115706. Temp = 2,
  115707. /**
  115708. * Texture data comes from raw data (ArrayBuffer)
  115709. */
  115710. Raw = 3,
  115711. /**
  115712. * Texture content is dynamic (video or dynamic texture)
  115713. */
  115714. Dynamic = 4,
  115715. /**
  115716. * Texture content is generated by rendering to it
  115717. */
  115718. RenderTarget = 5,
  115719. /**
  115720. * Texture content is part of a multi render target process
  115721. */
  115722. MultiRenderTarget = 6,
  115723. /**
  115724. * Texture data comes from a cube data file
  115725. */
  115726. Cube = 7,
  115727. /**
  115728. * Texture data comes from a raw cube data
  115729. */
  115730. CubeRaw = 8,
  115731. /**
  115732. * Texture data come from a prefiltered cube data file
  115733. */
  115734. CubePrefiltered = 9,
  115735. /**
  115736. * Texture content is raw 3D data
  115737. */
  115738. Raw3D = 10,
  115739. /**
  115740. * Texture content is raw 2D array data
  115741. */
  115742. Raw2DArray = 11,
  115743. /**
  115744. * Texture content is a depth texture
  115745. */
  115746. Depth = 12,
  115747. /**
  115748. * Texture data comes from a raw cube data encoded with RGBD
  115749. */
  115750. CubeRawRGBD = 13
  115751. }
  115752. /**
  115753. * Class used to store data associated with WebGL texture data for the engine
  115754. * This class should not be used directly
  115755. */
  115756. export class InternalTexture {
  115757. /** @hidden */
  115758. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  115759. /**
  115760. * Defines if the texture is ready
  115761. */
  115762. isReady: boolean;
  115763. /**
  115764. * Defines if the texture is a cube texture
  115765. */
  115766. isCube: boolean;
  115767. /**
  115768. * Defines if the texture contains 3D data
  115769. */
  115770. is3D: boolean;
  115771. /**
  115772. * Defines if the texture contains 2D array data
  115773. */
  115774. is2DArray: boolean;
  115775. /**
  115776. * Defines if the texture contains multiview data
  115777. */
  115778. isMultiview: boolean;
  115779. /**
  115780. * Gets the URL used to load this texture
  115781. */
  115782. url: string;
  115783. /**
  115784. * Gets the sampling mode of the texture
  115785. */
  115786. samplingMode: number;
  115787. /**
  115788. * Gets a boolean indicating if the texture needs mipmaps generation
  115789. */
  115790. generateMipMaps: boolean;
  115791. /**
  115792. * Gets the number of samples used by the texture (WebGL2+ only)
  115793. */
  115794. samples: number;
  115795. /**
  115796. * Gets the type of the texture (int, float...)
  115797. */
  115798. type: number;
  115799. /**
  115800. * Gets the format of the texture (RGB, RGBA...)
  115801. */
  115802. format: number;
  115803. /**
  115804. * Observable called when the texture is loaded
  115805. */
  115806. onLoadedObservable: Observable<InternalTexture>;
  115807. /**
  115808. * Gets the width of the texture
  115809. */
  115810. width: number;
  115811. /**
  115812. * Gets the height of the texture
  115813. */
  115814. height: number;
  115815. /**
  115816. * Gets the depth of the texture
  115817. */
  115818. depth: number;
  115819. /**
  115820. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  115821. */
  115822. baseWidth: number;
  115823. /**
  115824. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  115825. */
  115826. baseHeight: number;
  115827. /**
  115828. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  115829. */
  115830. baseDepth: number;
  115831. /**
  115832. * Gets a boolean indicating if the texture is inverted on Y axis
  115833. */
  115834. invertY: boolean;
  115835. /** @hidden */
  115836. _invertVScale: boolean;
  115837. /** @hidden */
  115838. _associatedChannel: number;
  115839. /** @hidden */
  115840. _source: InternalTextureSource;
  115841. /** @hidden */
  115842. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  115843. /** @hidden */
  115844. _bufferView: Nullable<ArrayBufferView>;
  115845. /** @hidden */
  115846. _bufferViewArray: Nullable<ArrayBufferView[]>;
  115847. /** @hidden */
  115848. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  115849. /** @hidden */
  115850. _size: number;
  115851. /** @hidden */
  115852. _extension: string;
  115853. /** @hidden */
  115854. _files: Nullable<string[]>;
  115855. /** @hidden */
  115856. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  115857. /** @hidden */
  115858. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  115859. /** @hidden */
  115860. _framebuffer: Nullable<WebGLFramebuffer>;
  115861. /** @hidden */
  115862. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  115863. /** @hidden */
  115864. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  115865. /** @hidden */
  115866. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  115867. /** @hidden */
  115868. _attachments: Nullable<number[]>;
  115869. /** @hidden */
  115870. _textureArray: Nullable<InternalTexture[]>;
  115871. /** @hidden */
  115872. _cachedCoordinatesMode: Nullable<number>;
  115873. /** @hidden */
  115874. _cachedWrapU: Nullable<number>;
  115875. /** @hidden */
  115876. _cachedWrapV: Nullable<number>;
  115877. /** @hidden */
  115878. _cachedWrapR: Nullable<number>;
  115879. /** @hidden */
  115880. _cachedAnisotropicFilteringLevel: Nullable<number>;
  115881. /** @hidden */
  115882. _isDisabled: boolean;
  115883. /** @hidden */
  115884. _compression: Nullable<string>;
  115885. /** @hidden */
  115886. _generateStencilBuffer: boolean;
  115887. /** @hidden */
  115888. _generateDepthBuffer: boolean;
  115889. /** @hidden */
  115890. _comparisonFunction: number;
  115891. /** @hidden */
  115892. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  115893. /** @hidden */
  115894. _lodGenerationScale: number;
  115895. /** @hidden */
  115896. _lodGenerationOffset: number;
  115897. /** @hidden */
  115898. _depthStencilTexture: Nullable<InternalTexture>;
  115899. /** @hidden */
  115900. _colorTextureArray: Nullable<WebGLTexture>;
  115901. /** @hidden */
  115902. _depthStencilTextureArray: Nullable<WebGLTexture>;
  115903. /** @hidden */
  115904. _lodTextureHigh: Nullable<BaseTexture>;
  115905. /** @hidden */
  115906. _lodTextureMid: Nullable<BaseTexture>;
  115907. /** @hidden */
  115908. _lodTextureLow: Nullable<BaseTexture>;
  115909. /** @hidden */
  115910. _isRGBD: boolean;
  115911. /** @hidden */
  115912. _linearSpecularLOD: boolean;
  115913. /** @hidden */
  115914. _irradianceTexture: Nullable<BaseTexture>;
  115915. /** @hidden */
  115916. _webGLTexture: Nullable<WebGLTexture>;
  115917. /** @hidden */
  115918. _references: number;
  115919. private _engine;
  115920. /**
  115921. * Gets the Engine the texture belongs to.
  115922. * @returns The babylon engine
  115923. */
  115924. getEngine(): ThinEngine;
  115925. /**
  115926. * Gets the data source type of the texture
  115927. */
  115928. get source(): InternalTextureSource;
  115929. /**
  115930. * Creates a new InternalTexture
  115931. * @param engine defines the engine to use
  115932. * @param source defines the type of data that will be used
  115933. * @param delayAllocation if the texture allocation should be delayed (default: false)
  115934. */
  115935. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  115936. /**
  115937. * Increments the number of references (ie. the number of Texture that point to it)
  115938. */
  115939. incrementReferences(): void;
  115940. /**
  115941. * Change the size of the texture (not the size of the content)
  115942. * @param width defines the new width
  115943. * @param height defines the new height
  115944. * @param depth defines the new depth (1 by default)
  115945. */
  115946. updateSize(width: int, height: int, depth?: int): void;
  115947. /** @hidden */
  115948. _rebuild(): void;
  115949. /** @hidden */
  115950. _swapAndDie(target: InternalTexture): void;
  115951. /**
  115952. * Dispose the current allocated resources
  115953. */
  115954. dispose(): void;
  115955. }
  115956. }
  115957. declare module BABYLON {
  115958. /**
  115959. * Class used to work with sound analyzer using fast fourier transform (FFT)
  115960. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  115961. */
  115962. export class Analyser {
  115963. /**
  115964. * Gets or sets the smoothing
  115965. * @ignorenaming
  115966. */
  115967. SMOOTHING: number;
  115968. /**
  115969. * Gets or sets the FFT table size
  115970. * @ignorenaming
  115971. */
  115972. FFT_SIZE: number;
  115973. /**
  115974. * Gets or sets the bar graph amplitude
  115975. * @ignorenaming
  115976. */
  115977. BARGRAPHAMPLITUDE: number;
  115978. /**
  115979. * Gets or sets the position of the debug canvas
  115980. * @ignorenaming
  115981. */
  115982. DEBUGCANVASPOS: {
  115983. x: number;
  115984. y: number;
  115985. };
  115986. /**
  115987. * Gets or sets the debug canvas size
  115988. * @ignorenaming
  115989. */
  115990. DEBUGCANVASSIZE: {
  115991. width: number;
  115992. height: number;
  115993. };
  115994. private _byteFreqs;
  115995. private _byteTime;
  115996. private _floatFreqs;
  115997. private _webAudioAnalyser;
  115998. private _debugCanvas;
  115999. private _debugCanvasContext;
  116000. private _scene;
  116001. private _registerFunc;
  116002. private _audioEngine;
  116003. /**
  116004. * Creates a new analyser
  116005. * @param scene defines hosting scene
  116006. */
  116007. constructor(scene: Scene);
  116008. /**
  116009. * Get the number of data values you will have to play with for the visualization
  116010. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  116011. * @returns a number
  116012. */
  116013. getFrequencyBinCount(): number;
  116014. /**
  116015. * Gets the current frequency data as a byte array
  116016. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  116017. * @returns a Uint8Array
  116018. */
  116019. getByteFrequencyData(): Uint8Array;
  116020. /**
  116021. * Gets the current waveform as a byte array
  116022. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  116023. * @returns a Uint8Array
  116024. */
  116025. getByteTimeDomainData(): Uint8Array;
  116026. /**
  116027. * Gets the current frequency data as a float array
  116028. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  116029. * @returns a Float32Array
  116030. */
  116031. getFloatFrequencyData(): Float32Array;
  116032. /**
  116033. * Renders the debug canvas
  116034. */
  116035. drawDebugCanvas(): void;
  116036. /**
  116037. * Stops rendering the debug canvas and removes it
  116038. */
  116039. stopDebugCanvas(): void;
  116040. /**
  116041. * Connects two audio nodes
  116042. * @param inputAudioNode defines first node to connect
  116043. * @param outputAudioNode defines second node to connect
  116044. */
  116045. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  116046. /**
  116047. * Releases all associated resources
  116048. */
  116049. dispose(): void;
  116050. }
  116051. }
  116052. declare module BABYLON {
  116053. /**
  116054. * This represents an audio engine and it is responsible
  116055. * to play, synchronize and analyse sounds throughout the application.
  116056. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  116057. */
  116058. export interface IAudioEngine extends IDisposable {
  116059. /**
  116060. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  116061. */
  116062. readonly canUseWebAudio: boolean;
  116063. /**
  116064. * Gets the current AudioContext if available.
  116065. */
  116066. readonly audioContext: Nullable<AudioContext>;
  116067. /**
  116068. * The master gain node defines the global audio volume of your audio engine.
  116069. */
  116070. readonly masterGain: GainNode;
  116071. /**
  116072. * Gets whether or not mp3 are supported by your browser.
  116073. */
  116074. readonly isMP3supported: boolean;
  116075. /**
  116076. * Gets whether or not ogg are supported by your browser.
  116077. */
  116078. readonly isOGGsupported: boolean;
  116079. /**
  116080. * Defines if Babylon should emit a warning if WebAudio is not supported.
  116081. * @ignoreNaming
  116082. */
  116083. WarnedWebAudioUnsupported: boolean;
  116084. /**
  116085. * Defines if the audio engine relies on a custom unlocked button.
  116086. * In this case, the embedded button will not be displayed.
  116087. */
  116088. useCustomUnlockedButton: boolean;
  116089. /**
  116090. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  116091. */
  116092. readonly unlocked: boolean;
  116093. /**
  116094. * Event raised when audio has been unlocked on the browser.
  116095. */
  116096. onAudioUnlockedObservable: Observable<AudioEngine>;
  116097. /**
  116098. * Event raised when audio has been locked on the browser.
  116099. */
  116100. onAudioLockedObservable: Observable<AudioEngine>;
  116101. /**
  116102. * Flags the audio engine in Locked state.
  116103. * This happens due to new browser policies preventing audio to autoplay.
  116104. */
  116105. lock(): void;
  116106. /**
  116107. * Unlocks the audio engine once a user action has been done on the dom.
  116108. * This is helpful to resume play once browser policies have been satisfied.
  116109. */
  116110. unlock(): void;
  116111. /**
  116112. * Gets the global volume sets on the master gain.
  116113. * @returns the global volume if set or -1 otherwise
  116114. */
  116115. getGlobalVolume(): number;
  116116. /**
  116117. * Sets the global volume of your experience (sets on the master gain).
  116118. * @param newVolume Defines the new global volume of the application
  116119. */
  116120. setGlobalVolume(newVolume: number): void;
  116121. /**
  116122. * Connect the audio engine to an audio analyser allowing some amazing
  116123. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  116124. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  116125. * @param analyser The analyser to connect to the engine
  116126. */
  116127. connectToAnalyser(analyser: Analyser): void;
  116128. }
  116129. /**
  116130. * This represents the default audio engine used in babylon.
  116131. * It is responsible to play, synchronize and analyse sounds throughout the application.
  116132. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  116133. */
  116134. export class AudioEngine implements IAudioEngine {
  116135. private _audioContext;
  116136. private _audioContextInitialized;
  116137. private _muteButton;
  116138. private _hostElement;
  116139. /**
  116140. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  116141. */
  116142. canUseWebAudio: boolean;
  116143. /**
  116144. * The master gain node defines the global audio volume of your audio engine.
  116145. */
  116146. masterGain: GainNode;
  116147. /**
  116148. * Defines if Babylon should emit a warning if WebAudio is not supported.
  116149. * @ignoreNaming
  116150. */
  116151. WarnedWebAudioUnsupported: boolean;
  116152. /**
  116153. * Gets whether or not mp3 are supported by your browser.
  116154. */
  116155. isMP3supported: boolean;
  116156. /**
  116157. * Gets whether or not ogg are supported by your browser.
  116158. */
  116159. isOGGsupported: boolean;
  116160. /**
  116161. * Gets whether audio has been unlocked on the device.
  116162. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  116163. * a user interaction has happened.
  116164. */
  116165. unlocked: boolean;
  116166. /**
  116167. * Defines if the audio engine relies on a custom unlocked button.
  116168. * In this case, the embedded button will not be displayed.
  116169. */
  116170. useCustomUnlockedButton: boolean;
  116171. /**
  116172. * Event raised when audio has been unlocked on the browser.
  116173. */
  116174. onAudioUnlockedObservable: Observable<AudioEngine>;
  116175. /**
  116176. * Event raised when audio has been locked on the browser.
  116177. */
  116178. onAudioLockedObservable: Observable<AudioEngine>;
  116179. /**
  116180. * Gets the current AudioContext if available.
  116181. */
  116182. get audioContext(): Nullable<AudioContext>;
  116183. private _connectedAnalyser;
  116184. /**
  116185. * Instantiates a new audio engine.
  116186. *
  116187. * There should be only one per page as some browsers restrict the number
  116188. * of audio contexts you can create.
  116189. * @param hostElement defines the host element where to display the mute icon if necessary
  116190. */
  116191. constructor(hostElement?: Nullable<HTMLElement>);
  116192. /**
  116193. * Flags the audio engine in Locked state.
  116194. * This happens due to new browser policies preventing audio to autoplay.
  116195. */
  116196. lock(): void;
  116197. /**
  116198. * Unlocks the audio engine once a user action has been done on the dom.
  116199. * This is helpful to resume play once browser policies have been satisfied.
  116200. */
  116201. unlock(): void;
  116202. private _resumeAudioContext;
  116203. private _initializeAudioContext;
  116204. private _tryToRun;
  116205. private _triggerRunningState;
  116206. private _triggerSuspendedState;
  116207. private _displayMuteButton;
  116208. private _moveButtonToTopLeft;
  116209. private _onResize;
  116210. private _hideMuteButton;
  116211. /**
  116212. * Destroy and release the resources associated with the audio ccontext.
  116213. */
  116214. dispose(): void;
  116215. /**
  116216. * Gets the global volume sets on the master gain.
  116217. * @returns the global volume if set or -1 otherwise
  116218. */
  116219. getGlobalVolume(): number;
  116220. /**
  116221. * Sets the global volume of your experience (sets on the master gain).
  116222. * @param newVolume Defines the new global volume of the application
  116223. */
  116224. setGlobalVolume(newVolume: number): void;
  116225. /**
  116226. * Connect the audio engine to an audio analyser allowing some amazing
  116227. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  116228. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  116229. * @param analyser The analyser to connect to the engine
  116230. */
  116231. connectToAnalyser(analyser: Analyser): void;
  116232. }
  116233. }
  116234. declare module BABYLON {
  116235. /**
  116236. * Interface used to present a loading screen while loading a scene
  116237. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  116238. */
  116239. export interface ILoadingScreen {
  116240. /**
  116241. * Function called to display the loading screen
  116242. */
  116243. displayLoadingUI: () => void;
  116244. /**
  116245. * Function called to hide the loading screen
  116246. */
  116247. hideLoadingUI: () => void;
  116248. /**
  116249. * Gets or sets the color to use for the background
  116250. */
  116251. loadingUIBackgroundColor: string;
  116252. /**
  116253. * Gets or sets the text to display while loading
  116254. */
  116255. loadingUIText: string;
  116256. }
  116257. /**
  116258. * Class used for the default loading screen
  116259. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  116260. */
  116261. export class DefaultLoadingScreen implements ILoadingScreen {
  116262. private _renderingCanvas;
  116263. private _loadingText;
  116264. private _loadingDivBackgroundColor;
  116265. private _loadingDiv;
  116266. private _loadingTextDiv;
  116267. /** Gets or sets the logo url to use for the default loading screen */
  116268. static DefaultLogoUrl: string;
  116269. /** Gets or sets the spinner url to use for the default loading screen */
  116270. static DefaultSpinnerUrl: string;
  116271. /**
  116272. * Creates a new default loading screen
  116273. * @param _renderingCanvas defines the canvas used to render the scene
  116274. * @param _loadingText defines the default text to display
  116275. * @param _loadingDivBackgroundColor defines the default background color
  116276. */
  116277. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  116278. /**
  116279. * Function called to display the loading screen
  116280. */
  116281. displayLoadingUI(): void;
  116282. /**
  116283. * Function called to hide the loading screen
  116284. */
  116285. hideLoadingUI(): void;
  116286. /**
  116287. * Gets or sets the text to display while loading
  116288. */
  116289. set loadingUIText(text: string);
  116290. get loadingUIText(): string;
  116291. /**
  116292. * Gets or sets the color to use for the background
  116293. */
  116294. get loadingUIBackgroundColor(): string;
  116295. set loadingUIBackgroundColor(color: string);
  116296. private _resizeLoadingUI;
  116297. }
  116298. }
  116299. declare module BABYLON {
  116300. /**
  116301. * Interface for any object that can request an animation frame
  116302. */
  116303. export interface ICustomAnimationFrameRequester {
  116304. /**
  116305. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  116306. */
  116307. renderFunction?: Function;
  116308. /**
  116309. * Called to request the next frame to render to
  116310. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  116311. */
  116312. requestAnimationFrame: Function;
  116313. /**
  116314. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  116315. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  116316. */
  116317. requestID?: number;
  116318. }
  116319. }
  116320. declare module BABYLON {
  116321. /**
  116322. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  116323. */
  116324. export class PerformanceMonitor {
  116325. private _enabled;
  116326. private _rollingFrameTime;
  116327. private _lastFrameTimeMs;
  116328. /**
  116329. * constructor
  116330. * @param frameSampleSize The number of samples required to saturate the sliding window
  116331. */
  116332. constructor(frameSampleSize?: number);
  116333. /**
  116334. * Samples current frame
  116335. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  116336. */
  116337. sampleFrame(timeMs?: number): void;
  116338. /**
  116339. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  116340. */
  116341. get averageFrameTime(): number;
  116342. /**
  116343. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  116344. */
  116345. get averageFrameTimeVariance(): number;
  116346. /**
  116347. * Returns the frame time of the most recent frame
  116348. */
  116349. get instantaneousFrameTime(): number;
  116350. /**
  116351. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  116352. */
  116353. get averageFPS(): number;
  116354. /**
  116355. * Returns the average framerate in frames per second using the most recent frame time
  116356. */
  116357. get instantaneousFPS(): number;
  116358. /**
  116359. * Returns true if enough samples have been taken to completely fill the sliding window
  116360. */
  116361. get isSaturated(): boolean;
  116362. /**
  116363. * Enables contributions to the sliding window sample set
  116364. */
  116365. enable(): void;
  116366. /**
  116367. * Disables contributions to the sliding window sample set
  116368. * Samples will not be interpolated over the disabled period
  116369. */
  116370. disable(): void;
  116371. /**
  116372. * Returns true if sampling is enabled
  116373. */
  116374. get isEnabled(): boolean;
  116375. /**
  116376. * Resets performance monitor
  116377. */
  116378. reset(): void;
  116379. }
  116380. /**
  116381. * RollingAverage
  116382. *
  116383. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  116384. */
  116385. export class RollingAverage {
  116386. /**
  116387. * Current average
  116388. */
  116389. average: number;
  116390. /**
  116391. * Current variance
  116392. */
  116393. variance: number;
  116394. protected _samples: Array<number>;
  116395. protected _sampleCount: number;
  116396. protected _pos: number;
  116397. protected _m2: number;
  116398. /**
  116399. * constructor
  116400. * @param length The number of samples required to saturate the sliding window
  116401. */
  116402. constructor(length: number);
  116403. /**
  116404. * Adds a sample to the sample set
  116405. * @param v The sample value
  116406. */
  116407. add(v: number): void;
  116408. /**
  116409. * Returns previously added values or null if outside of history or outside the sliding window domain
  116410. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  116411. * @return Value previously recorded with add() or null if outside of range
  116412. */
  116413. history(i: number): number;
  116414. /**
  116415. * Returns true if enough samples have been taken to completely fill the sliding window
  116416. * @return true if sample-set saturated
  116417. */
  116418. isSaturated(): boolean;
  116419. /**
  116420. * Resets the rolling average (equivalent to 0 samples taken so far)
  116421. */
  116422. reset(): void;
  116423. /**
  116424. * Wraps a value around the sample range boundaries
  116425. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  116426. * @return Wrapped position in sample range
  116427. */
  116428. protected _wrapPosition(i: number): number;
  116429. }
  116430. }
  116431. declare module BABYLON {
  116432. /**
  116433. * This class is used to track a performance counter which is number based.
  116434. * The user has access to many properties which give statistics of different nature.
  116435. *
  116436. * The implementer can track two kinds of Performance Counter: time and count.
  116437. * 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.
  116438. * 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.
  116439. */
  116440. export class PerfCounter {
  116441. /**
  116442. * Gets or sets a global boolean to turn on and off all the counters
  116443. */
  116444. static Enabled: boolean;
  116445. /**
  116446. * Returns the smallest value ever
  116447. */
  116448. get min(): number;
  116449. /**
  116450. * Returns the biggest value ever
  116451. */
  116452. get max(): number;
  116453. /**
  116454. * Returns the average value since the performance counter is running
  116455. */
  116456. get average(): number;
  116457. /**
  116458. * Returns the average value of the last second the counter was monitored
  116459. */
  116460. get lastSecAverage(): number;
  116461. /**
  116462. * Returns the current value
  116463. */
  116464. get current(): number;
  116465. /**
  116466. * Gets the accumulated total
  116467. */
  116468. get total(): number;
  116469. /**
  116470. * Gets the total value count
  116471. */
  116472. get count(): number;
  116473. /**
  116474. * Creates a new counter
  116475. */
  116476. constructor();
  116477. /**
  116478. * Call this method to start monitoring a new frame.
  116479. * 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.
  116480. */
  116481. fetchNewFrame(): void;
  116482. /**
  116483. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  116484. * @param newCount the count value to add to the monitored count
  116485. * @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.
  116486. */
  116487. addCount(newCount: number, fetchResult: boolean): void;
  116488. /**
  116489. * Start monitoring this performance counter
  116490. */
  116491. beginMonitoring(): void;
  116492. /**
  116493. * Compute the time lapsed since the previous beginMonitoring() call.
  116494. * @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
  116495. */
  116496. endMonitoring(newFrame?: boolean): void;
  116497. private _fetchResult;
  116498. private _startMonitoringTime;
  116499. private _min;
  116500. private _max;
  116501. private _average;
  116502. private _current;
  116503. private _totalValueCount;
  116504. private _totalAccumulated;
  116505. private _lastSecAverage;
  116506. private _lastSecAccumulated;
  116507. private _lastSecTime;
  116508. private _lastSecValueCount;
  116509. }
  116510. }
  116511. declare module BABYLON {
  116512. interface ThinEngine {
  116513. /** @hidden */
  116514. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  116515. }
  116516. }
  116517. declare module BABYLON {
  116518. /**
  116519. * Defines the interface used by display changed events
  116520. */
  116521. export interface IDisplayChangedEventArgs {
  116522. /** Gets the vrDisplay object (if any) */
  116523. vrDisplay: Nullable<any>;
  116524. /** Gets a boolean indicating if webVR is supported */
  116525. vrSupported: boolean;
  116526. }
  116527. /**
  116528. * Defines the interface used by objects containing a viewport (like a camera)
  116529. */
  116530. interface IViewportOwnerLike {
  116531. /**
  116532. * Gets or sets the viewport
  116533. */
  116534. viewport: IViewportLike;
  116535. }
  116536. /**
  116537. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  116538. */
  116539. export class Engine extends ThinEngine {
  116540. /** Defines that alpha blending is disabled */
  116541. static readonly ALPHA_DISABLE: number;
  116542. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  116543. static readonly ALPHA_ADD: number;
  116544. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  116545. static readonly ALPHA_COMBINE: number;
  116546. /** Defines that alpha blending to DEST - SRC * DEST */
  116547. static readonly ALPHA_SUBTRACT: number;
  116548. /** Defines that alpha blending to SRC * DEST */
  116549. static readonly ALPHA_MULTIPLY: number;
  116550. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  116551. static readonly ALPHA_MAXIMIZED: number;
  116552. /** Defines that alpha blending to SRC + DEST */
  116553. static readonly ALPHA_ONEONE: number;
  116554. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  116555. static readonly ALPHA_PREMULTIPLIED: number;
  116556. /**
  116557. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  116558. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  116559. */
  116560. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  116561. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  116562. static readonly ALPHA_INTERPOLATE: number;
  116563. /**
  116564. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  116565. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  116566. */
  116567. static readonly ALPHA_SCREENMODE: number;
  116568. /** Defines that the ressource is not delayed*/
  116569. static readonly DELAYLOADSTATE_NONE: number;
  116570. /** Defines that the ressource was successfully delay loaded */
  116571. static readonly DELAYLOADSTATE_LOADED: number;
  116572. /** Defines that the ressource is currently delay loading */
  116573. static readonly DELAYLOADSTATE_LOADING: number;
  116574. /** Defines that the ressource is delayed and has not started loading */
  116575. static readonly DELAYLOADSTATE_NOTLOADED: number;
  116576. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  116577. static readonly NEVER: number;
  116578. /** 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 */
  116579. static readonly ALWAYS: number;
  116580. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  116581. static readonly LESS: number;
  116582. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  116583. static readonly EQUAL: number;
  116584. /** 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 */
  116585. static readonly LEQUAL: number;
  116586. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  116587. static readonly GREATER: number;
  116588. /** 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 */
  116589. static readonly GEQUAL: number;
  116590. /** 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 */
  116591. static readonly NOTEQUAL: number;
  116592. /** Passed to stencilOperation to specify that stencil value must be kept */
  116593. static readonly KEEP: number;
  116594. /** Passed to stencilOperation to specify that stencil value must be replaced */
  116595. static readonly REPLACE: number;
  116596. /** Passed to stencilOperation to specify that stencil value must be incremented */
  116597. static readonly INCR: number;
  116598. /** Passed to stencilOperation to specify that stencil value must be decremented */
  116599. static readonly DECR: number;
  116600. /** Passed to stencilOperation to specify that stencil value must be inverted */
  116601. static readonly INVERT: number;
  116602. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  116603. static readonly INCR_WRAP: number;
  116604. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  116605. static readonly DECR_WRAP: number;
  116606. /** Texture is not repeating outside of 0..1 UVs */
  116607. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  116608. /** Texture is repeating outside of 0..1 UVs */
  116609. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  116610. /** Texture is repeating and mirrored */
  116611. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  116612. /** ALPHA */
  116613. static readonly TEXTUREFORMAT_ALPHA: number;
  116614. /** LUMINANCE */
  116615. static readonly TEXTUREFORMAT_LUMINANCE: number;
  116616. /** LUMINANCE_ALPHA */
  116617. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  116618. /** RGB */
  116619. static readonly TEXTUREFORMAT_RGB: number;
  116620. /** RGBA */
  116621. static readonly TEXTUREFORMAT_RGBA: number;
  116622. /** RED */
  116623. static readonly TEXTUREFORMAT_RED: number;
  116624. /** RED (2nd reference) */
  116625. static readonly TEXTUREFORMAT_R: number;
  116626. /** RG */
  116627. static readonly TEXTUREFORMAT_RG: number;
  116628. /** RED_INTEGER */
  116629. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  116630. /** RED_INTEGER (2nd reference) */
  116631. static readonly TEXTUREFORMAT_R_INTEGER: number;
  116632. /** RG_INTEGER */
  116633. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  116634. /** RGB_INTEGER */
  116635. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  116636. /** RGBA_INTEGER */
  116637. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  116638. /** UNSIGNED_BYTE */
  116639. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  116640. /** UNSIGNED_BYTE (2nd reference) */
  116641. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  116642. /** FLOAT */
  116643. static readonly TEXTURETYPE_FLOAT: number;
  116644. /** HALF_FLOAT */
  116645. static readonly TEXTURETYPE_HALF_FLOAT: number;
  116646. /** BYTE */
  116647. static readonly TEXTURETYPE_BYTE: number;
  116648. /** SHORT */
  116649. static readonly TEXTURETYPE_SHORT: number;
  116650. /** UNSIGNED_SHORT */
  116651. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  116652. /** INT */
  116653. static readonly TEXTURETYPE_INT: number;
  116654. /** UNSIGNED_INT */
  116655. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  116656. /** UNSIGNED_SHORT_4_4_4_4 */
  116657. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  116658. /** UNSIGNED_SHORT_5_5_5_1 */
  116659. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  116660. /** UNSIGNED_SHORT_5_6_5 */
  116661. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  116662. /** UNSIGNED_INT_2_10_10_10_REV */
  116663. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  116664. /** UNSIGNED_INT_24_8 */
  116665. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  116666. /** UNSIGNED_INT_10F_11F_11F_REV */
  116667. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  116668. /** UNSIGNED_INT_5_9_9_9_REV */
  116669. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  116670. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  116671. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  116672. /** nearest is mag = nearest and min = nearest and mip = linear */
  116673. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  116674. /** Bilinear is mag = linear and min = linear and mip = nearest */
  116675. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  116676. /** Trilinear is mag = linear and min = linear and mip = linear */
  116677. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  116678. /** nearest is mag = nearest and min = nearest and mip = linear */
  116679. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  116680. /** Bilinear is mag = linear and min = linear and mip = nearest */
  116681. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  116682. /** Trilinear is mag = linear and min = linear and mip = linear */
  116683. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  116684. /** mag = nearest and min = nearest and mip = nearest */
  116685. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  116686. /** mag = nearest and min = linear and mip = nearest */
  116687. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  116688. /** mag = nearest and min = linear and mip = linear */
  116689. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  116690. /** mag = nearest and min = linear and mip = none */
  116691. static readonly TEXTURE_NEAREST_LINEAR: number;
  116692. /** mag = nearest and min = nearest and mip = none */
  116693. static readonly TEXTURE_NEAREST_NEAREST: number;
  116694. /** mag = linear and min = nearest and mip = nearest */
  116695. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  116696. /** mag = linear and min = nearest and mip = linear */
  116697. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  116698. /** mag = linear and min = linear and mip = none */
  116699. static readonly TEXTURE_LINEAR_LINEAR: number;
  116700. /** mag = linear and min = nearest and mip = none */
  116701. static readonly TEXTURE_LINEAR_NEAREST: number;
  116702. /** Explicit coordinates mode */
  116703. static readonly TEXTURE_EXPLICIT_MODE: number;
  116704. /** Spherical coordinates mode */
  116705. static readonly TEXTURE_SPHERICAL_MODE: number;
  116706. /** Planar coordinates mode */
  116707. static readonly TEXTURE_PLANAR_MODE: number;
  116708. /** Cubic coordinates mode */
  116709. static readonly TEXTURE_CUBIC_MODE: number;
  116710. /** Projection coordinates mode */
  116711. static readonly TEXTURE_PROJECTION_MODE: number;
  116712. /** Skybox coordinates mode */
  116713. static readonly TEXTURE_SKYBOX_MODE: number;
  116714. /** Inverse Cubic coordinates mode */
  116715. static readonly TEXTURE_INVCUBIC_MODE: number;
  116716. /** Equirectangular coordinates mode */
  116717. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  116718. /** Equirectangular Fixed coordinates mode */
  116719. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  116720. /** Equirectangular Fixed Mirrored coordinates mode */
  116721. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  116722. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  116723. static readonly SCALEMODE_FLOOR: number;
  116724. /** Defines that texture rescaling will look for the nearest power of 2 size */
  116725. static readonly SCALEMODE_NEAREST: number;
  116726. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  116727. static readonly SCALEMODE_CEILING: number;
  116728. /**
  116729. * Returns the current npm package of the sdk
  116730. */
  116731. static get NpmPackage(): string;
  116732. /**
  116733. * Returns the current version of the framework
  116734. */
  116735. static get Version(): string;
  116736. /** Gets the list of created engines */
  116737. static get Instances(): Engine[];
  116738. /**
  116739. * Gets the latest created engine
  116740. */
  116741. static get LastCreatedEngine(): Nullable<Engine>;
  116742. /**
  116743. * Gets the latest created scene
  116744. */
  116745. static get LastCreatedScene(): Nullable<Scene>;
  116746. /**
  116747. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  116748. * @param flag defines which part of the materials must be marked as dirty
  116749. * @param predicate defines a predicate used to filter which materials should be affected
  116750. */
  116751. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  116752. /**
  116753. * Method called to create the default loading screen.
  116754. * This can be overriden in your own app.
  116755. * @param canvas The rendering canvas element
  116756. * @returns The loading screen
  116757. */
  116758. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  116759. /**
  116760. * Method called to create the default rescale post process on each engine.
  116761. */
  116762. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  116763. /**
  116764. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  116765. **/
  116766. enableOfflineSupport: boolean;
  116767. /**
  116768. * 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)
  116769. **/
  116770. disableManifestCheck: boolean;
  116771. /**
  116772. * Gets the list of created scenes
  116773. */
  116774. scenes: Scene[];
  116775. /**
  116776. * Event raised when a new scene is created
  116777. */
  116778. onNewSceneAddedObservable: Observable<Scene>;
  116779. /**
  116780. * Gets the list of created postprocesses
  116781. */
  116782. postProcesses: PostProcess[];
  116783. /**
  116784. * Gets a boolean indicating if the pointer is currently locked
  116785. */
  116786. isPointerLock: boolean;
  116787. /**
  116788. * Observable event triggered each time the rendering canvas is resized
  116789. */
  116790. onResizeObservable: Observable<Engine>;
  116791. /**
  116792. * Observable event triggered each time the canvas loses focus
  116793. */
  116794. onCanvasBlurObservable: Observable<Engine>;
  116795. /**
  116796. * Observable event triggered each time the canvas gains focus
  116797. */
  116798. onCanvasFocusObservable: Observable<Engine>;
  116799. /**
  116800. * Observable event triggered each time the canvas receives pointerout event
  116801. */
  116802. onCanvasPointerOutObservable: Observable<PointerEvent>;
  116803. /**
  116804. * Observable raised when the engine begins a new frame
  116805. */
  116806. onBeginFrameObservable: Observable<Engine>;
  116807. /**
  116808. * If set, will be used to request the next animation frame for the render loop
  116809. */
  116810. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  116811. /**
  116812. * Observable raised when the engine ends the current frame
  116813. */
  116814. onEndFrameObservable: Observable<Engine>;
  116815. /**
  116816. * Observable raised when the engine is about to compile a shader
  116817. */
  116818. onBeforeShaderCompilationObservable: Observable<Engine>;
  116819. /**
  116820. * Observable raised when the engine has jsut compiled a shader
  116821. */
  116822. onAfterShaderCompilationObservable: Observable<Engine>;
  116823. /**
  116824. * Gets the audio engine
  116825. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  116826. * @ignorenaming
  116827. */
  116828. static audioEngine: IAudioEngine;
  116829. /**
  116830. * Default AudioEngine factory responsible of creating the Audio Engine.
  116831. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  116832. */
  116833. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  116834. /**
  116835. * Default offline support factory responsible of creating a tool used to store data locally.
  116836. * By default, this will create a Database object if the workload has been embedded.
  116837. */
  116838. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  116839. private _loadingScreen;
  116840. private _pointerLockRequested;
  116841. private _rescalePostProcess;
  116842. private _deterministicLockstep;
  116843. private _lockstepMaxSteps;
  116844. private _timeStep;
  116845. protected get _supportsHardwareTextureRescaling(): boolean;
  116846. private _fps;
  116847. private _deltaTime;
  116848. /** @hidden */
  116849. _drawCalls: PerfCounter;
  116850. /** 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 */
  116851. canvasTabIndex: number;
  116852. /**
  116853. * Turn this value on if you want to pause FPS computation when in background
  116854. */
  116855. disablePerformanceMonitorInBackground: boolean;
  116856. private _performanceMonitor;
  116857. /**
  116858. * Gets the performance monitor attached to this engine
  116859. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  116860. */
  116861. get performanceMonitor(): PerformanceMonitor;
  116862. private _onFocus;
  116863. private _onBlur;
  116864. private _onCanvasPointerOut;
  116865. private _onCanvasBlur;
  116866. private _onCanvasFocus;
  116867. private _onFullscreenChange;
  116868. private _onPointerLockChange;
  116869. /**
  116870. * Gets the HTML element used to attach event listeners
  116871. * @returns a HTML element
  116872. */
  116873. getInputElement(): Nullable<HTMLElement>;
  116874. /**
  116875. * Creates a new engine
  116876. * @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
  116877. * @param antialias defines enable antialiasing (default: false)
  116878. * @param options defines further options to be sent to the getContext() function
  116879. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  116880. */
  116881. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  116882. /**
  116883. * Gets current aspect ratio
  116884. * @param viewportOwner defines the camera to use to get the aspect ratio
  116885. * @param useScreen defines if screen size must be used (or the current render target if any)
  116886. * @returns a number defining the aspect ratio
  116887. */
  116888. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  116889. /**
  116890. * Gets current screen aspect ratio
  116891. * @returns a number defining the aspect ratio
  116892. */
  116893. getScreenAspectRatio(): number;
  116894. /**
  116895. * Gets the client rect of the HTML canvas attached with the current webGL context
  116896. * @returns a client rectanglee
  116897. */
  116898. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  116899. /**
  116900. * Gets the client rect of the HTML element used for events
  116901. * @returns a client rectanglee
  116902. */
  116903. getInputElementClientRect(): Nullable<ClientRect>;
  116904. /**
  116905. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  116906. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116907. * @returns true if engine is in deterministic lock step mode
  116908. */
  116909. isDeterministicLockStep(): boolean;
  116910. /**
  116911. * Gets the max steps when engine is running in deterministic lock step
  116912. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116913. * @returns the max steps
  116914. */
  116915. getLockstepMaxSteps(): number;
  116916. /**
  116917. * Returns the time in ms between steps when using deterministic lock step.
  116918. * @returns time step in (ms)
  116919. */
  116920. getTimeStep(): number;
  116921. /**
  116922. * Force the mipmap generation for the given render target texture
  116923. * @param texture defines the render target texture to use
  116924. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  116925. */
  116926. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  116927. /** States */
  116928. /**
  116929. * Set various states to the webGL context
  116930. * @param culling defines backface culling state
  116931. * @param zOffset defines the value to apply to zOffset (0 by default)
  116932. * @param force defines if states must be applied even if cache is up to date
  116933. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  116934. */
  116935. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  116936. /**
  116937. * Set the z offset to apply to current rendering
  116938. * @param value defines the offset to apply
  116939. */
  116940. setZOffset(value: number): void;
  116941. /**
  116942. * Gets the current value of the zOffset
  116943. * @returns the current zOffset state
  116944. */
  116945. getZOffset(): number;
  116946. /**
  116947. * Enable or disable depth buffering
  116948. * @param enable defines the state to set
  116949. */
  116950. setDepthBuffer(enable: boolean): void;
  116951. /**
  116952. * Gets a boolean indicating if depth writing is enabled
  116953. * @returns the current depth writing state
  116954. */
  116955. getDepthWrite(): boolean;
  116956. /**
  116957. * Enable or disable depth writing
  116958. * @param enable defines the state to set
  116959. */
  116960. setDepthWrite(enable: boolean): void;
  116961. /**
  116962. * Gets a boolean indicating if stencil buffer is enabled
  116963. * @returns the current stencil buffer state
  116964. */
  116965. getStencilBuffer(): boolean;
  116966. /**
  116967. * Enable or disable the stencil buffer
  116968. * @param enable defines if the stencil buffer must be enabled or disabled
  116969. */
  116970. setStencilBuffer(enable: boolean): void;
  116971. /**
  116972. * Gets the current stencil mask
  116973. * @returns a number defining the new stencil mask to use
  116974. */
  116975. getStencilMask(): number;
  116976. /**
  116977. * Sets the current stencil mask
  116978. * @param mask defines the new stencil mask to use
  116979. */
  116980. setStencilMask(mask: number): void;
  116981. /**
  116982. * Gets the current stencil function
  116983. * @returns a number defining the stencil function to use
  116984. */
  116985. getStencilFunction(): number;
  116986. /**
  116987. * Gets the current stencil reference value
  116988. * @returns a number defining the stencil reference value to use
  116989. */
  116990. getStencilFunctionReference(): number;
  116991. /**
  116992. * Gets the current stencil mask
  116993. * @returns a number defining the stencil mask to use
  116994. */
  116995. getStencilFunctionMask(): number;
  116996. /**
  116997. * Sets the current stencil function
  116998. * @param stencilFunc defines the new stencil function to use
  116999. */
  117000. setStencilFunction(stencilFunc: number): void;
  117001. /**
  117002. * Sets the current stencil reference
  117003. * @param reference defines the new stencil reference to use
  117004. */
  117005. setStencilFunctionReference(reference: number): void;
  117006. /**
  117007. * Sets the current stencil mask
  117008. * @param mask defines the new stencil mask to use
  117009. */
  117010. setStencilFunctionMask(mask: number): void;
  117011. /**
  117012. * Gets the current stencil operation when stencil fails
  117013. * @returns a number defining stencil operation to use when stencil fails
  117014. */
  117015. getStencilOperationFail(): number;
  117016. /**
  117017. * Gets the current stencil operation when depth fails
  117018. * @returns a number defining stencil operation to use when depth fails
  117019. */
  117020. getStencilOperationDepthFail(): number;
  117021. /**
  117022. * Gets the current stencil operation when stencil passes
  117023. * @returns a number defining stencil operation to use when stencil passes
  117024. */
  117025. getStencilOperationPass(): number;
  117026. /**
  117027. * Sets the stencil operation to use when stencil fails
  117028. * @param operation defines the stencil operation to use when stencil fails
  117029. */
  117030. setStencilOperationFail(operation: number): void;
  117031. /**
  117032. * Sets the stencil operation to use when depth fails
  117033. * @param operation defines the stencil operation to use when depth fails
  117034. */
  117035. setStencilOperationDepthFail(operation: number): void;
  117036. /**
  117037. * Sets the stencil operation to use when stencil passes
  117038. * @param operation defines the stencil operation to use when stencil passes
  117039. */
  117040. setStencilOperationPass(operation: number): void;
  117041. /**
  117042. * Sets a boolean indicating if the dithering state is enabled or disabled
  117043. * @param value defines the dithering state
  117044. */
  117045. setDitheringState(value: boolean): void;
  117046. /**
  117047. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  117048. * @param value defines the rasterizer state
  117049. */
  117050. setRasterizerState(value: boolean): void;
  117051. /**
  117052. * Gets the current depth function
  117053. * @returns a number defining the depth function
  117054. */
  117055. getDepthFunction(): Nullable<number>;
  117056. /**
  117057. * Sets the current depth function
  117058. * @param depthFunc defines the function to use
  117059. */
  117060. setDepthFunction(depthFunc: number): void;
  117061. /**
  117062. * Sets the current depth function to GREATER
  117063. */
  117064. setDepthFunctionToGreater(): void;
  117065. /**
  117066. * Sets the current depth function to GEQUAL
  117067. */
  117068. setDepthFunctionToGreaterOrEqual(): void;
  117069. /**
  117070. * Sets the current depth function to LESS
  117071. */
  117072. setDepthFunctionToLess(): void;
  117073. /**
  117074. * Sets the current depth function to LEQUAL
  117075. */
  117076. setDepthFunctionToLessOrEqual(): void;
  117077. private _cachedStencilBuffer;
  117078. private _cachedStencilFunction;
  117079. private _cachedStencilMask;
  117080. private _cachedStencilOperationPass;
  117081. private _cachedStencilOperationFail;
  117082. private _cachedStencilOperationDepthFail;
  117083. private _cachedStencilReference;
  117084. /**
  117085. * Caches the the state of the stencil buffer
  117086. */
  117087. cacheStencilState(): void;
  117088. /**
  117089. * Restores the state of the stencil buffer
  117090. */
  117091. restoreStencilState(): void;
  117092. /**
  117093. * Directly set the WebGL Viewport
  117094. * @param x defines the x coordinate of the viewport (in screen space)
  117095. * @param y defines the y coordinate of the viewport (in screen space)
  117096. * @param width defines the width of the viewport (in screen space)
  117097. * @param height defines the height of the viewport (in screen space)
  117098. * @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
  117099. */
  117100. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  117101. /**
  117102. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  117103. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  117104. * @param y defines the y-coordinate of the corner of the clear rectangle
  117105. * @param width defines the width of the clear rectangle
  117106. * @param height defines the height of the clear rectangle
  117107. * @param clearColor defines the clear color
  117108. */
  117109. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  117110. /**
  117111. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  117112. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  117113. * @param y defines the y-coordinate of the corner of the clear rectangle
  117114. * @param width defines the width of the clear rectangle
  117115. * @param height defines the height of the clear rectangle
  117116. */
  117117. enableScissor(x: number, y: number, width: number, height: number): void;
  117118. /**
  117119. * Disable previously set scissor test rectangle
  117120. */
  117121. disableScissor(): void;
  117122. protected _reportDrawCall(): void;
  117123. /**
  117124. * Initializes a webVR display and starts listening to display change events
  117125. * The onVRDisplayChangedObservable will be notified upon these changes
  117126. * @returns The onVRDisplayChangedObservable
  117127. */
  117128. initWebVR(): Observable<IDisplayChangedEventArgs>;
  117129. /** @hidden */
  117130. _prepareVRComponent(): void;
  117131. /** @hidden */
  117132. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  117133. /** @hidden */
  117134. _submitVRFrame(): void;
  117135. /**
  117136. * Call this function to leave webVR mode
  117137. * Will do nothing if webVR is not supported or if there is no webVR device
  117138. * @see https://doc.babylonjs.com/how_to/webvr_camera
  117139. */
  117140. disableVR(): void;
  117141. /**
  117142. * Gets a boolean indicating that the system is in VR mode and is presenting
  117143. * @returns true if VR mode is engaged
  117144. */
  117145. isVRPresenting(): boolean;
  117146. /** @hidden */
  117147. _requestVRFrame(): void;
  117148. /** @hidden */
  117149. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  117150. /**
  117151. * Gets the source code of the vertex shader associated with a specific webGL program
  117152. * @param program defines the program to use
  117153. * @returns a string containing the source code of the vertex shader associated with the program
  117154. */
  117155. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  117156. /**
  117157. * Gets the source code of the fragment shader associated with a specific webGL program
  117158. * @param program defines the program to use
  117159. * @returns a string containing the source code of the fragment shader associated with the program
  117160. */
  117161. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  117162. /**
  117163. * Sets a depth stencil texture from a render target to the according uniform.
  117164. * @param channel The texture channel
  117165. * @param uniform The uniform to set
  117166. * @param texture The render target texture containing the depth stencil texture to apply
  117167. */
  117168. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  117169. /**
  117170. * Sets a texture to the webGL context from a postprocess
  117171. * @param channel defines the channel to use
  117172. * @param postProcess defines the source postprocess
  117173. */
  117174. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  117175. /**
  117176. * Binds the output of the passed in post process to the texture channel specified
  117177. * @param channel The channel the texture should be bound to
  117178. * @param postProcess The post process which's output should be bound
  117179. */
  117180. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  117181. protected _rebuildBuffers(): void;
  117182. /** @hidden */
  117183. _renderFrame(): void;
  117184. _renderLoop(): void;
  117185. /** @hidden */
  117186. _renderViews(): boolean;
  117187. /**
  117188. * Toggle full screen mode
  117189. * @param requestPointerLock defines if a pointer lock should be requested from the user
  117190. */
  117191. switchFullscreen(requestPointerLock: boolean): void;
  117192. /**
  117193. * Enters full screen mode
  117194. * @param requestPointerLock defines if a pointer lock should be requested from the user
  117195. */
  117196. enterFullscreen(requestPointerLock: boolean): void;
  117197. /**
  117198. * Exits full screen mode
  117199. */
  117200. exitFullscreen(): void;
  117201. /**
  117202. * Enters Pointerlock mode
  117203. */
  117204. enterPointerlock(): void;
  117205. /**
  117206. * Exits Pointerlock mode
  117207. */
  117208. exitPointerlock(): void;
  117209. /**
  117210. * Begin a new frame
  117211. */
  117212. beginFrame(): void;
  117213. /**
  117214. * Enf the current frame
  117215. */
  117216. endFrame(): void;
  117217. resize(): void;
  117218. /**
  117219. * Force a specific size of the canvas
  117220. * @param width defines the new canvas' width
  117221. * @param height defines the new canvas' height
  117222. * @returns true if the size was changed
  117223. */
  117224. setSize(width: number, height: number): boolean;
  117225. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  117226. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  117227. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  117228. _releaseTexture(texture: InternalTexture): void;
  117229. /**
  117230. * @hidden
  117231. * Rescales a texture
  117232. * @param source input texutre
  117233. * @param destination destination texture
  117234. * @param scene scene to use to render the resize
  117235. * @param internalFormat format to use when resizing
  117236. * @param onComplete callback to be called when resize has completed
  117237. */
  117238. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  117239. /**
  117240. * Gets the current framerate
  117241. * @returns a number representing the framerate
  117242. */
  117243. getFps(): number;
  117244. /**
  117245. * Gets the time spent between current and previous frame
  117246. * @returns a number representing the delta time in ms
  117247. */
  117248. getDeltaTime(): number;
  117249. private _measureFps;
  117250. /** @hidden */
  117251. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  117252. /**
  117253. * Updates the sample count of a render target texture
  117254. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  117255. * @param texture defines the texture to update
  117256. * @param samples defines the sample count to set
  117257. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  117258. */
  117259. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  117260. /**
  117261. * Updates a depth texture Comparison Mode and Function.
  117262. * If the comparison Function is equal to 0, the mode will be set to none.
  117263. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  117264. * @param texture The texture to set the comparison function for
  117265. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  117266. */
  117267. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  117268. /**
  117269. * Creates a webGL buffer to use with instanciation
  117270. * @param capacity defines the size of the buffer
  117271. * @returns the webGL buffer
  117272. */
  117273. createInstancesBuffer(capacity: number): DataBuffer;
  117274. /**
  117275. * Delete a webGL buffer used with instanciation
  117276. * @param buffer defines the webGL buffer to delete
  117277. */
  117278. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  117279. private _clientWaitAsync;
  117280. /** @hidden */
  117281. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  117282. dispose(): void;
  117283. private _disableTouchAction;
  117284. /**
  117285. * Display the loading screen
  117286. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  117287. */
  117288. displayLoadingUI(): void;
  117289. /**
  117290. * Hide the loading screen
  117291. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  117292. */
  117293. hideLoadingUI(): void;
  117294. /**
  117295. * Gets the current loading screen object
  117296. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  117297. */
  117298. get loadingScreen(): ILoadingScreen;
  117299. /**
  117300. * Sets the current loading screen object
  117301. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  117302. */
  117303. set loadingScreen(loadingScreen: ILoadingScreen);
  117304. /**
  117305. * Sets the current loading screen text
  117306. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  117307. */
  117308. set loadingUIText(text: string);
  117309. /**
  117310. * Sets the current loading screen background color
  117311. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  117312. */
  117313. set loadingUIBackgroundColor(color: string);
  117314. /** Pointerlock and fullscreen */
  117315. /**
  117316. * Ask the browser to promote the current element to pointerlock mode
  117317. * @param element defines the DOM element to promote
  117318. */
  117319. static _RequestPointerlock(element: HTMLElement): void;
  117320. /**
  117321. * Asks the browser to exit pointerlock mode
  117322. */
  117323. static _ExitPointerlock(): void;
  117324. /**
  117325. * Ask the browser to promote the current element to fullscreen rendering mode
  117326. * @param element defines the DOM element to promote
  117327. */
  117328. static _RequestFullscreen(element: HTMLElement): void;
  117329. /**
  117330. * Asks the browser to exit fullscreen mode
  117331. */
  117332. static _ExitFullscreen(): void;
  117333. }
  117334. }
  117335. declare module BABYLON {
  117336. /**
  117337. * The engine store class is responsible to hold all the instances of Engine and Scene created
  117338. * during the life time of the application.
  117339. */
  117340. export class EngineStore {
  117341. /** Gets the list of created engines */
  117342. static Instances: Engine[];
  117343. /** @hidden */
  117344. static _LastCreatedScene: Nullable<Scene>;
  117345. /**
  117346. * Gets the latest created engine
  117347. */
  117348. static get LastCreatedEngine(): Nullable<Engine>;
  117349. /**
  117350. * Gets the latest created scene
  117351. */
  117352. static get LastCreatedScene(): Nullable<Scene>;
  117353. /**
  117354. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  117355. * @ignorenaming
  117356. */
  117357. static UseFallbackTexture: boolean;
  117358. /**
  117359. * Texture content used if a texture cannot loaded
  117360. * @ignorenaming
  117361. */
  117362. static FallbackTexture: string;
  117363. }
  117364. }
  117365. declare module BABYLON {
  117366. /**
  117367. * Helper class that provides a small promise polyfill
  117368. */
  117369. export class PromisePolyfill {
  117370. /**
  117371. * Static function used to check if the polyfill is required
  117372. * If this is the case then the function will inject the polyfill to window.Promise
  117373. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  117374. */
  117375. static Apply(force?: boolean): void;
  117376. }
  117377. }
  117378. declare module BABYLON {
  117379. /**
  117380. * Interface for screenshot methods with describe argument called `size` as object with options
  117381. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  117382. */
  117383. export interface IScreenshotSize {
  117384. /**
  117385. * number in pixels for canvas height
  117386. */
  117387. height?: number;
  117388. /**
  117389. * multiplier allowing render at a higher or lower resolution
  117390. * If value is defined then height and width will be ignored and taken from camera
  117391. */
  117392. precision?: number;
  117393. /**
  117394. * number in pixels for canvas width
  117395. */
  117396. width?: number;
  117397. }
  117398. }
  117399. declare module BABYLON {
  117400. interface IColor4Like {
  117401. r: float;
  117402. g: float;
  117403. b: float;
  117404. a: float;
  117405. }
  117406. /**
  117407. * Class containing a set of static utilities functions
  117408. */
  117409. export class Tools {
  117410. /**
  117411. * Gets or sets the base URL to use to load assets
  117412. */
  117413. static get BaseUrl(): string;
  117414. static set BaseUrl(value: string);
  117415. /**
  117416. * Enable/Disable Custom HTTP Request Headers globally.
  117417. * default = false
  117418. * @see CustomRequestHeaders
  117419. */
  117420. static UseCustomRequestHeaders: boolean;
  117421. /**
  117422. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  117423. * i.e. when loading files, where the server/service expects an Authorization header
  117424. */
  117425. static CustomRequestHeaders: {
  117426. [key: string]: string;
  117427. };
  117428. /**
  117429. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  117430. */
  117431. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  117432. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  117433. /**
  117434. * Default behaviour for cors in the application.
  117435. * It can be a string if the expected behavior is identical in the entire app.
  117436. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  117437. */
  117438. static get CorsBehavior(): string | ((url: string | string[]) => string);
  117439. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  117440. /**
  117441. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  117442. * @ignorenaming
  117443. */
  117444. static get UseFallbackTexture(): boolean;
  117445. static set UseFallbackTexture(value: boolean);
  117446. /**
  117447. * Use this object to register external classes like custom textures or material
  117448. * to allow the laoders to instantiate them
  117449. */
  117450. static get RegisteredExternalClasses(): {
  117451. [key: string]: Object;
  117452. };
  117453. static set RegisteredExternalClasses(classes: {
  117454. [key: string]: Object;
  117455. });
  117456. /**
  117457. * Texture content used if a texture cannot loaded
  117458. * @ignorenaming
  117459. */
  117460. static get fallbackTexture(): string;
  117461. static set fallbackTexture(value: string);
  117462. /**
  117463. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  117464. * @param u defines the coordinate on X axis
  117465. * @param v defines the coordinate on Y axis
  117466. * @param width defines the width of the source data
  117467. * @param height defines the height of the source data
  117468. * @param pixels defines the source byte array
  117469. * @param color defines the output color
  117470. */
  117471. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  117472. /**
  117473. * Interpolates between a and b via alpha
  117474. * @param a The lower value (returned when alpha = 0)
  117475. * @param b The upper value (returned when alpha = 1)
  117476. * @param alpha The interpolation-factor
  117477. * @return The mixed value
  117478. */
  117479. static Mix(a: number, b: number, alpha: number): number;
  117480. /**
  117481. * Tries to instantiate a new object from a given class name
  117482. * @param className defines the class name to instantiate
  117483. * @returns the new object or null if the system was not able to do the instantiation
  117484. */
  117485. static Instantiate(className: string): any;
  117486. /**
  117487. * Provides a slice function that will work even on IE
  117488. * @param data defines the array to slice
  117489. * @param start defines the start of the data (optional)
  117490. * @param end defines the end of the data (optional)
  117491. * @returns the new sliced array
  117492. */
  117493. static Slice<T>(data: T, start?: number, end?: number): T;
  117494. /**
  117495. * Polyfill for setImmediate
  117496. * @param action defines the action to execute after the current execution block
  117497. */
  117498. static SetImmediate(action: () => void): void;
  117499. /**
  117500. * Function indicating if a number is an exponent of 2
  117501. * @param value defines the value to test
  117502. * @returns true if the value is an exponent of 2
  117503. */
  117504. static IsExponentOfTwo(value: number): boolean;
  117505. private static _tmpFloatArray;
  117506. /**
  117507. * Returns the nearest 32-bit single precision float representation of a Number
  117508. * @param value A Number. If the parameter is of a different type, it will get converted
  117509. * to a number or to NaN if it cannot be converted
  117510. * @returns number
  117511. */
  117512. static FloatRound(value: number): number;
  117513. /**
  117514. * Extracts the filename from a path
  117515. * @param path defines the path to use
  117516. * @returns the filename
  117517. */
  117518. static GetFilename(path: string): string;
  117519. /**
  117520. * Extracts the "folder" part of a path (everything before the filename).
  117521. * @param uri The URI to extract the info from
  117522. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  117523. * @returns The "folder" part of the path
  117524. */
  117525. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  117526. /**
  117527. * Extracts text content from a DOM element hierarchy
  117528. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  117529. */
  117530. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  117531. /**
  117532. * Convert an angle in radians to degrees
  117533. * @param angle defines the angle to convert
  117534. * @returns the angle in degrees
  117535. */
  117536. static ToDegrees(angle: number): number;
  117537. /**
  117538. * Convert an angle in degrees to radians
  117539. * @param angle defines the angle to convert
  117540. * @returns the angle in radians
  117541. */
  117542. static ToRadians(angle: number): number;
  117543. /**
  117544. * Returns an array if obj is not an array
  117545. * @param obj defines the object to evaluate as an array
  117546. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  117547. * @returns either obj directly if obj is an array or a new array containing obj
  117548. */
  117549. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  117550. /**
  117551. * Gets the pointer prefix to use
  117552. * @param engine defines the engine we are finding the prefix for
  117553. * @returns "pointer" if touch is enabled. Else returns "mouse"
  117554. */
  117555. static GetPointerPrefix(engine: Engine): string;
  117556. /**
  117557. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  117558. * @param url define the url we are trying
  117559. * @param element define the dom element where to configure the cors policy
  117560. */
  117561. static SetCorsBehavior(url: string | string[], element: {
  117562. crossOrigin: string | null;
  117563. }): void;
  117564. /**
  117565. * Removes unwanted characters from an url
  117566. * @param url defines the url to clean
  117567. * @returns the cleaned url
  117568. */
  117569. static CleanUrl(url: string): string;
  117570. /**
  117571. * Gets or sets a function used to pre-process url before using them to load assets
  117572. */
  117573. static get PreprocessUrl(): (url: string) => string;
  117574. static set PreprocessUrl(processor: (url: string) => string);
  117575. /**
  117576. * Loads an image as an HTMLImageElement.
  117577. * @param input url string, ArrayBuffer, or Blob to load
  117578. * @param onLoad callback called when the image successfully loads
  117579. * @param onError callback called when the image fails to load
  117580. * @param offlineProvider offline provider for caching
  117581. * @param mimeType optional mime type
  117582. * @returns the HTMLImageElement of the loaded image
  117583. */
  117584. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  117585. /**
  117586. * Loads a file from a url
  117587. * @param url url string, ArrayBuffer, or Blob to load
  117588. * @param onSuccess callback called when the file successfully loads
  117589. * @param onProgress callback called while file is loading (if the server supports this mode)
  117590. * @param offlineProvider defines the offline provider for caching
  117591. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  117592. * @param onError callback called when the file fails to load
  117593. * @returns a file request object
  117594. */
  117595. 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;
  117596. /**
  117597. * Loads a file from a url
  117598. * @param url the file url to load
  117599. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  117600. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  117601. */
  117602. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  117603. /**
  117604. * Load a script (identified by an url). When the url returns, the
  117605. * content of this file is added into a new script element, attached to the DOM (body element)
  117606. * @param scriptUrl defines the url of the script to laod
  117607. * @param onSuccess defines the callback called when the script is loaded
  117608. * @param onError defines the callback to call if an error occurs
  117609. * @param scriptId defines the id of the script element
  117610. */
  117611. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  117612. /**
  117613. * Load an asynchronous script (identified by an url). When the url returns, the
  117614. * content of this file is added into a new script element, attached to the DOM (body element)
  117615. * @param scriptUrl defines the url of the script to laod
  117616. * @param scriptId defines the id of the script element
  117617. * @returns a promise request object
  117618. */
  117619. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  117620. /**
  117621. * Loads a file from a blob
  117622. * @param fileToLoad defines the blob to use
  117623. * @param callback defines the callback to call when data is loaded
  117624. * @param progressCallback defines the callback to call during loading process
  117625. * @returns a file request object
  117626. */
  117627. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  117628. /**
  117629. * Reads a file from a File object
  117630. * @param file defines the file to load
  117631. * @param onSuccess defines the callback to call when data is loaded
  117632. * @param onProgress defines the callback to call during loading process
  117633. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  117634. * @param onError defines the callback to call when an error occurs
  117635. * @returns a file request object
  117636. */
  117637. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  117638. /**
  117639. * Creates a data url from a given string content
  117640. * @param content defines the content to convert
  117641. * @returns the new data url link
  117642. */
  117643. static FileAsURL(content: string): string;
  117644. /**
  117645. * Format the given number to a specific decimal format
  117646. * @param value defines the number to format
  117647. * @param decimals defines the number of decimals to use
  117648. * @returns the formatted string
  117649. */
  117650. static Format(value: number, decimals?: number): string;
  117651. /**
  117652. * Tries to copy an object by duplicating every property
  117653. * @param source defines the source object
  117654. * @param destination defines the target object
  117655. * @param doNotCopyList defines a list of properties to avoid
  117656. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  117657. */
  117658. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  117659. /**
  117660. * Gets a boolean indicating if the given object has no own property
  117661. * @param obj defines the object to test
  117662. * @returns true if object has no own property
  117663. */
  117664. static IsEmpty(obj: any): boolean;
  117665. /**
  117666. * Function used to register events at window level
  117667. * @param windowElement defines the Window object to use
  117668. * @param events defines the events to register
  117669. */
  117670. static RegisterTopRootEvents(windowElement: Window, events: {
  117671. name: string;
  117672. handler: Nullable<(e: FocusEvent) => any>;
  117673. }[]): void;
  117674. /**
  117675. * Function used to unregister events from window level
  117676. * @param windowElement defines the Window object to use
  117677. * @param events defines the events to unregister
  117678. */
  117679. static UnregisterTopRootEvents(windowElement: Window, events: {
  117680. name: string;
  117681. handler: Nullable<(e: FocusEvent) => any>;
  117682. }[]): void;
  117683. /**
  117684. * @ignore
  117685. */
  117686. static _ScreenshotCanvas: HTMLCanvasElement;
  117687. /**
  117688. * Dumps the current bound framebuffer
  117689. * @param width defines the rendering width
  117690. * @param height defines the rendering height
  117691. * @param engine defines the hosting engine
  117692. * @param successCallback defines the callback triggered once the data are available
  117693. * @param mimeType defines the mime type of the result
  117694. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  117695. */
  117696. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  117697. /**
  117698. * Converts the canvas data to blob.
  117699. * This acts as a polyfill for browsers not supporting the to blob function.
  117700. * @param canvas Defines the canvas to extract the data from
  117701. * @param successCallback Defines the callback triggered once the data are available
  117702. * @param mimeType Defines the mime type of the result
  117703. */
  117704. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  117705. /**
  117706. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  117707. * @param successCallback defines the callback triggered once the data are available
  117708. * @param mimeType defines the mime type of the result
  117709. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  117710. */
  117711. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  117712. /**
  117713. * Downloads a blob in the browser
  117714. * @param blob defines the blob to download
  117715. * @param fileName defines the name of the downloaded file
  117716. */
  117717. static Download(blob: Blob, fileName: string): void;
  117718. /**
  117719. * Captures a screenshot of the current rendering
  117720. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  117721. * @param engine defines the rendering engine
  117722. * @param camera defines the source camera
  117723. * @param size This parameter can be set to a single number or to an object with the
  117724. * following (optional) properties: precision, width, height. If a single number is passed,
  117725. * it will be used for both width and height. If an object is passed, the screenshot size
  117726. * will be derived from the parameters. The precision property is a multiplier allowing
  117727. * rendering at a higher or lower resolution
  117728. * @param successCallback defines the callback receives a single parameter which contains the
  117729. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  117730. * src parameter of an <img> to display it
  117731. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  117732. * Check your browser for supported MIME types
  117733. */
  117734. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  117735. /**
  117736. * Captures a screenshot of the current rendering
  117737. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  117738. * @param engine defines the rendering engine
  117739. * @param camera defines the source camera
  117740. * @param size This parameter can be set to a single number or to an object with the
  117741. * following (optional) properties: precision, width, height. If a single number is passed,
  117742. * it will be used for both width and height. If an object is passed, the screenshot size
  117743. * will be derived from the parameters. The precision property is a multiplier allowing
  117744. * rendering at a higher or lower resolution
  117745. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  117746. * Check your browser for supported MIME types
  117747. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  117748. * to the src parameter of an <img> to display it
  117749. */
  117750. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  117751. /**
  117752. * Generates an image screenshot from the specified camera.
  117753. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  117754. * @param engine The engine to use for rendering
  117755. * @param camera The camera to use for rendering
  117756. * @param size This parameter can be set to a single number or to an object with the
  117757. * following (optional) properties: precision, width, height. If a single number is passed,
  117758. * it will be used for both width and height. If an object is passed, the screenshot size
  117759. * will be derived from the parameters. The precision property is a multiplier allowing
  117760. * rendering at a higher or lower resolution
  117761. * @param successCallback The callback receives a single parameter which contains the
  117762. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  117763. * src parameter of an <img> to display it
  117764. * @param mimeType The MIME type of the screenshot image (default: image/png).
  117765. * Check your browser for supported MIME types
  117766. * @param samples Texture samples (default: 1)
  117767. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  117768. * @param fileName A name for for the downloaded file.
  117769. */
  117770. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  117771. /**
  117772. * Generates an image screenshot from the specified camera.
  117773. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  117774. * @param engine The engine to use for rendering
  117775. * @param camera The camera to use for rendering
  117776. * @param size This parameter can be set to a single number or to an object with the
  117777. * following (optional) properties: precision, width, height. If a single number is passed,
  117778. * it will be used for both width and height. If an object is passed, the screenshot size
  117779. * will be derived from the parameters. The precision property is a multiplier allowing
  117780. * rendering at a higher or lower resolution
  117781. * @param mimeType The MIME type of the screenshot image (default: image/png).
  117782. * Check your browser for supported MIME types
  117783. * @param samples Texture samples (default: 1)
  117784. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  117785. * @param fileName A name for for the downloaded file.
  117786. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  117787. * to the src parameter of an <img> to display it
  117788. */
  117789. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  117790. /**
  117791. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  117792. * Be aware Math.random() could cause collisions, but:
  117793. * "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"
  117794. * @returns a pseudo random id
  117795. */
  117796. static RandomId(): string;
  117797. /**
  117798. * Test if the given uri is a base64 string
  117799. * @param uri The uri to test
  117800. * @return True if the uri is a base64 string or false otherwise
  117801. */
  117802. static IsBase64(uri: string): boolean;
  117803. /**
  117804. * Decode the given base64 uri.
  117805. * @param uri The uri to decode
  117806. * @return The decoded base64 data.
  117807. */
  117808. static DecodeBase64(uri: string): ArrayBuffer;
  117809. /**
  117810. * Gets the absolute url.
  117811. * @param url the input url
  117812. * @return the absolute url
  117813. */
  117814. static GetAbsoluteUrl(url: string): string;
  117815. /**
  117816. * No log
  117817. */
  117818. static readonly NoneLogLevel: number;
  117819. /**
  117820. * Only message logs
  117821. */
  117822. static readonly MessageLogLevel: number;
  117823. /**
  117824. * Only warning logs
  117825. */
  117826. static readonly WarningLogLevel: number;
  117827. /**
  117828. * Only error logs
  117829. */
  117830. static readonly ErrorLogLevel: number;
  117831. /**
  117832. * All logs
  117833. */
  117834. static readonly AllLogLevel: number;
  117835. /**
  117836. * Gets a value indicating the number of loading errors
  117837. * @ignorenaming
  117838. */
  117839. static get errorsCount(): number;
  117840. /**
  117841. * Callback called when a new log is added
  117842. */
  117843. static OnNewCacheEntry: (entry: string) => void;
  117844. /**
  117845. * Log a message to the console
  117846. * @param message defines the message to log
  117847. */
  117848. static Log(message: string): void;
  117849. /**
  117850. * Write a warning message to the console
  117851. * @param message defines the message to log
  117852. */
  117853. static Warn(message: string): void;
  117854. /**
  117855. * Write an error message to the console
  117856. * @param message defines the message to log
  117857. */
  117858. static Error(message: string): void;
  117859. /**
  117860. * Gets current log cache (list of logs)
  117861. */
  117862. static get LogCache(): string;
  117863. /**
  117864. * Clears the log cache
  117865. */
  117866. static ClearLogCache(): void;
  117867. /**
  117868. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  117869. */
  117870. static set LogLevels(level: number);
  117871. /**
  117872. * Checks if the window object exists
  117873. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  117874. */
  117875. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  117876. /**
  117877. * No performance log
  117878. */
  117879. static readonly PerformanceNoneLogLevel: number;
  117880. /**
  117881. * Use user marks to log performance
  117882. */
  117883. static readonly PerformanceUserMarkLogLevel: number;
  117884. /**
  117885. * Log performance to the console
  117886. */
  117887. static readonly PerformanceConsoleLogLevel: number;
  117888. private static _performance;
  117889. /**
  117890. * Sets the current performance log level
  117891. */
  117892. static set PerformanceLogLevel(level: number);
  117893. private static _StartPerformanceCounterDisabled;
  117894. private static _EndPerformanceCounterDisabled;
  117895. private static _StartUserMark;
  117896. private static _EndUserMark;
  117897. private static _StartPerformanceConsole;
  117898. private static _EndPerformanceConsole;
  117899. /**
  117900. * Starts a performance counter
  117901. */
  117902. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  117903. /**
  117904. * Ends a specific performance coutner
  117905. */
  117906. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  117907. /**
  117908. * Gets either window.performance.now() if supported or Date.now() else
  117909. */
  117910. static get Now(): number;
  117911. /**
  117912. * This method will return the name of the class used to create the instance of the given object.
  117913. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  117914. * @param object the object to get the class name from
  117915. * @param isType defines if the object is actually a type
  117916. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  117917. */
  117918. static GetClassName(object: any, isType?: boolean): string;
  117919. /**
  117920. * Gets the first element of an array satisfying a given predicate
  117921. * @param array defines the array to browse
  117922. * @param predicate defines the predicate to use
  117923. * @returns null if not found or the element
  117924. */
  117925. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  117926. /**
  117927. * This method will return the name of the full name of the class, including its owning module (if any).
  117928. * 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).
  117929. * @param object the object to get the class name from
  117930. * @param isType defines if the object is actually a type
  117931. * @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.
  117932. * @ignorenaming
  117933. */
  117934. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  117935. /**
  117936. * Returns a promise that resolves after the given amount of time.
  117937. * @param delay Number of milliseconds to delay
  117938. * @returns Promise that resolves after the given amount of time
  117939. */
  117940. static DelayAsync(delay: number): Promise<void>;
  117941. /**
  117942. * Utility function to detect if the current user agent is Safari
  117943. * @returns whether or not the current user agent is safari
  117944. */
  117945. static IsSafari(): boolean;
  117946. }
  117947. /**
  117948. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  117949. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  117950. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  117951. * @param name The name of the class, case should be preserved
  117952. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  117953. */
  117954. export function className(name: string, module?: string): (target: Object) => void;
  117955. /**
  117956. * An implementation of a loop for asynchronous functions.
  117957. */
  117958. export class AsyncLoop {
  117959. /**
  117960. * Defines the number of iterations for the loop
  117961. */
  117962. iterations: number;
  117963. /**
  117964. * Defines the current index of the loop.
  117965. */
  117966. index: number;
  117967. private _done;
  117968. private _fn;
  117969. private _successCallback;
  117970. /**
  117971. * Constructor.
  117972. * @param iterations the number of iterations.
  117973. * @param func the function to run each iteration
  117974. * @param successCallback the callback that will be called upon succesful execution
  117975. * @param offset starting offset.
  117976. */
  117977. constructor(
  117978. /**
  117979. * Defines the number of iterations for the loop
  117980. */
  117981. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  117982. /**
  117983. * Execute the next iteration. Must be called after the last iteration was finished.
  117984. */
  117985. executeNext(): void;
  117986. /**
  117987. * Break the loop and run the success callback.
  117988. */
  117989. breakLoop(): void;
  117990. /**
  117991. * Create and run an async loop.
  117992. * @param iterations the number of iterations.
  117993. * @param fn the function to run each iteration
  117994. * @param successCallback the callback that will be called upon succesful execution
  117995. * @param offset starting offset.
  117996. * @returns the created async loop object
  117997. */
  117998. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  117999. /**
  118000. * A for-loop that will run a given number of iterations synchronous and the rest async.
  118001. * @param iterations total number of iterations
  118002. * @param syncedIterations number of synchronous iterations in each async iteration.
  118003. * @param fn the function to call each iteration.
  118004. * @param callback a success call back that will be called when iterating stops.
  118005. * @param breakFunction a break condition (optional)
  118006. * @param timeout timeout settings for the setTimeout function. default - 0.
  118007. * @returns the created async loop object
  118008. */
  118009. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  118010. }
  118011. }
  118012. declare module BABYLON {
  118013. /**
  118014. * This class implement a typical dictionary using a string as key and the generic type T as value.
  118015. * The underlying implementation relies on an associative array to ensure the best performances.
  118016. * The value can be anything including 'null' but except 'undefined'
  118017. */
  118018. export class StringDictionary<T> {
  118019. /**
  118020. * This will clear this dictionary and copy the content from the 'source' one.
  118021. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  118022. * @param source the dictionary to take the content from and copy to this dictionary
  118023. */
  118024. copyFrom(source: StringDictionary<T>): void;
  118025. /**
  118026. * Get a value based from its key
  118027. * @param key the given key to get the matching value from
  118028. * @return the value if found, otherwise undefined is returned
  118029. */
  118030. get(key: string): T | undefined;
  118031. /**
  118032. * Get a value from its key or add it if it doesn't exist.
  118033. * This method will ensure you that a given key/data will be present in the dictionary.
  118034. * @param key the given key to get the matching value from
  118035. * @param factory the factory that will create the value if the key is not present in the dictionary.
  118036. * The factory will only be invoked if there's no data for the given key.
  118037. * @return the value corresponding to the key.
  118038. */
  118039. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  118040. /**
  118041. * Get a value from its key if present in the dictionary otherwise add it
  118042. * @param key the key to get the value from
  118043. * @param val if there's no such key/value pair in the dictionary add it with this value
  118044. * @return the value corresponding to the key
  118045. */
  118046. getOrAdd(key: string, val: T): T;
  118047. /**
  118048. * Check if there's a given key in the dictionary
  118049. * @param key the key to check for
  118050. * @return true if the key is present, false otherwise
  118051. */
  118052. contains(key: string): boolean;
  118053. /**
  118054. * Add a new key and its corresponding value
  118055. * @param key the key to add
  118056. * @param value the value corresponding to the key
  118057. * @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
  118058. */
  118059. add(key: string, value: T): boolean;
  118060. /**
  118061. * Update a specific value associated to a key
  118062. * @param key defines the key to use
  118063. * @param value defines the value to store
  118064. * @returns true if the value was updated (or false if the key was not found)
  118065. */
  118066. set(key: string, value: T): boolean;
  118067. /**
  118068. * Get the element of the given key and remove it from the dictionary
  118069. * @param key defines the key to search
  118070. * @returns the value associated with the key or null if not found
  118071. */
  118072. getAndRemove(key: string): Nullable<T>;
  118073. /**
  118074. * Remove a key/value from the dictionary.
  118075. * @param key the key to remove
  118076. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  118077. */
  118078. remove(key: string): boolean;
  118079. /**
  118080. * Clear the whole content of the dictionary
  118081. */
  118082. clear(): void;
  118083. /**
  118084. * Gets the current count
  118085. */
  118086. get count(): number;
  118087. /**
  118088. * Execute a callback on each key/val of the dictionary.
  118089. * Note that you can remove any element in this dictionary in the callback implementation
  118090. * @param callback the callback to execute on a given key/value pair
  118091. */
  118092. forEach(callback: (key: string, val: T) => void): void;
  118093. /**
  118094. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  118095. * If the callback returns null or undefined the method will iterate to the next key/value pair
  118096. * Note that you can remove any element in this dictionary in the callback implementation
  118097. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  118098. * @returns the first item
  118099. */
  118100. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  118101. private _count;
  118102. private _data;
  118103. }
  118104. }
  118105. declare module BABYLON {
  118106. /** @hidden */
  118107. export interface ICollisionCoordinator {
  118108. createCollider(): Collider;
  118109. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  118110. init(scene: Scene): void;
  118111. }
  118112. /** @hidden */
  118113. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  118114. private _scene;
  118115. private _scaledPosition;
  118116. private _scaledVelocity;
  118117. private _finalPosition;
  118118. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  118119. createCollider(): Collider;
  118120. init(scene: Scene): void;
  118121. private _collideWithWorld;
  118122. }
  118123. }
  118124. declare module BABYLON {
  118125. /**
  118126. * Class used to manage all inputs for the scene.
  118127. */
  118128. export class InputManager {
  118129. /** The distance in pixel that you have to move to prevent some events */
  118130. static DragMovementThreshold: number;
  118131. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  118132. static LongPressDelay: number;
  118133. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  118134. static DoubleClickDelay: number;
  118135. /** If you need to check double click without raising a single click at first click, enable this flag */
  118136. static ExclusiveDoubleClickMode: boolean;
  118137. /** 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. */
  118138. private _alreadyAttached;
  118139. private _wheelEventName;
  118140. private _onPointerMove;
  118141. private _onPointerDown;
  118142. private _onPointerUp;
  118143. private _initClickEvent;
  118144. private _initActionManager;
  118145. private _delayedSimpleClick;
  118146. private _delayedSimpleClickTimeout;
  118147. private _previousDelayedSimpleClickTimeout;
  118148. private _meshPickProceed;
  118149. private _previousButtonPressed;
  118150. private _currentPickResult;
  118151. private _previousPickResult;
  118152. private _totalPointersPressed;
  118153. private _doubleClickOccured;
  118154. private _pointerOverMesh;
  118155. private _pickedDownMesh;
  118156. private _pickedUpMesh;
  118157. private _pointerX;
  118158. private _pointerY;
  118159. private _unTranslatedPointerX;
  118160. private _unTranslatedPointerY;
  118161. private _startingPointerPosition;
  118162. private _previousStartingPointerPosition;
  118163. private _startingPointerTime;
  118164. private _previousStartingPointerTime;
  118165. private _pointerCaptures;
  118166. private _onKeyDown;
  118167. private _onKeyUp;
  118168. private _onCanvasFocusObserver;
  118169. private _onCanvasBlurObserver;
  118170. private _scene;
  118171. /**
  118172. * Creates a new InputManager
  118173. * @param scene defines the hosting scene
  118174. */
  118175. constructor(scene: Scene);
  118176. /**
  118177. * Gets the mesh that is currently under the pointer
  118178. */
  118179. get meshUnderPointer(): Nullable<AbstractMesh>;
  118180. /**
  118181. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  118182. */
  118183. get unTranslatedPointer(): Vector2;
  118184. /**
  118185. * Gets or sets the current on-screen X position of the pointer
  118186. */
  118187. get pointerX(): number;
  118188. set pointerX(value: number);
  118189. /**
  118190. * Gets or sets the current on-screen Y position of the pointer
  118191. */
  118192. get pointerY(): number;
  118193. set pointerY(value: number);
  118194. private _updatePointerPosition;
  118195. private _processPointerMove;
  118196. private _setRayOnPointerInfo;
  118197. private _checkPrePointerObservable;
  118198. /**
  118199. * Use this method to simulate a pointer move on a mesh
  118200. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  118201. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  118202. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  118203. */
  118204. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  118205. /**
  118206. * Use this method to simulate a pointer down on a mesh
  118207. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  118208. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  118209. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  118210. */
  118211. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  118212. private _processPointerDown;
  118213. /** @hidden */
  118214. _isPointerSwiping(): boolean;
  118215. /**
  118216. * Use this method to simulate a pointer up on a mesh
  118217. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  118218. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  118219. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  118220. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  118221. */
  118222. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  118223. private _processPointerUp;
  118224. /**
  118225. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  118226. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  118227. * @returns true if the pointer was captured
  118228. */
  118229. isPointerCaptured(pointerId?: number): boolean;
  118230. /**
  118231. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  118232. * @param attachUp defines if you want to attach events to pointerup
  118233. * @param attachDown defines if you want to attach events to pointerdown
  118234. * @param attachMove defines if you want to attach events to pointermove
  118235. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  118236. */
  118237. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  118238. /**
  118239. * Detaches all event handlers
  118240. */
  118241. detachControl(): void;
  118242. /**
  118243. * Force the value of meshUnderPointer
  118244. * @param mesh defines the mesh to use
  118245. */
  118246. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  118247. /**
  118248. * Gets the mesh under the pointer
  118249. * @returns a Mesh or null if no mesh is under the pointer
  118250. */
  118251. getPointerOverMesh(): Nullable<AbstractMesh>;
  118252. }
  118253. }
  118254. declare module BABYLON {
  118255. /**
  118256. * This class defines the direct association between an animation and a target
  118257. */
  118258. export class TargetedAnimation {
  118259. /**
  118260. * Animation to perform
  118261. */
  118262. animation: Animation;
  118263. /**
  118264. * Target to animate
  118265. */
  118266. target: any;
  118267. /**
  118268. * Returns the string "TargetedAnimation"
  118269. * @returns "TargetedAnimation"
  118270. */
  118271. getClassName(): string;
  118272. /**
  118273. * Serialize the object
  118274. * @returns the JSON object representing the current entity
  118275. */
  118276. serialize(): any;
  118277. }
  118278. /**
  118279. * Use this class to create coordinated animations on multiple targets
  118280. */
  118281. export class AnimationGroup implements IDisposable {
  118282. /** The name of the animation group */
  118283. name: string;
  118284. private _scene;
  118285. private _targetedAnimations;
  118286. private _animatables;
  118287. private _from;
  118288. private _to;
  118289. private _isStarted;
  118290. private _isPaused;
  118291. private _speedRatio;
  118292. private _loopAnimation;
  118293. private _isAdditive;
  118294. /**
  118295. * Gets or sets the unique id of the node
  118296. */
  118297. uniqueId: number;
  118298. /**
  118299. * This observable will notify when one animation have ended
  118300. */
  118301. onAnimationEndObservable: Observable<TargetedAnimation>;
  118302. /**
  118303. * Observer raised when one animation loops
  118304. */
  118305. onAnimationLoopObservable: Observable<TargetedAnimation>;
  118306. /**
  118307. * Observer raised when all animations have looped
  118308. */
  118309. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  118310. /**
  118311. * This observable will notify when all animations have ended.
  118312. */
  118313. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  118314. /**
  118315. * This observable will notify when all animations have paused.
  118316. */
  118317. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  118318. /**
  118319. * This observable will notify when all animations are playing.
  118320. */
  118321. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  118322. /**
  118323. * Gets the first frame
  118324. */
  118325. get from(): number;
  118326. /**
  118327. * Gets the last frame
  118328. */
  118329. get to(): number;
  118330. /**
  118331. * Define if the animations are started
  118332. */
  118333. get isStarted(): boolean;
  118334. /**
  118335. * Gets a value indicating that the current group is playing
  118336. */
  118337. get isPlaying(): boolean;
  118338. /**
  118339. * Gets or sets the speed ratio to use for all animations
  118340. */
  118341. get speedRatio(): number;
  118342. /**
  118343. * Gets or sets the speed ratio to use for all animations
  118344. */
  118345. set speedRatio(value: number);
  118346. /**
  118347. * Gets or sets if all animations should loop or not
  118348. */
  118349. get loopAnimation(): boolean;
  118350. set loopAnimation(value: boolean);
  118351. /**
  118352. * Gets or sets if all animations should be evaluated additively
  118353. */
  118354. get isAdditive(): boolean;
  118355. set isAdditive(value: boolean);
  118356. /**
  118357. * Gets the targeted animations for this animation group
  118358. */
  118359. get targetedAnimations(): Array<TargetedAnimation>;
  118360. /**
  118361. * returning the list of animatables controlled by this animation group.
  118362. */
  118363. get animatables(): Array<Animatable>;
  118364. /**
  118365. * Gets the list of target animations
  118366. */
  118367. get children(): TargetedAnimation[];
  118368. /**
  118369. * Instantiates a new Animation Group.
  118370. * This helps managing several animations at once.
  118371. * @see https://doc.babylonjs.com/how_to/group
  118372. * @param name Defines the name of the group
  118373. * @param scene Defines the scene the group belongs to
  118374. */
  118375. constructor(
  118376. /** The name of the animation group */
  118377. name: string, scene?: Nullable<Scene>);
  118378. /**
  118379. * Add an animation (with its target) in the group
  118380. * @param animation defines the animation we want to add
  118381. * @param target defines the target of the animation
  118382. * @returns the TargetedAnimation object
  118383. */
  118384. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  118385. /**
  118386. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  118387. * It can add constant keys at begin or end
  118388. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  118389. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  118390. * @returns the animation group
  118391. */
  118392. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  118393. private _animationLoopCount;
  118394. private _animationLoopFlags;
  118395. private _processLoop;
  118396. /**
  118397. * Start all animations on given targets
  118398. * @param loop defines if animations must loop
  118399. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  118400. * @param from defines the from key (optional)
  118401. * @param to defines the to key (optional)
  118402. * @param isAdditive defines the additive state for the resulting animatables (optional)
  118403. * @returns the current animation group
  118404. */
  118405. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  118406. /**
  118407. * Pause all animations
  118408. * @returns the animation group
  118409. */
  118410. pause(): AnimationGroup;
  118411. /**
  118412. * Play all animations to initial state
  118413. * This function will start() the animations if they were not started or will restart() them if they were paused
  118414. * @param loop defines if animations must loop
  118415. * @returns the animation group
  118416. */
  118417. play(loop?: boolean): AnimationGroup;
  118418. /**
  118419. * Reset all animations to initial state
  118420. * @returns the animation group
  118421. */
  118422. reset(): AnimationGroup;
  118423. /**
  118424. * Restart animations from key 0
  118425. * @returns the animation group
  118426. */
  118427. restart(): AnimationGroup;
  118428. /**
  118429. * Stop all animations
  118430. * @returns the animation group
  118431. */
  118432. stop(): AnimationGroup;
  118433. /**
  118434. * Set animation weight for all animatables
  118435. * @param weight defines the weight to use
  118436. * @return the animationGroup
  118437. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  118438. */
  118439. setWeightForAllAnimatables(weight: number): AnimationGroup;
  118440. /**
  118441. * Synchronize and normalize all animatables with a source animatable
  118442. * @param root defines the root animatable to synchronize with
  118443. * @return the animationGroup
  118444. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  118445. */
  118446. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  118447. /**
  118448. * Goes to a specific frame in this animation group
  118449. * @param frame the frame number to go to
  118450. * @return the animationGroup
  118451. */
  118452. goToFrame(frame: number): AnimationGroup;
  118453. /**
  118454. * Dispose all associated resources
  118455. */
  118456. dispose(): void;
  118457. private _checkAnimationGroupEnded;
  118458. /**
  118459. * Clone the current animation group and returns a copy
  118460. * @param newName defines the name of the new group
  118461. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  118462. * @returns the new aniamtion group
  118463. */
  118464. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  118465. /**
  118466. * Serializes the animationGroup to an object
  118467. * @returns Serialized object
  118468. */
  118469. serialize(): any;
  118470. /**
  118471. * Returns a new AnimationGroup object parsed from the source provided.
  118472. * @param parsedAnimationGroup defines the source
  118473. * @param scene defines the scene that will receive the animationGroup
  118474. * @returns a new AnimationGroup
  118475. */
  118476. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  118477. /**
  118478. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  118479. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  118480. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  118481. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  118482. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  118483. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  118484. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  118485. */
  118486. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  118487. /**
  118488. * Returns the string "AnimationGroup"
  118489. * @returns "AnimationGroup"
  118490. */
  118491. getClassName(): string;
  118492. /**
  118493. * Creates a detailled string about the object
  118494. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  118495. * @returns a string representing the object
  118496. */
  118497. toString(fullDetails?: boolean): string;
  118498. }
  118499. }
  118500. declare module BABYLON {
  118501. /**
  118502. * Define an interface for all classes that will hold resources
  118503. */
  118504. export interface IDisposable {
  118505. /**
  118506. * Releases all held resources
  118507. */
  118508. dispose(): void;
  118509. }
  118510. /** Interface defining initialization parameters for Scene class */
  118511. export interface SceneOptions {
  118512. /**
  118513. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  118514. * It will improve performance when the number of geometries becomes important.
  118515. */
  118516. useGeometryUniqueIdsMap?: boolean;
  118517. /**
  118518. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  118519. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  118520. */
  118521. useMaterialMeshMap?: boolean;
  118522. /**
  118523. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  118524. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  118525. */
  118526. useClonedMeshMap?: boolean;
  118527. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  118528. virtual?: boolean;
  118529. }
  118530. /**
  118531. * Represents a scene to be rendered by the engine.
  118532. * @see https://doc.babylonjs.com/features/scene
  118533. */
  118534. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  118535. /** The fog is deactivated */
  118536. static readonly FOGMODE_NONE: number;
  118537. /** The fog density is following an exponential function */
  118538. static readonly FOGMODE_EXP: number;
  118539. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  118540. static readonly FOGMODE_EXP2: number;
  118541. /** The fog density is following a linear function. */
  118542. static readonly FOGMODE_LINEAR: number;
  118543. /**
  118544. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  118545. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  118546. */
  118547. static MinDeltaTime: number;
  118548. /**
  118549. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  118550. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  118551. */
  118552. static MaxDeltaTime: number;
  118553. /**
  118554. * Factory used to create the default material.
  118555. * @param name The name of the material to create
  118556. * @param scene The scene to create the material for
  118557. * @returns The default material
  118558. */
  118559. static DefaultMaterialFactory(scene: Scene): Material;
  118560. /**
  118561. * Factory used to create the a collision coordinator.
  118562. * @returns The collision coordinator
  118563. */
  118564. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  118565. /** @hidden */
  118566. _inputManager: InputManager;
  118567. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  118568. cameraToUseForPointers: Nullable<Camera>;
  118569. /** @hidden */
  118570. readonly _isScene: boolean;
  118571. /** @hidden */
  118572. _blockEntityCollection: boolean;
  118573. /**
  118574. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  118575. */
  118576. autoClear: boolean;
  118577. /**
  118578. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  118579. */
  118580. autoClearDepthAndStencil: boolean;
  118581. /**
  118582. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  118583. */
  118584. clearColor: Color4;
  118585. /**
  118586. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  118587. */
  118588. ambientColor: Color3;
  118589. /**
  118590. * This is use to store the default BRDF lookup for PBR materials in your scene.
  118591. * It should only be one of the following (if not the default embedded one):
  118592. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  118593. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  118594. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  118595. * The material properties need to be setup according to the type of texture in use.
  118596. */
  118597. environmentBRDFTexture: BaseTexture;
  118598. /** @hidden */
  118599. protected _environmentTexture: Nullable<BaseTexture>;
  118600. /**
  118601. * Texture used in all pbr material as the reflection texture.
  118602. * As in the majority of the scene they are the same (exception for multi room and so on),
  118603. * this is easier to reference from here than from all the materials.
  118604. */
  118605. get environmentTexture(): Nullable<BaseTexture>;
  118606. /**
  118607. * Texture used in all pbr material as the reflection texture.
  118608. * As in the majority of the scene they are the same (exception for multi room and so on),
  118609. * this is easier to set here than in all the materials.
  118610. */
  118611. set environmentTexture(value: Nullable<BaseTexture>);
  118612. /** @hidden */
  118613. protected _environmentIntensity: number;
  118614. /**
  118615. * Intensity of the environment in all pbr material.
  118616. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  118617. * As in the majority of the scene they are the same (exception for multi room and so on),
  118618. * this is easier to reference from here than from all the materials.
  118619. */
  118620. get environmentIntensity(): number;
  118621. /**
  118622. * Intensity of the environment in all pbr material.
  118623. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  118624. * As in the majority of the scene they are the same (exception for multi room and so on),
  118625. * this is easier to set here than in all the materials.
  118626. */
  118627. set environmentIntensity(value: number);
  118628. /** @hidden */
  118629. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  118630. /**
  118631. * Default image processing configuration used either in the rendering
  118632. * Forward main pass or through the imageProcessingPostProcess if present.
  118633. * As in the majority of the scene they are the same (exception for multi camera),
  118634. * this is easier to reference from here than from all the materials and post process.
  118635. *
  118636. * No setter as we it is a shared configuration, you can set the values instead.
  118637. */
  118638. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  118639. private _forceWireframe;
  118640. /**
  118641. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  118642. */
  118643. set forceWireframe(value: boolean);
  118644. get forceWireframe(): boolean;
  118645. private _skipFrustumClipping;
  118646. /**
  118647. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  118648. */
  118649. set skipFrustumClipping(value: boolean);
  118650. get skipFrustumClipping(): boolean;
  118651. private _forcePointsCloud;
  118652. /**
  118653. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  118654. */
  118655. set forcePointsCloud(value: boolean);
  118656. get forcePointsCloud(): boolean;
  118657. /**
  118658. * Gets or sets the active clipplane 1
  118659. */
  118660. clipPlane: Nullable<Plane>;
  118661. /**
  118662. * Gets or sets the active clipplane 2
  118663. */
  118664. clipPlane2: Nullable<Plane>;
  118665. /**
  118666. * Gets or sets the active clipplane 3
  118667. */
  118668. clipPlane3: Nullable<Plane>;
  118669. /**
  118670. * Gets or sets the active clipplane 4
  118671. */
  118672. clipPlane4: Nullable<Plane>;
  118673. /**
  118674. * Gets or sets the active clipplane 5
  118675. */
  118676. clipPlane5: Nullable<Plane>;
  118677. /**
  118678. * Gets or sets the active clipplane 6
  118679. */
  118680. clipPlane6: Nullable<Plane>;
  118681. /**
  118682. * Gets or sets a boolean indicating if animations are enabled
  118683. */
  118684. animationsEnabled: boolean;
  118685. private _animationPropertiesOverride;
  118686. /**
  118687. * Gets or sets the animation properties override
  118688. */
  118689. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  118690. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  118691. /**
  118692. * Gets or sets a boolean indicating if a constant deltatime has to be used
  118693. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  118694. */
  118695. useConstantAnimationDeltaTime: boolean;
  118696. /**
  118697. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  118698. * Please note that it requires to run a ray cast through the scene on every frame
  118699. */
  118700. constantlyUpdateMeshUnderPointer: boolean;
  118701. /**
  118702. * Defines the HTML cursor to use when hovering over interactive elements
  118703. */
  118704. hoverCursor: string;
  118705. /**
  118706. * Defines the HTML default cursor to use (empty by default)
  118707. */
  118708. defaultCursor: string;
  118709. /**
  118710. * Defines whether cursors are handled by the scene.
  118711. */
  118712. doNotHandleCursors: boolean;
  118713. /**
  118714. * This is used to call preventDefault() on pointer down
  118715. * in order to block unwanted artifacts like system double clicks
  118716. */
  118717. preventDefaultOnPointerDown: boolean;
  118718. /**
  118719. * This is used to call preventDefault() on pointer up
  118720. * in order to block unwanted artifacts like system double clicks
  118721. */
  118722. preventDefaultOnPointerUp: boolean;
  118723. /**
  118724. * Gets or sets user defined metadata
  118725. */
  118726. metadata: any;
  118727. /**
  118728. * For internal use only. Please do not use.
  118729. */
  118730. reservedDataStore: any;
  118731. /**
  118732. * Gets the name of the plugin used to load this scene (null by default)
  118733. */
  118734. loadingPluginName: string;
  118735. /**
  118736. * Use this array to add regular expressions used to disable offline support for specific urls
  118737. */
  118738. disableOfflineSupportExceptionRules: RegExp[];
  118739. /**
  118740. * An event triggered when the scene is disposed.
  118741. */
  118742. onDisposeObservable: Observable<Scene>;
  118743. private _onDisposeObserver;
  118744. /** Sets a function to be executed when this scene is disposed. */
  118745. set onDispose(callback: () => void);
  118746. /**
  118747. * An event triggered before rendering the scene (right after animations and physics)
  118748. */
  118749. onBeforeRenderObservable: Observable<Scene>;
  118750. private _onBeforeRenderObserver;
  118751. /** Sets a function to be executed before rendering this scene */
  118752. set beforeRender(callback: Nullable<() => void>);
  118753. /**
  118754. * An event triggered after rendering the scene
  118755. */
  118756. onAfterRenderObservable: Observable<Scene>;
  118757. /**
  118758. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  118759. */
  118760. onAfterRenderCameraObservable: Observable<Camera>;
  118761. private _onAfterRenderObserver;
  118762. /** Sets a function to be executed after rendering this scene */
  118763. set afterRender(callback: Nullable<() => void>);
  118764. /**
  118765. * An event triggered before animating the scene
  118766. */
  118767. onBeforeAnimationsObservable: Observable<Scene>;
  118768. /**
  118769. * An event triggered after animations processing
  118770. */
  118771. onAfterAnimationsObservable: Observable<Scene>;
  118772. /**
  118773. * An event triggered before draw calls are ready to be sent
  118774. */
  118775. onBeforeDrawPhaseObservable: Observable<Scene>;
  118776. /**
  118777. * An event triggered after draw calls have been sent
  118778. */
  118779. onAfterDrawPhaseObservable: Observable<Scene>;
  118780. /**
  118781. * An event triggered when the scene is ready
  118782. */
  118783. onReadyObservable: Observable<Scene>;
  118784. /**
  118785. * An event triggered before rendering a camera
  118786. */
  118787. onBeforeCameraRenderObservable: Observable<Camera>;
  118788. private _onBeforeCameraRenderObserver;
  118789. /** Sets a function to be executed before rendering a camera*/
  118790. set beforeCameraRender(callback: () => void);
  118791. /**
  118792. * An event triggered after rendering a camera
  118793. */
  118794. onAfterCameraRenderObservable: Observable<Camera>;
  118795. private _onAfterCameraRenderObserver;
  118796. /** Sets a function to be executed after rendering a camera*/
  118797. set afterCameraRender(callback: () => void);
  118798. /**
  118799. * An event triggered when active meshes evaluation is about to start
  118800. */
  118801. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  118802. /**
  118803. * An event triggered when active meshes evaluation is done
  118804. */
  118805. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  118806. /**
  118807. * An event triggered when particles rendering is about to start
  118808. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  118809. */
  118810. onBeforeParticlesRenderingObservable: Observable<Scene>;
  118811. /**
  118812. * An event triggered when particles rendering is done
  118813. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  118814. */
  118815. onAfterParticlesRenderingObservable: Observable<Scene>;
  118816. /**
  118817. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  118818. */
  118819. onDataLoadedObservable: Observable<Scene>;
  118820. /**
  118821. * An event triggered when a camera is created
  118822. */
  118823. onNewCameraAddedObservable: Observable<Camera>;
  118824. /**
  118825. * An event triggered when a camera is removed
  118826. */
  118827. onCameraRemovedObservable: Observable<Camera>;
  118828. /**
  118829. * An event triggered when a light is created
  118830. */
  118831. onNewLightAddedObservable: Observable<Light>;
  118832. /**
  118833. * An event triggered when a light is removed
  118834. */
  118835. onLightRemovedObservable: Observable<Light>;
  118836. /**
  118837. * An event triggered when a geometry is created
  118838. */
  118839. onNewGeometryAddedObservable: Observable<Geometry>;
  118840. /**
  118841. * An event triggered when a geometry is removed
  118842. */
  118843. onGeometryRemovedObservable: Observable<Geometry>;
  118844. /**
  118845. * An event triggered when a transform node is created
  118846. */
  118847. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  118848. /**
  118849. * An event triggered when a transform node is removed
  118850. */
  118851. onTransformNodeRemovedObservable: Observable<TransformNode>;
  118852. /**
  118853. * An event triggered when a mesh is created
  118854. */
  118855. onNewMeshAddedObservable: Observable<AbstractMesh>;
  118856. /**
  118857. * An event triggered when a mesh is removed
  118858. */
  118859. onMeshRemovedObservable: Observable<AbstractMesh>;
  118860. /**
  118861. * An event triggered when a skeleton is created
  118862. */
  118863. onNewSkeletonAddedObservable: Observable<Skeleton>;
  118864. /**
  118865. * An event triggered when a skeleton is removed
  118866. */
  118867. onSkeletonRemovedObservable: Observable<Skeleton>;
  118868. /**
  118869. * An event triggered when a material is created
  118870. */
  118871. onNewMaterialAddedObservable: Observable<Material>;
  118872. /**
  118873. * An event triggered when a material is removed
  118874. */
  118875. onMaterialRemovedObservable: Observable<Material>;
  118876. /**
  118877. * An event triggered when a texture is created
  118878. */
  118879. onNewTextureAddedObservable: Observable<BaseTexture>;
  118880. /**
  118881. * An event triggered when a texture is removed
  118882. */
  118883. onTextureRemovedObservable: Observable<BaseTexture>;
  118884. /**
  118885. * An event triggered when render targets are about to be rendered
  118886. * Can happen multiple times per frame.
  118887. */
  118888. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  118889. /**
  118890. * An event triggered when render targets were rendered.
  118891. * Can happen multiple times per frame.
  118892. */
  118893. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  118894. /**
  118895. * An event triggered before calculating deterministic simulation step
  118896. */
  118897. onBeforeStepObservable: Observable<Scene>;
  118898. /**
  118899. * An event triggered after calculating deterministic simulation step
  118900. */
  118901. onAfterStepObservable: Observable<Scene>;
  118902. /**
  118903. * An event triggered when the activeCamera property is updated
  118904. */
  118905. onActiveCameraChanged: Observable<Scene>;
  118906. /**
  118907. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  118908. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  118909. * 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)
  118910. */
  118911. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  118912. /**
  118913. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  118914. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  118915. * 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)
  118916. */
  118917. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  118918. /**
  118919. * This Observable will when a mesh has been imported into the scene.
  118920. */
  118921. onMeshImportedObservable: Observable<AbstractMesh>;
  118922. /**
  118923. * This Observable will when an animation file has been imported into the scene.
  118924. */
  118925. onAnimationFileImportedObservable: Observable<Scene>;
  118926. /**
  118927. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  118928. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  118929. */
  118930. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  118931. /** @hidden */
  118932. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  118933. /**
  118934. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  118935. */
  118936. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  118937. /**
  118938. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  118939. */
  118940. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  118941. /**
  118942. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  118943. */
  118944. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  118945. /** Callback called when a pointer move is detected */
  118946. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  118947. /** Callback called when a pointer down is detected */
  118948. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  118949. /** Callback called when a pointer up is detected */
  118950. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  118951. /** Callback called when a pointer pick is detected */
  118952. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  118953. /**
  118954. * 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).
  118955. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  118956. */
  118957. onPrePointerObservable: Observable<PointerInfoPre>;
  118958. /**
  118959. * Observable event triggered each time an input event is received from the rendering canvas
  118960. */
  118961. onPointerObservable: Observable<PointerInfo>;
  118962. /**
  118963. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  118964. */
  118965. get unTranslatedPointer(): Vector2;
  118966. /**
  118967. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  118968. */
  118969. static get DragMovementThreshold(): number;
  118970. static set DragMovementThreshold(value: number);
  118971. /**
  118972. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  118973. */
  118974. static get LongPressDelay(): number;
  118975. static set LongPressDelay(value: number);
  118976. /**
  118977. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  118978. */
  118979. static get DoubleClickDelay(): number;
  118980. static set DoubleClickDelay(value: number);
  118981. /** If you need to check double click without raising a single click at first click, enable this flag */
  118982. static get ExclusiveDoubleClickMode(): boolean;
  118983. static set ExclusiveDoubleClickMode(value: boolean);
  118984. /** @hidden */
  118985. _mirroredCameraPosition: Nullable<Vector3>;
  118986. /**
  118987. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  118988. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  118989. */
  118990. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  118991. /**
  118992. * Observable event triggered each time an keyboard event is received from the hosting window
  118993. */
  118994. onKeyboardObservable: Observable<KeyboardInfo>;
  118995. private _useRightHandedSystem;
  118996. /**
  118997. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  118998. */
  118999. set useRightHandedSystem(value: boolean);
  119000. get useRightHandedSystem(): boolean;
  119001. private _timeAccumulator;
  119002. private _currentStepId;
  119003. private _currentInternalStep;
  119004. /**
  119005. * Sets the step Id used by deterministic lock step
  119006. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119007. * @param newStepId defines the step Id
  119008. */
  119009. setStepId(newStepId: number): void;
  119010. /**
  119011. * Gets the step Id used by deterministic lock step
  119012. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119013. * @returns the step Id
  119014. */
  119015. getStepId(): number;
  119016. /**
  119017. * Gets the internal step used by deterministic lock step
  119018. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119019. * @returns the internal step
  119020. */
  119021. getInternalStep(): number;
  119022. private _fogEnabled;
  119023. /**
  119024. * Gets or sets a boolean indicating if fog is enabled on this scene
  119025. * @see https://doc.babylonjs.com/babylon101/environment#fog
  119026. * (Default is true)
  119027. */
  119028. set fogEnabled(value: boolean);
  119029. get fogEnabled(): boolean;
  119030. private _fogMode;
  119031. /**
  119032. * Gets or sets the fog mode to use
  119033. * @see https://doc.babylonjs.com/babylon101/environment#fog
  119034. * | mode | value |
  119035. * | --- | --- |
  119036. * | FOGMODE_NONE | 0 |
  119037. * | FOGMODE_EXP | 1 |
  119038. * | FOGMODE_EXP2 | 2 |
  119039. * | FOGMODE_LINEAR | 3 |
  119040. */
  119041. set fogMode(value: number);
  119042. get fogMode(): number;
  119043. /**
  119044. * Gets or sets the fog color to use
  119045. * @see https://doc.babylonjs.com/babylon101/environment#fog
  119046. * (Default is Color3(0.2, 0.2, 0.3))
  119047. */
  119048. fogColor: Color3;
  119049. /**
  119050. * Gets or sets the fog density to use
  119051. * @see https://doc.babylonjs.com/babylon101/environment#fog
  119052. * (Default is 0.1)
  119053. */
  119054. fogDensity: number;
  119055. /**
  119056. * Gets or sets the fog start distance to use
  119057. * @see https://doc.babylonjs.com/babylon101/environment#fog
  119058. * (Default is 0)
  119059. */
  119060. fogStart: number;
  119061. /**
  119062. * Gets or sets the fog end distance to use
  119063. * @see https://doc.babylonjs.com/babylon101/environment#fog
  119064. * (Default is 1000)
  119065. */
  119066. fogEnd: number;
  119067. /**
  119068. * Flag indicating that the frame buffer binding is handled by another component
  119069. */
  119070. prePass: boolean;
  119071. private _shadowsEnabled;
  119072. /**
  119073. * Gets or sets a boolean indicating if shadows are enabled on this scene
  119074. */
  119075. set shadowsEnabled(value: boolean);
  119076. get shadowsEnabled(): boolean;
  119077. private _lightsEnabled;
  119078. /**
  119079. * Gets or sets a boolean indicating if lights are enabled on this scene
  119080. */
  119081. set lightsEnabled(value: boolean);
  119082. get lightsEnabled(): boolean;
  119083. /** All of the active cameras added to this scene. */
  119084. activeCameras: Camera[];
  119085. /** @hidden */
  119086. _activeCamera: Nullable<Camera>;
  119087. /** Gets or sets the current active camera */
  119088. get activeCamera(): Nullable<Camera>;
  119089. set activeCamera(value: Nullable<Camera>);
  119090. private _defaultMaterial;
  119091. /** The default material used on meshes when no material is affected */
  119092. get defaultMaterial(): Material;
  119093. /** The default material used on meshes when no material is affected */
  119094. set defaultMaterial(value: Material);
  119095. private _texturesEnabled;
  119096. /**
  119097. * Gets or sets a boolean indicating if textures are enabled on this scene
  119098. */
  119099. set texturesEnabled(value: boolean);
  119100. get texturesEnabled(): boolean;
  119101. /**
  119102. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  119103. */
  119104. physicsEnabled: boolean;
  119105. /**
  119106. * Gets or sets a boolean indicating if particles are enabled on this scene
  119107. */
  119108. particlesEnabled: boolean;
  119109. /**
  119110. * Gets or sets a boolean indicating if sprites are enabled on this scene
  119111. */
  119112. spritesEnabled: boolean;
  119113. private _skeletonsEnabled;
  119114. /**
  119115. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  119116. */
  119117. set skeletonsEnabled(value: boolean);
  119118. get skeletonsEnabled(): boolean;
  119119. /**
  119120. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  119121. */
  119122. lensFlaresEnabled: boolean;
  119123. /**
  119124. * Gets or sets a boolean indicating if collisions are enabled on this scene
  119125. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  119126. */
  119127. collisionsEnabled: boolean;
  119128. private _collisionCoordinator;
  119129. /** @hidden */
  119130. get collisionCoordinator(): ICollisionCoordinator;
  119131. /**
  119132. * Defines the gravity applied to this scene (used only for collisions)
  119133. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  119134. */
  119135. gravity: Vector3;
  119136. /**
  119137. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  119138. */
  119139. postProcessesEnabled: boolean;
  119140. /**
  119141. * Gets the current postprocess manager
  119142. */
  119143. postProcessManager: PostProcessManager;
  119144. /**
  119145. * Gets or sets a boolean indicating if render targets are enabled on this scene
  119146. */
  119147. renderTargetsEnabled: boolean;
  119148. /**
  119149. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  119150. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  119151. */
  119152. dumpNextRenderTargets: boolean;
  119153. /**
  119154. * The list of user defined render targets added to the scene
  119155. */
  119156. customRenderTargets: RenderTargetTexture[];
  119157. /**
  119158. * Defines if texture loading must be delayed
  119159. * If true, textures will only be loaded when they need to be rendered
  119160. */
  119161. useDelayedTextureLoading: boolean;
  119162. /**
  119163. * Gets the list of meshes imported to the scene through SceneLoader
  119164. */
  119165. importedMeshesFiles: String[];
  119166. /**
  119167. * Gets or sets a boolean indicating if probes are enabled on this scene
  119168. */
  119169. probesEnabled: boolean;
  119170. /**
  119171. * Gets or sets the current offline provider to use to store scene data
  119172. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  119173. */
  119174. offlineProvider: IOfflineProvider;
  119175. /**
  119176. * Gets or sets the action manager associated with the scene
  119177. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  119178. */
  119179. actionManager: AbstractActionManager;
  119180. private _meshesForIntersections;
  119181. /**
  119182. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  119183. */
  119184. proceduralTexturesEnabled: boolean;
  119185. private _engine;
  119186. private _totalVertices;
  119187. /** @hidden */
  119188. _activeIndices: PerfCounter;
  119189. /** @hidden */
  119190. _activeParticles: PerfCounter;
  119191. /** @hidden */
  119192. _activeBones: PerfCounter;
  119193. private _animationRatio;
  119194. /** @hidden */
  119195. _animationTimeLast: number;
  119196. /** @hidden */
  119197. _animationTime: number;
  119198. /**
  119199. * Gets or sets a general scale for animation speed
  119200. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  119201. */
  119202. animationTimeScale: number;
  119203. /** @hidden */
  119204. _cachedMaterial: Nullable<Material>;
  119205. /** @hidden */
  119206. _cachedEffect: Nullable<Effect>;
  119207. /** @hidden */
  119208. _cachedVisibility: Nullable<number>;
  119209. private _renderId;
  119210. private _frameId;
  119211. private _executeWhenReadyTimeoutId;
  119212. private _intermediateRendering;
  119213. private _viewUpdateFlag;
  119214. private _projectionUpdateFlag;
  119215. /** @hidden */
  119216. _toBeDisposed: Nullable<IDisposable>[];
  119217. private _activeRequests;
  119218. /** @hidden */
  119219. _pendingData: any[];
  119220. private _isDisposed;
  119221. /**
  119222. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  119223. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  119224. */
  119225. dispatchAllSubMeshesOfActiveMeshes: boolean;
  119226. private _activeMeshes;
  119227. private _processedMaterials;
  119228. private _renderTargets;
  119229. /** @hidden */
  119230. _activeParticleSystems: SmartArray<IParticleSystem>;
  119231. private _activeSkeletons;
  119232. private _softwareSkinnedMeshes;
  119233. private _renderingManager;
  119234. /** @hidden */
  119235. _activeAnimatables: Animatable[];
  119236. private _transformMatrix;
  119237. private _sceneUbo;
  119238. /** @hidden */
  119239. _viewMatrix: Matrix;
  119240. private _projectionMatrix;
  119241. /** @hidden */
  119242. _forcedViewPosition: Nullable<Vector3>;
  119243. /** @hidden */
  119244. _frustumPlanes: Plane[];
  119245. /**
  119246. * Gets the list of frustum planes (built from the active camera)
  119247. */
  119248. get frustumPlanes(): Plane[];
  119249. /**
  119250. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  119251. * This is useful if there are more lights that the maximum simulteanous authorized
  119252. */
  119253. requireLightSorting: boolean;
  119254. /** @hidden */
  119255. readonly useMaterialMeshMap: boolean;
  119256. /** @hidden */
  119257. readonly useClonedMeshMap: boolean;
  119258. private _externalData;
  119259. private _uid;
  119260. /**
  119261. * @hidden
  119262. * Backing store of defined scene components.
  119263. */
  119264. _components: ISceneComponent[];
  119265. /**
  119266. * @hidden
  119267. * Backing store of defined scene components.
  119268. */
  119269. _serializableComponents: ISceneSerializableComponent[];
  119270. /**
  119271. * List of components to register on the next registration step.
  119272. */
  119273. private _transientComponents;
  119274. /**
  119275. * Registers the transient components if needed.
  119276. */
  119277. private _registerTransientComponents;
  119278. /**
  119279. * @hidden
  119280. * Add a component to the scene.
  119281. * Note that the ccomponent could be registered on th next frame if this is called after
  119282. * the register component stage.
  119283. * @param component Defines the component to add to the scene
  119284. */
  119285. _addComponent(component: ISceneComponent): void;
  119286. /**
  119287. * @hidden
  119288. * Gets a component from the scene.
  119289. * @param name defines the name of the component to retrieve
  119290. * @returns the component or null if not present
  119291. */
  119292. _getComponent(name: string): Nullable<ISceneComponent>;
  119293. /**
  119294. * @hidden
  119295. * Defines the actions happening before camera updates.
  119296. */
  119297. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  119298. /**
  119299. * @hidden
  119300. * Defines the actions happening before clear the canvas.
  119301. */
  119302. _beforeClearStage: Stage<SimpleStageAction>;
  119303. /**
  119304. * @hidden
  119305. * Defines the actions when collecting render targets for the frame.
  119306. */
  119307. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  119308. /**
  119309. * @hidden
  119310. * Defines the actions happening for one camera in the frame.
  119311. */
  119312. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  119313. /**
  119314. * @hidden
  119315. * Defines the actions happening during the per mesh ready checks.
  119316. */
  119317. _isReadyForMeshStage: Stage<MeshStageAction>;
  119318. /**
  119319. * @hidden
  119320. * Defines the actions happening before evaluate active mesh checks.
  119321. */
  119322. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  119323. /**
  119324. * @hidden
  119325. * Defines the actions happening during the evaluate sub mesh checks.
  119326. */
  119327. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  119328. /**
  119329. * @hidden
  119330. * Defines the actions happening during the active mesh stage.
  119331. */
  119332. _activeMeshStage: Stage<ActiveMeshStageAction>;
  119333. /**
  119334. * @hidden
  119335. * Defines the actions happening during the per camera render target step.
  119336. */
  119337. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  119338. /**
  119339. * @hidden
  119340. * Defines the actions happening just before the active camera is drawing.
  119341. */
  119342. _beforeCameraDrawStage: Stage<CameraStageAction>;
  119343. /**
  119344. * @hidden
  119345. * Defines the actions happening just before a render target is drawing.
  119346. */
  119347. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  119348. /**
  119349. * @hidden
  119350. * Defines the actions happening just before a rendering group is drawing.
  119351. */
  119352. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  119353. /**
  119354. * @hidden
  119355. * Defines the actions happening just before a mesh is drawing.
  119356. */
  119357. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  119358. /**
  119359. * @hidden
  119360. * Defines the actions happening just after a mesh has been drawn.
  119361. */
  119362. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  119363. /**
  119364. * @hidden
  119365. * Defines the actions happening just after a rendering group has been drawn.
  119366. */
  119367. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  119368. /**
  119369. * @hidden
  119370. * Defines the actions happening just after the active camera has been drawn.
  119371. */
  119372. _afterCameraDrawStage: Stage<CameraStageAction>;
  119373. /**
  119374. * @hidden
  119375. * Defines the actions happening just after a render target has been drawn.
  119376. */
  119377. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  119378. /**
  119379. * @hidden
  119380. * Defines the actions happening just after rendering all cameras and computing intersections.
  119381. */
  119382. _afterRenderStage: Stage<SimpleStageAction>;
  119383. /**
  119384. * @hidden
  119385. * Defines the actions happening when a pointer move event happens.
  119386. */
  119387. _pointerMoveStage: Stage<PointerMoveStageAction>;
  119388. /**
  119389. * @hidden
  119390. * Defines the actions happening when a pointer down event happens.
  119391. */
  119392. _pointerDownStage: Stage<PointerUpDownStageAction>;
  119393. /**
  119394. * @hidden
  119395. * Defines the actions happening when a pointer up event happens.
  119396. */
  119397. _pointerUpStage: Stage<PointerUpDownStageAction>;
  119398. /**
  119399. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  119400. */
  119401. private geometriesByUniqueId;
  119402. /**
  119403. * Creates a new Scene
  119404. * @param engine defines the engine to use to render this scene
  119405. * @param options defines the scene options
  119406. */
  119407. constructor(engine: Engine, options?: SceneOptions);
  119408. /**
  119409. * Gets a string identifying the name of the class
  119410. * @returns "Scene" string
  119411. */
  119412. getClassName(): string;
  119413. private _defaultMeshCandidates;
  119414. /**
  119415. * @hidden
  119416. */
  119417. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  119418. private _defaultSubMeshCandidates;
  119419. /**
  119420. * @hidden
  119421. */
  119422. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  119423. /**
  119424. * Sets the default candidate providers for the scene.
  119425. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  119426. * and getCollidingSubMeshCandidates to their default function
  119427. */
  119428. setDefaultCandidateProviders(): void;
  119429. /**
  119430. * Gets the mesh that is currently under the pointer
  119431. */
  119432. get meshUnderPointer(): Nullable<AbstractMesh>;
  119433. /**
  119434. * Gets or sets the current on-screen X position of the pointer
  119435. */
  119436. get pointerX(): number;
  119437. set pointerX(value: number);
  119438. /**
  119439. * Gets or sets the current on-screen Y position of the pointer
  119440. */
  119441. get pointerY(): number;
  119442. set pointerY(value: number);
  119443. /**
  119444. * Gets the cached material (ie. the latest rendered one)
  119445. * @returns the cached material
  119446. */
  119447. getCachedMaterial(): Nullable<Material>;
  119448. /**
  119449. * Gets the cached effect (ie. the latest rendered one)
  119450. * @returns the cached effect
  119451. */
  119452. getCachedEffect(): Nullable<Effect>;
  119453. /**
  119454. * Gets the cached visibility state (ie. the latest rendered one)
  119455. * @returns the cached visibility state
  119456. */
  119457. getCachedVisibility(): Nullable<number>;
  119458. /**
  119459. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  119460. * @param material defines the current material
  119461. * @param effect defines the current effect
  119462. * @param visibility defines the current visibility state
  119463. * @returns true if one parameter is not cached
  119464. */
  119465. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  119466. /**
  119467. * Gets the engine associated with the scene
  119468. * @returns an Engine
  119469. */
  119470. getEngine(): Engine;
  119471. /**
  119472. * Gets the total number of vertices rendered per frame
  119473. * @returns the total number of vertices rendered per frame
  119474. */
  119475. getTotalVertices(): number;
  119476. /**
  119477. * Gets the performance counter for total vertices
  119478. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  119479. */
  119480. get totalVerticesPerfCounter(): PerfCounter;
  119481. /**
  119482. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  119483. * @returns the total number of active indices rendered per frame
  119484. */
  119485. getActiveIndices(): number;
  119486. /**
  119487. * Gets the performance counter for active indices
  119488. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  119489. */
  119490. get totalActiveIndicesPerfCounter(): PerfCounter;
  119491. /**
  119492. * Gets the total number of active particles rendered per frame
  119493. * @returns the total number of active particles rendered per frame
  119494. */
  119495. getActiveParticles(): number;
  119496. /**
  119497. * Gets the performance counter for active particles
  119498. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  119499. */
  119500. get activeParticlesPerfCounter(): PerfCounter;
  119501. /**
  119502. * Gets the total number of active bones rendered per frame
  119503. * @returns the total number of active bones rendered per frame
  119504. */
  119505. getActiveBones(): number;
  119506. /**
  119507. * Gets the performance counter for active bones
  119508. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  119509. */
  119510. get activeBonesPerfCounter(): PerfCounter;
  119511. /**
  119512. * Gets the array of active meshes
  119513. * @returns an array of AbstractMesh
  119514. */
  119515. getActiveMeshes(): SmartArray<AbstractMesh>;
  119516. /**
  119517. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  119518. * @returns a number
  119519. */
  119520. getAnimationRatio(): number;
  119521. /**
  119522. * Gets an unique Id for the current render phase
  119523. * @returns a number
  119524. */
  119525. getRenderId(): number;
  119526. /**
  119527. * Gets an unique Id for the current frame
  119528. * @returns a number
  119529. */
  119530. getFrameId(): number;
  119531. /** Call this function if you want to manually increment the render Id*/
  119532. incrementRenderId(): void;
  119533. private _createUbo;
  119534. /**
  119535. * Use this method to simulate a pointer move on a mesh
  119536. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  119537. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  119538. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  119539. * @returns the current scene
  119540. */
  119541. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  119542. /**
  119543. * Use this method to simulate a pointer down on a mesh
  119544. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  119545. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  119546. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  119547. * @returns the current scene
  119548. */
  119549. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  119550. /**
  119551. * Use this method to simulate a pointer up on a mesh
  119552. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  119553. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  119554. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  119555. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  119556. * @returns the current scene
  119557. */
  119558. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  119559. /**
  119560. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  119561. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  119562. * @returns true if the pointer was captured
  119563. */
  119564. isPointerCaptured(pointerId?: number): boolean;
  119565. /**
  119566. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  119567. * @param attachUp defines if you want to attach events to pointerup
  119568. * @param attachDown defines if you want to attach events to pointerdown
  119569. * @param attachMove defines if you want to attach events to pointermove
  119570. */
  119571. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  119572. /** Detaches all event handlers*/
  119573. detachControl(): void;
  119574. /**
  119575. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  119576. * Delay loaded resources are not taking in account
  119577. * @return true if all required resources are ready
  119578. */
  119579. isReady(): boolean;
  119580. /** Resets all cached information relative to material (including effect and visibility) */
  119581. resetCachedMaterial(): void;
  119582. /**
  119583. * Registers a function to be called before every frame render
  119584. * @param func defines the function to register
  119585. */
  119586. registerBeforeRender(func: () => void): void;
  119587. /**
  119588. * Unregisters a function called before every frame render
  119589. * @param func defines the function to unregister
  119590. */
  119591. unregisterBeforeRender(func: () => void): void;
  119592. /**
  119593. * Registers a function to be called after every frame render
  119594. * @param func defines the function to register
  119595. */
  119596. registerAfterRender(func: () => void): void;
  119597. /**
  119598. * Unregisters a function called after every frame render
  119599. * @param func defines the function to unregister
  119600. */
  119601. unregisterAfterRender(func: () => void): void;
  119602. private _executeOnceBeforeRender;
  119603. /**
  119604. * The provided function will run before render once and will be disposed afterwards.
  119605. * A timeout delay can be provided so that the function will be executed in N ms.
  119606. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  119607. * @param func The function to be executed.
  119608. * @param timeout optional delay in ms
  119609. */
  119610. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  119611. /** @hidden */
  119612. _addPendingData(data: any): void;
  119613. /** @hidden */
  119614. _removePendingData(data: any): void;
  119615. /**
  119616. * Returns the number of items waiting to be loaded
  119617. * @returns the number of items waiting to be loaded
  119618. */
  119619. getWaitingItemsCount(): number;
  119620. /**
  119621. * Returns a boolean indicating if the scene is still loading data
  119622. */
  119623. get isLoading(): boolean;
  119624. /**
  119625. * Registers a function to be executed when the scene is ready
  119626. * @param {Function} func - the function to be executed
  119627. */
  119628. executeWhenReady(func: () => void): void;
  119629. /**
  119630. * Returns a promise that resolves when the scene is ready
  119631. * @returns A promise that resolves when the scene is ready
  119632. */
  119633. whenReadyAsync(): Promise<void>;
  119634. /** @hidden */
  119635. _checkIsReady(): void;
  119636. /**
  119637. * Gets all animatable attached to the scene
  119638. */
  119639. get animatables(): Animatable[];
  119640. /**
  119641. * Resets the last animation time frame.
  119642. * Useful to override when animations start running when loading a scene for the first time.
  119643. */
  119644. resetLastAnimationTimeFrame(): void;
  119645. /**
  119646. * Gets the current view matrix
  119647. * @returns a Matrix
  119648. */
  119649. getViewMatrix(): Matrix;
  119650. /**
  119651. * Gets the current projection matrix
  119652. * @returns a Matrix
  119653. */
  119654. getProjectionMatrix(): Matrix;
  119655. /**
  119656. * Gets the current transform matrix
  119657. * @returns a Matrix made of View * Projection
  119658. */
  119659. getTransformMatrix(): Matrix;
  119660. /**
  119661. * Sets the current transform matrix
  119662. * @param viewL defines the View matrix to use
  119663. * @param projectionL defines the Projection matrix to use
  119664. * @param viewR defines the right View matrix to use (if provided)
  119665. * @param projectionR defines the right Projection matrix to use (if provided)
  119666. */
  119667. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  119668. /**
  119669. * Gets the uniform buffer used to store scene data
  119670. * @returns a UniformBuffer
  119671. */
  119672. getSceneUniformBuffer(): UniformBuffer;
  119673. /**
  119674. * Gets an unique (relatively to the current scene) Id
  119675. * @returns an unique number for the scene
  119676. */
  119677. getUniqueId(): number;
  119678. /**
  119679. * Add a mesh to the list of scene's meshes
  119680. * @param newMesh defines the mesh to add
  119681. * @param recursive if all child meshes should also be added to the scene
  119682. */
  119683. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  119684. /**
  119685. * Remove a mesh for the list of scene's meshes
  119686. * @param toRemove defines the mesh to remove
  119687. * @param recursive if all child meshes should also be removed from the scene
  119688. * @returns the index where the mesh was in the mesh list
  119689. */
  119690. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  119691. /**
  119692. * Add a transform node to the list of scene's transform nodes
  119693. * @param newTransformNode defines the transform node to add
  119694. */
  119695. addTransformNode(newTransformNode: TransformNode): void;
  119696. /**
  119697. * Remove a transform node for the list of scene's transform nodes
  119698. * @param toRemove defines the transform node to remove
  119699. * @returns the index where the transform node was in the transform node list
  119700. */
  119701. removeTransformNode(toRemove: TransformNode): number;
  119702. /**
  119703. * Remove a skeleton for the list of scene's skeletons
  119704. * @param toRemove defines the skeleton to remove
  119705. * @returns the index where the skeleton was in the skeleton list
  119706. */
  119707. removeSkeleton(toRemove: Skeleton): number;
  119708. /**
  119709. * Remove a morph target for the list of scene's morph targets
  119710. * @param toRemove defines the morph target to remove
  119711. * @returns the index where the morph target was in the morph target list
  119712. */
  119713. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  119714. /**
  119715. * Remove a light for the list of scene's lights
  119716. * @param toRemove defines the light to remove
  119717. * @returns the index where the light was in the light list
  119718. */
  119719. removeLight(toRemove: Light): number;
  119720. /**
  119721. * Remove a camera for the list of scene's cameras
  119722. * @param toRemove defines the camera to remove
  119723. * @returns the index where the camera was in the camera list
  119724. */
  119725. removeCamera(toRemove: Camera): number;
  119726. /**
  119727. * Remove a particle system for the list of scene's particle systems
  119728. * @param toRemove defines the particle system to remove
  119729. * @returns the index where the particle system was in the particle system list
  119730. */
  119731. removeParticleSystem(toRemove: IParticleSystem): number;
  119732. /**
  119733. * Remove a animation for the list of scene's animations
  119734. * @param toRemove defines the animation to remove
  119735. * @returns the index where the animation was in the animation list
  119736. */
  119737. removeAnimation(toRemove: Animation): number;
  119738. /**
  119739. * Will stop the animation of the given target
  119740. * @param target - the target
  119741. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  119742. * @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)
  119743. */
  119744. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  119745. /**
  119746. * Removes the given animation group from this scene.
  119747. * @param toRemove The animation group to remove
  119748. * @returns The index of the removed animation group
  119749. */
  119750. removeAnimationGroup(toRemove: AnimationGroup): number;
  119751. /**
  119752. * Removes the given multi-material from this scene.
  119753. * @param toRemove The multi-material to remove
  119754. * @returns The index of the removed multi-material
  119755. */
  119756. removeMultiMaterial(toRemove: MultiMaterial): number;
  119757. /**
  119758. * Removes the given material from this scene.
  119759. * @param toRemove The material to remove
  119760. * @returns The index of the removed material
  119761. */
  119762. removeMaterial(toRemove: Material): number;
  119763. /**
  119764. * Removes the given action manager from this scene.
  119765. * @param toRemove The action manager to remove
  119766. * @returns The index of the removed action manager
  119767. */
  119768. removeActionManager(toRemove: AbstractActionManager): number;
  119769. /**
  119770. * Removes the given texture from this scene.
  119771. * @param toRemove The texture to remove
  119772. * @returns The index of the removed texture
  119773. */
  119774. removeTexture(toRemove: BaseTexture): number;
  119775. /**
  119776. * Adds the given light to this scene
  119777. * @param newLight The light to add
  119778. */
  119779. addLight(newLight: Light): void;
  119780. /**
  119781. * Sorts the list list based on light priorities
  119782. */
  119783. sortLightsByPriority(): void;
  119784. /**
  119785. * Adds the given camera to this scene
  119786. * @param newCamera The camera to add
  119787. */
  119788. addCamera(newCamera: Camera): void;
  119789. /**
  119790. * Adds the given skeleton to this scene
  119791. * @param newSkeleton The skeleton to add
  119792. */
  119793. addSkeleton(newSkeleton: Skeleton): void;
  119794. /**
  119795. * Adds the given particle system to this scene
  119796. * @param newParticleSystem The particle system to add
  119797. */
  119798. addParticleSystem(newParticleSystem: IParticleSystem): void;
  119799. /**
  119800. * Adds the given animation to this scene
  119801. * @param newAnimation The animation to add
  119802. */
  119803. addAnimation(newAnimation: Animation): void;
  119804. /**
  119805. * Adds the given animation group to this scene.
  119806. * @param newAnimationGroup The animation group to add
  119807. */
  119808. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  119809. /**
  119810. * Adds the given multi-material to this scene
  119811. * @param newMultiMaterial The multi-material to add
  119812. */
  119813. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  119814. /**
  119815. * Adds the given material to this scene
  119816. * @param newMaterial The material to add
  119817. */
  119818. addMaterial(newMaterial: Material): void;
  119819. /**
  119820. * Adds the given morph target to this scene
  119821. * @param newMorphTargetManager The morph target to add
  119822. */
  119823. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  119824. /**
  119825. * Adds the given geometry to this scene
  119826. * @param newGeometry The geometry to add
  119827. */
  119828. addGeometry(newGeometry: Geometry): void;
  119829. /**
  119830. * Adds the given action manager to this scene
  119831. * @param newActionManager The action manager to add
  119832. */
  119833. addActionManager(newActionManager: AbstractActionManager): void;
  119834. /**
  119835. * Adds the given texture to this scene.
  119836. * @param newTexture The texture to add
  119837. */
  119838. addTexture(newTexture: BaseTexture): void;
  119839. /**
  119840. * Switch active camera
  119841. * @param newCamera defines the new active camera
  119842. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  119843. */
  119844. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  119845. /**
  119846. * sets the active camera of the scene using its ID
  119847. * @param id defines the camera's ID
  119848. * @return the new active camera or null if none found.
  119849. */
  119850. setActiveCameraByID(id: string): Nullable<Camera>;
  119851. /**
  119852. * sets the active camera of the scene using its name
  119853. * @param name defines the camera's name
  119854. * @returns the new active camera or null if none found.
  119855. */
  119856. setActiveCameraByName(name: string): Nullable<Camera>;
  119857. /**
  119858. * get an animation group using its name
  119859. * @param name defines the material's name
  119860. * @return the animation group or null if none found.
  119861. */
  119862. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  119863. /**
  119864. * Get a material using its unique id
  119865. * @param uniqueId defines the material's unique id
  119866. * @return the material or null if none found.
  119867. */
  119868. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  119869. /**
  119870. * get a material using its id
  119871. * @param id defines the material's ID
  119872. * @return the material or null if none found.
  119873. */
  119874. getMaterialByID(id: string): Nullable<Material>;
  119875. /**
  119876. * Gets a the last added material using a given id
  119877. * @param id defines the material's ID
  119878. * @return the last material with the given id or null if none found.
  119879. */
  119880. getLastMaterialByID(id: string): Nullable<Material>;
  119881. /**
  119882. * Gets a material using its name
  119883. * @param name defines the material's name
  119884. * @return the material or null if none found.
  119885. */
  119886. getMaterialByName(name: string): Nullable<Material>;
  119887. /**
  119888. * Get a texture using its unique id
  119889. * @param uniqueId defines the texture's unique id
  119890. * @return the texture or null if none found.
  119891. */
  119892. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  119893. /**
  119894. * Gets a camera using its id
  119895. * @param id defines the id to look for
  119896. * @returns the camera or null if not found
  119897. */
  119898. getCameraByID(id: string): Nullable<Camera>;
  119899. /**
  119900. * Gets a camera using its unique id
  119901. * @param uniqueId defines the unique id to look for
  119902. * @returns the camera or null if not found
  119903. */
  119904. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  119905. /**
  119906. * Gets a camera using its name
  119907. * @param name defines the camera's name
  119908. * @return the camera or null if none found.
  119909. */
  119910. getCameraByName(name: string): Nullable<Camera>;
  119911. /**
  119912. * Gets a bone using its id
  119913. * @param id defines the bone's id
  119914. * @return the bone or null if not found
  119915. */
  119916. getBoneByID(id: string): Nullable<Bone>;
  119917. /**
  119918. * Gets a bone using its id
  119919. * @param name defines the bone's name
  119920. * @return the bone or null if not found
  119921. */
  119922. getBoneByName(name: string): Nullable<Bone>;
  119923. /**
  119924. * Gets a light node using its name
  119925. * @param name defines the the light's name
  119926. * @return the light or null if none found.
  119927. */
  119928. getLightByName(name: string): Nullable<Light>;
  119929. /**
  119930. * Gets a light node using its id
  119931. * @param id defines the light's id
  119932. * @return the light or null if none found.
  119933. */
  119934. getLightByID(id: string): Nullable<Light>;
  119935. /**
  119936. * Gets a light node using its scene-generated unique ID
  119937. * @param uniqueId defines the light's unique id
  119938. * @return the light or null if none found.
  119939. */
  119940. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  119941. /**
  119942. * Gets a particle system by id
  119943. * @param id defines the particle system id
  119944. * @return the corresponding system or null if none found
  119945. */
  119946. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  119947. /**
  119948. * Gets a geometry using its ID
  119949. * @param id defines the geometry's id
  119950. * @return the geometry or null if none found.
  119951. */
  119952. getGeometryByID(id: string): Nullable<Geometry>;
  119953. private _getGeometryByUniqueID;
  119954. /**
  119955. * Add a new geometry to this scene
  119956. * @param geometry defines the geometry to be added to the scene.
  119957. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  119958. * @return a boolean defining if the geometry was added or not
  119959. */
  119960. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  119961. /**
  119962. * Removes an existing geometry
  119963. * @param geometry defines the geometry to be removed from the scene
  119964. * @return a boolean defining if the geometry was removed or not
  119965. */
  119966. removeGeometry(geometry: Geometry): boolean;
  119967. /**
  119968. * Gets the list of geometries attached to the scene
  119969. * @returns an array of Geometry
  119970. */
  119971. getGeometries(): Geometry[];
  119972. /**
  119973. * Gets the first added mesh found of a given ID
  119974. * @param id defines the id to search for
  119975. * @return the mesh found or null if not found at all
  119976. */
  119977. getMeshByID(id: string): Nullable<AbstractMesh>;
  119978. /**
  119979. * Gets a list of meshes using their id
  119980. * @param id defines the id to search for
  119981. * @returns a list of meshes
  119982. */
  119983. getMeshesByID(id: string): Array<AbstractMesh>;
  119984. /**
  119985. * Gets the first added transform node found of a given ID
  119986. * @param id defines the id to search for
  119987. * @return the found transform node or null if not found at all.
  119988. */
  119989. getTransformNodeByID(id: string): Nullable<TransformNode>;
  119990. /**
  119991. * Gets a transform node with its auto-generated unique id
  119992. * @param uniqueId efines the unique id to search for
  119993. * @return the found transform node or null if not found at all.
  119994. */
  119995. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  119996. /**
  119997. * Gets a list of transform nodes using their id
  119998. * @param id defines the id to search for
  119999. * @returns a list of transform nodes
  120000. */
  120001. getTransformNodesByID(id: string): Array<TransformNode>;
  120002. /**
  120003. * Gets a mesh with its auto-generated unique id
  120004. * @param uniqueId defines the unique id to search for
  120005. * @return the found mesh or null if not found at all.
  120006. */
  120007. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  120008. /**
  120009. * Gets a the last added mesh using a given id
  120010. * @param id defines the id to search for
  120011. * @return the found mesh or null if not found at all.
  120012. */
  120013. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  120014. /**
  120015. * Gets a the last added node (Mesh, Camera, Light) using a given id
  120016. * @param id defines the id to search for
  120017. * @return the found node or null if not found at all
  120018. */
  120019. getLastEntryByID(id: string): Nullable<Node>;
  120020. /**
  120021. * Gets a node (Mesh, Camera, Light) using a given id
  120022. * @param id defines the id to search for
  120023. * @return the found node or null if not found at all
  120024. */
  120025. getNodeByID(id: string): Nullable<Node>;
  120026. /**
  120027. * Gets a node (Mesh, Camera, Light) using a given name
  120028. * @param name defines the name to search for
  120029. * @return the found node or null if not found at all.
  120030. */
  120031. getNodeByName(name: string): Nullable<Node>;
  120032. /**
  120033. * Gets a mesh using a given name
  120034. * @param name defines the name to search for
  120035. * @return the found mesh or null if not found at all.
  120036. */
  120037. getMeshByName(name: string): Nullable<AbstractMesh>;
  120038. /**
  120039. * Gets a transform node using a given name
  120040. * @param name defines the name to search for
  120041. * @return the found transform node or null if not found at all.
  120042. */
  120043. getTransformNodeByName(name: string): Nullable<TransformNode>;
  120044. /**
  120045. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  120046. * @param id defines the id to search for
  120047. * @return the found skeleton or null if not found at all.
  120048. */
  120049. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  120050. /**
  120051. * Gets a skeleton using a given auto generated unique id
  120052. * @param uniqueId defines the unique id to search for
  120053. * @return the found skeleton or null if not found at all.
  120054. */
  120055. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  120056. /**
  120057. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  120058. * @param id defines the id to search for
  120059. * @return the found skeleton or null if not found at all.
  120060. */
  120061. getSkeletonById(id: string): Nullable<Skeleton>;
  120062. /**
  120063. * Gets a skeleton using a given name
  120064. * @param name defines the name to search for
  120065. * @return the found skeleton or null if not found at all.
  120066. */
  120067. getSkeletonByName(name: string): Nullable<Skeleton>;
  120068. /**
  120069. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  120070. * @param id defines the id to search for
  120071. * @return the found morph target manager or null if not found at all.
  120072. */
  120073. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  120074. /**
  120075. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  120076. * @param id defines the id to search for
  120077. * @return the found morph target or null if not found at all.
  120078. */
  120079. getMorphTargetById(id: string): Nullable<MorphTarget>;
  120080. /**
  120081. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  120082. * @param name defines the name to search for
  120083. * @return the found morph target or null if not found at all.
  120084. */
  120085. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  120086. /**
  120087. * Gets a post process using a given name (if many are found, this function will pick the first one)
  120088. * @param name defines the name to search for
  120089. * @return the found post process or null if not found at all.
  120090. */
  120091. getPostProcessByName(name: string): Nullable<PostProcess>;
  120092. /**
  120093. * Gets a boolean indicating if the given mesh is active
  120094. * @param mesh defines the mesh to look for
  120095. * @returns true if the mesh is in the active list
  120096. */
  120097. isActiveMesh(mesh: AbstractMesh): boolean;
  120098. /**
  120099. * Return a unique id as a string which can serve as an identifier for the scene
  120100. */
  120101. get uid(): string;
  120102. /**
  120103. * Add an externaly attached data from its key.
  120104. * This method call will fail and return false, if such key already exists.
  120105. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  120106. * @param key the unique key that identifies the data
  120107. * @param data the data object to associate to the key for this Engine instance
  120108. * @return true if no such key were already present and the data was added successfully, false otherwise
  120109. */
  120110. addExternalData<T>(key: string, data: T): boolean;
  120111. /**
  120112. * Get an externaly attached data from its key
  120113. * @param key the unique key that identifies the data
  120114. * @return the associated data, if present (can be null), or undefined if not present
  120115. */
  120116. getExternalData<T>(key: string): Nullable<T>;
  120117. /**
  120118. * Get an externaly attached data from its key, create it using a factory if it's not already present
  120119. * @param key the unique key that identifies the data
  120120. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  120121. * @return the associated data, can be null if the factory returned null.
  120122. */
  120123. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  120124. /**
  120125. * Remove an externaly attached data from the Engine instance
  120126. * @param key the unique key that identifies the data
  120127. * @return true if the data was successfully removed, false if it doesn't exist
  120128. */
  120129. removeExternalData(key: string): boolean;
  120130. private _evaluateSubMesh;
  120131. /**
  120132. * Clear the processed materials smart array preventing retention point in material dispose.
  120133. */
  120134. freeProcessedMaterials(): void;
  120135. private _preventFreeActiveMeshesAndRenderingGroups;
  120136. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  120137. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  120138. * when disposing several meshes in a row or a hierarchy of meshes.
  120139. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  120140. */
  120141. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  120142. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  120143. /**
  120144. * Clear the active meshes smart array preventing retention point in mesh dispose.
  120145. */
  120146. freeActiveMeshes(): void;
  120147. /**
  120148. * Clear the info related to rendering groups preventing retention points during dispose.
  120149. */
  120150. freeRenderingGroups(): void;
  120151. /** @hidden */
  120152. _isInIntermediateRendering(): boolean;
  120153. /**
  120154. * Lambda returning the list of potentially active meshes.
  120155. */
  120156. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  120157. /**
  120158. * Lambda returning the list of potentially active sub meshes.
  120159. */
  120160. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  120161. /**
  120162. * Lambda returning the list of potentially intersecting sub meshes.
  120163. */
  120164. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  120165. /**
  120166. * Lambda returning the list of potentially colliding sub meshes.
  120167. */
  120168. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  120169. private _activeMeshesFrozen;
  120170. private _skipEvaluateActiveMeshesCompletely;
  120171. /**
  120172. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  120173. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  120174. * @returns the current scene
  120175. */
  120176. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  120177. /**
  120178. * Use this function to restart evaluating active meshes on every frame
  120179. * @returns the current scene
  120180. */
  120181. unfreezeActiveMeshes(): Scene;
  120182. private _evaluateActiveMeshes;
  120183. private _activeMesh;
  120184. /**
  120185. * Update the transform matrix to update from the current active camera
  120186. * @param force defines a boolean used to force the update even if cache is up to date
  120187. */
  120188. updateTransformMatrix(force?: boolean): void;
  120189. private _bindFrameBuffer;
  120190. /** @hidden */
  120191. _allowPostProcessClearColor: boolean;
  120192. /** @hidden */
  120193. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  120194. private _processSubCameras;
  120195. private _checkIntersections;
  120196. /** @hidden */
  120197. _advancePhysicsEngineStep(step: number): void;
  120198. /**
  120199. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  120200. */
  120201. getDeterministicFrameTime: () => number;
  120202. /** @hidden */
  120203. _animate(): void;
  120204. /** Execute all animations (for a frame) */
  120205. animate(): void;
  120206. /**
  120207. * Render the scene
  120208. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  120209. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  120210. */
  120211. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  120212. /**
  120213. * Freeze all materials
  120214. * A frozen material will not be updatable but should be faster to render
  120215. */
  120216. freezeMaterials(): void;
  120217. /**
  120218. * Unfreeze all materials
  120219. * A frozen material will not be updatable but should be faster to render
  120220. */
  120221. unfreezeMaterials(): void;
  120222. /**
  120223. * Releases all held ressources
  120224. */
  120225. dispose(): void;
  120226. /**
  120227. * Gets if the scene is already disposed
  120228. */
  120229. get isDisposed(): boolean;
  120230. /**
  120231. * Call this function to reduce memory footprint of the scene.
  120232. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  120233. */
  120234. clearCachedVertexData(): void;
  120235. /**
  120236. * This function will remove the local cached buffer data from texture.
  120237. * It will save memory but will prevent the texture from being rebuilt
  120238. */
  120239. cleanCachedTextureBuffer(): void;
  120240. /**
  120241. * Get the world extend vectors with an optional filter
  120242. *
  120243. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  120244. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  120245. */
  120246. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  120247. min: Vector3;
  120248. max: Vector3;
  120249. };
  120250. /**
  120251. * Creates a ray that can be used to pick in the scene
  120252. * @param x defines the x coordinate of the origin (on-screen)
  120253. * @param y defines the y coordinate of the origin (on-screen)
  120254. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  120255. * @param camera defines the camera to use for the picking
  120256. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  120257. * @returns a Ray
  120258. */
  120259. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  120260. /**
  120261. * Creates a ray that can be used to pick in the scene
  120262. * @param x defines the x coordinate of the origin (on-screen)
  120263. * @param y defines the y coordinate of the origin (on-screen)
  120264. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  120265. * @param result defines the ray where to store the picking ray
  120266. * @param camera defines the camera to use for the picking
  120267. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  120268. * @returns the current scene
  120269. */
  120270. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  120271. /**
  120272. * Creates a ray that can be used to pick in the scene
  120273. * @param x defines the x coordinate of the origin (on-screen)
  120274. * @param y defines the y coordinate of the origin (on-screen)
  120275. * @param camera defines the camera to use for the picking
  120276. * @returns a Ray
  120277. */
  120278. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  120279. /**
  120280. * Creates a ray that can be used to pick in the scene
  120281. * @param x defines the x coordinate of the origin (on-screen)
  120282. * @param y defines the y coordinate of the origin (on-screen)
  120283. * @param result defines the ray where to store the picking ray
  120284. * @param camera defines the camera to use for the picking
  120285. * @returns the current scene
  120286. */
  120287. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  120288. /** Launch a ray to try to pick a mesh in the scene
  120289. * @param x position on screen
  120290. * @param y position on screen
  120291. * @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
  120292. * @param fastCheck defines if the first intersection will be used (and not the closest)
  120293. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  120294. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  120295. * @returns a PickingInfo
  120296. */
  120297. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  120298. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  120299. * @param x position on screen
  120300. * @param y position on screen
  120301. * @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
  120302. * @param fastCheck defines if the first intersection will be used (and not the closest)
  120303. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  120304. * @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)
  120305. */
  120306. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  120307. /** Use the given ray to pick a mesh in the scene
  120308. * @param ray The ray to use to pick meshes
  120309. * @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
  120310. * @param fastCheck defines if the first intersection will be used (and not the closest)
  120311. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  120312. * @returns a PickingInfo
  120313. */
  120314. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  120315. /**
  120316. * Launch a ray to try to pick a mesh in the scene
  120317. * @param x X position on screen
  120318. * @param y Y position on screen
  120319. * @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
  120320. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  120321. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  120322. * @returns an array of PickingInfo
  120323. */
  120324. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  120325. /**
  120326. * Launch a ray to try to pick a mesh in the scene
  120327. * @param ray Ray to use
  120328. * @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
  120329. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  120330. * @returns an array of PickingInfo
  120331. */
  120332. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  120333. /**
  120334. * Force the value of meshUnderPointer
  120335. * @param mesh defines the mesh to use
  120336. */
  120337. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  120338. /**
  120339. * Gets the mesh under the pointer
  120340. * @returns a Mesh or null if no mesh is under the pointer
  120341. */
  120342. getPointerOverMesh(): Nullable<AbstractMesh>;
  120343. /** @hidden */
  120344. _rebuildGeometries(): void;
  120345. /** @hidden */
  120346. _rebuildTextures(): void;
  120347. private _getByTags;
  120348. /**
  120349. * Get a list of meshes by tags
  120350. * @param tagsQuery defines the tags query to use
  120351. * @param forEach defines a predicate used to filter results
  120352. * @returns an array of Mesh
  120353. */
  120354. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  120355. /**
  120356. * Get a list of cameras by tags
  120357. * @param tagsQuery defines the tags query to use
  120358. * @param forEach defines a predicate used to filter results
  120359. * @returns an array of Camera
  120360. */
  120361. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  120362. /**
  120363. * Get a list of lights by tags
  120364. * @param tagsQuery defines the tags query to use
  120365. * @param forEach defines a predicate used to filter results
  120366. * @returns an array of Light
  120367. */
  120368. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  120369. /**
  120370. * Get a list of materials by tags
  120371. * @param tagsQuery defines the tags query to use
  120372. * @param forEach defines a predicate used to filter results
  120373. * @returns an array of Material
  120374. */
  120375. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  120376. /**
  120377. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  120378. * This allowed control for front to back rendering or reversly depending of the special needs.
  120379. *
  120380. * @param renderingGroupId The rendering group id corresponding to its index
  120381. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  120382. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  120383. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  120384. */
  120385. 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;
  120386. /**
  120387. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  120388. *
  120389. * @param renderingGroupId The rendering group id corresponding to its index
  120390. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  120391. * @param depth Automatically clears depth between groups if true and autoClear is true.
  120392. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  120393. */
  120394. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  120395. /**
  120396. * Gets the current auto clear configuration for one rendering group of the rendering
  120397. * manager.
  120398. * @param index the rendering group index to get the information for
  120399. * @returns The auto clear setup for the requested rendering group
  120400. */
  120401. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  120402. private _blockMaterialDirtyMechanism;
  120403. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  120404. get blockMaterialDirtyMechanism(): boolean;
  120405. set blockMaterialDirtyMechanism(value: boolean);
  120406. /**
  120407. * Will flag all materials as dirty to trigger new shader compilation
  120408. * @param flag defines the flag used to specify which material part must be marked as dirty
  120409. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  120410. */
  120411. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  120412. /** @hidden */
  120413. _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;
  120414. /** @hidden */
  120415. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  120416. /** @hidden */
  120417. _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;
  120418. /** @hidden */
  120419. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  120420. /** @hidden */
  120421. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  120422. /** @hidden */
  120423. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  120424. }
  120425. }
  120426. declare module BABYLON {
  120427. /**
  120428. * Set of assets to keep when moving a scene into an asset container.
  120429. */
  120430. export class KeepAssets extends AbstractScene {
  120431. }
  120432. /**
  120433. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  120434. */
  120435. export class InstantiatedEntries {
  120436. /**
  120437. * List of new root nodes (eg. nodes with no parent)
  120438. */
  120439. rootNodes: TransformNode[];
  120440. /**
  120441. * List of new skeletons
  120442. */
  120443. skeletons: Skeleton[];
  120444. /**
  120445. * List of new animation groups
  120446. */
  120447. animationGroups: AnimationGroup[];
  120448. }
  120449. /**
  120450. * Container with a set of assets that can be added or removed from a scene.
  120451. */
  120452. export class AssetContainer extends AbstractScene {
  120453. private _wasAddedToScene;
  120454. /**
  120455. * The scene the AssetContainer belongs to.
  120456. */
  120457. scene: Scene;
  120458. /**
  120459. * Instantiates an AssetContainer.
  120460. * @param scene The scene the AssetContainer belongs to.
  120461. */
  120462. constructor(scene: Scene);
  120463. /**
  120464. * Instantiate or clone all meshes and add the new ones to the scene.
  120465. * Skeletons and animation groups will all be cloned
  120466. * @param nameFunction defines an optional function used to get new names for clones
  120467. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  120468. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  120469. */
  120470. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  120471. /**
  120472. * Adds all the assets from the container to the scene.
  120473. */
  120474. addAllToScene(): void;
  120475. /**
  120476. * Removes all the assets in the container from the scene
  120477. */
  120478. removeAllFromScene(): void;
  120479. /**
  120480. * Disposes all the assets in the container
  120481. */
  120482. dispose(): void;
  120483. private _moveAssets;
  120484. /**
  120485. * Removes all the assets contained in the scene and adds them to the container.
  120486. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  120487. */
  120488. moveAllFromScene(keepAssets?: KeepAssets): void;
  120489. /**
  120490. * 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.
  120491. * @returns the root mesh
  120492. */
  120493. createRootMesh(): Mesh;
  120494. /**
  120495. * Merge animations (direct and animation groups) from this asset container into a scene
  120496. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  120497. * @param animatables set of animatables to retarget to a node from the scene
  120498. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  120499. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  120500. */
  120501. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  120502. }
  120503. }
  120504. declare module BABYLON {
  120505. /**
  120506. * Defines how the parser contract is defined.
  120507. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  120508. */
  120509. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  120510. /**
  120511. * Defines how the individual parser contract is defined.
  120512. * These parser can parse an individual asset
  120513. */
  120514. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  120515. /**
  120516. * Base class of the scene acting as a container for the different elements composing a scene.
  120517. * This class is dynamically extended by the different components of the scene increasing
  120518. * flexibility and reducing coupling
  120519. */
  120520. export abstract class AbstractScene {
  120521. /**
  120522. * Stores the list of available parsers in the application.
  120523. */
  120524. private static _BabylonFileParsers;
  120525. /**
  120526. * Stores the list of available individual parsers in the application.
  120527. */
  120528. private static _IndividualBabylonFileParsers;
  120529. /**
  120530. * Adds a parser in the list of available ones
  120531. * @param name Defines the name of the parser
  120532. * @param parser Defines the parser to add
  120533. */
  120534. static AddParser(name: string, parser: BabylonFileParser): void;
  120535. /**
  120536. * Gets a general parser from the list of avaialble ones
  120537. * @param name Defines the name of the parser
  120538. * @returns the requested parser or null
  120539. */
  120540. static GetParser(name: string): Nullable<BabylonFileParser>;
  120541. /**
  120542. * Adds n individual parser in the list of available ones
  120543. * @param name Defines the name of the parser
  120544. * @param parser Defines the parser to add
  120545. */
  120546. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  120547. /**
  120548. * Gets an individual parser from the list of avaialble ones
  120549. * @param name Defines the name of the parser
  120550. * @returns the requested parser or null
  120551. */
  120552. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  120553. /**
  120554. * Parser json data and populate both a scene and its associated container object
  120555. * @param jsonData Defines the data to parse
  120556. * @param scene Defines the scene to parse the data for
  120557. * @param container Defines the container attached to the parsing sequence
  120558. * @param rootUrl Defines the root url of the data
  120559. */
  120560. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  120561. /**
  120562. * Gets the list of root nodes (ie. nodes with no parent)
  120563. */
  120564. rootNodes: Node[];
  120565. /** All of the cameras added to this scene
  120566. * @see https://doc.babylonjs.com/babylon101/cameras
  120567. */
  120568. cameras: Camera[];
  120569. /**
  120570. * All of the lights added to this scene
  120571. * @see https://doc.babylonjs.com/babylon101/lights
  120572. */
  120573. lights: Light[];
  120574. /**
  120575. * All of the (abstract) meshes added to this scene
  120576. */
  120577. meshes: AbstractMesh[];
  120578. /**
  120579. * The list of skeletons added to the scene
  120580. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  120581. */
  120582. skeletons: Skeleton[];
  120583. /**
  120584. * All of the particle systems added to this scene
  120585. * @see https://doc.babylonjs.com/babylon101/particles
  120586. */
  120587. particleSystems: IParticleSystem[];
  120588. /**
  120589. * Gets a list of Animations associated with the scene
  120590. */
  120591. animations: Animation[];
  120592. /**
  120593. * All of the animation groups added to this scene
  120594. * @see https://doc.babylonjs.com/how_to/group
  120595. */
  120596. animationGroups: AnimationGroup[];
  120597. /**
  120598. * All of the multi-materials added to this scene
  120599. * @see https://doc.babylonjs.com/how_to/multi_materials
  120600. */
  120601. multiMaterials: MultiMaterial[];
  120602. /**
  120603. * All of the materials added to this scene
  120604. * In the context of a Scene, it is not supposed to be modified manually.
  120605. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  120606. * Note also that the order of the Material within the array is not significant and might change.
  120607. * @see https://doc.babylonjs.com/babylon101/materials
  120608. */
  120609. materials: Material[];
  120610. /**
  120611. * The list of morph target managers added to the scene
  120612. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  120613. */
  120614. morphTargetManagers: MorphTargetManager[];
  120615. /**
  120616. * The list of geometries used in the scene.
  120617. */
  120618. geometries: Geometry[];
  120619. /**
  120620. * All of the tranform nodes added to this scene
  120621. * In the context of a Scene, it is not supposed to be modified manually.
  120622. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  120623. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  120624. * @see https://doc.babylonjs.com/how_to/transformnode
  120625. */
  120626. transformNodes: TransformNode[];
  120627. /**
  120628. * ActionManagers available on the scene.
  120629. */
  120630. actionManagers: AbstractActionManager[];
  120631. /**
  120632. * Textures to keep.
  120633. */
  120634. textures: BaseTexture[];
  120635. /**
  120636. * Environment texture for the scene
  120637. */
  120638. environmentTexture: Nullable<BaseTexture>;
  120639. /**
  120640. * The list of postprocesses added to the scene
  120641. */
  120642. postProcesses: PostProcess[];
  120643. /**
  120644. * @returns all meshes, lights, cameras, transformNodes and bones
  120645. */
  120646. getNodes(): Array<Node>;
  120647. }
  120648. }
  120649. declare module BABYLON {
  120650. /**
  120651. * Interface used to define options for Sound class
  120652. */
  120653. export interface ISoundOptions {
  120654. /**
  120655. * Does the sound autoplay once loaded.
  120656. */
  120657. autoplay?: boolean;
  120658. /**
  120659. * Does the sound loop after it finishes playing once.
  120660. */
  120661. loop?: boolean;
  120662. /**
  120663. * Sound's volume
  120664. */
  120665. volume?: number;
  120666. /**
  120667. * Is it a spatial sound?
  120668. */
  120669. spatialSound?: boolean;
  120670. /**
  120671. * Maximum distance to hear that sound
  120672. */
  120673. maxDistance?: number;
  120674. /**
  120675. * Uses user defined attenuation function
  120676. */
  120677. useCustomAttenuation?: boolean;
  120678. /**
  120679. * Define the roll off factor of spatial sounds.
  120680. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120681. */
  120682. rolloffFactor?: number;
  120683. /**
  120684. * Define the reference distance the sound should be heard perfectly.
  120685. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120686. */
  120687. refDistance?: number;
  120688. /**
  120689. * Define the distance attenuation model the sound will follow.
  120690. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120691. */
  120692. distanceModel?: string;
  120693. /**
  120694. * Defines the playback speed (1 by default)
  120695. */
  120696. playbackRate?: number;
  120697. /**
  120698. * Defines if the sound is from a streaming source
  120699. */
  120700. streaming?: boolean;
  120701. /**
  120702. * Defines an optional length (in seconds) inside the sound file
  120703. */
  120704. length?: number;
  120705. /**
  120706. * Defines an optional offset (in seconds) inside the sound file
  120707. */
  120708. offset?: number;
  120709. /**
  120710. * If true, URLs will not be required to state the audio file codec to use.
  120711. */
  120712. skipCodecCheck?: boolean;
  120713. }
  120714. /**
  120715. * Defines a sound that can be played in the application.
  120716. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  120717. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120718. */
  120719. export class Sound {
  120720. /**
  120721. * The name of the sound in the scene.
  120722. */
  120723. name: string;
  120724. /**
  120725. * Does the sound autoplay once loaded.
  120726. */
  120727. autoplay: boolean;
  120728. /**
  120729. * Does the sound loop after it finishes playing once.
  120730. */
  120731. loop: boolean;
  120732. /**
  120733. * Does the sound use a custom attenuation curve to simulate the falloff
  120734. * happening when the source gets further away from the camera.
  120735. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  120736. */
  120737. useCustomAttenuation: boolean;
  120738. /**
  120739. * The sound track id this sound belongs to.
  120740. */
  120741. soundTrackId: number;
  120742. /**
  120743. * Is this sound currently played.
  120744. */
  120745. isPlaying: boolean;
  120746. /**
  120747. * Is this sound currently paused.
  120748. */
  120749. isPaused: boolean;
  120750. /**
  120751. * Does this sound enables spatial sound.
  120752. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120753. */
  120754. spatialSound: boolean;
  120755. /**
  120756. * Define the reference distance the sound should be heard perfectly.
  120757. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120758. */
  120759. refDistance: number;
  120760. /**
  120761. * Define the roll off factor of spatial sounds.
  120762. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120763. */
  120764. rolloffFactor: number;
  120765. /**
  120766. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  120767. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120768. */
  120769. maxDistance: number;
  120770. /**
  120771. * Define the distance attenuation model the sound will follow.
  120772. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120773. */
  120774. distanceModel: string;
  120775. /**
  120776. * @hidden
  120777. * Back Compat
  120778. **/
  120779. onended: () => any;
  120780. /**
  120781. * Gets or sets an object used to store user defined information for the sound.
  120782. */
  120783. metadata: any;
  120784. /**
  120785. * Observable event when the current playing sound finishes.
  120786. */
  120787. onEndedObservable: Observable<Sound>;
  120788. private _panningModel;
  120789. private _playbackRate;
  120790. private _streaming;
  120791. private _startTime;
  120792. private _startOffset;
  120793. private _position;
  120794. /** @hidden */
  120795. _positionInEmitterSpace: boolean;
  120796. private _localDirection;
  120797. private _volume;
  120798. private _isReadyToPlay;
  120799. private _isDirectional;
  120800. private _readyToPlayCallback;
  120801. private _audioBuffer;
  120802. private _soundSource;
  120803. private _streamingSource;
  120804. private _soundPanner;
  120805. private _soundGain;
  120806. private _inputAudioNode;
  120807. private _outputAudioNode;
  120808. private _coneInnerAngle;
  120809. private _coneOuterAngle;
  120810. private _coneOuterGain;
  120811. private _scene;
  120812. private _connectedTransformNode;
  120813. private _customAttenuationFunction;
  120814. private _registerFunc;
  120815. private _isOutputConnected;
  120816. private _htmlAudioElement;
  120817. private _urlType;
  120818. private _length?;
  120819. private _offset?;
  120820. /** @hidden */
  120821. static _SceneComponentInitialization: (scene: Scene) => void;
  120822. /**
  120823. * Create a sound and attach it to a scene
  120824. * @param name Name of your sound
  120825. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  120826. * @param scene defines the scene the sound belongs to
  120827. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  120828. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  120829. */
  120830. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  120831. /**
  120832. * Release the sound and its associated resources
  120833. */
  120834. dispose(): void;
  120835. /**
  120836. * Gets if the sounds is ready to be played or not.
  120837. * @returns true if ready, otherwise false
  120838. */
  120839. isReady(): boolean;
  120840. private _soundLoaded;
  120841. /**
  120842. * Sets the data of the sound from an audiobuffer
  120843. * @param audioBuffer The audioBuffer containing the data
  120844. */
  120845. setAudioBuffer(audioBuffer: AudioBuffer): void;
  120846. /**
  120847. * Updates the current sounds options such as maxdistance, loop...
  120848. * @param options A JSON object containing values named as the object properties
  120849. */
  120850. updateOptions(options: ISoundOptions): void;
  120851. private _createSpatialParameters;
  120852. private _updateSpatialParameters;
  120853. /**
  120854. * Switch the panning model to HRTF:
  120855. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  120856. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120857. */
  120858. switchPanningModelToHRTF(): void;
  120859. /**
  120860. * Switch the panning model to Equal Power:
  120861. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  120862. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120863. */
  120864. switchPanningModelToEqualPower(): void;
  120865. private _switchPanningModel;
  120866. /**
  120867. * Connect this sound to a sound track audio node like gain...
  120868. * @param soundTrackAudioNode the sound track audio node to connect to
  120869. */
  120870. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  120871. /**
  120872. * Transform this sound into a directional source
  120873. * @param coneInnerAngle Size of the inner cone in degree
  120874. * @param coneOuterAngle Size of the outer cone in degree
  120875. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  120876. */
  120877. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  120878. /**
  120879. * Gets or sets the inner angle for the directional cone.
  120880. */
  120881. get directionalConeInnerAngle(): number;
  120882. /**
  120883. * Gets or sets the inner angle for the directional cone.
  120884. */
  120885. set directionalConeInnerAngle(value: number);
  120886. /**
  120887. * Gets or sets the outer angle for the directional cone.
  120888. */
  120889. get directionalConeOuterAngle(): number;
  120890. /**
  120891. * Gets or sets the outer angle for the directional cone.
  120892. */
  120893. set directionalConeOuterAngle(value: number);
  120894. /**
  120895. * Sets the position of the emitter if spatial sound is enabled
  120896. * @param newPosition Defines the new posisiton
  120897. */
  120898. setPosition(newPosition: Vector3): void;
  120899. /**
  120900. * Sets the local direction of the emitter if spatial sound is enabled
  120901. * @param newLocalDirection Defines the new local direction
  120902. */
  120903. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  120904. private _updateDirection;
  120905. /** @hidden */
  120906. updateDistanceFromListener(): void;
  120907. /**
  120908. * Sets a new custom attenuation function for the sound.
  120909. * @param callback Defines the function used for the attenuation
  120910. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  120911. */
  120912. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  120913. /**
  120914. * Play the sound
  120915. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  120916. * @param offset (optional) Start the sound at a specific time in seconds
  120917. * @param length (optional) Sound duration (in seconds)
  120918. */
  120919. play(time?: number, offset?: number, length?: number): void;
  120920. private _onended;
  120921. /**
  120922. * Stop the sound
  120923. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  120924. */
  120925. stop(time?: number): void;
  120926. /**
  120927. * Put the sound in pause
  120928. */
  120929. pause(): void;
  120930. /**
  120931. * Sets a dedicated volume for this sounds
  120932. * @param newVolume Define the new volume of the sound
  120933. * @param time Define time for gradual change to new volume
  120934. */
  120935. setVolume(newVolume: number, time?: number): void;
  120936. /**
  120937. * Set the sound play back rate
  120938. * @param newPlaybackRate Define the playback rate the sound should be played at
  120939. */
  120940. setPlaybackRate(newPlaybackRate: number): void;
  120941. /**
  120942. * Gets the volume of the sound.
  120943. * @returns the volume of the sound
  120944. */
  120945. getVolume(): number;
  120946. /**
  120947. * Attach the sound to a dedicated mesh
  120948. * @param transformNode The transform node to connect the sound with
  120949. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  120950. */
  120951. attachToMesh(transformNode: TransformNode): void;
  120952. /**
  120953. * Detach the sound from the previously attached mesh
  120954. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  120955. */
  120956. detachFromMesh(): void;
  120957. private _onRegisterAfterWorldMatrixUpdate;
  120958. /**
  120959. * Clone the current sound in the scene.
  120960. * @returns the new sound clone
  120961. */
  120962. clone(): Nullable<Sound>;
  120963. /**
  120964. * Gets the current underlying audio buffer containing the data
  120965. * @returns the audio buffer
  120966. */
  120967. getAudioBuffer(): Nullable<AudioBuffer>;
  120968. /**
  120969. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  120970. * @returns the source node
  120971. */
  120972. getSoundSource(): Nullable<AudioBufferSourceNode>;
  120973. /**
  120974. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  120975. * @returns the gain node
  120976. */
  120977. getSoundGain(): Nullable<GainNode>;
  120978. /**
  120979. * Serializes the Sound in a JSON representation
  120980. * @returns the JSON representation of the sound
  120981. */
  120982. serialize(): any;
  120983. /**
  120984. * Parse a JSON representation of a sound to innstantiate in a given scene
  120985. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  120986. * @param scene Define the scene the new parsed sound should be created in
  120987. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  120988. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  120989. * @returns the newly parsed sound
  120990. */
  120991. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  120992. }
  120993. }
  120994. declare module BABYLON {
  120995. /**
  120996. * This defines an action helpful to play a defined sound on a triggered action.
  120997. */
  120998. export class PlaySoundAction extends Action {
  120999. private _sound;
  121000. /**
  121001. * Instantiate the action
  121002. * @param triggerOptions defines the trigger options
  121003. * @param sound defines the sound to play
  121004. * @param condition defines the trigger related conditions
  121005. */
  121006. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  121007. /** @hidden */
  121008. _prepare(): void;
  121009. /**
  121010. * Execute the action and play the sound.
  121011. */
  121012. execute(): void;
  121013. /**
  121014. * Serializes the actions and its related information.
  121015. * @param parent defines the object to serialize in
  121016. * @returns the serialized object
  121017. */
  121018. serialize(parent: any): any;
  121019. }
  121020. /**
  121021. * This defines an action helpful to stop a defined sound on a triggered action.
  121022. */
  121023. export class StopSoundAction extends Action {
  121024. private _sound;
  121025. /**
  121026. * Instantiate the action
  121027. * @param triggerOptions defines the trigger options
  121028. * @param sound defines the sound to stop
  121029. * @param condition defines the trigger related conditions
  121030. */
  121031. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  121032. /** @hidden */
  121033. _prepare(): void;
  121034. /**
  121035. * Execute the action and stop the sound.
  121036. */
  121037. execute(): void;
  121038. /**
  121039. * Serializes the actions and its related information.
  121040. * @param parent defines the object to serialize in
  121041. * @returns the serialized object
  121042. */
  121043. serialize(parent: any): any;
  121044. }
  121045. }
  121046. declare module BABYLON {
  121047. /**
  121048. * This defines an action responsible to change the value of a property
  121049. * by interpolating between its current value and the newly set one once triggered.
  121050. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  121051. */
  121052. export class InterpolateValueAction extends Action {
  121053. /**
  121054. * Defines the path of the property where the value should be interpolated
  121055. */
  121056. propertyPath: string;
  121057. /**
  121058. * Defines the target value at the end of the interpolation.
  121059. */
  121060. value: any;
  121061. /**
  121062. * Defines the time it will take for the property to interpolate to the value.
  121063. */
  121064. duration: number;
  121065. /**
  121066. * Defines if the other scene animations should be stopped when the action has been triggered
  121067. */
  121068. stopOtherAnimations?: boolean;
  121069. /**
  121070. * Defines a callback raised once the interpolation animation has been done.
  121071. */
  121072. onInterpolationDone?: () => void;
  121073. /**
  121074. * Observable triggered once the interpolation animation has been done.
  121075. */
  121076. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  121077. private _target;
  121078. private _effectiveTarget;
  121079. private _property;
  121080. /**
  121081. * Instantiate the action
  121082. * @param triggerOptions defines the trigger options
  121083. * @param target defines the object containing the value to interpolate
  121084. * @param propertyPath defines the path to the property in the target object
  121085. * @param value defines the target value at the end of the interpolation
  121086. * @param duration deines the time it will take for the property to interpolate to the value.
  121087. * @param condition defines the trigger related conditions
  121088. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  121089. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  121090. */
  121091. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  121092. /** @hidden */
  121093. _prepare(): void;
  121094. /**
  121095. * Execute the action starts the value interpolation.
  121096. */
  121097. execute(): void;
  121098. /**
  121099. * Serializes the actions and its related information.
  121100. * @param parent defines the object to serialize in
  121101. * @returns the serialized object
  121102. */
  121103. serialize(parent: any): any;
  121104. }
  121105. }
  121106. declare module BABYLON {
  121107. /**
  121108. * Options allowed during the creation of a sound track.
  121109. */
  121110. export interface ISoundTrackOptions {
  121111. /**
  121112. * The volume the sound track should take during creation
  121113. */
  121114. volume?: number;
  121115. /**
  121116. * Define if the sound track is the main sound track of the scene
  121117. */
  121118. mainTrack?: boolean;
  121119. }
  121120. /**
  121121. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  121122. * It will be also used in a future release to apply effects on a specific track.
  121123. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  121124. */
  121125. export class SoundTrack {
  121126. /**
  121127. * The unique identifier of the sound track in the scene.
  121128. */
  121129. id: number;
  121130. /**
  121131. * The list of sounds included in the sound track.
  121132. */
  121133. soundCollection: Array<Sound>;
  121134. private _outputAudioNode;
  121135. private _scene;
  121136. private _connectedAnalyser;
  121137. private _options;
  121138. private _isInitialized;
  121139. /**
  121140. * Creates a new sound track.
  121141. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  121142. * @param scene Define the scene the sound track belongs to
  121143. * @param options
  121144. */
  121145. constructor(scene: Scene, options?: ISoundTrackOptions);
  121146. private _initializeSoundTrackAudioGraph;
  121147. /**
  121148. * Release the sound track and its associated resources
  121149. */
  121150. dispose(): void;
  121151. /**
  121152. * Adds a sound to this sound track
  121153. * @param sound define the cound to add
  121154. * @ignoreNaming
  121155. */
  121156. AddSound(sound: Sound): void;
  121157. /**
  121158. * Removes a sound to this sound track
  121159. * @param sound define the cound to remove
  121160. * @ignoreNaming
  121161. */
  121162. RemoveSound(sound: Sound): void;
  121163. /**
  121164. * Set a global volume for the full sound track.
  121165. * @param newVolume Define the new volume of the sound track
  121166. */
  121167. setVolume(newVolume: number): void;
  121168. /**
  121169. * Switch the panning model to HRTF:
  121170. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  121171. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121172. */
  121173. switchPanningModelToHRTF(): void;
  121174. /**
  121175. * Switch the panning model to Equal Power:
  121176. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  121177. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121178. */
  121179. switchPanningModelToEqualPower(): void;
  121180. /**
  121181. * Connect the sound track to an audio analyser allowing some amazing
  121182. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  121183. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  121184. * @param analyser The analyser to connect to the engine
  121185. */
  121186. connectToAnalyser(analyser: Analyser): void;
  121187. }
  121188. }
  121189. declare module BABYLON {
  121190. interface AbstractScene {
  121191. /**
  121192. * The list of sounds used in the scene.
  121193. */
  121194. sounds: Nullable<Array<Sound>>;
  121195. }
  121196. interface Scene {
  121197. /**
  121198. * @hidden
  121199. * Backing field
  121200. */
  121201. _mainSoundTrack: SoundTrack;
  121202. /**
  121203. * The main sound track played by the scene.
  121204. * It cotains your primary collection of sounds.
  121205. */
  121206. mainSoundTrack: SoundTrack;
  121207. /**
  121208. * The list of sound tracks added to the scene
  121209. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  121210. */
  121211. soundTracks: Nullable<Array<SoundTrack>>;
  121212. /**
  121213. * Gets a sound using a given name
  121214. * @param name defines the name to search for
  121215. * @return the found sound or null if not found at all.
  121216. */
  121217. getSoundByName(name: string): Nullable<Sound>;
  121218. /**
  121219. * Gets or sets if audio support is enabled
  121220. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  121221. */
  121222. audioEnabled: boolean;
  121223. /**
  121224. * Gets or sets if audio will be output to headphones
  121225. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  121226. */
  121227. headphone: boolean;
  121228. /**
  121229. * Gets or sets custom audio listener position provider
  121230. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  121231. */
  121232. audioListenerPositionProvider: Nullable<() => Vector3>;
  121233. /**
  121234. * Gets or sets a refresh rate when using 3D audio positioning
  121235. */
  121236. audioPositioningRefreshRate: number;
  121237. }
  121238. /**
  121239. * Defines the sound scene component responsible to manage any sounds
  121240. * in a given scene.
  121241. */
  121242. export class AudioSceneComponent implements ISceneSerializableComponent {
  121243. /**
  121244. * The component name helpfull to identify the component in the list of scene components.
  121245. */
  121246. readonly name: string;
  121247. /**
  121248. * The scene the component belongs to.
  121249. */
  121250. scene: Scene;
  121251. private _audioEnabled;
  121252. /**
  121253. * Gets whether audio is enabled or not.
  121254. * Please use related enable/disable method to switch state.
  121255. */
  121256. get audioEnabled(): boolean;
  121257. private _headphone;
  121258. /**
  121259. * Gets whether audio is outputing to headphone or not.
  121260. * Please use the according Switch methods to change output.
  121261. */
  121262. get headphone(): boolean;
  121263. /**
  121264. * Gets or sets a refresh rate when using 3D audio positioning
  121265. */
  121266. audioPositioningRefreshRate: number;
  121267. private _audioListenerPositionProvider;
  121268. /**
  121269. * Gets the current audio listener position provider
  121270. */
  121271. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  121272. /**
  121273. * Sets a custom listener position for all sounds in the scene
  121274. * By default, this is the position of the first active camera
  121275. */
  121276. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  121277. /**
  121278. * Creates a new instance of the component for the given scene
  121279. * @param scene Defines the scene to register the component in
  121280. */
  121281. constructor(scene: Scene);
  121282. /**
  121283. * Registers the component in a given scene
  121284. */
  121285. register(): void;
  121286. /**
  121287. * Rebuilds the elements related to this component in case of
  121288. * context lost for instance.
  121289. */
  121290. rebuild(): void;
  121291. /**
  121292. * Serializes the component data to the specified json object
  121293. * @param serializationObject The object to serialize to
  121294. */
  121295. serialize(serializationObject: any): void;
  121296. /**
  121297. * Adds all the elements from the container to the scene
  121298. * @param container the container holding the elements
  121299. */
  121300. addFromContainer(container: AbstractScene): void;
  121301. /**
  121302. * Removes all the elements in the container from the scene
  121303. * @param container contains the elements to remove
  121304. * @param dispose if the removed element should be disposed (default: false)
  121305. */
  121306. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  121307. /**
  121308. * Disposes the component and the associated ressources.
  121309. */
  121310. dispose(): void;
  121311. /**
  121312. * Disables audio in the associated scene.
  121313. */
  121314. disableAudio(): void;
  121315. /**
  121316. * Enables audio in the associated scene.
  121317. */
  121318. enableAudio(): void;
  121319. /**
  121320. * Switch audio to headphone output.
  121321. */
  121322. switchAudioModeForHeadphones(): void;
  121323. /**
  121324. * Switch audio to normal speakers.
  121325. */
  121326. switchAudioModeForNormalSpeakers(): void;
  121327. private _cachedCameraDirection;
  121328. private _cachedCameraPosition;
  121329. private _lastCheck;
  121330. private _afterRender;
  121331. }
  121332. }
  121333. declare module BABYLON {
  121334. /**
  121335. * Wraps one or more Sound objects and selects one with random weight for playback.
  121336. */
  121337. export class WeightedSound {
  121338. /** When true a Sound will be selected and played when the current playing Sound completes. */
  121339. loop: boolean;
  121340. private _coneInnerAngle;
  121341. private _coneOuterAngle;
  121342. private _volume;
  121343. /** A Sound is currently playing. */
  121344. isPlaying: boolean;
  121345. /** A Sound is currently paused. */
  121346. isPaused: boolean;
  121347. private _sounds;
  121348. private _weights;
  121349. private _currentIndex?;
  121350. /**
  121351. * Creates a new WeightedSound from the list of sounds given.
  121352. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  121353. * @param sounds Array of Sounds that will be selected from.
  121354. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  121355. */
  121356. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  121357. /**
  121358. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  121359. */
  121360. get directionalConeInnerAngle(): number;
  121361. /**
  121362. * The size of cone in degress for a directional sound in which there will be no attenuation.
  121363. */
  121364. set directionalConeInnerAngle(value: number);
  121365. /**
  121366. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  121367. * Listener angles between innerAngle and outerAngle will falloff linearly.
  121368. */
  121369. get directionalConeOuterAngle(): number;
  121370. /**
  121371. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  121372. * Listener angles between innerAngle and outerAngle will falloff linearly.
  121373. */
  121374. set directionalConeOuterAngle(value: number);
  121375. /**
  121376. * Playback volume.
  121377. */
  121378. get volume(): number;
  121379. /**
  121380. * Playback volume.
  121381. */
  121382. set volume(value: number);
  121383. private _onended;
  121384. /**
  121385. * Suspend playback
  121386. */
  121387. pause(): void;
  121388. /**
  121389. * Stop playback
  121390. */
  121391. stop(): void;
  121392. /**
  121393. * Start playback.
  121394. * @param startOffset Position the clip head at a specific time in seconds.
  121395. */
  121396. play(startOffset?: number): void;
  121397. }
  121398. }
  121399. declare module BABYLON {
  121400. /**
  121401. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  121402. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  121403. */
  121404. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  121405. /**
  121406. * Gets the name of the behavior.
  121407. */
  121408. get name(): string;
  121409. /**
  121410. * The easing function used by animations
  121411. */
  121412. static EasingFunction: BackEase;
  121413. /**
  121414. * The easing mode used by animations
  121415. */
  121416. static EasingMode: number;
  121417. /**
  121418. * The duration of the animation, in milliseconds
  121419. */
  121420. transitionDuration: number;
  121421. /**
  121422. * Length of the distance animated by the transition when lower radius is reached
  121423. */
  121424. lowerRadiusTransitionRange: number;
  121425. /**
  121426. * Length of the distance animated by the transition when upper radius is reached
  121427. */
  121428. upperRadiusTransitionRange: number;
  121429. private _autoTransitionRange;
  121430. /**
  121431. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  121432. */
  121433. get autoTransitionRange(): boolean;
  121434. /**
  121435. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  121436. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  121437. */
  121438. set autoTransitionRange(value: boolean);
  121439. private _attachedCamera;
  121440. private _onAfterCheckInputsObserver;
  121441. private _onMeshTargetChangedObserver;
  121442. /**
  121443. * Initializes the behavior.
  121444. */
  121445. init(): void;
  121446. /**
  121447. * Attaches the behavior to its arc rotate camera.
  121448. * @param camera Defines the camera to attach the behavior to
  121449. */
  121450. attach(camera: ArcRotateCamera): void;
  121451. /**
  121452. * Detaches the behavior from its current arc rotate camera.
  121453. */
  121454. detach(): void;
  121455. private _radiusIsAnimating;
  121456. private _radiusBounceTransition;
  121457. private _animatables;
  121458. private _cachedWheelPrecision;
  121459. /**
  121460. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  121461. * @param radiusLimit The limit to check against.
  121462. * @return Bool to indicate if at limit.
  121463. */
  121464. private _isRadiusAtLimit;
  121465. /**
  121466. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  121467. * @param radiusDelta The delta by which to animate to. Can be negative.
  121468. */
  121469. private _applyBoundRadiusAnimation;
  121470. /**
  121471. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  121472. */
  121473. protected _clearAnimationLocks(): void;
  121474. /**
  121475. * Stops and removes all animations that have been applied to the camera
  121476. */
  121477. stopAllAnimations(): void;
  121478. }
  121479. }
  121480. declare module BABYLON {
  121481. /**
  121482. * 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.
  121483. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  121484. */
  121485. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  121486. /**
  121487. * Gets the name of the behavior.
  121488. */
  121489. get name(): string;
  121490. private _mode;
  121491. private _radiusScale;
  121492. private _positionScale;
  121493. private _defaultElevation;
  121494. private _elevationReturnTime;
  121495. private _elevationReturnWaitTime;
  121496. private _zoomStopsAnimation;
  121497. private _framingTime;
  121498. /**
  121499. * The easing function used by animations
  121500. */
  121501. static EasingFunction: ExponentialEase;
  121502. /**
  121503. * The easing mode used by animations
  121504. */
  121505. static EasingMode: number;
  121506. /**
  121507. * Sets the current mode used by the behavior
  121508. */
  121509. set mode(mode: number);
  121510. /**
  121511. * Gets current mode used by the behavior.
  121512. */
  121513. get mode(): number;
  121514. /**
  121515. * Sets the scale applied to the radius (1 by default)
  121516. */
  121517. set radiusScale(radius: number);
  121518. /**
  121519. * Gets the scale applied to the radius
  121520. */
  121521. get radiusScale(): number;
  121522. /**
  121523. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  121524. */
  121525. set positionScale(scale: number);
  121526. /**
  121527. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  121528. */
  121529. get positionScale(): number;
  121530. /**
  121531. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  121532. * behaviour is triggered, in radians.
  121533. */
  121534. set defaultElevation(elevation: number);
  121535. /**
  121536. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  121537. * behaviour is triggered, in radians.
  121538. */
  121539. get defaultElevation(): number;
  121540. /**
  121541. * Sets the time (in milliseconds) taken to return to the default beta position.
  121542. * Negative value indicates camera should not return to default.
  121543. */
  121544. set elevationReturnTime(speed: number);
  121545. /**
  121546. * Gets the time (in milliseconds) taken to return to the default beta position.
  121547. * Negative value indicates camera should not return to default.
  121548. */
  121549. get elevationReturnTime(): number;
  121550. /**
  121551. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  121552. */
  121553. set elevationReturnWaitTime(time: number);
  121554. /**
  121555. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  121556. */
  121557. get elevationReturnWaitTime(): number;
  121558. /**
  121559. * Sets the flag that indicates if user zooming should stop animation.
  121560. */
  121561. set zoomStopsAnimation(flag: boolean);
  121562. /**
  121563. * Gets the flag that indicates if user zooming should stop animation.
  121564. */
  121565. get zoomStopsAnimation(): boolean;
  121566. /**
  121567. * Sets the transition time when framing the mesh, in milliseconds
  121568. */
  121569. set framingTime(time: number);
  121570. /**
  121571. * Gets the transition time when framing the mesh, in milliseconds
  121572. */
  121573. get framingTime(): number;
  121574. /**
  121575. * Define if the behavior should automatically change the configured
  121576. * camera limits and sensibilities.
  121577. */
  121578. autoCorrectCameraLimitsAndSensibility: boolean;
  121579. private _onPrePointerObservableObserver;
  121580. private _onAfterCheckInputsObserver;
  121581. private _onMeshTargetChangedObserver;
  121582. private _attachedCamera;
  121583. private _isPointerDown;
  121584. private _lastInteractionTime;
  121585. /**
  121586. * Initializes the behavior.
  121587. */
  121588. init(): void;
  121589. /**
  121590. * Attaches the behavior to its arc rotate camera.
  121591. * @param camera Defines the camera to attach the behavior to
  121592. */
  121593. attach(camera: ArcRotateCamera): void;
  121594. /**
  121595. * Detaches the behavior from its current arc rotate camera.
  121596. */
  121597. detach(): void;
  121598. private _animatables;
  121599. private _betaIsAnimating;
  121600. private _betaTransition;
  121601. private _radiusTransition;
  121602. private _vectorTransition;
  121603. /**
  121604. * Targets the given mesh and updates zoom level accordingly.
  121605. * @param mesh The mesh to target.
  121606. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  121607. * @param onAnimationEnd Callback triggered at the end of the framing animation
  121608. */
  121609. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  121610. /**
  121611. * Targets the given mesh with its children and updates zoom level accordingly.
  121612. * @param mesh The mesh to target.
  121613. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  121614. * @param onAnimationEnd Callback triggered at the end of the framing animation
  121615. */
  121616. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  121617. /**
  121618. * Targets the given meshes with their children and updates zoom level accordingly.
  121619. * @param meshes The mesh to target.
  121620. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  121621. * @param onAnimationEnd Callback triggered at the end of the framing animation
  121622. */
  121623. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  121624. /**
  121625. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  121626. * @param minimumWorld Determines the smaller position of the bounding box extend
  121627. * @param maximumWorld Determines the bigger position of the bounding box extend
  121628. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  121629. * @param onAnimationEnd Callback triggered at the end of the framing animation
  121630. */
  121631. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  121632. /**
  121633. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  121634. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  121635. * frustum width.
  121636. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  121637. * to fully enclose the mesh in the viewing frustum.
  121638. */
  121639. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  121640. /**
  121641. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  121642. * is automatically returned to its default position (expected to be above ground plane).
  121643. */
  121644. private _maintainCameraAboveGround;
  121645. /**
  121646. * Returns the frustum slope based on the canvas ratio and camera FOV
  121647. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  121648. */
  121649. private _getFrustumSlope;
  121650. /**
  121651. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  121652. */
  121653. private _clearAnimationLocks;
  121654. /**
  121655. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  121656. */
  121657. private _applyUserInteraction;
  121658. /**
  121659. * Stops and removes all animations that have been applied to the camera
  121660. */
  121661. stopAllAnimations(): void;
  121662. /**
  121663. * Gets a value indicating if the user is moving the camera
  121664. */
  121665. get isUserIsMoving(): boolean;
  121666. /**
  121667. * The camera can move all the way towards the mesh.
  121668. */
  121669. static IgnoreBoundsSizeMode: number;
  121670. /**
  121671. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  121672. */
  121673. static FitFrustumSidesMode: number;
  121674. }
  121675. }
  121676. declare module BABYLON {
  121677. /**
  121678. * Base class for Camera Pointer Inputs.
  121679. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  121680. * for example usage.
  121681. */
  121682. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  121683. /**
  121684. * Defines the camera the input is attached to.
  121685. */
  121686. abstract camera: Camera;
  121687. /**
  121688. * Whether keyboard modifier keys are pressed at time of last mouse event.
  121689. */
  121690. protected _altKey: boolean;
  121691. protected _ctrlKey: boolean;
  121692. protected _metaKey: boolean;
  121693. protected _shiftKey: boolean;
  121694. /**
  121695. * Which mouse buttons were pressed at time of last mouse event.
  121696. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  121697. */
  121698. protected _buttonsPressed: number;
  121699. /**
  121700. * Defines the buttons associated with the input to handle camera move.
  121701. */
  121702. buttons: number[];
  121703. /**
  121704. * Attach the input controls to a specific dom element to get the input from.
  121705. * @param element Defines the element the controls should be listened from
  121706. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121707. */
  121708. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121709. /**
  121710. * Detach the current controls from the specified dom element.
  121711. * @param element Defines the element to stop listening the inputs from
  121712. */
  121713. detachControl(element: Nullable<HTMLElement>): void;
  121714. /**
  121715. * Gets the class name of the current input.
  121716. * @returns the class name
  121717. */
  121718. getClassName(): string;
  121719. /**
  121720. * Get the friendly name associated with the input class.
  121721. * @returns the input friendly name
  121722. */
  121723. getSimpleName(): string;
  121724. /**
  121725. * Called on pointer POINTERDOUBLETAP event.
  121726. * Override this method to provide functionality on POINTERDOUBLETAP event.
  121727. */
  121728. protected onDoubleTap(type: string): void;
  121729. /**
  121730. * Called on pointer POINTERMOVE event if only a single touch is active.
  121731. * Override this method to provide functionality.
  121732. */
  121733. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  121734. /**
  121735. * Called on pointer POINTERMOVE event if multiple touches are active.
  121736. * Override this method to provide functionality.
  121737. */
  121738. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  121739. /**
  121740. * Called on JS contextmenu event.
  121741. * Override this method to provide functionality.
  121742. */
  121743. protected onContextMenu(evt: PointerEvent): void;
  121744. /**
  121745. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  121746. * press.
  121747. * Override this method to provide functionality.
  121748. */
  121749. protected onButtonDown(evt: PointerEvent): void;
  121750. /**
  121751. * Called each time a new POINTERUP event occurs. Ie, for each button
  121752. * release.
  121753. * Override this method to provide functionality.
  121754. */
  121755. protected onButtonUp(evt: PointerEvent): void;
  121756. /**
  121757. * Called when window becomes inactive.
  121758. * Override this method to provide functionality.
  121759. */
  121760. protected onLostFocus(): void;
  121761. private _pointerInput;
  121762. private _observer;
  121763. private _onLostFocus;
  121764. private pointA;
  121765. private pointB;
  121766. }
  121767. }
  121768. declare module BABYLON {
  121769. /**
  121770. * Manage the pointers inputs to control an arc rotate camera.
  121771. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121772. */
  121773. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  121774. /**
  121775. * Defines the camera the input is attached to.
  121776. */
  121777. camera: ArcRotateCamera;
  121778. /**
  121779. * Gets the class name of the current input.
  121780. * @returns the class name
  121781. */
  121782. getClassName(): string;
  121783. /**
  121784. * Defines the buttons associated with the input to handle camera move.
  121785. */
  121786. buttons: number[];
  121787. /**
  121788. * Defines the pointer angular sensibility along the X axis or how fast is
  121789. * the camera rotating.
  121790. */
  121791. angularSensibilityX: number;
  121792. /**
  121793. * Defines the pointer angular sensibility along the Y axis or how fast is
  121794. * the camera rotating.
  121795. */
  121796. angularSensibilityY: number;
  121797. /**
  121798. * Defines the pointer pinch precision or how fast is the camera zooming.
  121799. */
  121800. pinchPrecision: number;
  121801. /**
  121802. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  121803. * from 0.
  121804. * It defines the percentage of current camera.radius to use as delta when
  121805. * pinch zoom is used.
  121806. */
  121807. pinchDeltaPercentage: number;
  121808. /**
  121809. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  121810. * that any object in the plane at the camera's target point will scale
  121811. * perfectly with finger motion.
  121812. * Overrides pinchDeltaPercentage and pinchPrecision.
  121813. */
  121814. useNaturalPinchZoom: boolean;
  121815. /**
  121816. * Defines the pointer panning sensibility or how fast is the camera moving.
  121817. */
  121818. panningSensibility: number;
  121819. /**
  121820. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  121821. */
  121822. multiTouchPanning: boolean;
  121823. /**
  121824. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  121825. * zoom (pinch) through multitouch.
  121826. */
  121827. multiTouchPanAndZoom: boolean;
  121828. /**
  121829. * Revers pinch action direction.
  121830. */
  121831. pinchInwards: boolean;
  121832. private _isPanClick;
  121833. private _twoFingerActivityCount;
  121834. private _isPinching;
  121835. /**
  121836. * Called on pointer POINTERMOVE event if only a single touch is active.
  121837. */
  121838. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  121839. /**
  121840. * Called on pointer POINTERDOUBLETAP event.
  121841. */
  121842. protected onDoubleTap(type: string): void;
  121843. /**
  121844. * Called on pointer POINTERMOVE event if multiple touches are active.
  121845. */
  121846. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  121847. /**
  121848. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  121849. * press.
  121850. */
  121851. protected onButtonDown(evt: PointerEvent): void;
  121852. /**
  121853. * Called each time a new POINTERUP event occurs. Ie, for each button
  121854. * release.
  121855. */
  121856. protected onButtonUp(evt: PointerEvent): void;
  121857. /**
  121858. * Called when window becomes inactive.
  121859. */
  121860. protected onLostFocus(): void;
  121861. }
  121862. }
  121863. declare module BABYLON {
  121864. /**
  121865. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  121866. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121867. */
  121868. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  121869. /**
  121870. * Defines the camera the input is attached to.
  121871. */
  121872. camera: ArcRotateCamera;
  121873. /**
  121874. * Defines the list of key codes associated with the up action (increase alpha)
  121875. */
  121876. keysUp: number[];
  121877. /**
  121878. * Defines the list of key codes associated with the down action (decrease alpha)
  121879. */
  121880. keysDown: number[];
  121881. /**
  121882. * Defines the list of key codes associated with the left action (increase beta)
  121883. */
  121884. keysLeft: number[];
  121885. /**
  121886. * Defines the list of key codes associated with the right action (decrease beta)
  121887. */
  121888. keysRight: number[];
  121889. /**
  121890. * Defines the list of key codes associated with the reset action.
  121891. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  121892. */
  121893. keysReset: number[];
  121894. /**
  121895. * Defines the panning sensibility of the inputs.
  121896. * (How fast is the camera panning)
  121897. */
  121898. panningSensibility: number;
  121899. /**
  121900. * Defines the zooming sensibility of the inputs.
  121901. * (How fast is the camera zooming)
  121902. */
  121903. zoomingSensibility: number;
  121904. /**
  121905. * Defines whether maintaining the alt key down switch the movement mode from
  121906. * orientation to zoom.
  121907. */
  121908. useAltToZoom: boolean;
  121909. /**
  121910. * Rotation speed of the camera
  121911. */
  121912. angularSpeed: number;
  121913. private _keys;
  121914. private _ctrlPressed;
  121915. private _altPressed;
  121916. private _onCanvasBlurObserver;
  121917. private _onKeyboardObserver;
  121918. private _engine;
  121919. private _scene;
  121920. /**
  121921. * Attach the input controls to a specific dom element to get the input from.
  121922. * @param element Defines the element the controls should be listened from
  121923. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121924. */
  121925. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121926. /**
  121927. * Detach the current controls from the specified dom element.
  121928. * @param element Defines the element to stop listening the inputs from
  121929. */
  121930. detachControl(element: Nullable<HTMLElement>): void;
  121931. /**
  121932. * Update the current camera state depending on the inputs that have been used this frame.
  121933. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  121934. */
  121935. checkInputs(): void;
  121936. /**
  121937. * Gets the class name of the current intput.
  121938. * @returns the class name
  121939. */
  121940. getClassName(): string;
  121941. /**
  121942. * Get the friendly name associated with the input class.
  121943. * @returns the input friendly name
  121944. */
  121945. getSimpleName(): string;
  121946. }
  121947. }
  121948. declare module BABYLON {
  121949. /**
  121950. * Manage the mouse wheel inputs to control an arc rotate camera.
  121951. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121952. */
  121953. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  121954. /**
  121955. * Defines the camera the input is attached to.
  121956. */
  121957. camera: ArcRotateCamera;
  121958. /**
  121959. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  121960. */
  121961. wheelPrecision: number;
  121962. /**
  121963. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  121964. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  121965. */
  121966. wheelDeltaPercentage: number;
  121967. private _wheel;
  121968. private _observer;
  121969. private computeDeltaFromMouseWheelLegacyEvent;
  121970. /**
  121971. * Attach the input controls to a specific dom element to get the input from.
  121972. * @param element Defines the element the controls should be listened from
  121973. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121974. */
  121975. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121976. /**
  121977. * Detach the current controls from the specified dom element.
  121978. * @param element Defines the element to stop listening the inputs from
  121979. */
  121980. detachControl(element: Nullable<HTMLElement>): void;
  121981. /**
  121982. * Gets the class name of the current intput.
  121983. * @returns the class name
  121984. */
  121985. getClassName(): string;
  121986. /**
  121987. * Get the friendly name associated with the input class.
  121988. * @returns the input friendly name
  121989. */
  121990. getSimpleName(): string;
  121991. }
  121992. }
  121993. declare module BABYLON {
  121994. /**
  121995. * Default Inputs manager for the ArcRotateCamera.
  121996. * It groups all the default supported inputs for ease of use.
  121997. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121998. */
  121999. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  122000. /**
  122001. * Instantiates a new ArcRotateCameraInputsManager.
  122002. * @param camera Defines the camera the inputs belong to
  122003. */
  122004. constructor(camera: ArcRotateCamera);
  122005. /**
  122006. * Add mouse wheel input support to the input manager.
  122007. * @returns the current input manager
  122008. */
  122009. addMouseWheel(): ArcRotateCameraInputsManager;
  122010. /**
  122011. * Add pointers input support to the input manager.
  122012. * @returns the current input manager
  122013. */
  122014. addPointers(): ArcRotateCameraInputsManager;
  122015. /**
  122016. * Add keyboard input support to the input manager.
  122017. * @returns the current input manager
  122018. */
  122019. addKeyboard(): ArcRotateCameraInputsManager;
  122020. }
  122021. }
  122022. declare module BABYLON {
  122023. /**
  122024. * This represents an orbital type of camera.
  122025. *
  122026. * 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.
  122027. * 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.
  122028. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  122029. */
  122030. export class ArcRotateCamera extends TargetCamera {
  122031. /**
  122032. * Defines the rotation angle of the camera along the longitudinal axis.
  122033. */
  122034. alpha: number;
  122035. /**
  122036. * Defines the rotation angle of the camera along the latitudinal axis.
  122037. */
  122038. beta: number;
  122039. /**
  122040. * Defines the radius of the camera from it s target point.
  122041. */
  122042. radius: number;
  122043. protected _target: Vector3;
  122044. protected _targetHost: Nullable<AbstractMesh>;
  122045. /**
  122046. * Defines the target point of the camera.
  122047. * The camera looks towards it form the radius distance.
  122048. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  122049. */
  122050. get target(): Vector3;
  122051. set target(value: Vector3);
  122052. /**
  122053. * Define the current local position of the camera in the scene
  122054. */
  122055. get position(): Vector3;
  122056. set position(newPosition: Vector3);
  122057. protected _upVector: Vector3;
  122058. protected _upToYMatrix: Matrix;
  122059. protected _YToUpMatrix: Matrix;
  122060. /**
  122061. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  122062. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  122063. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  122064. */
  122065. set upVector(vec: Vector3);
  122066. get upVector(): Vector3;
  122067. /**
  122068. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  122069. */
  122070. setMatUp(): void;
  122071. /**
  122072. * Current inertia value on the longitudinal axis.
  122073. * The bigger this number the longer it will take for the camera to stop.
  122074. */
  122075. inertialAlphaOffset: number;
  122076. /**
  122077. * Current inertia value on the latitudinal axis.
  122078. * The bigger this number the longer it will take for the camera to stop.
  122079. */
  122080. inertialBetaOffset: number;
  122081. /**
  122082. * Current inertia value on the radius axis.
  122083. * The bigger this number the longer it will take for the camera to stop.
  122084. */
  122085. inertialRadiusOffset: number;
  122086. /**
  122087. * Minimum allowed angle on the longitudinal axis.
  122088. * This can help limiting how the Camera is able to move in the scene.
  122089. */
  122090. lowerAlphaLimit: Nullable<number>;
  122091. /**
  122092. * Maximum allowed angle on the longitudinal axis.
  122093. * This can help limiting how the Camera is able to move in the scene.
  122094. */
  122095. upperAlphaLimit: Nullable<number>;
  122096. /**
  122097. * Minimum allowed angle on the latitudinal axis.
  122098. * This can help limiting how the Camera is able to move in the scene.
  122099. */
  122100. lowerBetaLimit: number;
  122101. /**
  122102. * Maximum allowed angle on the latitudinal axis.
  122103. * This can help limiting how the Camera is able to move in the scene.
  122104. */
  122105. upperBetaLimit: number;
  122106. /**
  122107. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  122108. * This can help limiting how the Camera is able to move in the scene.
  122109. */
  122110. lowerRadiusLimit: Nullable<number>;
  122111. /**
  122112. * Maximum allowed distance of the camera to the target (The camera can not get further).
  122113. * This can help limiting how the Camera is able to move in the scene.
  122114. */
  122115. upperRadiusLimit: Nullable<number>;
  122116. /**
  122117. * Defines the current inertia value used during panning of the camera along the X axis.
  122118. */
  122119. inertialPanningX: number;
  122120. /**
  122121. * Defines the current inertia value used during panning of the camera along the Y axis.
  122122. */
  122123. inertialPanningY: number;
  122124. /**
  122125. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  122126. * Basically if your fingers moves away from more than this distance you will be considered
  122127. * in pinch mode.
  122128. */
  122129. pinchToPanMaxDistance: number;
  122130. /**
  122131. * Defines the maximum distance the camera can pan.
  122132. * This could help keeping the cammera always in your scene.
  122133. */
  122134. panningDistanceLimit: Nullable<number>;
  122135. /**
  122136. * Defines the target of the camera before paning.
  122137. */
  122138. panningOriginTarget: Vector3;
  122139. /**
  122140. * Defines the value of the inertia used during panning.
  122141. * 0 would mean stop inertia and one would mean no decelleration at all.
  122142. */
  122143. panningInertia: number;
  122144. /**
  122145. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  122146. */
  122147. get angularSensibilityX(): number;
  122148. set angularSensibilityX(value: number);
  122149. /**
  122150. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  122151. */
  122152. get angularSensibilityY(): number;
  122153. set angularSensibilityY(value: number);
  122154. /**
  122155. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  122156. */
  122157. get pinchPrecision(): number;
  122158. set pinchPrecision(value: number);
  122159. /**
  122160. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  122161. * It will be used instead of pinchDeltaPrecision if different from 0.
  122162. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  122163. */
  122164. get pinchDeltaPercentage(): number;
  122165. set pinchDeltaPercentage(value: number);
  122166. /**
  122167. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  122168. * and pinch delta percentage.
  122169. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  122170. * that any object in the plane at the camera's target point will scale
  122171. * perfectly with finger motion.
  122172. */
  122173. get useNaturalPinchZoom(): boolean;
  122174. set useNaturalPinchZoom(value: boolean);
  122175. /**
  122176. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  122177. */
  122178. get panningSensibility(): number;
  122179. set panningSensibility(value: number);
  122180. /**
  122181. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  122182. */
  122183. get keysUp(): number[];
  122184. set keysUp(value: number[]);
  122185. /**
  122186. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  122187. */
  122188. get keysDown(): number[];
  122189. set keysDown(value: number[]);
  122190. /**
  122191. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  122192. */
  122193. get keysLeft(): number[];
  122194. set keysLeft(value: number[]);
  122195. /**
  122196. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  122197. */
  122198. get keysRight(): number[];
  122199. set keysRight(value: number[]);
  122200. /**
  122201. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  122202. */
  122203. get wheelPrecision(): number;
  122204. set wheelPrecision(value: number);
  122205. /**
  122206. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  122207. * It will be used instead of pinchDeltaPrecision if different from 0.
  122208. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  122209. */
  122210. get wheelDeltaPercentage(): number;
  122211. set wheelDeltaPercentage(value: number);
  122212. /**
  122213. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  122214. */
  122215. zoomOnFactor: number;
  122216. /**
  122217. * Defines a screen offset for the camera position.
  122218. */
  122219. targetScreenOffset: Vector2;
  122220. /**
  122221. * Allows the camera to be completely reversed.
  122222. * If false the camera can not arrive upside down.
  122223. */
  122224. allowUpsideDown: boolean;
  122225. /**
  122226. * Define if double tap/click is used to restore the previously saved state of the camera.
  122227. */
  122228. useInputToRestoreState: boolean;
  122229. /** @hidden */
  122230. _viewMatrix: Matrix;
  122231. /** @hidden */
  122232. _useCtrlForPanning: boolean;
  122233. /** @hidden */
  122234. _panningMouseButton: number;
  122235. /**
  122236. * Defines the input associated to the camera.
  122237. */
  122238. inputs: ArcRotateCameraInputsManager;
  122239. /** @hidden */
  122240. _reset: () => void;
  122241. /**
  122242. * Defines the allowed panning axis.
  122243. */
  122244. panningAxis: Vector3;
  122245. protected _localDirection: Vector3;
  122246. protected _transformedDirection: Vector3;
  122247. private _bouncingBehavior;
  122248. /**
  122249. * Gets the bouncing behavior of the camera if it has been enabled.
  122250. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  122251. */
  122252. get bouncingBehavior(): Nullable<BouncingBehavior>;
  122253. /**
  122254. * Defines if the bouncing behavior of the camera is enabled on the camera.
  122255. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  122256. */
  122257. get useBouncingBehavior(): boolean;
  122258. set useBouncingBehavior(value: boolean);
  122259. private _framingBehavior;
  122260. /**
  122261. * Gets the framing behavior of the camera if it has been enabled.
  122262. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  122263. */
  122264. get framingBehavior(): Nullable<FramingBehavior>;
  122265. /**
  122266. * Defines if the framing behavior of the camera is enabled on the camera.
  122267. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  122268. */
  122269. get useFramingBehavior(): boolean;
  122270. set useFramingBehavior(value: boolean);
  122271. private _autoRotationBehavior;
  122272. /**
  122273. * Gets the auto rotation behavior of the camera if it has been enabled.
  122274. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  122275. */
  122276. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  122277. /**
  122278. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  122279. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  122280. */
  122281. get useAutoRotationBehavior(): boolean;
  122282. set useAutoRotationBehavior(value: boolean);
  122283. /**
  122284. * Observable triggered when the mesh target has been changed on the camera.
  122285. */
  122286. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  122287. /**
  122288. * Event raised when the camera is colliding with a mesh.
  122289. */
  122290. onCollide: (collidedMesh: AbstractMesh) => void;
  122291. /**
  122292. * Defines whether the camera should check collision with the objects oh the scene.
  122293. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  122294. */
  122295. checkCollisions: boolean;
  122296. /**
  122297. * Defines the collision radius of the camera.
  122298. * This simulates a sphere around the camera.
  122299. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  122300. */
  122301. collisionRadius: Vector3;
  122302. protected _collider: Collider;
  122303. protected _previousPosition: Vector3;
  122304. protected _collisionVelocity: Vector3;
  122305. protected _newPosition: Vector3;
  122306. protected _previousAlpha: number;
  122307. protected _previousBeta: number;
  122308. protected _previousRadius: number;
  122309. protected _collisionTriggered: boolean;
  122310. protected _targetBoundingCenter: Nullable<Vector3>;
  122311. private _computationVector;
  122312. /**
  122313. * Instantiates a new ArcRotateCamera in a given scene
  122314. * @param name Defines the name of the camera
  122315. * @param alpha Defines the camera rotation along the logitudinal axis
  122316. * @param beta Defines the camera rotation along the latitudinal axis
  122317. * @param radius Defines the camera distance from its target
  122318. * @param target Defines the camera target
  122319. * @param scene Defines the scene the camera belongs to
  122320. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  122321. */
  122322. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  122323. /** @hidden */
  122324. _initCache(): void;
  122325. /** @hidden */
  122326. _updateCache(ignoreParentClass?: boolean): void;
  122327. protected _getTargetPosition(): Vector3;
  122328. private _storedAlpha;
  122329. private _storedBeta;
  122330. private _storedRadius;
  122331. private _storedTarget;
  122332. private _storedTargetScreenOffset;
  122333. /**
  122334. * Stores the current state of the camera (alpha, beta, radius and target)
  122335. * @returns the camera itself
  122336. */
  122337. storeState(): Camera;
  122338. /**
  122339. * @hidden
  122340. * Restored camera state. You must call storeState() first
  122341. */
  122342. _restoreStateValues(): boolean;
  122343. /** @hidden */
  122344. _isSynchronizedViewMatrix(): boolean;
  122345. /**
  122346. * Attached controls to the current camera.
  122347. * @param element Defines the element the controls should be listened from
  122348. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122349. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  122350. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  122351. */
  122352. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  122353. /**
  122354. * Detach the current controls from the camera.
  122355. * The camera will stop reacting to inputs.
  122356. * @param element Defines the element to stop listening the inputs from
  122357. */
  122358. detachControl(element: HTMLElement): void;
  122359. /** @hidden */
  122360. _checkInputs(): void;
  122361. protected _checkLimits(): void;
  122362. /**
  122363. * Rebuilds angles (alpha, beta) and radius from the give position and target
  122364. */
  122365. rebuildAnglesAndRadius(): void;
  122366. /**
  122367. * Use a position to define the current camera related information like alpha, beta and radius
  122368. * @param position Defines the position to set the camera at
  122369. */
  122370. setPosition(position: Vector3): void;
  122371. /**
  122372. * Defines the target the camera should look at.
  122373. * This will automatically adapt alpha beta and radius to fit within the new target.
  122374. * @param target Defines the new target as a Vector or a mesh
  122375. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  122376. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  122377. */
  122378. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  122379. /** @hidden */
  122380. _getViewMatrix(): Matrix;
  122381. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  122382. /**
  122383. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  122384. * @param meshes Defines the mesh to zoom on
  122385. * @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)
  122386. */
  122387. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  122388. /**
  122389. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  122390. * The target will be changed but the radius
  122391. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  122392. * @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)
  122393. */
  122394. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  122395. min: Vector3;
  122396. max: Vector3;
  122397. distance: number;
  122398. }, doNotUpdateMaxZ?: boolean): void;
  122399. /**
  122400. * @override
  122401. * Override Camera.createRigCamera
  122402. */
  122403. createRigCamera(name: string, cameraIndex: number): Camera;
  122404. /**
  122405. * @hidden
  122406. * @override
  122407. * Override Camera._updateRigCameras
  122408. */
  122409. _updateRigCameras(): void;
  122410. /**
  122411. * Destroy the camera and release the current resources hold by it.
  122412. */
  122413. dispose(): void;
  122414. /**
  122415. * Gets the current object class name.
  122416. * @return the class name
  122417. */
  122418. getClassName(): string;
  122419. }
  122420. }
  122421. declare module BABYLON {
  122422. /**
  122423. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  122424. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  122425. */
  122426. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  122427. /**
  122428. * Gets the name of the behavior.
  122429. */
  122430. get name(): string;
  122431. private _zoomStopsAnimation;
  122432. private _idleRotationSpeed;
  122433. private _idleRotationWaitTime;
  122434. private _idleRotationSpinupTime;
  122435. /**
  122436. * Sets the flag that indicates if user zooming should stop animation.
  122437. */
  122438. set zoomStopsAnimation(flag: boolean);
  122439. /**
  122440. * Gets the flag that indicates if user zooming should stop animation.
  122441. */
  122442. get zoomStopsAnimation(): boolean;
  122443. /**
  122444. * Sets the default speed at which the camera rotates around the model.
  122445. */
  122446. set idleRotationSpeed(speed: number);
  122447. /**
  122448. * Gets the default speed at which the camera rotates around the model.
  122449. */
  122450. get idleRotationSpeed(): number;
  122451. /**
  122452. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  122453. */
  122454. set idleRotationWaitTime(time: number);
  122455. /**
  122456. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  122457. */
  122458. get idleRotationWaitTime(): number;
  122459. /**
  122460. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  122461. */
  122462. set idleRotationSpinupTime(time: number);
  122463. /**
  122464. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  122465. */
  122466. get idleRotationSpinupTime(): number;
  122467. /**
  122468. * Gets a value indicating if the camera is currently rotating because of this behavior
  122469. */
  122470. get rotationInProgress(): boolean;
  122471. private _onPrePointerObservableObserver;
  122472. private _onAfterCheckInputsObserver;
  122473. private _attachedCamera;
  122474. private _isPointerDown;
  122475. private _lastFrameTime;
  122476. private _lastInteractionTime;
  122477. private _cameraRotationSpeed;
  122478. /**
  122479. * Initializes the behavior.
  122480. */
  122481. init(): void;
  122482. /**
  122483. * Attaches the behavior to its arc rotate camera.
  122484. * @param camera Defines the camera to attach the behavior to
  122485. */
  122486. attach(camera: ArcRotateCamera): void;
  122487. /**
  122488. * Detaches the behavior from its current arc rotate camera.
  122489. */
  122490. detach(): void;
  122491. /**
  122492. * Returns true if user is scrolling.
  122493. * @return true if user is scrolling.
  122494. */
  122495. private _userIsZooming;
  122496. private _lastFrameRadius;
  122497. private _shouldAnimationStopForInteraction;
  122498. /**
  122499. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  122500. */
  122501. private _applyUserInteraction;
  122502. private _userIsMoving;
  122503. }
  122504. }
  122505. declare module BABYLON {
  122506. /**
  122507. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  122508. */
  122509. export class AttachToBoxBehavior implements Behavior<Mesh> {
  122510. private ui;
  122511. /**
  122512. * The name of the behavior
  122513. */
  122514. name: string;
  122515. /**
  122516. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  122517. */
  122518. distanceAwayFromFace: number;
  122519. /**
  122520. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  122521. */
  122522. distanceAwayFromBottomOfFace: number;
  122523. private _faceVectors;
  122524. private _target;
  122525. private _scene;
  122526. private _onRenderObserver;
  122527. private _tmpMatrix;
  122528. private _tmpVector;
  122529. /**
  122530. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  122531. * @param ui The transform node that should be attched to the mesh
  122532. */
  122533. constructor(ui: TransformNode);
  122534. /**
  122535. * Initializes the behavior
  122536. */
  122537. init(): void;
  122538. private _closestFace;
  122539. private _zeroVector;
  122540. private _lookAtTmpMatrix;
  122541. private _lookAtToRef;
  122542. /**
  122543. * Attaches the AttachToBoxBehavior to the passed in mesh
  122544. * @param target The mesh that the specified node will be attached to
  122545. */
  122546. attach(target: Mesh): void;
  122547. /**
  122548. * Detaches the behavior from the mesh
  122549. */
  122550. detach(): void;
  122551. }
  122552. }
  122553. declare module BABYLON {
  122554. /**
  122555. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  122556. */
  122557. export class FadeInOutBehavior implements Behavior<Mesh> {
  122558. /**
  122559. * Time in milliseconds to delay before fading in (Default: 0)
  122560. */
  122561. delay: number;
  122562. /**
  122563. * Time in milliseconds for the mesh to fade in (Default: 300)
  122564. */
  122565. fadeInTime: number;
  122566. private _millisecondsPerFrame;
  122567. private _hovered;
  122568. private _hoverValue;
  122569. private _ownerNode;
  122570. /**
  122571. * Instatiates the FadeInOutBehavior
  122572. */
  122573. constructor();
  122574. /**
  122575. * The name of the behavior
  122576. */
  122577. get name(): string;
  122578. /**
  122579. * Initializes the behavior
  122580. */
  122581. init(): void;
  122582. /**
  122583. * Attaches the fade behavior on the passed in mesh
  122584. * @param ownerNode The mesh that will be faded in/out once attached
  122585. */
  122586. attach(ownerNode: Mesh): void;
  122587. /**
  122588. * Detaches the behavior from the mesh
  122589. */
  122590. detach(): void;
  122591. /**
  122592. * Triggers the mesh to begin fading in or out
  122593. * @param value if the object should fade in or out (true to fade in)
  122594. */
  122595. fadeIn(value: boolean): void;
  122596. private _update;
  122597. private _setAllVisibility;
  122598. }
  122599. }
  122600. declare module BABYLON {
  122601. /**
  122602. * Class containing a set of static utilities functions for managing Pivots
  122603. * @hidden
  122604. */
  122605. export class PivotTools {
  122606. private static _PivotCached;
  122607. private static _OldPivotPoint;
  122608. private static _PivotTranslation;
  122609. private static _PivotTmpVector;
  122610. /** @hidden */
  122611. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  122612. /** @hidden */
  122613. static _RestorePivotPoint(mesh: AbstractMesh): void;
  122614. }
  122615. }
  122616. declare module BABYLON {
  122617. /**
  122618. * Class containing static functions to help procedurally build meshes
  122619. */
  122620. export class PlaneBuilder {
  122621. /**
  122622. * Creates a plane mesh
  122623. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  122624. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  122625. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  122626. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122627. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122628. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122629. * @param name defines the name of the mesh
  122630. * @param options defines the options used to create the mesh
  122631. * @param scene defines the hosting scene
  122632. * @returns the plane mesh
  122633. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  122634. */
  122635. static CreatePlane(name: string, options: {
  122636. size?: number;
  122637. width?: number;
  122638. height?: number;
  122639. sideOrientation?: number;
  122640. frontUVs?: Vector4;
  122641. backUVs?: Vector4;
  122642. updatable?: boolean;
  122643. sourcePlane?: Plane;
  122644. }, scene?: Nullable<Scene>): Mesh;
  122645. }
  122646. }
  122647. declare module BABYLON {
  122648. /**
  122649. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  122650. */
  122651. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  122652. private static _AnyMouseID;
  122653. /**
  122654. * Abstract mesh the behavior is set on
  122655. */
  122656. attachedNode: AbstractMesh;
  122657. private _dragPlane;
  122658. private _scene;
  122659. private _pointerObserver;
  122660. private _beforeRenderObserver;
  122661. private static _planeScene;
  122662. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  122663. /**
  122664. * 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)
  122665. */
  122666. maxDragAngle: number;
  122667. /**
  122668. * @hidden
  122669. */
  122670. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  122671. /**
  122672. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  122673. */
  122674. currentDraggingPointerID: number;
  122675. /**
  122676. * The last position where the pointer hit the drag plane in world space
  122677. */
  122678. lastDragPosition: Vector3;
  122679. /**
  122680. * If the behavior is currently in a dragging state
  122681. */
  122682. dragging: boolean;
  122683. /**
  122684. * 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)
  122685. */
  122686. dragDeltaRatio: number;
  122687. /**
  122688. * If the drag plane orientation should be updated during the dragging (Default: true)
  122689. */
  122690. updateDragPlane: boolean;
  122691. private _debugMode;
  122692. private _moving;
  122693. /**
  122694. * Fires each time the attached mesh is dragged with the pointer
  122695. * * delta between last drag position and current drag position in world space
  122696. * * dragDistance along the drag axis
  122697. * * dragPlaneNormal normal of the current drag plane used during the drag
  122698. * * dragPlanePoint in world space where the drag intersects the drag plane
  122699. */
  122700. onDragObservable: Observable<{
  122701. delta: Vector3;
  122702. dragPlanePoint: Vector3;
  122703. dragPlaneNormal: Vector3;
  122704. dragDistance: number;
  122705. pointerId: number;
  122706. }>;
  122707. /**
  122708. * Fires each time a drag begins (eg. mouse down on mesh)
  122709. */
  122710. onDragStartObservable: Observable<{
  122711. dragPlanePoint: Vector3;
  122712. pointerId: number;
  122713. }>;
  122714. /**
  122715. * Fires each time a drag ends (eg. mouse release after drag)
  122716. */
  122717. onDragEndObservable: Observable<{
  122718. dragPlanePoint: Vector3;
  122719. pointerId: number;
  122720. }>;
  122721. /**
  122722. * If the attached mesh should be moved when dragged
  122723. */
  122724. moveAttached: boolean;
  122725. /**
  122726. * If the drag behavior will react to drag events (Default: true)
  122727. */
  122728. enabled: boolean;
  122729. /**
  122730. * If pointer events should start and release the drag (Default: true)
  122731. */
  122732. startAndReleaseDragOnPointerEvents: boolean;
  122733. /**
  122734. * If camera controls should be detached during the drag
  122735. */
  122736. detachCameraControls: boolean;
  122737. /**
  122738. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  122739. */
  122740. useObjectOrientationForDragging: boolean;
  122741. private _options;
  122742. /**
  122743. * Gets the options used by the behavior
  122744. */
  122745. get options(): {
  122746. dragAxis?: Vector3;
  122747. dragPlaneNormal?: Vector3;
  122748. };
  122749. /**
  122750. * Sets the options used by the behavior
  122751. */
  122752. set options(options: {
  122753. dragAxis?: Vector3;
  122754. dragPlaneNormal?: Vector3;
  122755. });
  122756. /**
  122757. * Creates a pointer drag behavior that can be attached to a mesh
  122758. * @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)
  122759. */
  122760. constructor(options?: {
  122761. dragAxis?: Vector3;
  122762. dragPlaneNormal?: Vector3;
  122763. });
  122764. /**
  122765. * Predicate to determine if it is valid to move the object to a new position when it is moved
  122766. */
  122767. validateDrag: (targetPosition: Vector3) => boolean;
  122768. /**
  122769. * The name of the behavior
  122770. */
  122771. get name(): string;
  122772. /**
  122773. * Initializes the behavior
  122774. */
  122775. init(): void;
  122776. private _tmpVector;
  122777. private _alternatePickedPoint;
  122778. private _worldDragAxis;
  122779. private _targetPosition;
  122780. private _attachedElement;
  122781. /**
  122782. * Attaches the drag behavior the passed in mesh
  122783. * @param ownerNode The mesh that will be dragged around once attached
  122784. * @param predicate Predicate to use for pick filtering
  122785. */
  122786. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  122787. /**
  122788. * Force relase the drag action by code.
  122789. */
  122790. releaseDrag(): void;
  122791. private _startDragRay;
  122792. private _lastPointerRay;
  122793. /**
  122794. * Simulates the start of a pointer drag event on the behavior
  122795. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  122796. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  122797. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  122798. */
  122799. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  122800. private _startDrag;
  122801. private _dragDelta;
  122802. private _moveDrag;
  122803. private _pickWithRayOnDragPlane;
  122804. private _pointA;
  122805. private _pointC;
  122806. private _localAxis;
  122807. private _lookAt;
  122808. private _updateDragPlanePosition;
  122809. /**
  122810. * Detaches the behavior from the mesh
  122811. */
  122812. detach(): void;
  122813. }
  122814. }
  122815. declare module BABYLON {
  122816. /**
  122817. * A behavior that when attached to a mesh will allow the mesh to be scaled
  122818. */
  122819. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  122820. private _dragBehaviorA;
  122821. private _dragBehaviorB;
  122822. private _startDistance;
  122823. private _initialScale;
  122824. private _targetScale;
  122825. private _ownerNode;
  122826. private _sceneRenderObserver;
  122827. /**
  122828. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  122829. */
  122830. constructor();
  122831. /**
  122832. * The name of the behavior
  122833. */
  122834. get name(): string;
  122835. /**
  122836. * Initializes the behavior
  122837. */
  122838. init(): void;
  122839. private _getCurrentDistance;
  122840. /**
  122841. * Attaches the scale behavior the passed in mesh
  122842. * @param ownerNode The mesh that will be scaled around once attached
  122843. */
  122844. attach(ownerNode: Mesh): void;
  122845. /**
  122846. * Detaches the behavior from the mesh
  122847. */
  122848. detach(): void;
  122849. }
  122850. }
  122851. declare module BABYLON {
  122852. /**
  122853. * 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
  122854. */
  122855. export class SixDofDragBehavior implements Behavior<Mesh> {
  122856. private static _virtualScene;
  122857. private _ownerNode;
  122858. private _sceneRenderObserver;
  122859. private _scene;
  122860. private _targetPosition;
  122861. private _virtualOriginMesh;
  122862. private _virtualDragMesh;
  122863. private _pointerObserver;
  122864. private _moving;
  122865. private _startingOrientation;
  122866. private _attachedElement;
  122867. /**
  122868. * 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)
  122869. */
  122870. private zDragFactor;
  122871. /**
  122872. * If the object should rotate to face the drag origin
  122873. */
  122874. rotateDraggedObject: boolean;
  122875. /**
  122876. * If the behavior is currently in a dragging state
  122877. */
  122878. dragging: boolean;
  122879. /**
  122880. * 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)
  122881. */
  122882. dragDeltaRatio: number;
  122883. /**
  122884. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  122885. */
  122886. currentDraggingPointerID: number;
  122887. /**
  122888. * If camera controls should be detached during the drag
  122889. */
  122890. detachCameraControls: boolean;
  122891. /**
  122892. * Fires each time a drag starts
  122893. */
  122894. onDragStartObservable: Observable<{}>;
  122895. /**
  122896. * Fires each time a drag ends (eg. mouse release after drag)
  122897. */
  122898. onDragEndObservable: Observable<{}>;
  122899. /**
  122900. * 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
  122901. */
  122902. constructor();
  122903. /**
  122904. * The name of the behavior
  122905. */
  122906. get name(): string;
  122907. /**
  122908. * Initializes the behavior
  122909. */
  122910. init(): void;
  122911. /**
  122912. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  122913. */
  122914. private get _pointerCamera();
  122915. /**
  122916. * Attaches the scale behavior the passed in mesh
  122917. * @param ownerNode The mesh that will be scaled around once attached
  122918. */
  122919. attach(ownerNode: Mesh): void;
  122920. /**
  122921. * Detaches the behavior from the mesh
  122922. */
  122923. detach(): void;
  122924. }
  122925. }
  122926. declare module BABYLON {
  122927. /**
  122928. * Class used to apply inverse kinematics to bones
  122929. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  122930. */
  122931. export class BoneIKController {
  122932. private static _tmpVecs;
  122933. private static _tmpQuat;
  122934. private static _tmpMats;
  122935. /**
  122936. * Gets or sets the target mesh
  122937. */
  122938. targetMesh: AbstractMesh;
  122939. /** Gets or sets the mesh used as pole */
  122940. poleTargetMesh: AbstractMesh;
  122941. /**
  122942. * Gets or sets the bone used as pole
  122943. */
  122944. poleTargetBone: Nullable<Bone>;
  122945. /**
  122946. * Gets or sets the target position
  122947. */
  122948. targetPosition: Vector3;
  122949. /**
  122950. * Gets or sets the pole target position
  122951. */
  122952. poleTargetPosition: Vector3;
  122953. /**
  122954. * Gets or sets the pole target local offset
  122955. */
  122956. poleTargetLocalOffset: Vector3;
  122957. /**
  122958. * Gets or sets the pole angle
  122959. */
  122960. poleAngle: number;
  122961. /**
  122962. * Gets or sets the mesh associated with the controller
  122963. */
  122964. mesh: AbstractMesh;
  122965. /**
  122966. * 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)
  122967. */
  122968. slerpAmount: number;
  122969. private _bone1Quat;
  122970. private _bone1Mat;
  122971. private _bone2Ang;
  122972. private _bone1;
  122973. private _bone2;
  122974. private _bone1Length;
  122975. private _bone2Length;
  122976. private _maxAngle;
  122977. private _maxReach;
  122978. private _rightHandedSystem;
  122979. private _bendAxis;
  122980. private _slerping;
  122981. private _adjustRoll;
  122982. /**
  122983. * Gets or sets maximum allowed angle
  122984. */
  122985. get maxAngle(): number;
  122986. set maxAngle(value: number);
  122987. /**
  122988. * Creates a new BoneIKController
  122989. * @param mesh defines the mesh to control
  122990. * @param bone defines the bone to control
  122991. * @param options defines options to set up the controller
  122992. */
  122993. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  122994. targetMesh?: AbstractMesh;
  122995. poleTargetMesh?: AbstractMesh;
  122996. poleTargetBone?: Bone;
  122997. poleTargetLocalOffset?: Vector3;
  122998. poleAngle?: number;
  122999. bendAxis?: Vector3;
  123000. maxAngle?: number;
  123001. slerpAmount?: number;
  123002. });
  123003. private _setMaxAngle;
  123004. /**
  123005. * Force the controller to update the bones
  123006. */
  123007. update(): void;
  123008. }
  123009. }
  123010. declare module BABYLON {
  123011. /**
  123012. * Class used to make a bone look toward a point in space
  123013. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  123014. */
  123015. export class BoneLookController {
  123016. private static _tmpVecs;
  123017. private static _tmpQuat;
  123018. private static _tmpMats;
  123019. /**
  123020. * The target Vector3 that the bone will look at
  123021. */
  123022. target: Vector3;
  123023. /**
  123024. * The mesh that the bone is attached to
  123025. */
  123026. mesh: AbstractMesh;
  123027. /**
  123028. * The bone that will be looking to the target
  123029. */
  123030. bone: Bone;
  123031. /**
  123032. * The up axis of the coordinate system that is used when the bone is rotated
  123033. */
  123034. upAxis: Vector3;
  123035. /**
  123036. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  123037. */
  123038. upAxisSpace: Space;
  123039. /**
  123040. * Used to make an adjustment to the yaw of the bone
  123041. */
  123042. adjustYaw: number;
  123043. /**
  123044. * Used to make an adjustment to the pitch of the bone
  123045. */
  123046. adjustPitch: number;
  123047. /**
  123048. * Used to make an adjustment to the roll of the bone
  123049. */
  123050. adjustRoll: number;
  123051. /**
  123052. * 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)
  123053. */
  123054. slerpAmount: number;
  123055. private _minYaw;
  123056. private _maxYaw;
  123057. private _minPitch;
  123058. private _maxPitch;
  123059. private _minYawSin;
  123060. private _minYawCos;
  123061. private _maxYawSin;
  123062. private _maxYawCos;
  123063. private _midYawConstraint;
  123064. private _minPitchTan;
  123065. private _maxPitchTan;
  123066. private _boneQuat;
  123067. private _slerping;
  123068. private _transformYawPitch;
  123069. private _transformYawPitchInv;
  123070. private _firstFrameSkipped;
  123071. private _yawRange;
  123072. private _fowardAxis;
  123073. /**
  123074. * Gets or sets the minimum yaw angle that the bone can look to
  123075. */
  123076. get minYaw(): number;
  123077. set minYaw(value: number);
  123078. /**
  123079. * Gets or sets the maximum yaw angle that the bone can look to
  123080. */
  123081. get maxYaw(): number;
  123082. set maxYaw(value: number);
  123083. /**
  123084. * Gets or sets the minimum pitch angle that the bone can look to
  123085. */
  123086. get minPitch(): number;
  123087. set minPitch(value: number);
  123088. /**
  123089. * Gets or sets the maximum pitch angle that the bone can look to
  123090. */
  123091. get maxPitch(): number;
  123092. set maxPitch(value: number);
  123093. /**
  123094. * Create a BoneLookController
  123095. * @param mesh the mesh that the bone belongs to
  123096. * @param bone the bone that will be looking to the target
  123097. * @param target the target Vector3 to look at
  123098. * @param options optional settings:
  123099. * * maxYaw: the maximum angle the bone will yaw to
  123100. * * minYaw: the minimum angle the bone will yaw to
  123101. * * maxPitch: the maximum angle the bone will pitch to
  123102. * * minPitch: the minimum angle the bone will yaw to
  123103. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  123104. * * upAxis: the up axis of the coordinate system
  123105. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  123106. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  123107. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  123108. * * adjustYaw: used to make an adjustment to the yaw of the bone
  123109. * * adjustPitch: used to make an adjustment to the pitch of the bone
  123110. * * adjustRoll: used to make an adjustment to the roll of the bone
  123111. **/
  123112. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  123113. maxYaw?: number;
  123114. minYaw?: number;
  123115. maxPitch?: number;
  123116. minPitch?: number;
  123117. slerpAmount?: number;
  123118. upAxis?: Vector3;
  123119. upAxisSpace?: Space;
  123120. yawAxis?: Vector3;
  123121. pitchAxis?: Vector3;
  123122. adjustYaw?: number;
  123123. adjustPitch?: number;
  123124. adjustRoll?: number;
  123125. });
  123126. /**
  123127. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  123128. */
  123129. update(): void;
  123130. private _getAngleDiff;
  123131. private _getAngleBetween;
  123132. private _isAngleBetween;
  123133. }
  123134. }
  123135. declare module BABYLON {
  123136. /**
  123137. * Manage the gamepad inputs to control an arc rotate camera.
  123138. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123139. */
  123140. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  123141. /**
  123142. * Defines the camera the input is attached to.
  123143. */
  123144. camera: ArcRotateCamera;
  123145. /**
  123146. * Defines the gamepad the input is gathering event from.
  123147. */
  123148. gamepad: Nullable<Gamepad>;
  123149. /**
  123150. * Defines the gamepad rotation sensiblity.
  123151. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  123152. */
  123153. gamepadRotationSensibility: number;
  123154. /**
  123155. * Defines the gamepad move sensiblity.
  123156. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  123157. */
  123158. gamepadMoveSensibility: number;
  123159. private _yAxisScale;
  123160. /**
  123161. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  123162. */
  123163. get invertYAxis(): boolean;
  123164. set invertYAxis(value: boolean);
  123165. private _onGamepadConnectedObserver;
  123166. private _onGamepadDisconnectedObserver;
  123167. /**
  123168. * Attach the input controls to a specific dom element to get the input from.
  123169. * @param element Defines the element the controls should be listened from
  123170. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123171. */
  123172. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123173. /**
  123174. * Detach the current controls from the specified dom element.
  123175. * @param element Defines the element to stop listening the inputs from
  123176. */
  123177. detachControl(element: Nullable<HTMLElement>): void;
  123178. /**
  123179. * Update the current camera state depending on the inputs that have been used this frame.
  123180. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  123181. */
  123182. checkInputs(): void;
  123183. /**
  123184. * Gets the class name of the current intput.
  123185. * @returns the class name
  123186. */
  123187. getClassName(): string;
  123188. /**
  123189. * Get the friendly name associated with the input class.
  123190. * @returns the input friendly name
  123191. */
  123192. getSimpleName(): string;
  123193. }
  123194. }
  123195. declare module BABYLON {
  123196. interface ArcRotateCameraInputsManager {
  123197. /**
  123198. * Add orientation input support to the input manager.
  123199. * @returns the current input manager
  123200. */
  123201. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  123202. }
  123203. /**
  123204. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  123205. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123206. */
  123207. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  123208. /**
  123209. * Defines the camera the input is attached to.
  123210. */
  123211. camera: ArcRotateCamera;
  123212. /**
  123213. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  123214. */
  123215. alphaCorrection: number;
  123216. /**
  123217. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  123218. */
  123219. gammaCorrection: number;
  123220. private _alpha;
  123221. private _gamma;
  123222. private _dirty;
  123223. private _deviceOrientationHandler;
  123224. /**
  123225. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  123226. */
  123227. constructor();
  123228. /**
  123229. * Attach the input controls to a specific dom element to get the input from.
  123230. * @param element Defines the element the controls should be listened from
  123231. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123232. */
  123233. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123234. /** @hidden */
  123235. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  123236. /**
  123237. * Update the current camera state depending on the inputs that have been used this frame.
  123238. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  123239. */
  123240. checkInputs(): void;
  123241. /**
  123242. * Detach the current controls from the specified dom element.
  123243. * @param element Defines the element to stop listening the inputs from
  123244. */
  123245. detachControl(element: Nullable<HTMLElement>): void;
  123246. /**
  123247. * Gets the class name of the current intput.
  123248. * @returns the class name
  123249. */
  123250. getClassName(): string;
  123251. /**
  123252. * Get the friendly name associated with the input class.
  123253. * @returns the input friendly name
  123254. */
  123255. getSimpleName(): string;
  123256. }
  123257. }
  123258. declare module BABYLON {
  123259. /**
  123260. * Listen to mouse events to control the camera.
  123261. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123262. */
  123263. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  123264. /**
  123265. * Defines the camera the input is attached to.
  123266. */
  123267. camera: FlyCamera;
  123268. /**
  123269. * Defines if touch is enabled. (Default is true.)
  123270. */
  123271. touchEnabled: boolean;
  123272. /**
  123273. * Defines the buttons associated with the input to handle camera rotation.
  123274. */
  123275. buttons: number[];
  123276. /**
  123277. * Assign buttons for Yaw control.
  123278. */
  123279. buttonsYaw: number[];
  123280. /**
  123281. * Assign buttons for Pitch control.
  123282. */
  123283. buttonsPitch: number[];
  123284. /**
  123285. * Assign buttons for Roll control.
  123286. */
  123287. buttonsRoll: number[];
  123288. /**
  123289. * Detect if any button is being pressed while mouse is moved.
  123290. * -1 = Mouse locked.
  123291. * 0 = Left button.
  123292. * 1 = Middle Button.
  123293. * 2 = Right Button.
  123294. */
  123295. activeButton: number;
  123296. /**
  123297. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  123298. * Higher values reduce its sensitivity.
  123299. */
  123300. angularSensibility: number;
  123301. private _mousemoveCallback;
  123302. private _observer;
  123303. private _rollObserver;
  123304. private previousPosition;
  123305. private noPreventDefault;
  123306. private element;
  123307. /**
  123308. * Listen to mouse events to control the camera.
  123309. * @param touchEnabled Define if touch is enabled. (Default is true.)
  123310. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123311. */
  123312. constructor(touchEnabled?: boolean);
  123313. /**
  123314. * Attach the mouse control to the HTML DOM element.
  123315. * @param element Defines the element that listens to the input events.
  123316. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  123317. */
  123318. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123319. /**
  123320. * Detach the current controls from the specified dom element.
  123321. * @param element Defines the element to stop listening the inputs from
  123322. */
  123323. detachControl(element: Nullable<HTMLElement>): void;
  123324. /**
  123325. * Gets the class name of the current input.
  123326. * @returns the class name.
  123327. */
  123328. getClassName(): string;
  123329. /**
  123330. * Get the friendly name associated with the input class.
  123331. * @returns the input's friendly name.
  123332. */
  123333. getSimpleName(): string;
  123334. private _pointerInput;
  123335. private _onMouseMove;
  123336. /**
  123337. * Rotate camera by mouse offset.
  123338. */
  123339. private rotateCamera;
  123340. }
  123341. }
  123342. declare module BABYLON {
  123343. /**
  123344. * Default Inputs manager for the FlyCamera.
  123345. * It groups all the default supported inputs for ease of use.
  123346. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123347. */
  123348. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  123349. /**
  123350. * Instantiates a new FlyCameraInputsManager.
  123351. * @param camera Defines the camera the inputs belong to.
  123352. */
  123353. constructor(camera: FlyCamera);
  123354. /**
  123355. * Add keyboard input support to the input manager.
  123356. * @returns the new FlyCameraKeyboardMoveInput().
  123357. */
  123358. addKeyboard(): FlyCameraInputsManager;
  123359. /**
  123360. * Add mouse input support to the input manager.
  123361. * @param touchEnabled Enable touch screen support.
  123362. * @returns the new FlyCameraMouseInput().
  123363. */
  123364. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  123365. }
  123366. }
  123367. declare module BABYLON {
  123368. /**
  123369. * This is a flying camera, designed for 3D movement and rotation in all directions,
  123370. * such as in a 3D Space Shooter or a Flight Simulator.
  123371. */
  123372. export class FlyCamera extends TargetCamera {
  123373. /**
  123374. * Define the collision ellipsoid of the camera.
  123375. * This is helpful for simulating a camera body, like a player's body.
  123376. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  123377. */
  123378. ellipsoid: Vector3;
  123379. /**
  123380. * Define an offset for the position of the ellipsoid around the camera.
  123381. * This can be helpful if the camera is attached away from the player's body center,
  123382. * such as at its head.
  123383. */
  123384. ellipsoidOffset: Vector3;
  123385. /**
  123386. * Enable or disable collisions of the camera with the rest of the scene objects.
  123387. */
  123388. checkCollisions: boolean;
  123389. /**
  123390. * Enable or disable gravity on the camera.
  123391. */
  123392. applyGravity: boolean;
  123393. /**
  123394. * Define the current direction the camera is moving to.
  123395. */
  123396. cameraDirection: Vector3;
  123397. /**
  123398. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  123399. * This overrides and empties cameraRotation.
  123400. */
  123401. rotationQuaternion: Quaternion;
  123402. /**
  123403. * Track Roll to maintain the wanted Rolling when looking around.
  123404. */
  123405. _trackRoll: number;
  123406. /**
  123407. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  123408. */
  123409. rollCorrect: number;
  123410. /**
  123411. * Mimic a banked turn, Rolling the camera when Yawing.
  123412. * It's recommended to use rollCorrect = 10 for faster banking correction.
  123413. */
  123414. bankedTurn: boolean;
  123415. /**
  123416. * Limit in radians for how much Roll banking will add. (Default: 90°)
  123417. */
  123418. bankedTurnLimit: number;
  123419. /**
  123420. * Value of 0 disables the banked Roll.
  123421. * Value of 1 is equal to the Yaw angle in radians.
  123422. */
  123423. bankedTurnMultiplier: number;
  123424. /**
  123425. * The inputs manager loads all the input sources, such as keyboard and mouse.
  123426. */
  123427. inputs: FlyCameraInputsManager;
  123428. /**
  123429. * Gets the input sensibility for mouse input.
  123430. * Higher values reduce sensitivity.
  123431. */
  123432. get angularSensibility(): number;
  123433. /**
  123434. * Sets the input sensibility for a mouse input.
  123435. * Higher values reduce sensitivity.
  123436. */
  123437. set angularSensibility(value: number);
  123438. /**
  123439. * Get the keys for camera movement forward.
  123440. */
  123441. get keysForward(): number[];
  123442. /**
  123443. * Set the keys for camera movement forward.
  123444. */
  123445. set keysForward(value: number[]);
  123446. /**
  123447. * Get the keys for camera movement backward.
  123448. */
  123449. get keysBackward(): number[];
  123450. set keysBackward(value: number[]);
  123451. /**
  123452. * Get the keys for camera movement up.
  123453. */
  123454. get keysUp(): number[];
  123455. /**
  123456. * Set the keys for camera movement up.
  123457. */
  123458. set keysUp(value: number[]);
  123459. /**
  123460. * Get the keys for camera movement down.
  123461. */
  123462. get keysDown(): number[];
  123463. /**
  123464. * Set the keys for camera movement down.
  123465. */
  123466. set keysDown(value: number[]);
  123467. /**
  123468. * Get the keys for camera movement left.
  123469. */
  123470. get keysLeft(): number[];
  123471. /**
  123472. * Set the keys for camera movement left.
  123473. */
  123474. set keysLeft(value: number[]);
  123475. /**
  123476. * Set the keys for camera movement right.
  123477. */
  123478. get keysRight(): number[];
  123479. /**
  123480. * Set the keys for camera movement right.
  123481. */
  123482. set keysRight(value: number[]);
  123483. /**
  123484. * Event raised when the camera collides with a mesh in the scene.
  123485. */
  123486. onCollide: (collidedMesh: AbstractMesh) => void;
  123487. private _collider;
  123488. private _needMoveForGravity;
  123489. private _oldPosition;
  123490. private _diffPosition;
  123491. private _newPosition;
  123492. /** @hidden */
  123493. _localDirection: Vector3;
  123494. /** @hidden */
  123495. _transformedDirection: Vector3;
  123496. /**
  123497. * Instantiates a FlyCamera.
  123498. * This is a flying camera, designed for 3D movement and rotation in all directions,
  123499. * such as in a 3D Space Shooter or a Flight Simulator.
  123500. * @param name Define the name of the camera in the scene.
  123501. * @param position Define the starting position of the camera in the scene.
  123502. * @param scene Define the scene the camera belongs to.
  123503. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  123504. */
  123505. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  123506. /**
  123507. * Attach a control to the HTML DOM element.
  123508. * @param element Defines the element that listens to the input events.
  123509. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  123510. */
  123511. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123512. /**
  123513. * Detach a control from the HTML DOM element.
  123514. * The camera will stop reacting to that input.
  123515. * @param element Defines the element that listens to the input events.
  123516. */
  123517. detachControl(element: HTMLElement): void;
  123518. private _collisionMask;
  123519. /**
  123520. * Get the mask that the camera ignores in collision events.
  123521. */
  123522. get collisionMask(): number;
  123523. /**
  123524. * Set the mask that the camera ignores in collision events.
  123525. */
  123526. set collisionMask(mask: number);
  123527. /** @hidden */
  123528. _collideWithWorld(displacement: Vector3): void;
  123529. /** @hidden */
  123530. private _onCollisionPositionChange;
  123531. /** @hidden */
  123532. _checkInputs(): void;
  123533. /** @hidden */
  123534. _decideIfNeedsToMove(): boolean;
  123535. /** @hidden */
  123536. _updatePosition(): void;
  123537. /**
  123538. * Restore the Roll to its target value at the rate specified.
  123539. * @param rate - Higher means slower restoring.
  123540. * @hidden
  123541. */
  123542. restoreRoll(rate: number): void;
  123543. /**
  123544. * Destroy the camera and release the current resources held by it.
  123545. */
  123546. dispose(): void;
  123547. /**
  123548. * Get the current object class name.
  123549. * @returns the class name.
  123550. */
  123551. getClassName(): string;
  123552. }
  123553. }
  123554. declare module BABYLON {
  123555. /**
  123556. * Listen to keyboard events to control the camera.
  123557. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123558. */
  123559. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  123560. /**
  123561. * Defines the camera the input is attached to.
  123562. */
  123563. camera: FlyCamera;
  123564. /**
  123565. * The list of keyboard keys used to control the forward move of the camera.
  123566. */
  123567. keysForward: number[];
  123568. /**
  123569. * The list of keyboard keys used to control the backward move of the camera.
  123570. */
  123571. keysBackward: number[];
  123572. /**
  123573. * The list of keyboard keys used to control the forward move of the camera.
  123574. */
  123575. keysUp: number[];
  123576. /**
  123577. * The list of keyboard keys used to control the backward move of the camera.
  123578. */
  123579. keysDown: number[];
  123580. /**
  123581. * The list of keyboard keys used to control the right strafe move of the camera.
  123582. */
  123583. keysRight: number[];
  123584. /**
  123585. * The list of keyboard keys used to control the left strafe move of the camera.
  123586. */
  123587. keysLeft: number[];
  123588. private _keys;
  123589. private _onCanvasBlurObserver;
  123590. private _onKeyboardObserver;
  123591. private _engine;
  123592. private _scene;
  123593. /**
  123594. * Attach the input controls to a specific dom element to get the input from.
  123595. * @param element Defines the element the controls should be listened from
  123596. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123597. */
  123598. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123599. /**
  123600. * Detach the current controls from the specified dom element.
  123601. * @param element Defines the element to stop listening the inputs from
  123602. */
  123603. detachControl(element: Nullable<HTMLElement>): void;
  123604. /**
  123605. * Gets the class name of the current intput.
  123606. * @returns the class name
  123607. */
  123608. getClassName(): string;
  123609. /** @hidden */
  123610. _onLostFocus(e: FocusEvent): void;
  123611. /**
  123612. * Get the friendly name associated with the input class.
  123613. * @returns the input friendly name
  123614. */
  123615. getSimpleName(): string;
  123616. /**
  123617. * Update the current camera state depending on the inputs that have been used this frame.
  123618. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  123619. */
  123620. checkInputs(): void;
  123621. }
  123622. }
  123623. declare module BABYLON {
  123624. /**
  123625. * Manage the mouse wheel inputs to control a follow camera.
  123626. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123627. */
  123628. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  123629. /**
  123630. * Defines the camera the input is attached to.
  123631. */
  123632. camera: FollowCamera;
  123633. /**
  123634. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  123635. */
  123636. axisControlRadius: boolean;
  123637. /**
  123638. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  123639. */
  123640. axisControlHeight: boolean;
  123641. /**
  123642. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  123643. */
  123644. axisControlRotation: boolean;
  123645. /**
  123646. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  123647. * relation to mouseWheel events.
  123648. */
  123649. wheelPrecision: number;
  123650. /**
  123651. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  123652. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  123653. */
  123654. wheelDeltaPercentage: number;
  123655. private _wheel;
  123656. private _observer;
  123657. /**
  123658. * Attach the input controls to a specific dom element to get the input from.
  123659. * @param element Defines the element the controls should be listened from
  123660. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123661. */
  123662. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123663. /**
  123664. * Detach the current controls from the specified dom element.
  123665. * @param element Defines the element to stop listening the inputs from
  123666. */
  123667. detachControl(element: Nullable<HTMLElement>): void;
  123668. /**
  123669. * Gets the class name of the current intput.
  123670. * @returns the class name
  123671. */
  123672. getClassName(): string;
  123673. /**
  123674. * Get the friendly name associated with the input class.
  123675. * @returns the input friendly name
  123676. */
  123677. getSimpleName(): string;
  123678. }
  123679. }
  123680. declare module BABYLON {
  123681. /**
  123682. * Manage the pointers inputs to control an follow camera.
  123683. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123684. */
  123685. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  123686. /**
  123687. * Defines the camera the input is attached to.
  123688. */
  123689. camera: FollowCamera;
  123690. /**
  123691. * Gets the class name of the current input.
  123692. * @returns the class name
  123693. */
  123694. getClassName(): string;
  123695. /**
  123696. * Defines the pointer angular sensibility along the X axis or how fast is
  123697. * the camera rotating.
  123698. * A negative number will reverse the axis direction.
  123699. */
  123700. angularSensibilityX: number;
  123701. /**
  123702. * Defines the pointer angular sensibility along the Y axis or how fast is
  123703. * the camera rotating.
  123704. * A negative number will reverse the axis direction.
  123705. */
  123706. angularSensibilityY: number;
  123707. /**
  123708. * Defines the pointer pinch precision or how fast is the camera zooming.
  123709. * A negative number will reverse the axis direction.
  123710. */
  123711. pinchPrecision: number;
  123712. /**
  123713. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  123714. * from 0.
  123715. * It defines the percentage of current camera.radius to use as delta when
  123716. * pinch zoom is used.
  123717. */
  123718. pinchDeltaPercentage: number;
  123719. /**
  123720. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  123721. */
  123722. axisXControlRadius: boolean;
  123723. /**
  123724. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  123725. */
  123726. axisXControlHeight: boolean;
  123727. /**
  123728. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  123729. */
  123730. axisXControlRotation: boolean;
  123731. /**
  123732. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  123733. */
  123734. axisYControlRadius: boolean;
  123735. /**
  123736. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  123737. */
  123738. axisYControlHeight: boolean;
  123739. /**
  123740. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  123741. */
  123742. axisYControlRotation: boolean;
  123743. /**
  123744. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  123745. */
  123746. axisPinchControlRadius: boolean;
  123747. /**
  123748. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  123749. */
  123750. axisPinchControlHeight: boolean;
  123751. /**
  123752. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  123753. */
  123754. axisPinchControlRotation: boolean;
  123755. /**
  123756. * Log error messages if basic misconfiguration has occurred.
  123757. */
  123758. warningEnable: boolean;
  123759. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  123760. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  123761. private _warningCounter;
  123762. private _warning;
  123763. }
  123764. }
  123765. declare module BABYLON {
  123766. /**
  123767. * Default Inputs manager for the FollowCamera.
  123768. * It groups all the default supported inputs for ease of use.
  123769. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123770. */
  123771. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  123772. /**
  123773. * Instantiates a new FollowCameraInputsManager.
  123774. * @param camera Defines the camera the inputs belong to
  123775. */
  123776. constructor(camera: FollowCamera);
  123777. /**
  123778. * Add keyboard input support to the input manager.
  123779. * @returns the current input manager
  123780. */
  123781. addKeyboard(): FollowCameraInputsManager;
  123782. /**
  123783. * Add mouse wheel input support to the input manager.
  123784. * @returns the current input manager
  123785. */
  123786. addMouseWheel(): FollowCameraInputsManager;
  123787. /**
  123788. * Add pointers input support to the input manager.
  123789. * @returns the current input manager
  123790. */
  123791. addPointers(): FollowCameraInputsManager;
  123792. /**
  123793. * Add orientation input support to the input manager.
  123794. * @returns the current input manager
  123795. */
  123796. addVRDeviceOrientation(): FollowCameraInputsManager;
  123797. }
  123798. }
  123799. declare module BABYLON {
  123800. /**
  123801. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  123802. * an arc rotate version arcFollowCamera are available.
  123803. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  123804. */
  123805. export class FollowCamera extends TargetCamera {
  123806. /**
  123807. * Distance the follow camera should follow an object at
  123808. */
  123809. radius: number;
  123810. /**
  123811. * Minimum allowed distance of the camera to the axis of rotation
  123812. * (The camera can not get closer).
  123813. * This can help limiting how the Camera is able to move in the scene.
  123814. */
  123815. lowerRadiusLimit: Nullable<number>;
  123816. /**
  123817. * Maximum allowed distance of the camera to the axis of rotation
  123818. * (The camera can not get further).
  123819. * This can help limiting how the Camera is able to move in the scene.
  123820. */
  123821. upperRadiusLimit: Nullable<number>;
  123822. /**
  123823. * Define a rotation offset between the camera and the object it follows
  123824. */
  123825. rotationOffset: number;
  123826. /**
  123827. * Minimum allowed angle to camera position relative to target object.
  123828. * This can help limiting how the Camera is able to move in the scene.
  123829. */
  123830. lowerRotationOffsetLimit: Nullable<number>;
  123831. /**
  123832. * Maximum allowed angle to camera position relative to target object.
  123833. * This can help limiting how the Camera is able to move in the scene.
  123834. */
  123835. upperRotationOffsetLimit: Nullable<number>;
  123836. /**
  123837. * Define a height offset between the camera and the object it follows.
  123838. * It can help following an object from the top (like a car chaing a plane)
  123839. */
  123840. heightOffset: number;
  123841. /**
  123842. * Minimum allowed height of camera position relative to target object.
  123843. * This can help limiting how the Camera is able to move in the scene.
  123844. */
  123845. lowerHeightOffsetLimit: Nullable<number>;
  123846. /**
  123847. * Maximum allowed height of camera position relative to target object.
  123848. * This can help limiting how the Camera is able to move in the scene.
  123849. */
  123850. upperHeightOffsetLimit: Nullable<number>;
  123851. /**
  123852. * Define how fast the camera can accelerate to follow it s target.
  123853. */
  123854. cameraAcceleration: number;
  123855. /**
  123856. * Define the speed limit of the camera following an object.
  123857. */
  123858. maxCameraSpeed: number;
  123859. /**
  123860. * Define the target of the camera.
  123861. */
  123862. lockedTarget: Nullable<AbstractMesh>;
  123863. /**
  123864. * Defines the input associated with the camera.
  123865. */
  123866. inputs: FollowCameraInputsManager;
  123867. /**
  123868. * Instantiates the follow camera.
  123869. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  123870. * @param name Define the name of the camera in the scene
  123871. * @param position Define the position of the camera
  123872. * @param scene Define the scene the camera belong to
  123873. * @param lockedTarget Define the target of the camera
  123874. */
  123875. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  123876. private _follow;
  123877. /**
  123878. * Attached controls to the current camera.
  123879. * @param element Defines the element the controls should be listened from
  123880. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123881. */
  123882. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123883. /**
  123884. * Detach the current controls from the camera.
  123885. * The camera will stop reacting to inputs.
  123886. * @param element Defines the element to stop listening the inputs from
  123887. */
  123888. detachControl(element: HTMLElement): void;
  123889. /** @hidden */
  123890. _checkInputs(): void;
  123891. private _checkLimits;
  123892. /**
  123893. * Gets the camera class name.
  123894. * @returns the class name
  123895. */
  123896. getClassName(): string;
  123897. }
  123898. /**
  123899. * Arc Rotate version of the follow camera.
  123900. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  123901. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  123902. */
  123903. export class ArcFollowCamera extends TargetCamera {
  123904. /** The longitudinal angle of the camera */
  123905. alpha: number;
  123906. /** The latitudinal angle of the camera */
  123907. beta: number;
  123908. /** The radius of the camera from its target */
  123909. radius: number;
  123910. private _cartesianCoordinates;
  123911. /** Define the camera target (the mesh it should follow) */
  123912. private _meshTarget;
  123913. /**
  123914. * Instantiates a new ArcFollowCamera
  123915. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  123916. * @param name Define the name of the camera
  123917. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  123918. * @param beta Define the rotation angle of the camera around the elevation axis
  123919. * @param radius Define the radius of the camera from its target point
  123920. * @param target Define the target of the camera
  123921. * @param scene Define the scene the camera belongs to
  123922. */
  123923. constructor(name: string,
  123924. /** The longitudinal angle of the camera */
  123925. alpha: number,
  123926. /** The latitudinal angle of the camera */
  123927. beta: number,
  123928. /** The radius of the camera from its target */
  123929. radius: number,
  123930. /** Define the camera target (the mesh it should follow) */
  123931. target: Nullable<AbstractMesh>, scene: Scene);
  123932. private _follow;
  123933. /** @hidden */
  123934. _checkInputs(): void;
  123935. /**
  123936. * Returns the class name of the object.
  123937. * It is mostly used internally for serialization purposes.
  123938. */
  123939. getClassName(): string;
  123940. }
  123941. }
  123942. declare module BABYLON {
  123943. /**
  123944. * Manage the keyboard inputs to control the movement of a follow camera.
  123945. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123946. */
  123947. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  123948. /**
  123949. * Defines the camera the input is attached to.
  123950. */
  123951. camera: FollowCamera;
  123952. /**
  123953. * Defines the list of key codes associated with the up action (increase heightOffset)
  123954. */
  123955. keysHeightOffsetIncr: number[];
  123956. /**
  123957. * Defines the list of key codes associated with the down action (decrease heightOffset)
  123958. */
  123959. keysHeightOffsetDecr: number[];
  123960. /**
  123961. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  123962. */
  123963. keysHeightOffsetModifierAlt: boolean;
  123964. /**
  123965. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  123966. */
  123967. keysHeightOffsetModifierCtrl: boolean;
  123968. /**
  123969. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  123970. */
  123971. keysHeightOffsetModifierShift: boolean;
  123972. /**
  123973. * Defines the list of key codes associated with the left action (increase rotationOffset)
  123974. */
  123975. keysRotationOffsetIncr: number[];
  123976. /**
  123977. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  123978. */
  123979. keysRotationOffsetDecr: number[];
  123980. /**
  123981. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  123982. */
  123983. keysRotationOffsetModifierAlt: boolean;
  123984. /**
  123985. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  123986. */
  123987. keysRotationOffsetModifierCtrl: boolean;
  123988. /**
  123989. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  123990. */
  123991. keysRotationOffsetModifierShift: boolean;
  123992. /**
  123993. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  123994. */
  123995. keysRadiusIncr: number[];
  123996. /**
  123997. * Defines the list of key codes associated with the zoom-out action (increase radius)
  123998. */
  123999. keysRadiusDecr: number[];
  124000. /**
  124001. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  124002. */
  124003. keysRadiusModifierAlt: boolean;
  124004. /**
  124005. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  124006. */
  124007. keysRadiusModifierCtrl: boolean;
  124008. /**
  124009. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  124010. */
  124011. keysRadiusModifierShift: boolean;
  124012. /**
  124013. * Defines the rate of change of heightOffset.
  124014. */
  124015. heightSensibility: number;
  124016. /**
  124017. * Defines the rate of change of rotationOffset.
  124018. */
  124019. rotationSensibility: number;
  124020. /**
  124021. * Defines the rate of change of radius.
  124022. */
  124023. radiusSensibility: number;
  124024. private _keys;
  124025. private _ctrlPressed;
  124026. private _altPressed;
  124027. private _shiftPressed;
  124028. private _onCanvasBlurObserver;
  124029. private _onKeyboardObserver;
  124030. private _engine;
  124031. private _scene;
  124032. /**
  124033. * Attach the input controls to a specific dom element to get the input from.
  124034. * @param element Defines the element the controls should be listened from
  124035. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124036. */
  124037. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124038. /**
  124039. * Detach the current controls from the specified dom element.
  124040. * @param element Defines the element to stop listening the inputs from
  124041. */
  124042. detachControl(element: Nullable<HTMLElement>): void;
  124043. /**
  124044. * Update the current camera state depending on the inputs that have been used this frame.
  124045. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  124046. */
  124047. checkInputs(): void;
  124048. /**
  124049. * Gets the class name of the current input.
  124050. * @returns the class name
  124051. */
  124052. getClassName(): string;
  124053. /**
  124054. * Get the friendly name associated with the input class.
  124055. * @returns the input friendly name
  124056. */
  124057. getSimpleName(): string;
  124058. /**
  124059. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  124060. * allow modification of the heightOffset value.
  124061. */
  124062. private _modifierHeightOffset;
  124063. /**
  124064. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  124065. * allow modification of the rotationOffset value.
  124066. */
  124067. private _modifierRotationOffset;
  124068. /**
  124069. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  124070. * allow modification of the radius value.
  124071. */
  124072. private _modifierRadius;
  124073. }
  124074. }
  124075. declare module BABYLON {
  124076. interface FreeCameraInputsManager {
  124077. /**
  124078. * @hidden
  124079. */
  124080. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  124081. /**
  124082. * Add orientation input support to the input manager.
  124083. * @returns the current input manager
  124084. */
  124085. addDeviceOrientation(): FreeCameraInputsManager;
  124086. }
  124087. /**
  124088. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  124089. * Screen rotation is taken into account.
  124090. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124091. */
  124092. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  124093. private _camera;
  124094. private _screenOrientationAngle;
  124095. private _constantTranform;
  124096. private _screenQuaternion;
  124097. private _alpha;
  124098. private _beta;
  124099. private _gamma;
  124100. /**
  124101. * Can be used to detect if a device orientation sensor is available on a device
  124102. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  124103. * @returns a promise that will resolve on orientation change
  124104. */
  124105. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  124106. /**
  124107. * @hidden
  124108. */
  124109. _onDeviceOrientationChangedObservable: Observable<void>;
  124110. /**
  124111. * Instantiates a new input
  124112. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124113. */
  124114. constructor();
  124115. /**
  124116. * Define the camera controlled by the input.
  124117. */
  124118. get camera(): FreeCamera;
  124119. set camera(camera: FreeCamera);
  124120. /**
  124121. * Attach the input controls to a specific dom element to get the input from.
  124122. * @param element Defines the element the controls should be listened from
  124123. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124124. */
  124125. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124126. private _orientationChanged;
  124127. private _deviceOrientation;
  124128. /**
  124129. * Detach the current controls from the specified dom element.
  124130. * @param element Defines the element to stop listening the inputs from
  124131. */
  124132. detachControl(element: Nullable<HTMLElement>): void;
  124133. /**
  124134. * Update the current camera state depending on the inputs that have been used this frame.
  124135. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  124136. */
  124137. checkInputs(): void;
  124138. /**
  124139. * Gets the class name of the current intput.
  124140. * @returns the class name
  124141. */
  124142. getClassName(): string;
  124143. /**
  124144. * Get the friendly name associated with the input class.
  124145. * @returns the input friendly name
  124146. */
  124147. getSimpleName(): string;
  124148. }
  124149. }
  124150. declare module BABYLON {
  124151. /**
  124152. * Manage the gamepad inputs to control a free camera.
  124153. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124154. */
  124155. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  124156. /**
  124157. * Define the camera the input is attached to.
  124158. */
  124159. camera: FreeCamera;
  124160. /**
  124161. * Define the Gamepad controlling the input
  124162. */
  124163. gamepad: Nullable<Gamepad>;
  124164. /**
  124165. * Defines the gamepad rotation sensiblity.
  124166. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  124167. */
  124168. gamepadAngularSensibility: number;
  124169. /**
  124170. * Defines the gamepad move sensiblity.
  124171. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  124172. */
  124173. gamepadMoveSensibility: number;
  124174. private _yAxisScale;
  124175. /**
  124176. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  124177. */
  124178. get invertYAxis(): boolean;
  124179. set invertYAxis(value: boolean);
  124180. private _onGamepadConnectedObserver;
  124181. private _onGamepadDisconnectedObserver;
  124182. private _cameraTransform;
  124183. private _deltaTransform;
  124184. private _vector3;
  124185. private _vector2;
  124186. /**
  124187. * Attach the input controls to a specific dom element to get the input from.
  124188. * @param element Defines the element the controls should be listened from
  124189. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124190. */
  124191. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124192. /**
  124193. * Detach the current controls from the specified dom element.
  124194. * @param element Defines the element to stop listening the inputs from
  124195. */
  124196. detachControl(element: Nullable<HTMLElement>): void;
  124197. /**
  124198. * Update the current camera state depending on the inputs that have been used this frame.
  124199. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  124200. */
  124201. checkInputs(): void;
  124202. /**
  124203. * Gets the class name of the current intput.
  124204. * @returns the class name
  124205. */
  124206. getClassName(): string;
  124207. /**
  124208. * Get the friendly name associated with the input class.
  124209. * @returns the input friendly name
  124210. */
  124211. getSimpleName(): string;
  124212. }
  124213. }
  124214. declare module BABYLON {
  124215. /**
  124216. * Defines the potential axis of a Joystick
  124217. */
  124218. export enum JoystickAxis {
  124219. /** X axis */
  124220. X = 0,
  124221. /** Y axis */
  124222. Y = 1,
  124223. /** Z axis */
  124224. Z = 2
  124225. }
  124226. /**
  124227. * Represents the different customization options available
  124228. * for VirtualJoystick
  124229. */
  124230. interface VirtualJoystickCustomizations {
  124231. /**
  124232. * Size of the joystick's puck
  124233. */
  124234. puckSize: number;
  124235. /**
  124236. * Size of the joystick's container
  124237. */
  124238. containerSize: number;
  124239. /**
  124240. * Color of the joystick && puck
  124241. */
  124242. color: string;
  124243. /**
  124244. * Image URL for the joystick's puck
  124245. */
  124246. puckImage?: string;
  124247. /**
  124248. * Image URL for the joystick's container
  124249. */
  124250. containerImage?: string;
  124251. /**
  124252. * Defines the unmoving position of the joystick container
  124253. */
  124254. position?: {
  124255. x: number;
  124256. y: number;
  124257. };
  124258. /**
  124259. * Defines whether or not the joystick container is always visible
  124260. */
  124261. alwaysVisible: boolean;
  124262. /**
  124263. * Defines whether or not to limit the movement of the puck to the joystick's container
  124264. */
  124265. limitToContainer: boolean;
  124266. }
  124267. /**
  124268. * Class used to define virtual joystick (used in touch mode)
  124269. */
  124270. export class VirtualJoystick {
  124271. /**
  124272. * Gets or sets a boolean indicating that left and right values must be inverted
  124273. */
  124274. reverseLeftRight: boolean;
  124275. /**
  124276. * Gets or sets a boolean indicating that up and down values must be inverted
  124277. */
  124278. reverseUpDown: boolean;
  124279. /**
  124280. * Gets the offset value for the position (ie. the change of the position value)
  124281. */
  124282. deltaPosition: Vector3;
  124283. /**
  124284. * Gets a boolean indicating if the virtual joystick was pressed
  124285. */
  124286. pressed: boolean;
  124287. /**
  124288. * Canvas the virtual joystick will render onto, default z-index of this is 5
  124289. */
  124290. static Canvas: Nullable<HTMLCanvasElement>;
  124291. /**
  124292. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  124293. */
  124294. limitToContainer: boolean;
  124295. private static _globalJoystickIndex;
  124296. private static _alwaysVisibleSticks;
  124297. private static vjCanvasContext;
  124298. private static vjCanvasWidth;
  124299. private static vjCanvasHeight;
  124300. private static halfWidth;
  124301. private static _GetDefaultOptions;
  124302. private _action;
  124303. private _axisTargetedByLeftAndRight;
  124304. private _axisTargetedByUpAndDown;
  124305. private _joystickSensibility;
  124306. private _inversedSensibility;
  124307. private _joystickPointerID;
  124308. private _joystickColor;
  124309. private _joystickPointerPos;
  124310. private _joystickPreviousPointerPos;
  124311. private _joystickPointerStartPos;
  124312. private _deltaJoystickVector;
  124313. private _leftJoystick;
  124314. private _touches;
  124315. private _joystickPosition;
  124316. private _alwaysVisible;
  124317. private _puckImage;
  124318. private _containerImage;
  124319. private _joystickPuckSize;
  124320. private _joystickContainerSize;
  124321. private _clearPuckSize;
  124322. private _clearContainerSize;
  124323. private _clearPuckSizeOffset;
  124324. private _clearContainerSizeOffset;
  124325. private _onPointerDownHandlerRef;
  124326. private _onPointerMoveHandlerRef;
  124327. private _onPointerUpHandlerRef;
  124328. private _onResize;
  124329. /**
  124330. * Creates a new virtual joystick
  124331. * @param leftJoystick defines that the joystick is for left hand (false by default)
  124332. * @param customizations Defines the options we want to customize the VirtualJoystick
  124333. */
  124334. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  124335. /**
  124336. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  124337. * @param newJoystickSensibility defines the new sensibility
  124338. */
  124339. setJoystickSensibility(newJoystickSensibility: number): void;
  124340. private _onPointerDown;
  124341. private _onPointerMove;
  124342. private _onPointerUp;
  124343. /**
  124344. * Change the color of the virtual joystick
  124345. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  124346. */
  124347. setJoystickColor(newColor: string): void;
  124348. /**
  124349. * Size of the joystick's container
  124350. */
  124351. set containerSize(newSize: number);
  124352. get containerSize(): number;
  124353. /**
  124354. * Size of the joystick's puck
  124355. */
  124356. set puckSize(newSize: number);
  124357. get puckSize(): number;
  124358. /**
  124359. * Clears the set position of the joystick
  124360. */
  124361. clearPosition(): void;
  124362. /**
  124363. * Defines whether or not the joystick container is always visible
  124364. */
  124365. set alwaysVisible(value: boolean);
  124366. get alwaysVisible(): boolean;
  124367. /**
  124368. * Sets the constant position of the Joystick container
  124369. * @param x X axis coordinate
  124370. * @param y Y axis coordinate
  124371. */
  124372. setPosition(x: number, y: number): void;
  124373. /**
  124374. * Defines a callback to call when the joystick is touched
  124375. * @param action defines the callback
  124376. */
  124377. setActionOnTouch(action: () => any): void;
  124378. /**
  124379. * Defines which axis you'd like to control for left & right
  124380. * @param axis defines the axis to use
  124381. */
  124382. setAxisForLeftRight(axis: JoystickAxis): void;
  124383. /**
  124384. * Defines which axis you'd like to control for up & down
  124385. * @param axis defines the axis to use
  124386. */
  124387. setAxisForUpDown(axis: JoystickAxis): void;
  124388. /**
  124389. * Clears the canvas from the previous puck / container draw
  124390. */
  124391. private _clearPreviousDraw;
  124392. /**
  124393. * Loads `urlPath` to be used for the container's image
  124394. * @param urlPath defines the urlPath of an image to use
  124395. */
  124396. setContainerImage(urlPath: string): void;
  124397. /**
  124398. * Loads `urlPath` to be used for the puck's image
  124399. * @param urlPath defines the urlPath of an image to use
  124400. */
  124401. setPuckImage(urlPath: string): void;
  124402. /**
  124403. * Draws the Virtual Joystick's container
  124404. */
  124405. private _drawContainer;
  124406. /**
  124407. * Draws the Virtual Joystick's puck
  124408. */
  124409. private _drawPuck;
  124410. private _drawVirtualJoystick;
  124411. /**
  124412. * Release internal HTML canvas
  124413. */
  124414. releaseCanvas(): void;
  124415. }
  124416. }
  124417. declare module BABYLON {
  124418. interface FreeCameraInputsManager {
  124419. /**
  124420. * Add virtual joystick input support to the input manager.
  124421. * @returns the current input manager
  124422. */
  124423. addVirtualJoystick(): FreeCameraInputsManager;
  124424. }
  124425. /**
  124426. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  124427. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124428. */
  124429. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  124430. /**
  124431. * Defines the camera the input is attached to.
  124432. */
  124433. camera: FreeCamera;
  124434. private _leftjoystick;
  124435. private _rightjoystick;
  124436. /**
  124437. * Gets the left stick of the virtual joystick.
  124438. * @returns The virtual Joystick
  124439. */
  124440. getLeftJoystick(): VirtualJoystick;
  124441. /**
  124442. * Gets the right stick of the virtual joystick.
  124443. * @returns The virtual Joystick
  124444. */
  124445. getRightJoystick(): VirtualJoystick;
  124446. /**
  124447. * Update the current camera state depending on the inputs that have been used this frame.
  124448. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  124449. */
  124450. checkInputs(): void;
  124451. /**
  124452. * Attach the input controls to a specific dom element to get the input from.
  124453. * @param element Defines the element the controls should be listened from
  124454. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124455. */
  124456. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124457. /**
  124458. * Detach the current controls from the specified dom element.
  124459. * @param element Defines the element to stop listening the inputs from
  124460. */
  124461. detachControl(element: Nullable<HTMLElement>): void;
  124462. /**
  124463. * Gets the class name of the current intput.
  124464. * @returns the class name
  124465. */
  124466. getClassName(): string;
  124467. /**
  124468. * Get the friendly name associated with the input class.
  124469. * @returns the input friendly name
  124470. */
  124471. getSimpleName(): string;
  124472. }
  124473. }
  124474. declare module BABYLON {
  124475. /**
  124476. * This represents a FPS type of camera controlled by touch.
  124477. * This is like a universal camera minus the Gamepad controls.
  124478. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  124479. */
  124480. export class TouchCamera extends FreeCamera {
  124481. /**
  124482. * Defines the touch sensibility for rotation.
  124483. * The higher the faster.
  124484. */
  124485. get touchAngularSensibility(): number;
  124486. set touchAngularSensibility(value: number);
  124487. /**
  124488. * Defines the touch sensibility for move.
  124489. * The higher the faster.
  124490. */
  124491. get touchMoveSensibility(): number;
  124492. set touchMoveSensibility(value: number);
  124493. /**
  124494. * Instantiates a new touch camera.
  124495. * This represents a FPS type of camera controlled by touch.
  124496. * This is like a universal camera minus the Gamepad controls.
  124497. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  124498. * @param name Define the name of the camera in the scene
  124499. * @param position Define the start position of the camera in the scene
  124500. * @param scene Define the scene the camera belongs to
  124501. */
  124502. constructor(name: string, position: Vector3, scene: Scene);
  124503. /**
  124504. * Gets the current object class name.
  124505. * @return the class name
  124506. */
  124507. getClassName(): string;
  124508. /** @hidden */
  124509. _setupInputs(): void;
  124510. }
  124511. }
  124512. declare module BABYLON {
  124513. /**
  124514. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  124515. * being tilted forward or back and left or right.
  124516. */
  124517. export class DeviceOrientationCamera extends FreeCamera {
  124518. private _initialQuaternion;
  124519. private _quaternionCache;
  124520. private _tmpDragQuaternion;
  124521. private _disablePointerInputWhenUsingDeviceOrientation;
  124522. /**
  124523. * Creates a new device orientation camera
  124524. * @param name The name of the camera
  124525. * @param position The start position camera
  124526. * @param scene The scene the camera belongs to
  124527. */
  124528. constructor(name: string, position: Vector3, scene: Scene);
  124529. /**
  124530. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  124531. */
  124532. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  124533. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  124534. private _dragFactor;
  124535. /**
  124536. * Enabled turning on the y axis when the orientation sensor is active
  124537. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  124538. */
  124539. enableHorizontalDragging(dragFactor?: number): void;
  124540. /**
  124541. * Gets the current instance class name ("DeviceOrientationCamera").
  124542. * This helps avoiding instanceof at run time.
  124543. * @returns the class name
  124544. */
  124545. getClassName(): string;
  124546. /**
  124547. * @hidden
  124548. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  124549. */
  124550. _checkInputs(): void;
  124551. /**
  124552. * Reset the camera to its default orientation on the specified axis only.
  124553. * @param axis The axis to reset
  124554. */
  124555. resetToCurrentRotation(axis?: Axis): void;
  124556. }
  124557. }
  124558. declare module BABYLON {
  124559. /**
  124560. * Defines supported buttons for XBox360 compatible gamepads
  124561. */
  124562. export enum Xbox360Button {
  124563. /** A */
  124564. A = 0,
  124565. /** B */
  124566. B = 1,
  124567. /** X */
  124568. X = 2,
  124569. /** Y */
  124570. Y = 3,
  124571. /** Left button */
  124572. LB = 4,
  124573. /** Right button */
  124574. RB = 5,
  124575. /** Back */
  124576. Back = 8,
  124577. /** Start */
  124578. Start = 9,
  124579. /** Left stick */
  124580. LeftStick = 10,
  124581. /** Right stick */
  124582. RightStick = 11
  124583. }
  124584. /** Defines values for XBox360 DPad */
  124585. export enum Xbox360Dpad {
  124586. /** Up */
  124587. Up = 12,
  124588. /** Down */
  124589. Down = 13,
  124590. /** Left */
  124591. Left = 14,
  124592. /** Right */
  124593. Right = 15
  124594. }
  124595. /**
  124596. * Defines a XBox360 gamepad
  124597. */
  124598. export class Xbox360Pad extends Gamepad {
  124599. private _leftTrigger;
  124600. private _rightTrigger;
  124601. private _onlefttriggerchanged;
  124602. private _onrighttriggerchanged;
  124603. private _onbuttondown;
  124604. private _onbuttonup;
  124605. private _ondpaddown;
  124606. private _ondpadup;
  124607. /** Observable raised when a button is pressed */
  124608. onButtonDownObservable: Observable<Xbox360Button>;
  124609. /** Observable raised when a button is released */
  124610. onButtonUpObservable: Observable<Xbox360Button>;
  124611. /** Observable raised when a pad is pressed */
  124612. onPadDownObservable: Observable<Xbox360Dpad>;
  124613. /** Observable raised when a pad is released */
  124614. onPadUpObservable: Observable<Xbox360Dpad>;
  124615. private _buttonA;
  124616. private _buttonB;
  124617. private _buttonX;
  124618. private _buttonY;
  124619. private _buttonBack;
  124620. private _buttonStart;
  124621. private _buttonLB;
  124622. private _buttonRB;
  124623. private _buttonLeftStick;
  124624. private _buttonRightStick;
  124625. private _dPadUp;
  124626. private _dPadDown;
  124627. private _dPadLeft;
  124628. private _dPadRight;
  124629. private _isXboxOnePad;
  124630. /**
  124631. * Creates a new XBox360 gamepad object
  124632. * @param id defines the id of this gamepad
  124633. * @param index defines its index
  124634. * @param gamepad defines the internal HTML gamepad object
  124635. * @param xboxOne defines if it is a XBox One gamepad
  124636. */
  124637. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  124638. /**
  124639. * Defines the callback to call when left trigger is pressed
  124640. * @param callback defines the callback to use
  124641. */
  124642. onlefttriggerchanged(callback: (value: number) => void): void;
  124643. /**
  124644. * Defines the callback to call when right trigger is pressed
  124645. * @param callback defines the callback to use
  124646. */
  124647. onrighttriggerchanged(callback: (value: number) => void): void;
  124648. /**
  124649. * Gets the left trigger value
  124650. */
  124651. get leftTrigger(): number;
  124652. /**
  124653. * Sets the left trigger value
  124654. */
  124655. set leftTrigger(newValue: number);
  124656. /**
  124657. * Gets the right trigger value
  124658. */
  124659. get rightTrigger(): number;
  124660. /**
  124661. * Sets the right trigger value
  124662. */
  124663. set rightTrigger(newValue: number);
  124664. /**
  124665. * Defines the callback to call when a button is pressed
  124666. * @param callback defines the callback to use
  124667. */
  124668. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  124669. /**
  124670. * Defines the callback to call when a button is released
  124671. * @param callback defines the callback to use
  124672. */
  124673. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  124674. /**
  124675. * Defines the callback to call when a pad is pressed
  124676. * @param callback defines the callback to use
  124677. */
  124678. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  124679. /**
  124680. * Defines the callback to call when a pad is released
  124681. * @param callback defines the callback to use
  124682. */
  124683. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  124684. private _setButtonValue;
  124685. private _setDPadValue;
  124686. /**
  124687. * Gets the value of the `A` button
  124688. */
  124689. get buttonA(): number;
  124690. /**
  124691. * Sets the value of the `A` button
  124692. */
  124693. set buttonA(value: number);
  124694. /**
  124695. * Gets the value of the `B` button
  124696. */
  124697. get buttonB(): number;
  124698. /**
  124699. * Sets the value of the `B` button
  124700. */
  124701. set buttonB(value: number);
  124702. /**
  124703. * Gets the value of the `X` button
  124704. */
  124705. get buttonX(): number;
  124706. /**
  124707. * Sets the value of the `X` button
  124708. */
  124709. set buttonX(value: number);
  124710. /**
  124711. * Gets the value of the `Y` button
  124712. */
  124713. get buttonY(): number;
  124714. /**
  124715. * Sets the value of the `Y` button
  124716. */
  124717. set buttonY(value: number);
  124718. /**
  124719. * Gets the value of the `Start` button
  124720. */
  124721. get buttonStart(): number;
  124722. /**
  124723. * Sets the value of the `Start` button
  124724. */
  124725. set buttonStart(value: number);
  124726. /**
  124727. * Gets the value of the `Back` button
  124728. */
  124729. get buttonBack(): number;
  124730. /**
  124731. * Sets the value of the `Back` button
  124732. */
  124733. set buttonBack(value: number);
  124734. /**
  124735. * Gets the value of the `Left` button
  124736. */
  124737. get buttonLB(): number;
  124738. /**
  124739. * Sets the value of the `Left` button
  124740. */
  124741. set buttonLB(value: number);
  124742. /**
  124743. * Gets the value of the `Right` button
  124744. */
  124745. get buttonRB(): number;
  124746. /**
  124747. * Sets the value of the `Right` button
  124748. */
  124749. set buttonRB(value: number);
  124750. /**
  124751. * Gets the value of the Left joystick
  124752. */
  124753. get buttonLeftStick(): number;
  124754. /**
  124755. * Sets the value of the Left joystick
  124756. */
  124757. set buttonLeftStick(value: number);
  124758. /**
  124759. * Gets the value of the Right joystick
  124760. */
  124761. get buttonRightStick(): number;
  124762. /**
  124763. * Sets the value of the Right joystick
  124764. */
  124765. set buttonRightStick(value: number);
  124766. /**
  124767. * Gets the value of D-pad up
  124768. */
  124769. get dPadUp(): number;
  124770. /**
  124771. * Sets the value of D-pad up
  124772. */
  124773. set dPadUp(value: number);
  124774. /**
  124775. * Gets the value of D-pad down
  124776. */
  124777. get dPadDown(): number;
  124778. /**
  124779. * Sets the value of D-pad down
  124780. */
  124781. set dPadDown(value: number);
  124782. /**
  124783. * Gets the value of D-pad left
  124784. */
  124785. get dPadLeft(): number;
  124786. /**
  124787. * Sets the value of D-pad left
  124788. */
  124789. set dPadLeft(value: number);
  124790. /**
  124791. * Gets the value of D-pad right
  124792. */
  124793. get dPadRight(): number;
  124794. /**
  124795. * Sets the value of D-pad right
  124796. */
  124797. set dPadRight(value: number);
  124798. /**
  124799. * Force the gamepad to synchronize with device values
  124800. */
  124801. update(): void;
  124802. /**
  124803. * Disposes the gamepad
  124804. */
  124805. dispose(): void;
  124806. }
  124807. }
  124808. declare module BABYLON {
  124809. /**
  124810. * Defines supported buttons for DualShock compatible gamepads
  124811. */
  124812. export enum DualShockButton {
  124813. /** Cross */
  124814. Cross = 0,
  124815. /** Circle */
  124816. Circle = 1,
  124817. /** Square */
  124818. Square = 2,
  124819. /** Triangle */
  124820. Triangle = 3,
  124821. /** L1 */
  124822. L1 = 4,
  124823. /** R1 */
  124824. R1 = 5,
  124825. /** Share */
  124826. Share = 8,
  124827. /** Options */
  124828. Options = 9,
  124829. /** Left stick */
  124830. LeftStick = 10,
  124831. /** Right stick */
  124832. RightStick = 11
  124833. }
  124834. /** Defines values for DualShock DPad */
  124835. export enum DualShockDpad {
  124836. /** Up */
  124837. Up = 12,
  124838. /** Down */
  124839. Down = 13,
  124840. /** Left */
  124841. Left = 14,
  124842. /** Right */
  124843. Right = 15
  124844. }
  124845. /**
  124846. * Defines a DualShock gamepad
  124847. */
  124848. export class DualShockPad extends Gamepad {
  124849. private _leftTrigger;
  124850. private _rightTrigger;
  124851. private _onlefttriggerchanged;
  124852. private _onrighttriggerchanged;
  124853. private _onbuttondown;
  124854. private _onbuttonup;
  124855. private _ondpaddown;
  124856. private _ondpadup;
  124857. /** Observable raised when a button is pressed */
  124858. onButtonDownObservable: Observable<DualShockButton>;
  124859. /** Observable raised when a button is released */
  124860. onButtonUpObservable: Observable<DualShockButton>;
  124861. /** Observable raised when a pad is pressed */
  124862. onPadDownObservable: Observable<DualShockDpad>;
  124863. /** Observable raised when a pad is released */
  124864. onPadUpObservable: Observable<DualShockDpad>;
  124865. private _buttonCross;
  124866. private _buttonCircle;
  124867. private _buttonSquare;
  124868. private _buttonTriangle;
  124869. private _buttonShare;
  124870. private _buttonOptions;
  124871. private _buttonL1;
  124872. private _buttonR1;
  124873. private _buttonLeftStick;
  124874. private _buttonRightStick;
  124875. private _dPadUp;
  124876. private _dPadDown;
  124877. private _dPadLeft;
  124878. private _dPadRight;
  124879. /**
  124880. * Creates a new DualShock gamepad object
  124881. * @param id defines the id of this gamepad
  124882. * @param index defines its index
  124883. * @param gamepad defines the internal HTML gamepad object
  124884. */
  124885. constructor(id: string, index: number, gamepad: any);
  124886. /**
  124887. * Defines the callback to call when left trigger is pressed
  124888. * @param callback defines the callback to use
  124889. */
  124890. onlefttriggerchanged(callback: (value: number) => void): void;
  124891. /**
  124892. * Defines the callback to call when right trigger is pressed
  124893. * @param callback defines the callback to use
  124894. */
  124895. onrighttriggerchanged(callback: (value: number) => void): void;
  124896. /**
  124897. * Gets the left trigger value
  124898. */
  124899. get leftTrigger(): number;
  124900. /**
  124901. * Sets the left trigger value
  124902. */
  124903. set leftTrigger(newValue: number);
  124904. /**
  124905. * Gets the right trigger value
  124906. */
  124907. get rightTrigger(): number;
  124908. /**
  124909. * Sets the right trigger value
  124910. */
  124911. set rightTrigger(newValue: number);
  124912. /**
  124913. * Defines the callback to call when a button is pressed
  124914. * @param callback defines the callback to use
  124915. */
  124916. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  124917. /**
  124918. * Defines the callback to call when a button is released
  124919. * @param callback defines the callback to use
  124920. */
  124921. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  124922. /**
  124923. * Defines the callback to call when a pad is pressed
  124924. * @param callback defines the callback to use
  124925. */
  124926. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  124927. /**
  124928. * Defines the callback to call when a pad is released
  124929. * @param callback defines the callback to use
  124930. */
  124931. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  124932. private _setButtonValue;
  124933. private _setDPadValue;
  124934. /**
  124935. * Gets the value of the `Cross` button
  124936. */
  124937. get buttonCross(): number;
  124938. /**
  124939. * Sets the value of the `Cross` button
  124940. */
  124941. set buttonCross(value: number);
  124942. /**
  124943. * Gets the value of the `Circle` button
  124944. */
  124945. get buttonCircle(): number;
  124946. /**
  124947. * Sets the value of the `Circle` button
  124948. */
  124949. set buttonCircle(value: number);
  124950. /**
  124951. * Gets the value of the `Square` button
  124952. */
  124953. get buttonSquare(): number;
  124954. /**
  124955. * Sets the value of the `Square` button
  124956. */
  124957. set buttonSquare(value: number);
  124958. /**
  124959. * Gets the value of the `Triangle` button
  124960. */
  124961. get buttonTriangle(): number;
  124962. /**
  124963. * Sets the value of the `Triangle` button
  124964. */
  124965. set buttonTriangle(value: number);
  124966. /**
  124967. * Gets the value of the `Options` button
  124968. */
  124969. get buttonOptions(): number;
  124970. /**
  124971. * Sets the value of the `Options` button
  124972. */
  124973. set buttonOptions(value: number);
  124974. /**
  124975. * Gets the value of the `Share` button
  124976. */
  124977. get buttonShare(): number;
  124978. /**
  124979. * Sets the value of the `Share` button
  124980. */
  124981. set buttonShare(value: number);
  124982. /**
  124983. * Gets the value of the `L1` button
  124984. */
  124985. get buttonL1(): number;
  124986. /**
  124987. * Sets the value of the `L1` button
  124988. */
  124989. set buttonL1(value: number);
  124990. /**
  124991. * Gets the value of the `R1` button
  124992. */
  124993. get buttonR1(): number;
  124994. /**
  124995. * Sets the value of the `R1` button
  124996. */
  124997. set buttonR1(value: number);
  124998. /**
  124999. * Gets the value of the Left joystick
  125000. */
  125001. get buttonLeftStick(): number;
  125002. /**
  125003. * Sets the value of the Left joystick
  125004. */
  125005. set buttonLeftStick(value: number);
  125006. /**
  125007. * Gets the value of the Right joystick
  125008. */
  125009. get buttonRightStick(): number;
  125010. /**
  125011. * Sets the value of the Right joystick
  125012. */
  125013. set buttonRightStick(value: number);
  125014. /**
  125015. * Gets the value of D-pad up
  125016. */
  125017. get dPadUp(): number;
  125018. /**
  125019. * Sets the value of D-pad up
  125020. */
  125021. set dPadUp(value: number);
  125022. /**
  125023. * Gets the value of D-pad down
  125024. */
  125025. get dPadDown(): number;
  125026. /**
  125027. * Sets the value of D-pad down
  125028. */
  125029. set dPadDown(value: number);
  125030. /**
  125031. * Gets the value of D-pad left
  125032. */
  125033. get dPadLeft(): number;
  125034. /**
  125035. * Sets the value of D-pad left
  125036. */
  125037. set dPadLeft(value: number);
  125038. /**
  125039. * Gets the value of D-pad right
  125040. */
  125041. get dPadRight(): number;
  125042. /**
  125043. * Sets the value of D-pad right
  125044. */
  125045. set dPadRight(value: number);
  125046. /**
  125047. * Force the gamepad to synchronize with device values
  125048. */
  125049. update(): void;
  125050. /**
  125051. * Disposes the gamepad
  125052. */
  125053. dispose(): void;
  125054. }
  125055. }
  125056. declare module BABYLON {
  125057. /**
  125058. * Manager for handling gamepads
  125059. */
  125060. export class GamepadManager {
  125061. private _scene?;
  125062. private _babylonGamepads;
  125063. private _oneGamepadConnected;
  125064. /** @hidden */
  125065. _isMonitoring: boolean;
  125066. private _gamepadEventSupported;
  125067. private _gamepadSupport?;
  125068. /**
  125069. * observable to be triggered when the gamepad controller has been connected
  125070. */
  125071. onGamepadConnectedObservable: Observable<Gamepad>;
  125072. /**
  125073. * observable to be triggered when the gamepad controller has been disconnected
  125074. */
  125075. onGamepadDisconnectedObservable: Observable<Gamepad>;
  125076. private _onGamepadConnectedEvent;
  125077. private _onGamepadDisconnectedEvent;
  125078. /**
  125079. * Initializes the gamepad manager
  125080. * @param _scene BabylonJS scene
  125081. */
  125082. constructor(_scene?: Scene | undefined);
  125083. /**
  125084. * The gamepads in the game pad manager
  125085. */
  125086. get gamepads(): Gamepad[];
  125087. /**
  125088. * Get the gamepad controllers based on type
  125089. * @param type The type of gamepad controller
  125090. * @returns Nullable gamepad
  125091. */
  125092. getGamepadByType(type?: number): Nullable<Gamepad>;
  125093. /**
  125094. * Disposes the gamepad manager
  125095. */
  125096. dispose(): void;
  125097. private _addNewGamepad;
  125098. private _startMonitoringGamepads;
  125099. private _stopMonitoringGamepads;
  125100. /** @hidden */
  125101. _checkGamepadsStatus(): void;
  125102. private _updateGamepadObjects;
  125103. }
  125104. }
  125105. declare module BABYLON {
  125106. interface Scene {
  125107. /** @hidden */
  125108. _gamepadManager: Nullable<GamepadManager>;
  125109. /**
  125110. * Gets the gamepad manager associated with the scene
  125111. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  125112. */
  125113. gamepadManager: GamepadManager;
  125114. }
  125115. /**
  125116. * Interface representing a free camera inputs manager
  125117. */
  125118. interface FreeCameraInputsManager {
  125119. /**
  125120. * Adds gamepad input support to the FreeCameraInputsManager.
  125121. * @returns the FreeCameraInputsManager
  125122. */
  125123. addGamepad(): FreeCameraInputsManager;
  125124. }
  125125. /**
  125126. * Interface representing an arc rotate camera inputs manager
  125127. */
  125128. interface ArcRotateCameraInputsManager {
  125129. /**
  125130. * Adds gamepad input support to the ArcRotateCamera InputManager.
  125131. * @returns the camera inputs manager
  125132. */
  125133. addGamepad(): ArcRotateCameraInputsManager;
  125134. }
  125135. /**
  125136. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  125137. */
  125138. export class GamepadSystemSceneComponent implements ISceneComponent {
  125139. /**
  125140. * The component name helpfull to identify the component in the list of scene components.
  125141. */
  125142. readonly name: string;
  125143. /**
  125144. * The scene the component belongs to.
  125145. */
  125146. scene: Scene;
  125147. /**
  125148. * Creates a new instance of the component for the given scene
  125149. * @param scene Defines the scene to register the component in
  125150. */
  125151. constructor(scene: Scene);
  125152. /**
  125153. * Registers the component in a given scene
  125154. */
  125155. register(): void;
  125156. /**
  125157. * Rebuilds the elements related to this component in case of
  125158. * context lost for instance.
  125159. */
  125160. rebuild(): void;
  125161. /**
  125162. * Disposes the component and the associated ressources
  125163. */
  125164. dispose(): void;
  125165. private _beforeCameraUpdate;
  125166. }
  125167. }
  125168. declare module BABYLON {
  125169. /**
  125170. * 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,
  125171. * which still works and will still be found in many Playgrounds.
  125172. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  125173. */
  125174. export class UniversalCamera extends TouchCamera {
  125175. /**
  125176. * Defines the gamepad rotation sensiblity.
  125177. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  125178. */
  125179. get gamepadAngularSensibility(): number;
  125180. set gamepadAngularSensibility(value: number);
  125181. /**
  125182. * Defines the gamepad move sensiblity.
  125183. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  125184. */
  125185. get gamepadMoveSensibility(): number;
  125186. set gamepadMoveSensibility(value: number);
  125187. /**
  125188. * 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,
  125189. * which still works and will still be found in many Playgrounds.
  125190. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  125191. * @param name Define the name of the camera in the scene
  125192. * @param position Define the start position of the camera in the scene
  125193. * @param scene Define the scene the camera belongs to
  125194. */
  125195. constructor(name: string, position: Vector3, scene: Scene);
  125196. /**
  125197. * Gets the current object class name.
  125198. * @return the class name
  125199. */
  125200. getClassName(): string;
  125201. }
  125202. }
  125203. declare module BABYLON {
  125204. /**
  125205. * This represents a FPS type of camera. This is only here for back compat purpose.
  125206. * Please use the UniversalCamera instead as both are identical.
  125207. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  125208. */
  125209. export class GamepadCamera extends UniversalCamera {
  125210. /**
  125211. * Instantiates a new Gamepad Camera
  125212. * This represents a FPS type of camera. This is only here for back compat purpose.
  125213. * Please use the UniversalCamera instead as both are identical.
  125214. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  125215. * @param name Define the name of the camera in the scene
  125216. * @param position Define the start position of the camera in the scene
  125217. * @param scene Define the scene the camera belongs to
  125218. */
  125219. constructor(name: string, position: Vector3, scene: Scene);
  125220. /**
  125221. * Gets the current object class name.
  125222. * @return the class name
  125223. */
  125224. getClassName(): string;
  125225. }
  125226. }
  125227. declare module BABYLON {
  125228. /** @hidden */
  125229. export var passPixelShader: {
  125230. name: string;
  125231. shader: string;
  125232. };
  125233. }
  125234. declare module BABYLON {
  125235. /** @hidden */
  125236. export var passCubePixelShader: {
  125237. name: string;
  125238. shader: string;
  125239. };
  125240. }
  125241. declare module BABYLON {
  125242. /**
  125243. * PassPostProcess which produces an output the same as it's input
  125244. */
  125245. export class PassPostProcess extends PostProcess {
  125246. /**
  125247. * Gets a string identifying the name of the class
  125248. * @returns "PassPostProcess" string
  125249. */
  125250. getClassName(): string;
  125251. /**
  125252. * Creates the PassPostProcess
  125253. * @param name The name of the effect.
  125254. * @param options The required width/height ratio to downsize to before computing the render pass.
  125255. * @param camera The camera to apply the render pass to.
  125256. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125257. * @param engine The engine which the post process will be applied. (default: current engine)
  125258. * @param reusable If the post process can be reused on the same frame. (default: false)
  125259. * @param textureType The type of texture to be used when performing the post processing.
  125260. * @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)
  125261. */
  125262. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125263. /** @hidden */
  125264. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  125265. }
  125266. /**
  125267. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  125268. */
  125269. export class PassCubePostProcess extends PostProcess {
  125270. private _face;
  125271. /**
  125272. * Gets or sets the cube face to display.
  125273. * * 0 is +X
  125274. * * 1 is -X
  125275. * * 2 is +Y
  125276. * * 3 is -Y
  125277. * * 4 is +Z
  125278. * * 5 is -Z
  125279. */
  125280. get face(): number;
  125281. set face(value: number);
  125282. /**
  125283. * Gets a string identifying the name of the class
  125284. * @returns "PassCubePostProcess" string
  125285. */
  125286. getClassName(): string;
  125287. /**
  125288. * Creates the PassCubePostProcess
  125289. * @param name The name of the effect.
  125290. * @param options The required width/height ratio to downsize to before computing the render pass.
  125291. * @param camera The camera to apply the render pass to.
  125292. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125293. * @param engine The engine which the post process will be applied. (default: current engine)
  125294. * @param reusable If the post process can be reused on the same frame. (default: false)
  125295. * @param textureType The type of texture to be used when performing the post processing.
  125296. * @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)
  125297. */
  125298. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125299. /** @hidden */
  125300. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  125301. }
  125302. }
  125303. declare module BABYLON {
  125304. /** @hidden */
  125305. export var anaglyphPixelShader: {
  125306. name: string;
  125307. shader: string;
  125308. };
  125309. }
  125310. declare module BABYLON {
  125311. /**
  125312. * Postprocess used to generate anaglyphic rendering
  125313. */
  125314. export class AnaglyphPostProcess extends PostProcess {
  125315. private _passedProcess;
  125316. /**
  125317. * Gets a string identifying the name of the class
  125318. * @returns "AnaglyphPostProcess" string
  125319. */
  125320. getClassName(): string;
  125321. /**
  125322. * Creates a new AnaglyphPostProcess
  125323. * @param name defines postprocess name
  125324. * @param options defines creation options or target ratio scale
  125325. * @param rigCameras defines cameras using this postprocess
  125326. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  125327. * @param engine defines hosting engine
  125328. * @param reusable defines if the postprocess will be reused multiple times per frame
  125329. */
  125330. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  125331. }
  125332. }
  125333. declare module BABYLON {
  125334. /**
  125335. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  125336. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  125337. */
  125338. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  125339. /**
  125340. * Creates a new AnaglyphArcRotateCamera
  125341. * @param name defines camera name
  125342. * @param alpha defines alpha angle (in radians)
  125343. * @param beta defines beta angle (in radians)
  125344. * @param radius defines radius
  125345. * @param target defines camera target
  125346. * @param interaxialDistance defines distance between each color axis
  125347. * @param scene defines the hosting scene
  125348. */
  125349. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  125350. /**
  125351. * Gets camera class name
  125352. * @returns AnaglyphArcRotateCamera
  125353. */
  125354. getClassName(): string;
  125355. }
  125356. }
  125357. declare module BABYLON {
  125358. /**
  125359. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  125360. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  125361. */
  125362. export class AnaglyphFreeCamera extends FreeCamera {
  125363. /**
  125364. * Creates a new AnaglyphFreeCamera
  125365. * @param name defines camera name
  125366. * @param position defines initial position
  125367. * @param interaxialDistance defines distance between each color axis
  125368. * @param scene defines the hosting scene
  125369. */
  125370. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  125371. /**
  125372. * Gets camera class name
  125373. * @returns AnaglyphFreeCamera
  125374. */
  125375. getClassName(): string;
  125376. }
  125377. }
  125378. declare module BABYLON {
  125379. /**
  125380. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  125381. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  125382. */
  125383. export class AnaglyphGamepadCamera extends GamepadCamera {
  125384. /**
  125385. * Creates a new AnaglyphGamepadCamera
  125386. * @param name defines camera name
  125387. * @param position defines initial position
  125388. * @param interaxialDistance defines distance between each color axis
  125389. * @param scene defines the hosting scene
  125390. */
  125391. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  125392. /**
  125393. * Gets camera class name
  125394. * @returns AnaglyphGamepadCamera
  125395. */
  125396. getClassName(): string;
  125397. }
  125398. }
  125399. declare module BABYLON {
  125400. /**
  125401. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  125402. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  125403. */
  125404. export class AnaglyphUniversalCamera extends UniversalCamera {
  125405. /**
  125406. * Creates a new AnaglyphUniversalCamera
  125407. * @param name defines camera name
  125408. * @param position defines initial position
  125409. * @param interaxialDistance defines distance between each color axis
  125410. * @param scene defines the hosting scene
  125411. */
  125412. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  125413. /**
  125414. * Gets camera class name
  125415. * @returns AnaglyphUniversalCamera
  125416. */
  125417. getClassName(): string;
  125418. }
  125419. }
  125420. declare module BABYLON {
  125421. /**
  125422. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  125423. * @see https://doc.babylonjs.com/features/cameras
  125424. */
  125425. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  125426. /**
  125427. * Creates a new StereoscopicArcRotateCamera
  125428. * @param name defines camera name
  125429. * @param alpha defines alpha angle (in radians)
  125430. * @param beta defines beta angle (in radians)
  125431. * @param radius defines radius
  125432. * @param target defines camera target
  125433. * @param interaxialDistance defines distance between each color axis
  125434. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  125435. * @param scene defines the hosting scene
  125436. */
  125437. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  125438. /**
  125439. * Gets camera class name
  125440. * @returns StereoscopicArcRotateCamera
  125441. */
  125442. getClassName(): string;
  125443. }
  125444. }
  125445. declare module BABYLON {
  125446. /**
  125447. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  125448. * @see https://doc.babylonjs.com/features/cameras
  125449. */
  125450. export class StereoscopicFreeCamera extends FreeCamera {
  125451. /**
  125452. * Creates a new StereoscopicFreeCamera
  125453. * @param name defines camera name
  125454. * @param position defines initial position
  125455. * @param interaxialDistance defines distance between each color axis
  125456. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  125457. * @param scene defines the hosting scene
  125458. */
  125459. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  125460. /**
  125461. * Gets camera class name
  125462. * @returns StereoscopicFreeCamera
  125463. */
  125464. getClassName(): string;
  125465. }
  125466. }
  125467. declare module BABYLON {
  125468. /**
  125469. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  125470. * @see https://doc.babylonjs.com/features/cameras
  125471. */
  125472. export class StereoscopicGamepadCamera extends GamepadCamera {
  125473. /**
  125474. * Creates a new StereoscopicGamepadCamera
  125475. * @param name defines camera name
  125476. * @param position defines initial position
  125477. * @param interaxialDistance defines distance between each color axis
  125478. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  125479. * @param scene defines the hosting scene
  125480. */
  125481. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  125482. /**
  125483. * Gets camera class name
  125484. * @returns StereoscopicGamepadCamera
  125485. */
  125486. getClassName(): string;
  125487. }
  125488. }
  125489. declare module BABYLON {
  125490. /**
  125491. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  125492. * @see https://doc.babylonjs.com/features/cameras
  125493. */
  125494. export class StereoscopicUniversalCamera extends UniversalCamera {
  125495. /**
  125496. * Creates a new StereoscopicUniversalCamera
  125497. * @param name defines camera name
  125498. * @param position defines initial position
  125499. * @param interaxialDistance defines distance between each color axis
  125500. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  125501. * @param scene defines the hosting scene
  125502. */
  125503. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  125504. /**
  125505. * Gets camera class name
  125506. * @returns StereoscopicUniversalCamera
  125507. */
  125508. getClassName(): string;
  125509. }
  125510. }
  125511. declare module BABYLON {
  125512. /**
  125513. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  125514. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  125515. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  125516. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  125517. */
  125518. export class VirtualJoysticksCamera extends FreeCamera {
  125519. /**
  125520. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  125521. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  125522. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  125523. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  125524. * @param name Define the name of the camera in the scene
  125525. * @param position Define the start position of the camera in the scene
  125526. * @param scene Define the scene the camera belongs to
  125527. */
  125528. constructor(name: string, position: Vector3, scene: Scene);
  125529. /**
  125530. * Gets the current object class name.
  125531. * @return the class name
  125532. */
  125533. getClassName(): string;
  125534. }
  125535. }
  125536. declare module BABYLON {
  125537. /**
  125538. * This represents all the required metrics to create a VR camera.
  125539. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  125540. */
  125541. export class VRCameraMetrics {
  125542. /**
  125543. * Define the horizontal resolution off the screen.
  125544. */
  125545. hResolution: number;
  125546. /**
  125547. * Define the vertical resolution off the screen.
  125548. */
  125549. vResolution: number;
  125550. /**
  125551. * Define the horizontal screen size.
  125552. */
  125553. hScreenSize: number;
  125554. /**
  125555. * Define the vertical screen size.
  125556. */
  125557. vScreenSize: number;
  125558. /**
  125559. * Define the vertical screen center position.
  125560. */
  125561. vScreenCenter: number;
  125562. /**
  125563. * Define the distance of the eyes to the screen.
  125564. */
  125565. eyeToScreenDistance: number;
  125566. /**
  125567. * Define the distance between both lenses
  125568. */
  125569. lensSeparationDistance: number;
  125570. /**
  125571. * Define the distance between both viewer's eyes.
  125572. */
  125573. interpupillaryDistance: number;
  125574. /**
  125575. * Define the distortion factor of the VR postprocess.
  125576. * Please, touch with care.
  125577. */
  125578. distortionK: number[];
  125579. /**
  125580. * Define the chromatic aberration correction factors for the VR post process.
  125581. */
  125582. chromaAbCorrection: number[];
  125583. /**
  125584. * Define the scale factor of the post process.
  125585. * The smaller the better but the slower.
  125586. */
  125587. postProcessScaleFactor: number;
  125588. /**
  125589. * Define an offset for the lens center.
  125590. */
  125591. lensCenterOffset: number;
  125592. /**
  125593. * Define if the current vr camera should compensate the distortion of the lense or not.
  125594. */
  125595. compensateDistortion: boolean;
  125596. /**
  125597. * Defines if multiview should be enabled when rendering (Default: false)
  125598. */
  125599. multiviewEnabled: boolean;
  125600. /**
  125601. * Gets the rendering aspect ratio based on the provided resolutions.
  125602. */
  125603. get aspectRatio(): number;
  125604. /**
  125605. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  125606. */
  125607. get aspectRatioFov(): number;
  125608. /**
  125609. * @hidden
  125610. */
  125611. get leftHMatrix(): Matrix;
  125612. /**
  125613. * @hidden
  125614. */
  125615. get rightHMatrix(): Matrix;
  125616. /**
  125617. * @hidden
  125618. */
  125619. get leftPreViewMatrix(): Matrix;
  125620. /**
  125621. * @hidden
  125622. */
  125623. get rightPreViewMatrix(): Matrix;
  125624. /**
  125625. * Get the default VRMetrics based on the most generic setup.
  125626. * @returns the default vr metrics
  125627. */
  125628. static GetDefault(): VRCameraMetrics;
  125629. }
  125630. }
  125631. declare module BABYLON {
  125632. /** @hidden */
  125633. export var vrDistortionCorrectionPixelShader: {
  125634. name: string;
  125635. shader: string;
  125636. };
  125637. }
  125638. declare module BABYLON {
  125639. /**
  125640. * VRDistortionCorrectionPostProcess used for mobile VR
  125641. */
  125642. export class VRDistortionCorrectionPostProcess extends PostProcess {
  125643. private _isRightEye;
  125644. private _distortionFactors;
  125645. private _postProcessScaleFactor;
  125646. private _lensCenterOffset;
  125647. private _scaleIn;
  125648. private _scaleFactor;
  125649. private _lensCenter;
  125650. /**
  125651. * Gets a string identifying the name of the class
  125652. * @returns "VRDistortionCorrectionPostProcess" string
  125653. */
  125654. getClassName(): string;
  125655. /**
  125656. * Initializes the VRDistortionCorrectionPostProcess
  125657. * @param name The name of the effect.
  125658. * @param camera The camera to apply the render pass to.
  125659. * @param isRightEye If this is for the right eye distortion
  125660. * @param vrMetrics All the required metrics for the VR camera
  125661. */
  125662. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  125663. }
  125664. }
  125665. declare module BABYLON {
  125666. /**
  125667. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  125668. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  125669. */
  125670. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  125671. /**
  125672. * Creates a new VRDeviceOrientationArcRotateCamera
  125673. * @param name defines camera name
  125674. * @param alpha defines the camera rotation along the logitudinal axis
  125675. * @param beta defines the camera rotation along the latitudinal axis
  125676. * @param radius defines the camera distance from its target
  125677. * @param target defines the camera target
  125678. * @param scene defines the scene the camera belongs to
  125679. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  125680. * @param vrCameraMetrics defines the vr metrics associated to the camera
  125681. */
  125682. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  125683. /**
  125684. * Gets camera class name
  125685. * @returns VRDeviceOrientationArcRotateCamera
  125686. */
  125687. getClassName(): string;
  125688. }
  125689. }
  125690. declare module BABYLON {
  125691. /**
  125692. * Camera used to simulate VR rendering (based on FreeCamera)
  125693. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  125694. */
  125695. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  125696. /**
  125697. * Creates a new VRDeviceOrientationFreeCamera
  125698. * @param name defines camera name
  125699. * @param position defines the start position of the camera
  125700. * @param scene defines the scene the camera belongs to
  125701. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  125702. * @param vrCameraMetrics defines the vr metrics associated to the camera
  125703. */
  125704. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  125705. /**
  125706. * Gets camera class name
  125707. * @returns VRDeviceOrientationFreeCamera
  125708. */
  125709. getClassName(): string;
  125710. }
  125711. }
  125712. declare module BABYLON {
  125713. /**
  125714. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  125715. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  125716. */
  125717. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  125718. /**
  125719. * Creates a new VRDeviceOrientationGamepadCamera
  125720. * @param name defines camera name
  125721. * @param position defines the start position of the camera
  125722. * @param scene defines the scene the camera belongs to
  125723. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  125724. * @param vrCameraMetrics defines the vr metrics associated to the camera
  125725. */
  125726. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  125727. /**
  125728. * Gets camera class name
  125729. * @returns VRDeviceOrientationGamepadCamera
  125730. */
  125731. getClassName(): string;
  125732. }
  125733. }
  125734. declare module BABYLON {
  125735. /**
  125736. * A class extending Texture allowing drawing on a texture
  125737. * @see https://doc.babylonjs.com/how_to/dynamictexture
  125738. */
  125739. export class DynamicTexture extends Texture {
  125740. private _generateMipMaps;
  125741. private _canvas;
  125742. private _context;
  125743. /**
  125744. * Creates a DynamicTexture
  125745. * @param name defines the name of the texture
  125746. * @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
  125747. * @param scene defines the scene where you want the texture
  125748. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  125749. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  125750. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  125751. */
  125752. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  125753. /**
  125754. * Get the current class name of the texture useful for serialization or dynamic coding.
  125755. * @returns "DynamicTexture"
  125756. */
  125757. getClassName(): string;
  125758. /**
  125759. * Gets the current state of canRescale
  125760. */
  125761. get canRescale(): boolean;
  125762. private _recreate;
  125763. /**
  125764. * Scales the texture
  125765. * @param ratio the scale factor to apply to both width and height
  125766. */
  125767. scale(ratio: number): void;
  125768. /**
  125769. * Resizes the texture
  125770. * @param width the new width
  125771. * @param height the new height
  125772. */
  125773. scaleTo(width: number, height: number): void;
  125774. /**
  125775. * Gets the context of the canvas used by the texture
  125776. * @returns the canvas context of the dynamic texture
  125777. */
  125778. getContext(): CanvasRenderingContext2D;
  125779. /**
  125780. * Clears the texture
  125781. */
  125782. clear(): void;
  125783. /**
  125784. * Updates the texture
  125785. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  125786. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  125787. */
  125788. update(invertY?: boolean, premulAlpha?: boolean): void;
  125789. /**
  125790. * Draws text onto the texture
  125791. * @param text defines the text to be drawn
  125792. * @param x defines the placement of the text from the left
  125793. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  125794. * @param font defines the font to be used with font-style, font-size, font-name
  125795. * @param color defines the color used for the text
  125796. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  125797. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  125798. * @param update defines whether texture is immediately update (default is true)
  125799. */
  125800. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  125801. /**
  125802. * Clones the texture
  125803. * @returns the clone of the texture.
  125804. */
  125805. clone(): DynamicTexture;
  125806. /**
  125807. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  125808. * @returns a serialized dynamic texture object
  125809. */
  125810. serialize(): any;
  125811. private _IsCanvasElement;
  125812. /** @hidden */
  125813. _rebuild(): void;
  125814. }
  125815. }
  125816. declare module BABYLON {
  125817. /**
  125818. * Class containing static functions to help procedurally build meshes
  125819. */
  125820. export class GroundBuilder {
  125821. /**
  125822. * Creates a ground mesh
  125823. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  125824. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  125825. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125826. * @param name defines the name of the mesh
  125827. * @param options defines the options used to create the mesh
  125828. * @param scene defines the hosting scene
  125829. * @returns the ground mesh
  125830. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  125831. */
  125832. static CreateGround(name: string, options: {
  125833. width?: number;
  125834. height?: number;
  125835. subdivisions?: number;
  125836. subdivisionsX?: number;
  125837. subdivisionsY?: number;
  125838. updatable?: boolean;
  125839. }, scene: any): Mesh;
  125840. /**
  125841. * Creates a tiled ground mesh
  125842. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  125843. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  125844. * * 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
  125845. * * 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
  125846. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125847. * @param name defines the name of the mesh
  125848. * @param options defines the options used to create the mesh
  125849. * @param scene defines the hosting scene
  125850. * @returns the tiled ground mesh
  125851. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  125852. */
  125853. static CreateTiledGround(name: string, options: {
  125854. xmin: number;
  125855. zmin: number;
  125856. xmax: number;
  125857. zmax: number;
  125858. subdivisions?: {
  125859. w: number;
  125860. h: number;
  125861. };
  125862. precision?: {
  125863. w: number;
  125864. h: number;
  125865. };
  125866. updatable?: boolean;
  125867. }, scene?: Nullable<Scene>): Mesh;
  125868. /**
  125869. * Creates a ground mesh from a height map
  125870. * * The parameter `url` sets the URL of the height map image resource.
  125871. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  125872. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  125873. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  125874. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  125875. * * 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.
  125876. * * 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).
  125877. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  125878. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125879. * @param name defines the name of the mesh
  125880. * @param url defines the url to the height map
  125881. * @param options defines the options used to create the mesh
  125882. * @param scene defines the hosting scene
  125883. * @returns the ground mesh
  125884. * @see https://doc.babylonjs.com/babylon101/height_map
  125885. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  125886. */
  125887. static CreateGroundFromHeightMap(name: string, url: string, options: {
  125888. width?: number;
  125889. height?: number;
  125890. subdivisions?: number;
  125891. minHeight?: number;
  125892. maxHeight?: number;
  125893. colorFilter?: Color3;
  125894. alphaFilter?: number;
  125895. updatable?: boolean;
  125896. onReady?: (mesh: GroundMesh) => void;
  125897. }, scene?: Nullable<Scene>): GroundMesh;
  125898. }
  125899. }
  125900. declare module BABYLON {
  125901. /**
  125902. * Class containing static functions to help procedurally build meshes
  125903. */
  125904. export class TorusBuilder {
  125905. /**
  125906. * Creates a torus mesh
  125907. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  125908. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  125909. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  125910. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125911. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125912. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125913. * @param name defines the name of the mesh
  125914. * @param options defines the options used to create the mesh
  125915. * @param scene defines the hosting scene
  125916. * @returns the torus mesh
  125917. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  125918. */
  125919. static CreateTorus(name: string, options: {
  125920. diameter?: number;
  125921. thickness?: number;
  125922. tessellation?: number;
  125923. updatable?: boolean;
  125924. sideOrientation?: number;
  125925. frontUVs?: Vector4;
  125926. backUVs?: Vector4;
  125927. }, scene: any): Mesh;
  125928. }
  125929. }
  125930. declare module BABYLON {
  125931. /**
  125932. * Class containing static functions to help procedurally build meshes
  125933. */
  125934. export class CylinderBuilder {
  125935. /**
  125936. * Creates a cylinder or a cone mesh
  125937. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  125938. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  125939. * * 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.
  125940. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  125941. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  125942. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  125943. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  125944. * * 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).
  125945. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  125946. * * 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).
  125947. * * 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
  125948. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  125949. * * 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
  125950. * * 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.
  125951. * * If `enclose` is false, a ring surface is one element.
  125952. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  125953. * * 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
  125954. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125955. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125956. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125957. * @param name defines the name of the mesh
  125958. * @param options defines the options used to create the mesh
  125959. * @param scene defines the hosting scene
  125960. * @returns the cylinder mesh
  125961. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  125962. */
  125963. static CreateCylinder(name: string, options: {
  125964. height?: number;
  125965. diameterTop?: number;
  125966. diameterBottom?: number;
  125967. diameter?: number;
  125968. tessellation?: number;
  125969. subdivisions?: number;
  125970. arc?: number;
  125971. faceColors?: Color4[];
  125972. faceUV?: Vector4[];
  125973. updatable?: boolean;
  125974. hasRings?: boolean;
  125975. enclose?: boolean;
  125976. cap?: number;
  125977. sideOrientation?: number;
  125978. frontUVs?: Vector4;
  125979. backUVs?: Vector4;
  125980. }, scene: any): Mesh;
  125981. }
  125982. }
  125983. declare module BABYLON {
  125984. /**
  125985. * States of the webXR experience
  125986. */
  125987. export enum WebXRState {
  125988. /**
  125989. * Transitioning to being in XR mode
  125990. */
  125991. ENTERING_XR = 0,
  125992. /**
  125993. * Transitioning to non XR mode
  125994. */
  125995. EXITING_XR = 1,
  125996. /**
  125997. * In XR mode and presenting
  125998. */
  125999. IN_XR = 2,
  126000. /**
  126001. * Not entered XR mode
  126002. */
  126003. NOT_IN_XR = 3
  126004. }
  126005. /**
  126006. * Abstraction of the XR render target
  126007. */
  126008. export interface WebXRRenderTarget extends IDisposable {
  126009. /**
  126010. * xrpresent context of the canvas which can be used to display/mirror xr content
  126011. */
  126012. canvasContext: WebGLRenderingContext;
  126013. /**
  126014. * xr layer for the canvas
  126015. */
  126016. xrLayer: Nullable<XRWebGLLayer>;
  126017. /**
  126018. * Initializes the xr layer for the session
  126019. * @param xrSession xr session
  126020. * @returns a promise that will resolve once the XR Layer has been created
  126021. */
  126022. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  126023. }
  126024. }
  126025. declare module BABYLON {
  126026. /**
  126027. * COnfiguration object for WebXR output canvas
  126028. */
  126029. export class WebXRManagedOutputCanvasOptions {
  126030. /**
  126031. * An optional canvas in case you wish to create it yourself and provide it here.
  126032. * If not provided, a new canvas will be created
  126033. */
  126034. canvasElement?: HTMLCanvasElement;
  126035. /**
  126036. * Options for this XR Layer output
  126037. */
  126038. canvasOptions?: XRWebGLLayerOptions;
  126039. /**
  126040. * CSS styling for a newly created canvas (if not provided)
  126041. */
  126042. newCanvasCssStyle?: string;
  126043. /**
  126044. * Get the default values of the configuration object
  126045. * @returns default values of this configuration object
  126046. */
  126047. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  126048. }
  126049. /**
  126050. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  126051. */
  126052. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  126053. private _options;
  126054. private _canvas;
  126055. private _engine;
  126056. private _originalCanvasSize;
  126057. /**
  126058. * Rendering context of the canvas which can be used to display/mirror xr content
  126059. */
  126060. canvasContext: WebGLRenderingContext;
  126061. /**
  126062. * xr layer for the canvas
  126063. */
  126064. xrLayer: Nullable<XRWebGLLayer>;
  126065. /**
  126066. * Obseervers registered here will be triggered when the xr layer was initialized
  126067. */
  126068. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  126069. /**
  126070. * Initializes the canvas to be added/removed upon entering/exiting xr
  126071. * @param _xrSessionManager The XR Session manager
  126072. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  126073. */
  126074. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  126075. /**
  126076. * Disposes of the object
  126077. */
  126078. dispose(): void;
  126079. /**
  126080. * Initializes the xr layer for the session
  126081. * @param xrSession xr session
  126082. * @returns a promise that will resolve once the XR Layer has been created
  126083. */
  126084. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  126085. private _addCanvas;
  126086. private _removeCanvas;
  126087. private _setCanvasSize;
  126088. private _setManagedOutputCanvas;
  126089. }
  126090. }
  126091. declare module BABYLON {
  126092. /**
  126093. * Manages an XRSession to work with Babylon's engine
  126094. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  126095. */
  126096. export class WebXRSessionManager implements IDisposable {
  126097. /** The scene which the session should be created for */
  126098. scene: Scene;
  126099. private _referenceSpace;
  126100. private _rttProvider;
  126101. private _sessionEnded;
  126102. private _xrNavigator;
  126103. private baseLayer;
  126104. /**
  126105. * The base reference space from which the session started. good if you want to reset your
  126106. * reference space
  126107. */
  126108. baseReferenceSpace: XRReferenceSpace;
  126109. /**
  126110. * Current XR frame
  126111. */
  126112. currentFrame: Nullable<XRFrame>;
  126113. /** WebXR timestamp updated every frame */
  126114. currentTimestamp: number;
  126115. /**
  126116. * Used just in case of a failure to initialize an immersive session.
  126117. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  126118. */
  126119. defaultHeightCompensation: number;
  126120. /**
  126121. * Fires every time a new xrFrame arrives which can be used to update the camera
  126122. */
  126123. onXRFrameObservable: Observable<XRFrame>;
  126124. /**
  126125. * Fires when the reference space changed
  126126. */
  126127. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  126128. /**
  126129. * Fires when the xr session is ended either by the device or manually done
  126130. */
  126131. onXRSessionEnded: Observable<any>;
  126132. /**
  126133. * Fires when the xr session is ended either by the device or manually done
  126134. */
  126135. onXRSessionInit: Observable<XRSession>;
  126136. /**
  126137. * Underlying xr session
  126138. */
  126139. session: XRSession;
  126140. /**
  126141. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  126142. * or get the offset the player is currently at.
  126143. */
  126144. viewerReferenceSpace: XRReferenceSpace;
  126145. /**
  126146. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  126147. * @param scene The scene which the session should be created for
  126148. */
  126149. constructor(
  126150. /** The scene which the session should be created for */
  126151. scene: Scene);
  126152. /**
  126153. * The current reference space used in this session. This reference space can constantly change!
  126154. * It is mainly used to offset the camera's position.
  126155. */
  126156. get referenceSpace(): XRReferenceSpace;
  126157. /**
  126158. * Set a new reference space and triggers the observable
  126159. */
  126160. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  126161. /**
  126162. * Disposes of the session manager
  126163. */
  126164. dispose(): void;
  126165. /**
  126166. * Stops the xrSession and restores the render loop
  126167. * @returns Promise which resolves after it exits XR
  126168. */
  126169. exitXRAsync(): Promise<void>;
  126170. /**
  126171. * Gets the correct render target texture to be rendered this frame for this eye
  126172. * @param eye the eye for which to get the render target
  126173. * @returns the render target for the specified eye
  126174. */
  126175. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  126176. /**
  126177. * Creates a WebXRRenderTarget object for the XR session
  126178. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  126179. * @param options optional options to provide when creating a new render target
  126180. * @returns a WebXR render target to which the session can render
  126181. */
  126182. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  126183. /**
  126184. * Initializes the manager
  126185. * After initialization enterXR can be called to start an XR session
  126186. * @returns Promise which resolves after it is initialized
  126187. */
  126188. initializeAsync(): Promise<void>;
  126189. /**
  126190. * Initializes an xr session
  126191. * @param xrSessionMode mode to initialize
  126192. * @param xrSessionInit defines optional and required values to pass to the session builder
  126193. * @returns a promise which will resolve once the session has been initialized
  126194. */
  126195. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  126196. /**
  126197. * Checks if a session would be supported for the creation options specified
  126198. * @param sessionMode session mode to check if supported eg. immersive-vr
  126199. * @returns A Promise that resolves to true if supported and false if not
  126200. */
  126201. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  126202. /**
  126203. * Resets the reference space to the one started the session
  126204. */
  126205. resetReferenceSpace(): void;
  126206. /**
  126207. * Starts rendering to the xr layer
  126208. */
  126209. runXRRenderLoop(): void;
  126210. /**
  126211. * Sets the reference space on the xr session
  126212. * @param referenceSpaceType space to set
  126213. * @returns a promise that will resolve once the reference space has been set
  126214. */
  126215. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  126216. /**
  126217. * Updates the render state of the session
  126218. * @param state state to set
  126219. * @returns a promise that resolves once the render state has been updated
  126220. */
  126221. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  126222. /**
  126223. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  126224. * @param sessionMode defines the session to test
  126225. * @returns a promise with boolean as final value
  126226. */
  126227. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  126228. private _createRenderTargetTexture;
  126229. }
  126230. }
  126231. declare module BABYLON {
  126232. /**
  126233. * WebXR Camera which holds the views for the xrSession
  126234. * @see https://doc.babylonjs.com/how_to/webxr_camera
  126235. */
  126236. export class WebXRCamera extends FreeCamera {
  126237. private _xrSessionManager;
  126238. private _firstFrame;
  126239. private _referenceQuaternion;
  126240. private _referencedPosition;
  126241. private _xrInvPositionCache;
  126242. private _xrInvQuaternionCache;
  126243. /**
  126244. * Observable raised before camera teleportation
  126245. */
  126246. onBeforeCameraTeleport: Observable<Vector3>;
  126247. /**
  126248. * Observable raised after camera teleportation
  126249. */
  126250. onAfterCameraTeleport: Observable<Vector3>;
  126251. /**
  126252. * Should position compensation execute on first frame.
  126253. * This is used when copying the position from a native (non XR) camera
  126254. */
  126255. compensateOnFirstFrame: boolean;
  126256. /**
  126257. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  126258. * @param name the name of the camera
  126259. * @param scene the scene to add the camera to
  126260. * @param _xrSessionManager a constructed xr session manager
  126261. */
  126262. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  126263. /**
  126264. * Return the user's height, unrelated to the current ground.
  126265. * This will be the y position of this camera, when ground level is 0.
  126266. */
  126267. get realWorldHeight(): number;
  126268. /** @hidden */
  126269. _updateForDualEyeDebugging(): void;
  126270. /**
  126271. * Sets this camera's transformation based on a non-vr camera
  126272. * @param otherCamera the non-vr camera to copy the transformation from
  126273. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  126274. */
  126275. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  126276. /**
  126277. * Gets the current instance class name ("WebXRCamera").
  126278. * @returns the class name
  126279. */
  126280. getClassName(): string;
  126281. private _rotate180;
  126282. private _updateFromXRSession;
  126283. private _updateNumberOfRigCameras;
  126284. private _updateReferenceSpace;
  126285. private _updateReferenceSpaceOffset;
  126286. }
  126287. }
  126288. declare module BABYLON {
  126289. /**
  126290. * Defining the interface required for a (webxr) feature
  126291. */
  126292. export interface IWebXRFeature extends IDisposable {
  126293. /**
  126294. * Is this feature attached
  126295. */
  126296. attached: boolean;
  126297. /**
  126298. * Should auto-attach be disabled?
  126299. */
  126300. disableAutoAttach: boolean;
  126301. /**
  126302. * Attach the feature to the session
  126303. * Will usually be called by the features manager
  126304. *
  126305. * @param force should attachment be forced (even when already attached)
  126306. * @returns true if successful.
  126307. */
  126308. attach(force?: boolean): boolean;
  126309. /**
  126310. * Detach the feature from the session
  126311. * Will usually be called by the features manager
  126312. *
  126313. * @returns true if successful.
  126314. */
  126315. detach(): boolean;
  126316. /**
  126317. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  126318. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  126319. *
  126320. * @returns whether or not the feature is compatible in this environment
  126321. */
  126322. isCompatible(): boolean;
  126323. /**
  126324. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  126325. */
  126326. xrNativeFeatureName?: string;
  126327. }
  126328. /**
  126329. * A list of the currently available features without referencing them
  126330. */
  126331. export class WebXRFeatureName {
  126332. /**
  126333. * The name of the anchor system feature
  126334. */
  126335. static ANCHOR_SYSTEM: string;
  126336. /**
  126337. * The name of the background remover feature
  126338. */
  126339. static BACKGROUND_REMOVER: string;
  126340. /**
  126341. * The name of the hit test feature
  126342. */
  126343. static HIT_TEST: string;
  126344. /**
  126345. * physics impostors for xr controllers feature
  126346. */
  126347. static PHYSICS_CONTROLLERS: string;
  126348. /**
  126349. * The name of the plane detection feature
  126350. */
  126351. static PLANE_DETECTION: string;
  126352. /**
  126353. * The name of the pointer selection feature
  126354. */
  126355. static POINTER_SELECTION: string;
  126356. /**
  126357. * The name of the teleportation feature
  126358. */
  126359. static TELEPORTATION: string;
  126360. }
  126361. /**
  126362. * Defining the constructor of a feature. Used to register the modules.
  126363. */
  126364. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  126365. /**
  126366. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  126367. * It is mainly used in AR sessions.
  126368. *
  126369. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  126370. */
  126371. export class WebXRFeaturesManager implements IDisposable {
  126372. private _xrSessionManager;
  126373. private static readonly _AvailableFeatures;
  126374. private _features;
  126375. /**
  126376. * constructs a new features manages.
  126377. *
  126378. * @param _xrSessionManager an instance of WebXRSessionManager
  126379. */
  126380. constructor(_xrSessionManager: WebXRSessionManager);
  126381. /**
  126382. * Used to register a module. After calling this function a developer can use this feature in the scene.
  126383. * Mainly used internally.
  126384. *
  126385. * @param featureName the name of the feature to register
  126386. * @param constructorFunction the function used to construct the module
  126387. * @param version the (babylon) version of the module
  126388. * @param stable is that a stable version of this module
  126389. */
  126390. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  126391. /**
  126392. * Returns a constructor of a specific feature.
  126393. *
  126394. * @param featureName the name of the feature to construct
  126395. * @param version the version of the feature to load
  126396. * @param xrSessionManager the xrSessionManager. Used to construct the module
  126397. * @param options optional options provided to the module.
  126398. * @returns a function that, when called, will return a new instance of this feature
  126399. */
  126400. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  126401. /**
  126402. * Can be used to return the list of features currently registered
  126403. *
  126404. * @returns an Array of available features
  126405. */
  126406. static GetAvailableFeatures(): string[];
  126407. /**
  126408. * Gets the versions available for a specific feature
  126409. * @param featureName the name of the feature
  126410. * @returns an array with the available versions
  126411. */
  126412. static GetAvailableVersions(featureName: string): string[];
  126413. /**
  126414. * Return the latest unstable version of this feature
  126415. * @param featureName the name of the feature to search
  126416. * @returns the version number. if not found will return -1
  126417. */
  126418. static GetLatestVersionOfFeature(featureName: string): number;
  126419. /**
  126420. * Return the latest stable version of this feature
  126421. * @param featureName the name of the feature to search
  126422. * @returns the version number. if not found will return -1
  126423. */
  126424. static GetStableVersionOfFeature(featureName: string): number;
  126425. /**
  126426. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  126427. * Can be used during a session to start a feature
  126428. * @param featureName the name of feature to attach
  126429. */
  126430. attachFeature(featureName: string): void;
  126431. /**
  126432. * Can be used inside a session or when the session ends to detach a specific feature
  126433. * @param featureName the name of the feature to detach
  126434. */
  126435. detachFeature(featureName: string): void;
  126436. /**
  126437. * Used to disable an already-enabled feature
  126438. * The feature will be disposed and will be recreated once enabled.
  126439. * @param featureName the feature to disable
  126440. * @returns true if disable was successful
  126441. */
  126442. disableFeature(featureName: string | {
  126443. Name: string;
  126444. }): boolean;
  126445. /**
  126446. * dispose this features manager
  126447. */
  126448. dispose(): void;
  126449. /**
  126450. * 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.
  126451. * 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.
  126452. *
  126453. * @param featureName the name of the feature to load or the class of the feature
  126454. * @param version optional version to load. if not provided the latest version will be enabled
  126455. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  126456. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  126457. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  126458. * @returns a new constructed feature or throws an error if feature not found.
  126459. */
  126460. enableFeature(featureName: string | {
  126461. Name: string;
  126462. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  126463. /**
  126464. * get the implementation of an enabled feature.
  126465. * @param featureName the name of the feature to load
  126466. * @returns the feature class, if found
  126467. */
  126468. getEnabledFeature(featureName: string): IWebXRFeature;
  126469. /**
  126470. * Get the list of enabled features
  126471. * @returns an array of enabled features
  126472. */
  126473. getEnabledFeatures(): string[];
  126474. /**
  126475. * This function will exten the session creation configuration object with enabled features.
  126476. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  126477. * according to the defined "required" variable, provided during enableFeature call
  126478. * @param xrSessionInit the xr Session init object to extend
  126479. *
  126480. * @returns an extended XRSessionInit object
  126481. */
  126482. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  126483. }
  126484. }
  126485. declare module BABYLON {
  126486. /**
  126487. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  126488. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  126489. */
  126490. export class WebXRExperienceHelper implements IDisposable {
  126491. private scene;
  126492. private _nonVRCamera;
  126493. private _originalSceneAutoClear;
  126494. private _supported;
  126495. /**
  126496. * Camera used to render xr content
  126497. */
  126498. camera: WebXRCamera;
  126499. /** A features manager for this xr session */
  126500. featuresManager: WebXRFeaturesManager;
  126501. /**
  126502. * Observers registered here will be triggered after the camera's initial transformation is set
  126503. * This can be used to set a different ground level or an extra rotation.
  126504. *
  126505. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  126506. * to the position set after this observable is done executing.
  126507. */
  126508. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  126509. /**
  126510. * Fires when the state of the experience helper has changed
  126511. */
  126512. onStateChangedObservable: Observable<WebXRState>;
  126513. /** Session manager used to keep track of xr session */
  126514. sessionManager: WebXRSessionManager;
  126515. /**
  126516. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  126517. */
  126518. state: WebXRState;
  126519. /**
  126520. * Creates a WebXRExperienceHelper
  126521. * @param scene The scene the helper should be created in
  126522. */
  126523. private constructor();
  126524. /**
  126525. * Creates the experience helper
  126526. * @param scene the scene to attach the experience helper to
  126527. * @returns a promise for the experience helper
  126528. */
  126529. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  126530. /**
  126531. * Disposes of the experience helper
  126532. */
  126533. dispose(): void;
  126534. /**
  126535. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  126536. * @param sessionMode options for the XR session
  126537. * @param referenceSpaceType frame of reference of the XR session
  126538. * @param renderTarget the output canvas that will be used to enter XR mode
  126539. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  126540. * @returns promise that resolves after xr mode has entered
  126541. */
  126542. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  126543. /**
  126544. * Exits XR mode and returns the scene to its original state
  126545. * @returns promise that resolves after xr mode has exited
  126546. */
  126547. exitXRAsync(): Promise<void>;
  126548. private _nonXRToXRCamera;
  126549. private _setState;
  126550. }
  126551. }
  126552. declare module BABYLON {
  126553. /**
  126554. * X-Y values for axes in WebXR
  126555. */
  126556. export interface IWebXRMotionControllerAxesValue {
  126557. /**
  126558. * The value of the x axis
  126559. */
  126560. x: number;
  126561. /**
  126562. * The value of the y-axis
  126563. */
  126564. y: number;
  126565. }
  126566. /**
  126567. * changed / previous values for the values of this component
  126568. */
  126569. export interface IWebXRMotionControllerComponentChangesValues<T> {
  126570. /**
  126571. * current (this frame) value
  126572. */
  126573. current: T;
  126574. /**
  126575. * previous (last change) value
  126576. */
  126577. previous: T;
  126578. }
  126579. /**
  126580. * Represents changes in the component between current frame and last values recorded
  126581. */
  126582. export interface IWebXRMotionControllerComponentChanges {
  126583. /**
  126584. * will be populated with previous and current values if axes changed
  126585. */
  126586. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  126587. /**
  126588. * will be populated with previous and current values if pressed changed
  126589. */
  126590. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  126591. /**
  126592. * will be populated with previous and current values if touched changed
  126593. */
  126594. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  126595. /**
  126596. * will be populated with previous and current values if value changed
  126597. */
  126598. value?: IWebXRMotionControllerComponentChangesValues<number>;
  126599. }
  126600. /**
  126601. * This class represents a single component (for example button or thumbstick) of a motion controller
  126602. */
  126603. export class WebXRControllerComponent implements IDisposable {
  126604. /**
  126605. * the id of this component
  126606. */
  126607. id: string;
  126608. /**
  126609. * the type of the component
  126610. */
  126611. type: MotionControllerComponentType;
  126612. private _buttonIndex;
  126613. private _axesIndices;
  126614. private _axes;
  126615. private _changes;
  126616. private _currentValue;
  126617. private _hasChanges;
  126618. private _pressed;
  126619. private _touched;
  126620. /**
  126621. * button component type
  126622. */
  126623. static BUTTON_TYPE: MotionControllerComponentType;
  126624. /**
  126625. * squeeze component type
  126626. */
  126627. static SQUEEZE_TYPE: MotionControllerComponentType;
  126628. /**
  126629. * Thumbstick component type
  126630. */
  126631. static THUMBSTICK_TYPE: MotionControllerComponentType;
  126632. /**
  126633. * Touchpad component type
  126634. */
  126635. static TOUCHPAD_TYPE: MotionControllerComponentType;
  126636. /**
  126637. * trigger component type
  126638. */
  126639. static TRIGGER_TYPE: MotionControllerComponentType;
  126640. /**
  126641. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  126642. * the axes data changes
  126643. */
  126644. onAxisValueChangedObservable: Observable<{
  126645. x: number;
  126646. y: number;
  126647. }>;
  126648. /**
  126649. * Observers registered here will be triggered when the state of a button changes
  126650. * State change is either pressed / touched / value
  126651. */
  126652. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  126653. /**
  126654. * Creates a new component for a motion controller.
  126655. * It is created by the motion controller itself
  126656. *
  126657. * @param id the id of this component
  126658. * @param type the type of the component
  126659. * @param _buttonIndex index in the buttons array of the gamepad
  126660. * @param _axesIndices indices of the values in the axes array of the gamepad
  126661. */
  126662. constructor(
  126663. /**
  126664. * the id of this component
  126665. */
  126666. id: string,
  126667. /**
  126668. * the type of the component
  126669. */
  126670. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  126671. /**
  126672. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  126673. */
  126674. get axes(): IWebXRMotionControllerAxesValue;
  126675. /**
  126676. * Get the changes. Elements will be populated only if they changed with their previous and current value
  126677. */
  126678. get changes(): IWebXRMotionControllerComponentChanges;
  126679. /**
  126680. * Return whether or not the component changed the last frame
  126681. */
  126682. get hasChanges(): boolean;
  126683. /**
  126684. * is the button currently pressed
  126685. */
  126686. get pressed(): boolean;
  126687. /**
  126688. * is the button currently touched
  126689. */
  126690. get touched(): boolean;
  126691. /**
  126692. * Get the current value of this component
  126693. */
  126694. get value(): number;
  126695. /**
  126696. * Dispose this component
  126697. */
  126698. dispose(): void;
  126699. /**
  126700. * Are there axes correlating to this component
  126701. * @return true is axes data is available
  126702. */
  126703. isAxes(): boolean;
  126704. /**
  126705. * Is this component a button (hence - pressable)
  126706. * @returns true if can be pressed
  126707. */
  126708. isButton(): boolean;
  126709. /**
  126710. * update this component using the gamepad object it is in. Called on every frame
  126711. * @param nativeController the native gamepad controller object
  126712. */
  126713. update(nativeController: IMinimalMotionControllerObject): void;
  126714. }
  126715. }
  126716. declare module BABYLON {
  126717. /**
  126718. * Interface used to represent data loading progression
  126719. */
  126720. export interface ISceneLoaderProgressEvent {
  126721. /**
  126722. * Defines if data length to load can be evaluated
  126723. */
  126724. readonly lengthComputable: boolean;
  126725. /**
  126726. * Defines the loaded data length
  126727. */
  126728. readonly loaded: number;
  126729. /**
  126730. * Defines the data length to load
  126731. */
  126732. readonly total: number;
  126733. }
  126734. /**
  126735. * Interface used by SceneLoader plugins to define supported file extensions
  126736. */
  126737. export interface ISceneLoaderPluginExtensions {
  126738. /**
  126739. * Defines the list of supported extensions
  126740. */
  126741. [extension: string]: {
  126742. isBinary: boolean;
  126743. };
  126744. }
  126745. /**
  126746. * Interface used by SceneLoader plugin factory
  126747. */
  126748. export interface ISceneLoaderPluginFactory {
  126749. /**
  126750. * Defines the name of the factory
  126751. */
  126752. name: string;
  126753. /**
  126754. * Function called to create a new plugin
  126755. * @return the new plugin
  126756. */
  126757. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  126758. /**
  126759. * The callback that returns true if the data can be directly loaded.
  126760. * @param data string containing the file data
  126761. * @returns if the data can be loaded directly
  126762. */
  126763. canDirectLoad?(data: string): boolean;
  126764. }
  126765. /**
  126766. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  126767. */
  126768. export interface ISceneLoaderPluginBase {
  126769. /**
  126770. * The friendly name of this plugin.
  126771. */
  126772. name: string;
  126773. /**
  126774. * The file extensions supported by this plugin.
  126775. */
  126776. extensions: string | ISceneLoaderPluginExtensions;
  126777. /**
  126778. * The callback called when loading from a url.
  126779. * @param scene scene loading this url
  126780. * @param url url to load
  126781. * @param onSuccess callback called when the file successfully loads
  126782. * @param onProgress callback called while file is loading (if the server supports this mode)
  126783. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  126784. * @param onError callback called when the file fails to load
  126785. * @returns a file request object
  126786. */
  126787. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  126788. /**
  126789. * The callback called when loading from a file object.
  126790. * @param scene scene loading this file
  126791. * @param file defines the file to load
  126792. * @param onSuccess defines the callback to call when data is loaded
  126793. * @param onProgress defines the callback to call during loading process
  126794. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  126795. * @param onError defines the callback to call when an error occurs
  126796. * @returns a file request object
  126797. */
  126798. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  126799. /**
  126800. * The callback that returns true if the data can be directly loaded.
  126801. * @param data string containing the file data
  126802. * @returns if the data can be loaded directly
  126803. */
  126804. canDirectLoad?(data: string): boolean;
  126805. /**
  126806. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  126807. * @param scene scene loading this data
  126808. * @param data string containing the data
  126809. * @returns data to pass to the plugin
  126810. */
  126811. directLoad?(scene: Scene, data: string): any;
  126812. /**
  126813. * The callback that allows custom handling of the root url based on the response url.
  126814. * @param rootUrl the original root url
  126815. * @param responseURL the response url if available
  126816. * @returns the new root url
  126817. */
  126818. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  126819. }
  126820. /**
  126821. * Interface used to define a SceneLoader plugin
  126822. */
  126823. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  126824. /**
  126825. * Import meshes into a scene.
  126826. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  126827. * @param scene The scene to import into
  126828. * @param data The data to import
  126829. * @param rootUrl The root url for scene and resources
  126830. * @param meshes The meshes array to import into
  126831. * @param particleSystems The particle systems array to import into
  126832. * @param skeletons The skeletons array to import into
  126833. * @param onError The callback when import fails
  126834. * @returns True if successful or false otherwise
  126835. */
  126836. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  126837. /**
  126838. * Load into a scene.
  126839. * @param scene The scene to load into
  126840. * @param data The data to import
  126841. * @param rootUrl The root url for scene and resources
  126842. * @param onError The callback when import fails
  126843. * @returns True if successful or false otherwise
  126844. */
  126845. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  126846. /**
  126847. * Load into an asset container.
  126848. * @param scene The scene to load into
  126849. * @param data The data to import
  126850. * @param rootUrl The root url for scene and resources
  126851. * @param onError The callback when import fails
  126852. * @returns The loaded asset container
  126853. */
  126854. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  126855. }
  126856. /**
  126857. * Interface used to define an async SceneLoader plugin
  126858. */
  126859. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  126860. /**
  126861. * Import meshes into a scene.
  126862. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  126863. * @param scene The scene to import into
  126864. * @param data The data to import
  126865. * @param rootUrl The root url for scene and resources
  126866. * @param onProgress The callback when the load progresses
  126867. * @param fileName Defines the name of the file to load
  126868. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  126869. */
  126870. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  126871. meshes: AbstractMesh[];
  126872. particleSystems: IParticleSystem[];
  126873. skeletons: Skeleton[];
  126874. animationGroups: AnimationGroup[];
  126875. }>;
  126876. /**
  126877. * Load into a scene.
  126878. * @param scene The scene to load into
  126879. * @param data The data to import
  126880. * @param rootUrl The root url for scene and resources
  126881. * @param onProgress The callback when the load progresses
  126882. * @param fileName Defines the name of the file to load
  126883. * @returns Nothing
  126884. */
  126885. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  126886. /**
  126887. * Load into an asset container.
  126888. * @param scene The scene to load into
  126889. * @param data The data to import
  126890. * @param rootUrl The root url for scene and resources
  126891. * @param onProgress The callback when the load progresses
  126892. * @param fileName Defines the name of the file to load
  126893. * @returns The loaded asset container
  126894. */
  126895. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  126896. }
  126897. /**
  126898. * Mode that determines how to handle old animation groups before loading new ones.
  126899. */
  126900. export enum SceneLoaderAnimationGroupLoadingMode {
  126901. /**
  126902. * Reset all old animations to initial state then dispose them.
  126903. */
  126904. Clean = 0,
  126905. /**
  126906. * Stop all old animations.
  126907. */
  126908. Stop = 1,
  126909. /**
  126910. * Restart old animations from first frame.
  126911. */
  126912. Sync = 2,
  126913. /**
  126914. * Old animations remains untouched.
  126915. */
  126916. NoSync = 3
  126917. }
  126918. /**
  126919. * Defines a plugin registered by the SceneLoader
  126920. */
  126921. interface IRegisteredPlugin {
  126922. /**
  126923. * Defines the plugin to use
  126924. */
  126925. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  126926. /**
  126927. * Defines if the plugin supports binary data
  126928. */
  126929. isBinary: boolean;
  126930. }
  126931. /**
  126932. * Class used to load scene from various file formats using registered plugins
  126933. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  126934. */
  126935. export class SceneLoader {
  126936. /**
  126937. * No logging while loading
  126938. */
  126939. static readonly NO_LOGGING: number;
  126940. /**
  126941. * Minimal logging while loading
  126942. */
  126943. static readonly MINIMAL_LOGGING: number;
  126944. /**
  126945. * Summary logging while loading
  126946. */
  126947. static readonly SUMMARY_LOGGING: number;
  126948. /**
  126949. * Detailled logging while loading
  126950. */
  126951. static readonly DETAILED_LOGGING: number;
  126952. /**
  126953. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  126954. */
  126955. static get ForceFullSceneLoadingForIncremental(): boolean;
  126956. static set ForceFullSceneLoadingForIncremental(value: boolean);
  126957. /**
  126958. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  126959. */
  126960. static get ShowLoadingScreen(): boolean;
  126961. static set ShowLoadingScreen(value: boolean);
  126962. /**
  126963. * Defines the current logging level (while loading the scene)
  126964. * @ignorenaming
  126965. */
  126966. static get loggingLevel(): number;
  126967. static set loggingLevel(value: number);
  126968. /**
  126969. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  126970. */
  126971. static get CleanBoneMatrixWeights(): boolean;
  126972. static set CleanBoneMatrixWeights(value: boolean);
  126973. /**
  126974. * Event raised when a plugin is used to load a scene
  126975. */
  126976. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  126977. private static _registeredPlugins;
  126978. private static _showingLoadingScreen;
  126979. /**
  126980. * Gets the default plugin (used to load Babylon files)
  126981. * @returns the .babylon plugin
  126982. */
  126983. static GetDefaultPlugin(): IRegisteredPlugin;
  126984. private static _GetPluginForExtension;
  126985. private static _GetPluginForDirectLoad;
  126986. private static _GetPluginForFilename;
  126987. private static _GetDirectLoad;
  126988. private static _LoadData;
  126989. private static _GetFileInfo;
  126990. /**
  126991. * Gets a plugin that can load the given extension
  126992. * @param extension defines the extension to load
  126993. * @returns a plugin or null if none works
  126994. */
  126995. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  126996. /**
  126997. * Gets a boolean indicating that the given extension can be loaded
  126998. * @param extension defines the extension to load
  126999. * @returns true if the extension is supported
  127000. */
  127001. static IsPluginForExtensionAvailable(extension: string): boolean;
  127002. /**
  127003. * Adds a new plugin to the list of registered plugins
  127004. * @param plugin defines the plugin to add
  127005. */
  127006. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  127007. /**
  127008. * Import meshes into a scene
  127009. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  127010. * @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)
  127011. * @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)
  127012. * @param scene the instance of BABYLON.Scene to append to
  127013. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  127014. * @param onProgress a callback with a progress event for each file being loaded
  127015. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  127016. * @param pluginExtension the extension used to determine the plugin
  127017. * @returns The loaded plugin
  127018. */
  127019. 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>;
  127020. /**
  127021. * Import meshes into a scene
  127022. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  127023. * @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)
  127024. * @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)
  127025. * @param scene the instance of BABYLON.Scene to append to
  127026. * @param onProgress a callback with a progress event for each file being loaded
  127027. * @param pluginExtension the extension used to determine the plugin
  127028. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  127029. */
  127030. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  127031. meshes: AbstractMesh[];
  127032. particleSystems: IParticleSystem[];
  127033. skeletons: Skeleton[];
  127034. animationGroups: AnimationGroup[];
  127035. }>;
  127036. /**
  127037. * Load a scene
  127038. * @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)
  127039. * @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)
  127040. * @param engine is the instance of BABYLON.Engine to use to create the scene
  127041. * @param onSuccess a callback with the scene when import succeeds
  127042. * @param onProgress a callback with a progress event for each file being loaded
  127043. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  127044. * @param pluginExtension the extension used to determine the plugin
  127045. * @returns The loaded plugin
  127046. */
  127047. 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>;
  127048. /**
  127049. * Load a scene
  127050. * @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)
  127051. * @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)
  127052. * @param engine is the instance of BABYLON.Engine to use to create the scene
  127053. * @param onProgress a callback with a progress event for each file being loaded
  127054. * @param pluginExtension the extension used to determine the plugin
  127055. * @returns The loaded scene
  127056. */
  127057. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  127058. /**
  127059. * Append a scene
  127060. * @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)
  127061. * @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)
  127062. * @param scene is the instance of BABYLON.Scene to append to
  127063. * @param onSuccess a callback with the scene when import succeeds
  127064. * @param onProgress a callback with a progress event for each file being loaded
  127065. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  127066. * @param pluginExtension the extension used to determine the plugin
  127067. * @returns The loaded plugin
  127068. */
  127069. 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>;
  127070. /**
  127071. * Append a scene
  127072. * @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)
  127073. * @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)
  127074. * @param scene is the instance of BABYLON.Scene to append to
  127075. * @param onProgress a callback with a progress event for each file being loaded
  127076. * @param pluginExtension the extension used to determine the plugin
  127077. * @returns The given scene
  127078. */
  127079. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  127080. /**
  127081. * Load a scene into an asset container
  127082. * @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)
  127083. * @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)
  127084. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  127085. * @param onSuccess a callback with the scene when import succeeds
  127086. * @param onProgress a callback with a progress event for each file being loaded
  127087. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  127088. * @param pluginExtension the extension used to determine the plugin
  127089. * @returns The loaded plugin
  127090. */
  127091. 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>;
  127092. /**
  127093. * Load a scene into an asset container
  127094. * @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)
  127095. * @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)
  127096. * @param scene is the instance of Scene to append to
  127097. * @param onProgress a callback with a progress event for each file being loaded
  127098. * @param pluginExtension the extension used to determine the plugin
  127099. * @returns The loaded asset container
  127100. */
  127101. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  127102. /**
  127103. * Import animations from a file into a scene
  127104. * @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)
  127105. * @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)
  127106. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  127107. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  127108. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  127109. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  127110. * @param onSuccess a callback with the scene when import succeeds
  127111. * @param onProgress a callback with a progress event for each file being loaded
  127112. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  127113. * @param pluginExtension the extension used to determine the plugin
  127114. */
  127115. 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;
  127116. /**
  127117. * Import animations from a file into a scene
  127118. * @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)
  127119. * @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)
  127120. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  127121. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  127122. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  127123. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  127124. * @param onSuccess a callback with the scene when import succeeds
  127125. * @param onProgress a callback with a progress event for each file being loaded
  127126. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  127127. * @param pluginExtension the extension used to determine the plugin
  127128. * @returns the updated scene with imported animations
  127129. */
  127130. 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>;
  127131. }
  127132. }
  127133. declare module BABYLON {
  127134. /**
  127135. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  127136. */
  127137. export type MotionControllerHandedness = "none" | "left" | "right";
  127138. /**
  127139. * The type of components available in motion controllers.
  127140. * This is not the name of the component.
  127141. */
  127142. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  127143. /**
  127144. * The state of a controller component
  127145. */
  127146. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  127147. /**
  127148. * The schema of motion controller layout.
  127149. * No object will be initialized using this interface
  127150. * This is used just to define the profile.
  127151. */
  127152. export interface IMotionControllerLayout {
  127153. /**
  127154. * Path to load the assets. Usually relative to the base path
  127155. */
  127156. assetPath: string;
  127157. /**
  127158. * Available components (unsorted)
  127159. */
  127160. components: {
  127161. /**
  127162. * A map of component Ids
  127163. */
  127164. [componentId: string]: {
  127165. /**
  127166. * The type of input the component outputs
  127167. */
  127168. type: MotionControllerComponentType;
  127169. /**
  127170. * The indices of this component in the gamepad object
  127171. */
  127172. gamepadIndices: {
  127173. /**
  127174. * Index of button
  127175. */
  127176. button?: number;
  127177. /**
  127178. * If available, index of x-axis
  127179. */
  127180. xAxis?: number;
  127181. /**
  127182. * If available, index of y-axis
  127183. */
  127184. yAxis?: number;
  127185. };
  127186. /**
  127187. * The mesh's root node name
  127188. */
  127189. rootNodeName: string;
  127190. /**
  127191. * Animation definitions for this model
  127192. */
  127193. visualResponses: {
  127194. [stateKey: string]: {
  127195. /**
  127196. * What property will be animated
  127197. */
  127198. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  127199. /**
  127200. * What states influence this visual response
  127201. */
  127202. states: MotionControllerComponentStateType[];
  127203. /**
  127204. * Type of animation - movement or visibility
  127205. */
  127206. valueNodeProperty: "transform" | "visibility";
  127207. /**
  127208. * Base node name to move. Its position will be calculated according to the min and max nodes
  127209. */
  127210. valueNodeName?: string;
  127211. /**
  127212. * Minimum movement node
  127213. */
  127214. minNodeName?: string;
  127215. /**
  127216. * Max movement node
  127217. */
  127218. maxNodeName?: string;
  127219. };
  127220. };
  127221. /**
  127222. * If touch enabled, what is the name of node to display user feedback
  127223. */
  127224. touchPointNodeName?: string;
  127225. };
  127226. };
  127227. /**
  127228. * Is it xr standard mapping or not
  127229. */
  127230. gamepadMapping: "" | "xr-standard";
  127231. /**
  127232. * Base root node of this entire model
  127233. */
  127234. rootNodeName: string;
  127235. /**
  127236. * Defines the main button component id
  127237. */
  127238. selectComponentId: string;
  127239. }
  127240. /**
  127241. * A definition for the layout map in the input profile
  127242. */
  127243. export interface IMotionControllerLayoutMap {
  127244. /**
  127245. * Layouts with handedness type as a key
  127246. */
  127247. [handedness: string]: IMotionControllerLayout;
  127248. }
  127249. /**
  127250. * The XR Input profile schema
  127251. * Profiles can be found here:
  127252. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  127253. */
  127254. export interface IMotionControllerProfile {
  127255. /**
  127256. * fallback profiles for this profileId
  127257. */
  127258. fallbackProfileIds: string[];
  127259. /**
  127260. * The layout map, with handedness as key
  127261. */
  127262. layouts: IMotionControllerLayoutMap;
  127263. /**
  127264. * The id of this profile
  127265. * correlates to the profile(s) in the xrInput.profiles array
  127266. */
  127267. profileId: string;
  127268. }
  127269. /**
  127270. * A helper-interface for the 3 meshes needed for controller button animation
  127271. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  127272. */
  127273. export interface IMotionControllerButtonMeshMap {
  127274. /**
  127275. * the mesh that defines the pressed value mesh position.
  127276. * This is used to find the max-position of this button
  127277. */
  127278. pressedMesh: AbstractMesh;
  127279. /**
  127280. * the mesh that defines the unpressed value mesh position.
  127281. * This is used to find the min (or initial) position of this button
  127282. */
  127283. unpressedMesh: AbstractMesh;
  127284. /**
  127285. * The mesh that will be changed when value changes
  127286. */
  127287. valueMesh: AbstractMesh;
  127288. }
  127289. /**
  127290. * A helper-interface for the 3 meshes needed for controller axis animation.
  127291. * This will be expanded when touchpad animations are fully supported
  127292. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  127293. */
  127294. export interface IMotionControllerMeshMap {
  127295. /**
  127296. * the mesh that defines the maximum value mesh position.
  127297. */
  127298. maxMesh?: AbstractMesh;
  127299. /**
  127300. * the mesh that defines the minimum value mesh position.
  127301. */
  127302. minMesh?: AbstractMesh;
  127303. /**
  127304. * The mesh that will be changed when axis value changes
  127305. */
  127306. valueMesh: AbstractMesh;
  127307. }
  127308. /**
  127309. * The elements needed for change-detection of the gamepad objects in motion controllers
  127310. */
  127311. export interface IMinimalMotionControllerObject {
  127312. /**
  127313. * Available axes of this controller
  127314. */
  127315. axes: number[];
  127316. /**
  127317. * An array of available buttons
  127318. */
  127319. buttons: Array<{
  127320. /**
  127321. * Value of the button/trigger
  127322. */
  127323. value: number;
  127324. /**
  127325. * If the button/trigger is currently touched
  127326. */
  127327. touched: boolean;
  127328. /**
  127329. * If the button/trigger is currently pressed
  127330. */
  127331. pressed: boolean;
  127332. }>;
  127333. /**
  127334. * EXPERIMENTAL haptic support.
  127335. */
  127336. hapticActuators?: Array<{
  127337. pulse: (value: number, duration: number) => Promise<boolean>;
  127338. }>;
  127339. }
  127340. /**
  127341. * An Abstract Motion controller
  127342. * This class receives an xrInput and a profile layout and uses those to initialize the components
  127343. * Each component has an observable to check for changes in value and state
  127344. */
  127345. export abstract class WebXRAbstractMotionController implements IDisposable {
  127346. protected scene: Scene;
  127347. protected layout: IMotionControllerLayout;
  127348. /**
  127349. * The gamepad object correlating to this controller
  127350. */
  127351. gamepadObject: IMinimalMotionControllerObject;
  127352. /**
  127353. * handedness (left/right/none) of this controller
  127354. */
  127355. handedness: MotionControllerHandedness;
  127356. private _initComponent;
  127357. private _modelReady;
  127358. /**
  127359. * A map of components (WebXRControllerComponent) in this motion controller
  127360. * Components have a ComponentType and can also have both button and axis definitions
  127361. */
  127362. readonly components: {
  127363. [id: string]: WebXRControllerComponent;
  127364. };
  127365. /**
  127366. * Disable the model's animation. Can be set at any time.
  127367. */
  127368. disableAnimation: boolean;
  127369. /**
  127370. * Observers registered here will be triggered when the model of this controller is done loading
  127371. */
  127372. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  127373. /**
  127374. * The profile id of this motion controller
  127375. */
  127376. abstract profileId: string;
  127377. /**
  127378. * The root mesh of the model. It is null if the model was not yet initialized
  127379. */
  127380. rootMesh: Nullable<AbstractMesh>;
  127381. /**
  127382. * constructs a new abstract motion controller
  127383. * @param scene the scene to which the model of the controller will be added
  127384. * @param layout The profile layout to load
  127385. * @param gamepadObject The gamepad object correlating to this controller
  127386. * @param handedness handedness (left/right/none) of this controller
  127387. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  127388. */
  127389. constructor(scene: Scene, layout: IMotionControllerLayout,
  127390. /**
  127391. * The gamepad object correlating to this controller
  127392. */
  127393. gamepadObject: IMinimalMotionControllerObject,
  127394. /**
  127395. * handedness (left/right/none) of this controller
  127396. */
  127397. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  127398. /**
  127399. * Dispose this controller, the model mesh and all its components
  127400. */
  127401. dispose(): void;
  127402. /**
  127403. * Returns all components of specific type
  127404. * @param type the type to search for
  127405. * @return an array of components with this type
  127406. */
  127407. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  127408. /**
  127409. * get a component based an its component id as defined in layout.components
  127410. * @param id the id of the component
  127411. * @returns the component correlates to the id or undefined if not found
  127412. */
  127413. getComponent(id: string): WebXRControllerComponent;
  127414. /**
  127415. * Get the list of components available in this motion controller
  127416. * @returns an array of strings correlating to available components
  127417. */
  127418. getComponentIds(): string[];
  127419. /**
  127420. * Get the first component of specific type
  127421. * @param type type of component to find
  127422. * @return a controller component or null if not found
  127423. */
  127424. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  127425. /**
  127426. * Get the main (Select) component of this controller as defined in the layout
  127427. * @returns the main component of this controller
  127428. */
  127429. getMainComponent(): WebXRControllerComponent;
  127430. /**
  127431. * Loads the model correlating to this controller
  127432. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  127433. * @returns A promise fulfilled with the result of the model loading
  127434. */
  127435. loadModel(): Promise<boolean>;
  127436. /**
  127437. * Update this model using the current XRFrame
  127438. * @param xrFrame the current xr frame to use and update the model
  127439. */
  127440. updateFromXRFrame(xrFrame: XRFrame): void;
  127441. /**
  127442. * Backwards compatibility due to a deeply-integrated typo
  127443. */
  127444. get handness(): XREye;
  127445. /**
  127446. * Pulse (vibrate) this controller
  127447. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  127448. * Consecutive calls to this function will cancel the last pulse call
  127449. *
  127450. * @param value the strength of the pulse in 0.0...1.0 range
  127451. * @param duration Duration of the pulse in milliseconds
  127452. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  127453. * @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
  127454. */
  127455. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  127456. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  127457. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  127458. /**
  127459. * Moves the axis on the controller mesh based on its current state
  127460. * @param axis the index of the axis
  127461. * @param axisValue the value of the axis which determines the meshes new position
  127462. * @hidden
  127463. */
  127464. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  127465. /**
  127466. * Update the model itself with the current frame data
  127467. * @param xrFrame the frame to use for updating the model mesh
  127468. */
  127469. protected updateModel(xrFrame: XRFrame): void;
  127470. /**
  127471. * Get the filename and path for this controller's model
  127472. * @returns a map of filename and path
  127473. */
  127474. protected abstract _getFilenameAndPath(): {
  127475. filename: string;
  127476. path: string;
  127477. };
  127478. /**
  127479. * This function is called before the mesh is loaded. It checks for loading constraints.
  127480. * For example, this function can check if the GLB loader is available
  127481. * If this function returns false, the generic controller will be loaded instead
  127482. * @returns Is the client ready to load the mesh
  127483. */
  127484. protected abstract _getModelLoadingConstraints(): boolean;
  127485. /**
  127486. * This function will be called after the model was successfully loaded and can be used
  127487. * for mesh transformations before it is available for the user
  127488. * @param meshes the loaded meshes
  127489. */
  127490. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  127491. /**
  127492. * Set the root mesh for this controller. Important for the WebXR controller class
  127493. * @param meshes the loaded meshes
  127494. */
  127495. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  127496. /**
  127497. * A function executed each frame that updates the mesh (if needed)
  127498. * @param xrFrame the current xrFrame
  127499. */
  127500. protected abstract _updateModel(xrFrame: XRFrame): void;
  127501. private _getGenericFilenameAndPath;
  127502. private _getGenericParentMesh;
  127503. }
  127504. }
  127505. declare module BABYLON {
  127506. /**
  127507. * A generic trigger-only motion controller for WebXR
  127508. */
  127509. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  127510. /**
  127511. * Static version of the profile id of this controller
  127512. */
  127513. static ProfileId: string;
  127514. profileId: string;
  127515. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  127516. protected _getFilenameAndPath(): {
  127517. filename: string;
  127518. path: string;
  127519. };
  127520. protected _getModelLoadingConstraints(): boolean;
  127521. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  127522. protected _setRootMesh(meshes: AbstractMesh[]): void;
  127523. protected _updateModel(): void;
  127524. }
  127525. }
  127526. declare module BABYLON {
  127527. /**
  127528. * Class containing static functions to help procedurally build meshes
  127529. */
  127530. export class SphereBuilder {
  127531. /**
  127532. * Creates a sphere mesh
  127533. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  127534. * * 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`)
  127535. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  127536. * * 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
  127537. * * 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)
  127538. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127539. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127540. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127541. * @param name defines the name of the mesh
  127542. * @param options defines the options used to create the mesh
  127543. * @param scene defines the hosting scene
  127544. * @returns the sphere mesh
  127545. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  127546. */
  127547. static CreateSphere(name: string, options: {
  127548. segments?: number;
  127549. diameter?: number;
  127550. diameterX?: number;
  127551. diameterY?: number;
  127552. diameterZ?: number;
  127553. arc?: number;
  127554. slice?: number;
  127555. sideOrientation?: number;
  127556. frontUVs?: Vector4;
  127557. backUVs?: Vector4;
  127558. updatable?: boolean;
  127559. }, scene?: Nullable<Scene>): Mesh;
  127560. }
  127561. }
  127562. declare module BABYLON {
  127563. /**
  127564. * A profiled motion controller has its profile loaded from an online repository.
  127565. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  127566. */
  127567. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  127568. private _repositoryUrl;
  127569. private _buttonMeshMapping;
  127570. private _touchDots;
  127571. /**
  127572. * The profile ID of this controller. Will be populated when the controller initializes.
  127573. */
  127574. profileId: string;
  127575. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  127576. dispose(): void;
  127577. protected _getFilenameAndPath(): {
  127578. filename: string;
  127579. path: string;
  127580. };
  127581. protected _getModelLoadingConstraints(): boolean;
  127582. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  127583. protected _setRootMesh(meshes: AbstractMesh[]): void;
  127584. protected _updateModel(_xrFrame: XRFrame): void;
  127585. }
  127586. }
  127587. declare module BABYLON {
  127588. /**
  127589. * A construction function type to create a new controller based on an xrInput object
  127590. */
  127591. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  127592. /**
  127593. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  127594. *
  127595. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  127596. * it should be replaced with auto-loaded controllers.
  127597. *
  127598. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  127599. */
  127600. export class WebXRMotionControllerManager {
  127601. private static _AvailableControllers;
  127602. private static _Fallbacks;
  127603. private static _ProfileLoadingPromises;
  127604. private static _ProfilesList;
  127605. /**
  127606. * The base URL of the online controller repository. Can be changed at any time.
  127607. */
  127608. static BaseRepositoryUrl: string;
  127609. /**
  127610. * Which repository gets priority - local or online
  127611. */
  127612. static PrioritizeOnlineRepository: boolean;
  127613. /**
  127614. * Use the online repository, or use only locally-defined controllers
  127615. */
  127616. static UseOnlineRepository: boolean;
  127617. /**
  127618. * Clear the cache used for profile loading and reload when requested again
  127619. */
  127620. static ClearProfilesCache(): void;
  127621. /**
  127622. * Register the default fallbacks.
  127623. * This function is called automatically when this file is imported.
  127624. */
  127625. static DefaultFallbacks(): void;
  127626. /**
  127627. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  127628. * @param profileId the profile to which a fallback needs to be found
  127629. * @return an array with corresponding fallback profiles
  127630. */
  127631. static FindFallbackWithProfileId(profileId: string): string[];
  127632. /**
  127633. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  127634. * The order of search:
  127635. *
  127636. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  127637. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  127638. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  127639. * 4) return the generic trigger controller if none were found
  127640. *
  127641. * @param xrInput the xrInput to which a new controller is initialized
  127642. * @param scene the scene to which the model will be added
  127643. * @param forceProfile force a certain profile for this controller
  127644. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  127645. */
  127646. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  127647. /**
  127648. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  127649. *
  127650. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  127651. *
  127652. * @param type the profile type to register
  127653. * @param constructFunction the function to be called when loading this profile
  127654. */
  127655. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  127656. /**
  127657. * Register a fallback to a specific profile.
  127658. * @param profileId the profileId that will receive the fallbacks
  127659. * @param fallbacks A list of fallback profiles
  127660. */
  127661. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  127662. /**
  127663. * Will update the list of profiles available in the repository
  127664. * @return a promise that resolves to a map of profiles available online
  127665. */
  127666. static UpdateProfilesList(): Promise<{
  127667. [profile: string]: string;
  127668. }>;
  127669. private static _LoadProfileFromRepository;
  127670. private static _LoadProfilesFromAvailableControllers;
  127671. }
  127672. }
  127673. declare module BABYLON {
  127674. /**
  127675. * Configuration options for the WebXR controller creation
  127676. */
  127677. export interface IWebXRControllerOptions {
  127678. /**
  127679. * Should the controller mesh be animated when a user interacts with it
  127680. * The pressed buttons / thumbstick and touchpad animations will be disabled
  127681. */
  127682. disableMotionControllerAnimation?: boolean;
  127683. /**
  127684. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  127685. */
  127686. doNotLoadControllerMesh?: boolean;
  127687. /**
  127688. * Force a specific controller type for this controller.
  127689. * This can be used when creating your own profile or when testing different controllers
  127690. */
  127691. forceControllerProfile?: string;
  127692. /**
  127693. * Defines a rendering group ID for meshes that will be loaded.
  127694. * This is for the default controllers only.
  127695. */
  127696. renderingGroupId?: number;
  127697. }
  127698. /**
  127699. * Represents an XR controller
  127700. */
  127701. export class WebXRInputSource {
  127702. private _scene;
  127703. /** The underlying input source for the controller */
  127704. inputSource: XRInputSource;
  127705. private _options;
  127706. private _tmpVector;
  127707. private _uniqueId;
  127708. /**
  127709. * 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
  127710. */
  127711. grip?: AbstractMesh;
  127712. /**
  127713. * If available, this is the gamepad object related to this controller.
  127714. * Using this object it is possible to get click events and trackpad changes of the
  127715. * webxr controller that is currently being used.
  127716. */
  127717. motionController?: WebXRAbstractMotionController;
  127718. /**
  127719. * Event that fires when the controller is removed/disposed.
  127720. * The object provided as event data is this controller, after associated assets were disposed.
  127721. * uniqueId is still available.
  127722. */
  127723. onDisposeObservable: Observable<WebXRInputSource>;
  127724. /**
  127725. * Will be triggered when the mesh associated with the motion controller is done loading.
  127726. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  127727. * A shortened version of controller -> motion controller -> on mesh loaded.
  127728. */
  127729. onMeshLoadedObservable: Observable<AbstractMesh>;
  127730. /**
  127731. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  127732. */
  127733. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  127734. /**
  127735. * Pointer which can be used to select objects or attach a visible laser to
  127736. */
  127737. pointer: AbstractMesh;
  127738. /**
  127739. * Creates the input source object
  127740. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  127741. * @param _scene the scene which the controller should be associated to
  127742. * @param inputSource the underlying input source for the controller
  127743. * @param _options options for this controller creation
  127744. */
  127745. constructor(_scene: Scene,
  127746. /** The underlying input source for the controller */
  127747. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  127748. /**
  127749. * Get this controllers unique id
  127750. */
  127751. get uniqueId(): string;
  127752. /**
  127753. * Disposes of the object
  127754. */
  127755. dispose(): void;
  127756. /**
  127757. * Gets a world space ray coming from the pointer or grip
  127758. * @param result the resulting ray
  127759. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  127760. */
  127761. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  127762. /**
  127763. * Updates the controller pose based on the given XRFrame
  127764. * @param xrFrame xr frame to update the pose with
  127765. * @param referenceSpace reference space to use
  127766. */
  127767. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  127768. }
  127769. }
  127770. declare module BABYLON {
  127771. /**
  127772. * The schema for initialization options of the XR Input class
  127773. */
  127774. export interface IWebXRInputOptions {
  127775. /**
  127776. * If set to true no model will be automatically loaded
  127777. */
  127778. doNotLoadControllerMeshes?: boolean;
  127779. /**
  127780. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  127781. * If not found, the xr input profile data will be used.
  127782. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  127783. */
  127784. forceInputProfile?: string;
  127785. /**
  127786. * Do not send a request to the controller repository to load the profile.
  127787. *
  127788. * Instead, use the controllers available in babylon itself.
  127789. */
  127790. disableOnlineControllerRepository?: boolean;
  127791. /**
  127792. * A custom URL for the controllers repository
  127793. */
  127794. customControllersRepositoryURL?: string;
  127795. /**
  127796. * Should the controller model's components not move according to the user input
  127797. */
  127798. disableControllerAnimation?: boolean;
  127799. /**
  127800. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  127801. */
  127802. controllerOptions?: IWebXRControllerOptions;
  127803. }
  127804. /**
  127805. * XR input used to track XR inputs such as controllers/rays
  127806. */
  127807. export class WebXRInput implements IDisposable {
  127808. /**
  127809. * the xr session manager for this session
  127810. */
  127811. xrSessionManager: WebXRSessionManager;
  127812. /**
  127813. * the WebXR camera for this session. Mainly used for teleportation
  127814. */
  127815. xrCamera: WebXRCamera;
  127816. private readonly options;
  127817. /**
  127818. * XR controllers being tracked
  127819. */
  127820. controllers: Array<WebXRInputSource>;
  127821. private _frameObserver;
  127822. private _sessionEndedObserver;
  127823. private _sessionInitObserver;
  127824. /**
  127825. * Event when a controller has been connected/added
  127826. */
  127827. onControllerAddedObservable: Observable<WebXRInputSource>;
  127828. /**
  127829. * Event when a controller has been removed/disconnected
  127830. */
  127831. onControllerRemovedObservable: Observable<WebXRInputSource>;
  127832. /**
  127833. * Initializes the WebXRInput
  127834. * @param xrSessionManager the xr session manager for this session
  127835. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  127836. * @param options = initialization options for this xr input
  127837. */
  127838. constructor(
  127839. /**
  127840. * the xr session manager for this session
  127841. */
  127842. xrSessionManager: WebXRSessionManager,
  127843. /**
  127844. * the WebXR camera for this session. Mainly used for teleportation
  127845. */
  127846. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  127847. private _onInputSourcesChange;
  127848. private _addAndRemoveControllers;
  127849. /**
  127850. * Disposes of the object
  127851. */
  127852. dispose(): void;
  127853. }
  127854. }
  127855. declare module BABYLON {
  127856. /**
  127857. * This is the base class for all WebXR features.
  127858. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  127859. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  127860. */
  127861. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  127862. protected _xrSessionManager: WebXRSessionManager;
  127863. private _attached;
  127864. private _removeOnDetach;
  127865. /**
  127866. * Should auto-attach be disabled?
  127867. */
  127868. disableAutoAttach: boolean;
  127869. /**
  127870. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  127871. */
  127872. xrNativeFeatureName: string;
  127873. /**
  127874. * Construct a new (abstract) WebXR feature
  127875. * @param _xrSessionManager the xr session manager for this feature
  127876. */
  127877. constructor(_xrSessionManager: WebXRSessionManager);
  127878. /**
  127879. * Is this feature attached
  127880. */
  127881. get attached(): boolean;
  127882. /**
  127883. * attach this feature
  127884. *
  127885. * @param force should attachment be forced (even when already attached)
  127886. * @returns true if successful, false is failed or already attached
  127887. */
  127888. attach(force?: boolean): boolean;
  127889. /**
  127890. * detach this feature.
  127891. *
  127892. * @returns true if successful, false if failed or already detached
  127893. */
  127894. detach(): boolean;
  127895. /**
  127896. * Dispose this feature and all of the resources attached
  127897. */
  127898. dispose(): void;
  127899. /**
  127900. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  127901. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  127902. *
  127903. * @returns whether or not the feature is compatible in this environment
  127904. */
  127905. isCompatible(): boolean;
  127906. /**
  127907. * This is used to register callbacks that will automatically be removed when detach is called.
  127908. * @param observable the observable to which the observer will be attached
  127909. * @param callback the callback to register
  127910. */
  127911. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  127912. /**
  127913. * Code in this function will be executed on each xrFrame received from the browser.
  127914. * This function will not execute after the feature is detached.
  127915. * @param _xrFrame the current frame
  127916. */
  127917. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  127918. }
  127919. }
  127920. declare module BABYLON {
  127921. /**
  127922. * Renders a layer on top of an existing scene
  127923. */
  127924. export class UtilityLayerRenderer implements IDisposable {
  127925. /** the original scene that will be rendered on top of */
  127926. originalScene: Scene;
  127927. private _pointerCaptures;
  127928. private _lastPointerEvents;
  127929. private static _DefaultUtilityLayer;
  127930. private static _DefaultKeepDepthUtilityLayer;
  127931. private _sharedGizmoLight;
  127932. private _renderCamera;
  127933. /**
  127934. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  127935. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  127936. * @returns the camera that is used when rendering the utility layer
  127937. */
  127938. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  127939. /**
  127940. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  127941. * @param cam the camera that should be used when rendering the utility layer
  127942. */
  127943. setRenderCamera(cam: Nullable<Camera>): void;
  127944. /**
  127945. * @hidden
  127946. * Light which used by gizmos to get light shading
  127947. */
  127948. _getSharedGizmoLight(): HemisphericLight;
  127949. /**
  127950. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  127951. */
  127952. pickUtilitySceneFirst: boolean;
  127953. /**
  127954. * 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)
  127955. */
  127956. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  127957. /**
  127958. * 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)
  127959. */
  127960. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  127961. /**
  127962. * The scene that is rendered on top of the original scene
  127963. */
  127964. utilityLayerScene: Scene;
  127965. /**
  127966. * If the utility layer should automatically be rendered on top of existing scene
  127967. */
  127968. shouldRender: boolean;
  127969. /**
  127970. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  127971. */
  127972. onlyCheckPointerDownEvents: boolean;
  127973. /**
  127974. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  127975. */
  127976. processAllEvents: boolean;
  127977. /**
  127978. * Observable raised when the pointer move from the utility layer scene to the main scene
  127979. */
  127980. onPointerOutObservable: Observable<number>;
  127981. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  127982. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  127983. private _afterRenderObserver;
  127984. private _sceneDisposeObserver;
  127985. private _originalPointerObserver;
  127986. /**
  127987. * Instantiates a UtilityLayerRenderer
  127988. * @param originalScene the original scene that will be rendered on top of
  127989. * @param handleEvents boolean indicating if the utility layer should handle events
  127990. */
  127991. constructor(
  127992. /** the original scene that will be rendered on top of */
  127993. originalScene: Scene, handleEvents?: boolean);
  127994. private _notifyObservers;
  127995. /**
  127996. * Renders the utility layers scene on top of the original scene
  127997. */
  127998. render(): void;
  127999. /**
  128000. * Disposes of the renderer
  128001. */
  128002. dispose(): void;
  128003. private _updateCamera;
  128004. }
  128005. }
  128006. declare module BABYLON {
  128007. /**
  128008. * Options interface for the pointer selection module
  128009. */
  128010. export interface IWebXRControllerPointerSelectionOptions {
  128011. /**
  128012. * if provided, this scene will be used to render meshes.
  128013. */
  128014. customUtilityLayerScene?: Scene;
  128015. /**
  128016. * 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)
  128017. * If not disabled, the last picked point will be used to execute a pointer up event
  128018. * If disabled, pointer up event will be triggered right after the pointer down event.
  128019. * Used in screen and gaze target ray mode only
  128020. */
  128021. disablePointerUpOnTouchOut: boolean;
  128022. /**
  128023. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  128024. */
  128025. forceGazeMode: boolean;
  128026. /**
  128027. * 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
  128028. * to start a new countdown to the pointer down event.
  128029. * Defaults to 1.
  128030. */
  128031. gazeModePointerMovedFactor?: number;
  128032. /**
  128033. * Different button type to use instead of the main component
  128034. */
  128035. overrideButtonId?: string;
  128036. /**
  128037. * use this rendering group id for the meshes (optional)
  128038. */
  128039. renderingGroupId?: number;
  128040. /**
  128041. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  128042. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  128043. * 3000 means 3 seconds between pointing at something and selecting it
  128044. */
  128045. timeToSelect?: number;
  128046. /**
  128047. * Should meshes created here be added to a utility layer or the main scene
  128048. */
  128049. useUtilityLayer?: boolean;
  128050. /**
  128051. * Optional WebXR camera to be used for gaze selection
  128052. */
  128053. gazeCamera?: WebXRCamera;
  128054. /**
  128055. * the xr input to use with this pointer selection
  128056. */
  128057. xrInput: WebXRInput;
  128058. }
  128059. /**
  128060. * A module that will enable pointer selection for motion controllers of XR Input Sources
  128061. */
  128062. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  128063. private readonly _options;
  128064. private static _idCounter;
  128065. private _attachController;
  128066. private _controllers;
  128067. private _scene;
  128068. private _tmpVectorForPickCompare;
  128069. /**
  128070. * The module's name
  128071. */
  128072. static readonly Name: string;
  128073. /**
  128074. * The (Babylon) version of this module.
  128075. * This is an integer representing the implementation version.
  128076. * This number does not correspond to the WebXR specs version
  128077. */
  128078. static readonly Version: number;
  128079. /**
  128080. * Disable lighting on the laser pointer (so it will always be visible)
  128081. */
  128082. disablePointerLighting: boolean;
  128083. /**
  128084. * Disable lighting on the selection mesh (so it will always be visible)
  128085. */
  128086. disableSelectionMeshLighting: boolean;
  128087. /**
  128088. * Should the laser pointer be displayed
  128089. */
  128090. displayLaserPointer: boolean;
  128091. /**
  128092. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  128093. */
  128094. displaySelectionMesh: boolean;
  128095. /**
  128096. * This color will be set to the laser pointer when selection is triggered
  128097. */
  128098. laserPointerPickedColor: Color3;
  128099. /**
  128100. * Default color of the laser pointer
  128101. */
  128102. laserPointerDefaultColor: Color3;
  128103. /**
  128104. * default color of the selection ring
  128105. */
  128106. selectionMeshDefaultColor: Color3;
  128107. /**
  128108. * This color will be applied to the selection ring when selection is triggered
  128109. */
  128110. selectionMeshPickedColor: Color3;
  128111. /**
  128112. * Optional filter to be used for ray selection. This predicate shares behavior with
  128113. * scene.pointerMovePredicate which takes priority if it is also assigned.
  128114. */
  128115. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  128116. /**
  128117. * constructs a new background remover module
  128118. * @param _xrSessionManager the session manager for this module
  128119. * @param _options read-only options to be used in this module
  128120. */
  128121. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  128122. /**
  128123. * attach this feature
  128124. * Will usually be called by the features manager
  128125. *
  128126. * @returns true if successful.
  128127. */
  128128. attach(): boolean;
  128129. /**
  128130. * detach this feature.
  128131. * Will usually be called by the features manager
  128132. *
  128133. * @returns true if successful.
  128134. */
  128135. detach(): boolean;
  128136. /**
  128137. * Will get the mesh under a specific pointer.
  128138. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  128139. * @param controllerId the controllerId to check
  128140. * @returns The mesh under pointer or null if no mesh is under the pointer
  128141. */
  128142. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  128143. /**
  128144. * Get the xr controller that correlates to the pointer id in the pointer event
  128145. *
  128146. * @param id the pointer id to search for
  128147. * @returns the controller that correlates to this id or null if not found
  128148. */
  128149. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  128150. protected _onXRFrame(_xrFrame: XRFrame): void;
  128151. private _attachGazeMode;
  128152. private _attachScreenRayMode;
  128153. private _attachTrackedPointerRayMode;
  128154. private _convertNormalToDirectionOfRay;
  128155. private _detachController;
  128156. private _generateNewMeshPair;
  128157. private _pickingMoved;
  128158. private _updatePointerDistance;
  128159. /** @hidden */
  128160. get lasterPointerDefaultColor(): Color3;
  128161. }
  128162. }
  128163. declare module BABYLON {
  128164. /**
  128165. * Button which can be used to enter a different mode of XR
  128166. */
  128167. export class WebXREnterExitUIButton {
  128168. /** button element */
  128169. element: HTMLElement;
  128170. /** XR initialization options for the button */
  128171. sessionMode: XRSessionMode;
  128172. /** Reference space type */
  128173. referenceSpaceType: XRReferenceSpaceType;
  128174. /**
  128175. * Creates a WebXREnterExitUIButton
  128176. * @param element button element
  128177. * @param sessionMode XR initialization session mode
  128178. * @param referenceSpaceType the type of reference space to be used
  128179. */
  128180. constructor(
  128181. /** button element */
  128182. element: HTMLElement,
  128183. /** XR initialization options for the button */
  128184. sessionMode: XRSessionMode,
  128185. /** Reference space type */
  128186. referenceSpaceType: XRReferenceSpaceType);
  128187. /**
  128188. * Extendable function which can be used to update the button's visuals when the state changes
  128189. * @param activeButton the current active button in the UI
  128190. */
  128191. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  128192. }
  128193. /**
  128194. * Options to create the webXR UI
  128195. */
  128196. export class WebXREnterExitUIOptions {
  128197. /**
  128198. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  128199. */
  128200. customButtons?: Array<WebXREnterExitUIButton>;
  128201. /**
  128202. * A reference space type to use when creating the default button.
  128203. * Default is local-floor
  128204. */
  128205. referenceSpaceType?: XRReferenceSpaceType;
  128206. /**
  128207. * Context to enter xr with
  128208. */
  128209. renderTarget?: Nullable<WebXRRenderTarget>;
  128210. /**
  128211. * A session mode to use when creating the default button.
  128212. * Default is immersive-vr
  128213. */
  128214. sessionMode?: XRSessionMode;
  128215. /**
  128216. * A list of optional features to init the session with
  128217. */
  128218. optionalFeatures?: string[];
  128219. /**
  128220. * A list of optional features to init the session with
  128221. */
  128222. requiredFeatures?: string[];
  128223. }
  128224. /**
  128225. * UI to allow the user to enter/exit XR mode
  128226. */
  128227. export class WebXREnterExitUI implements IDisposable {
  128228. private scene;
  128229. /** version of the options passed to this UI */
  128230. options: WebXREnterExitUIOptions;
  128231. private _activeButton;
  128232. private _buttons;
  128233. private _overlay;
  128234. /**
  128235. * Fired every time the active button is changed.
  128236. *
  128237. * When xr is entered via a button that launches xr that button will be the callback parameter
  128238. *
  128239. * When exiting xr the callback parameter will be null)
  128240. */
  128241. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  128242. /**
  128243. *
  128244. * @param scene babylon scene object to use
  128245. * @param options (read-only) version of the options passed to this UI
  128246. */
  128247. private constructor();
  128248. /**
  128249. * Creates UI to allow the user to enter/exit XR mode
  128250. * @param scene the scene to add the ui to
  128251. * @param helper the xr experience helper to enter/exit xr with
  128252. * @param options options to configure the UI
  128253. * @returns the created ui
  128254. */
  128255. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  128256. /**
  128257. * Disposes of the XR UI component
  128258. */
  128259. dispose(): void;
  128260. private _updateButtons;
  128261. }
  128262. }
  128263. declare module BABYLON {
  128264. /**
  128265. * Class containing static functions to help procedurally build meshes
  128266. */
  128267. export class LinesBuilder {
  128268. /**
  128269. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  128270. * * 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
  128271. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  128272. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  128273. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  128274. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  128275. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  128276. * * 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
  128277. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  128278. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128279. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  128280. * @param name defines the name of the new line system
  128281. * @param options defines the options used to create the line system
  128282. * @param scene defines the hosting scene
  128283. * @returns a new line system mesh
  128284. */
  128285. static CreateLineSystem(name: string, options: {
  128286. lines: Vector3[][];
  128287. updatable?: boolean;
  128288. instance?: Nullable<LinesMesh>;
  128289. colors?: Nullable<Color4[][]>;
  128290. useVertexAlpha?: boolean;
  128291. }, scene: Nullable<Scene>): LinesMesh;
  128292. /**
  128293. * Creates a line mesh
  128294. * 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
  128295. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  128296. * * The parameter `points` is an array successive Vector3
  128297. * * 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
  128298. * * The optional parameter `colors` is an array of successive Color4, one per line point
  128299. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  128300. * * When updating an instance, remember that only point positions can change, not the number of points
  128301. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128302. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  128303. * @param name defines the name of the new line system
  128304. * @param options defines the options used to create the line system
  128305. * @param scene defines the hosting scene
  128306. * @returns a new line mesh
  128307. */
  128308. static CreateLines(name: string, options: {
  128309. points: Vector3[];
  128310. updatable?: boolean;
  128311. instance?: Nullable<LinesMesh>;
  128312. colors?: Color4[];
  128313. useVertexAlpha?: boolean;
  128314. }, scene?: Nullable<Scene>): LinesMesh;
  128315. /**
  128316. * Creates a dashed line mesh
  128317. * * 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
  128318. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  128319. * * The parameter `points` is an array successive Vector3
  128320. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  128321. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  128322. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  128323. * * 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
  128324. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  128325. * * When updating an instance, remember that only point positions can change, not the number of points
  128326. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128327. * @param name defines the name of the mesh
  128328. * @param options defines the options used to create the mesh
  128329. * @param scene defines the hosting scene
  128330. * @returns the dashed line mesh
  128331. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  128332. */
  128333. static CreateDashedLines(name: string, options: {
  128334. points: Vector3[];
  128335. dashSize?: number;
  128336. gapSize?: number;
  128337. dashNb?: number;
  128338. updatable?: boolean;
  128339. instance?: LinesMesh;
  128340. useVertexAlpha?: boolean;
  128341. }, scene?: Nullable<Scene>): LinesMesh;
  128342. }
  128343. }
  128344. declare module BABYLON {
  128345. /**
  128346. * Construction options for a timer
  128347. */
  128348. export interface ITimerOptions<T> {
  128349. /**
  128350. * Time-to-end
  128351. */
  128352. timeout: number;
  128353. /**
  128354. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  128355. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  128356. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  128357. */
  128358. contextObservable: Observable<T>;
  128359. /**
  128360. * Optional parameters when adding an observer to the observable
  128361. */
  128362. observableParameters?: {
  128363. mask?: number;
  128364. insertFirst?: boolean;
  128365. scope?: any;
  128366. };
  128367. /**
  128368. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  128369. */
  128370. breakCondition?: (data?: ITimerData<T>) => boolean;
  128371. /**
  128372. * Will be triggered when the time condition has met
  128373. */
  128374. onEnded?: (data: ITimerData<any>) => void;
  128375. /**
  128376. * Will be triggered when the break condition has met (prematurely ended)
  128377. */
  128378. onAborted?: (data: ITimerData<any>) => void;
  128379. /**
  128380. * Optional function to execute on each tick (or count)
  128381. */
  128382. onTick?: (data: ITimerData<any>) => void;
  128383. }
  128384. /**
  128385. * An interface defining the data sent by the timer
  128386. */
  128387. export interface ITimerData<T> {
  128388. /**
  128389. * When did it start
  128390. */
  128391. startTime: number;
  128392. /**
  128393. * Time now
  128394. */
  128395. currentTime: number;
  128396. /**
  128397. * Time passed since started
  128398. */
  128399. deltaTime: number;
  128400. /**
  128401. * How much is completed, in [0.0...1.0].
  128402. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  128403. */
  128404. completeRate: number;
  128405. /**
  128406. * What the registered observable sent in the last count
  128407. */
  128408. payload: T;
  128409. }
  128410. /**
  128411. * The current state of the timer
  128412. */
  128413. export enum TimerState {
  128414. /**
  128415. * Timer initialized, not yet started
  128416. */
  128417. INIT = 0,
  128418. /**
  128419. * Timer started and counting
  128420. */
  128421. STARTED = 1,
  128422. /**
  128423. * Timer ended (whether aborted or time reached)
  128424. */
  128425. ENDED = 2
  128426. }
  128427. /**
  128428. * A simple version of the timer. Will take options and start the timer immediately after calling it
  128429. *
  128430. * @param options options with which to initialize this timer
  128431. */
  128432. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  128433. /**
  128434. * An advanced implementation of a timer class
  128435. */
  128436. export class AdvancedTimer<T = any> implements IDisposable {
  128437. /**
  128438. * Will notify each time the timer calculates the remaining time
  128439. */
  128440. onEachCountObservable: Observable<ITimerData<T>>;
  128441. /**
  128442. * Will trigger when the timer was aborted due to the break condition
  128443. */
  128444. onTimerAbortedObservable: Observable<ITimerData<T>>;
  128445. /**
  128446. * Will trigger when the timer ended successfully
  128447. */
  128448. onTimerEndedObservable: Observable<ITimerData<T>>;
  128449. /**
  128450. * Will trigger when the timer state has changed
  128451. */
  128452. onStateChangedObservable: Observable<TimerState>;
  128453. private _observer;
  128454. private _contextObservable;
  128455. private _observableParameters;
  128456. private _startTime;
  128457. private _timer;
  128458. private _state;
  128459. private _breakCondition;
  128460. private _timeToEnd;
  128461. private _breakOnNextTick;
  128462. /**
  128463. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  128464. * @param options construction options for this advanced timer
  128465. */
  128466. constructor(options: ITimerOptions<T>);
  128467. /**
  128468. * set a breaking condition for this timer. Default is to never break during count
  128469. * @param predicate the new break condition. Returns true to break, false otherwise
  128470. */
  128471. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  128472. /**
  128473. * Reset ALL associated observables in this advanced timer
  128474. */
  128475. clearObservables(): void;
  128476. /**
  128477. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  128478. *
  128479. * @param timeToEnd how much time to measure until timer ended
  128480. */
  128481. start(timeToEnd?: number): void;
  128482. /**
  128483. * Will force a stop on the next tick.
  128484. */
  128485. stop(): void;
  128486. /**
  128487. * Dispose this timer, clearing all resources
  128488. */
  128489. dispose(): void;
  128490. private _setState;
  128491. private _tick;
  128492. private _stop;
  128493. }
  128494. }
  128495. declare module BABYLON {
  128496. /**
  128497. * The options container for the teleportation module
  128498. */
  128499. export interface IWebXRTeleportationOptions {
  128500. /**
  128501. * if provided, this scene will be used to render meshes.
  128502. */
  128503. customUtilityLayerScene?: Scene;
  128504. /**
  128505. * Values to configure the default target mesh
  128506. */
  128507. defaultTargetMeshOptions?: {
  128508. /**
  128509. * Fill color of the teleportation area
  128510. */
  128511. teleportationFillColor?: string;
  128512. /**
  128513. * Border color for the teleportation area
  128514. */
  128515. teleportationBorderColor?: string;
  128516. /**
  128517. * Disable the mesh's animation sequence
  128518. */
  128519. disableAnimation?: boolean;
  128520. /**
  128521. * Disable lighting on the material or the ring and arrow
  128522. */
  128523. disableLighting?: boolean;
  128524. /**
  128525. * Override the default material of the torus and arrow
  128526. */
  128527. torusArrowMaterial?: Material;
  128528. };
  128529. /**
  128530. * A list of meshes to use as floor meshes.
  128531. * Meshes can be added and removed after initializing the feature using the
  128532. * addFloorMesh and removeFloorMesh functions
  128533. * If empty, rotation will still work
  128534. */
  128535. floorMeshes?: AbstractMesh[];
  128536. /**
  128537. * use this rendering group id for the meshes (optional)
  128538. */
  128539. renderingGroupId?: number;
  128540. /**
  128541. * Should teleportation move only to snap points
  128542. */
  128543. snapPointsOnly?: boolean;
  128544. /**
  128545. * An array of points to which the teleportation will snap to.
  128546. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  128547. */
  128548. snapPositions?: Vector3[];
  128549. /**
  128550. * How close should the teleportation ray be in order to snap to position.
  128551. * Default to 0.8 units (meters)
  128552. */
  128553. snapToPositionRadius?: number;
  128554. /**
  128555. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  128556. * If you want to support rotation, make sure your mesh has a direction indicator.
  128557. *
  128558. * When left untouched, the default mesh will be initialized.
  128559. */
  128560. teleportationTargetMesh?: AbstractMesh;
  128561. /**
  128562. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  128563. */
  128564. timeToTeleport?: number;
  128565. /**
  128566. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  128567. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  128568. */
  128569. useMainComponentOnly?: boolean;
  128570. /**
  128571. * Should meshes created here be added to a utility layer or the main scene
  128572. */
  128573. useUtilityLayer?: boolean;
  128574. /**
  128575. * Babylon XR Input class for controller
  128576. */
  128577. xrInput: WebXRInput;
  128578. }
  128579. /**
  128580. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  128581. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  128582. * the input of the attached controllers.
  128583. */
  128584. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  128585. private _options;
  128586. private _controllers;
  128587. private _currentTeleportationControllerId;
  128588. private _floorMeshes;
  128589. private _quadraticBezierCurve;
  128590. private _selectionFeature;
  128591. private _snapToPositions;
  128592. private _snappedToPoint;
  128593. private _teleportationRingMaterial?;
  128594. private _tmpRay;
  128595. private _tmpVector;
  128596. /**
  128597. * The module's name
  128598. */
  128599. static readonly Name: string;
  128600. /**
  128601. * The (Babylon) version of this module.
  128602. * This is an integer representing the implementation version.
  128603. * This number does not correspond to the webxr specs version
  128604. */
  128605. static readonly Version: number;
  128606. /**
  128607. * Is movement backwards enabled
  128608. */
  128609. backwardsMovementEnabled: boolean;
  128610. /**
  128611. * Distance to travel when moving backwards
  128612. */
  128613. backwardsTeleportationDistance: number;
  128614. /**
  128615. * The distance from the user to the inspection point in the direction of the controller
  128616. * A higher number will allow the user to move further
  128617. * defaults to 5 (meters, in xr units)
  128618. */
  128619. parabolicCheckRadius: number;
  128620. /**
  128621. * Should the module support parabolic ray on top of direct ray
  128622. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  128623. * Very helpful when moving between floors / different heights
  128624. */
  128625. parabolicRayEnabled: boolean;
  128626. /**
  128627. * How much rotation should be applied when rotating right and left
  128628. */
  128629. rotationAngle: number;
  128630. /**
  128631. * Is rotation enabled when moving forward?
  128632. * Disabling this feature will prevent the user from deciding the direction when teleporting
  128633. */
  128634. rotationEnabled: boolean;
  128635. /**
  128636. * constructs a new anchor system
  128637. * @param _xrSessionManager an instance of WebXRSessionManager
  128638. * @param _options configuration object for this feature
  128639. */
  128640. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  128641. /**
  128642. * Get the snapPointsOnly flag
  128643. */
  128644. get snapPointsOnly(): boolean;
  128645. /**
  128646. * Sets the snapPointsOnly flag
  128647. * @param snapToPoints should teleportation be exclusively to snap points
  128648. */
  128649. set snapPointsOnly(snapToPoints: boolean);
  128650. /**
  128651. * Add a new mesh to the floor meshes array
  128652. * @param mesh the mesh to use as floor mesh
  128653. */
  128654. addFloorMesh(mesh: AbstractMesh): void;
  128655. /**
  128656. * Add a new snap-to point to fix teleportation to this position
  128657. * @param newSnapPoint The new Snap-To point
  128658. */
  128659. addSnapPoint(newSnapPoint: Vector3): void;
  128660. attach(): boolean;
  128661. detach(): boolean;
  128662. dispose(): void;
  128663. /**
  128664. * Remove a mesh from the floor meshes array
  128665. * @param mesh the mesh to remove
  128666. */
  128667. removeFloorMesh(mesh: AbstractMesh): void;
  128668. /**
  128669. * Remove a mesh from the floor meshes array using its name
  128670. * @param name the mesh name to remove
  128671. */
  128672. removeFloorMeshByName(name: string): void;
  128673. /**
  128674. * 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
  128675. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  128676. * @returns was the point found and removed or not
  128677. */
  128678. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  128679. /**
  128680. * This function sets a selection feature that will be disabled when
  128681. * the forward ray is shown and will be reattached when hidden.
  128682. * This is used to remove the selection rays when moving.
  128683. * @param selectionFeature the feature to disable when forward movement is enabled
  128684. */
  128685. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  128686. protected _onXRFrame(_xrFrame: XRFrame): void;
  128687. private _attachController;
  128688. private _createDefaultTargetMesh;
  128689. private _detachController;
  128690. private _findClosestSnapPointWithRadius;
  128691. private _setTargetMeshPosition;
  128692. private _setTargetMeshVisibility;
  128693. private _showParabolicPath;
  128694. private _teleportForward;
  128695. }
  128696. }
  128697. declare module BABYLON {
  128698. /**
  128699. * Options for the default xr helper
  128700. */
  128701. export class WebXRDefaultExperienceOptions {
  128702. /**
  128703. * Enable or disable default UI to enter XR
  128704. */
  128705. disableDefaultUI?: boolean;
  128706. /**
  128707. * Should teleportation not initialize. defaults to false.
  128708. */
  128709. disableTeleportation?: boolean;
  128710. /**
  128711. * Floor meshes that will be used for teleport
  128712. */
  128713. floorMeshes?: Array<AbstractMesh>;
  128714. /**
  128715. * If set to true, the first frame will not be used to reset position
  128716. * The first frame is mainly used when copying transformation from the old camera
  128717. * Mainly used in AR
  128718. */
  128719. ignoreNativeCameraTransformation?: boolean;
  128720. /**
  128721. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  128722. */
  128723. inputOptions?: IWebXRInputOptions;
  128724. /**
  128725. * optional configuration for the output canvas
  128726. */
  128727. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  128728. /**
  128729. * optional UI options. This can be used among other to change session mode and reference space type
  128730. */
  128731. uiOptions?: WebXREnterExitUIOptions;
  128732. /**
  128733. * When loading teleportation and pointer select, use stable versions instead of latest.
  128734. */
  128735. useStablePlugins?: boolean;
  128736. /**
  128737. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  128738. */
  128739. renderingGroupId?: number;
  128740. /**
  128741. * A list of optional features to init the session with
  128742. * If set to true, all features we support will be added
  128743. */
  128744. optionalFeatures?: boolean | string[];
  128745. }
  128746. /**
  128747. * Default experience which provides a similar setup to the previous webVRExperience
  128748. */
  128749. export class WebXRDefaultExperience {
  128750. /**
  128751. * Base experience
  128752. */
  128753. baseExperience: WebXRExperienceHelper;
  128754. /**
  128755. * Enables ui for entering/exiting xr
  128756. */
  128757. enterExitUI: WebXREnterExitUI;
  128758. /**
  128759. * Input experience extension
  128760. */
  128761. input: WebXRInput;
  128762. /**
  128763. * Enables laser pointer and selection
  128764. */
  128765. pointerSelection: WebXRControllerPointerSelection;
  128766. /**
  128767. * Default target xr should render to
  128768. */
  128769. renderTarget: WebXRRenderTarget;
  128770. /**
  128771. * Enables teleportation
  128772. */
  128773. teleportation: WebXRMotionControllerTeleportation;
  128774. private constructor();
  128775. /**
  128776. * Creates the default xr experience
  128777. * @param scene scene
  128778. * @param options options for basic configuration
  128779. * @returns resulting WebXRDefaultExperience
  128780. */
  128781. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  128782. /**
  128783. * DIsposes of the experience helper
  128784. */
  128785. dispose(): void;
  128786. }
  128787. }
  128788. declare module BABYLON {
  128789. /**
  128790. * Options to modify the vr teleportation behavior.
  128791. */
  128792. export interface VRTeleportationOptions {
  128793. /**
  128794. * The name of the mesh which should be used as the teleportation floor. (default: null)
  128795. */
  128796. floorMeshName?: string;
  128797. /**
  128798. * A list of meshes to be used as the teleportation floor. (default: empty)
  128799. */
  128800. floorMeshes?: Mesh[];
  128801. /**
  128802. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  128803. */
  128804. teleportationMode?: number;
  128805. /**
  128806. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  128807. */
  128808. teleportationTime?: number;
  128809. /**
  128810. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  128811. */
  128812. teleportationSpeed?: number;
  128813. /**
  128814. * The easing function used in the animation or null for Linear. (default CircleEase)
  128815. */
  128816. easingFunction?: EasingFunction;
  128817. }
  128818. /**
  128819. * Options to modify the vr experience helper's behavior.
  128820. */
  128821. export interface VRExperienceHelperOptions extends WebVROptions {
  128822. /**
  128823. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  128824. */
  128825. createDeviceOrientationCamera?: boolean;
  128826. /**
  128827. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  128828. */
  128829. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  128830. /**
  128831. * Uses the main button on the controller to toggle the laser casted. (default: true)
  128832. */
  128833. laserToggle?: boolean;
  128834. /**
  128835. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  128836. */
  128837. floorMeshes?: Mesh[];
  128838. /**
  128839. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  128840. */
  128841. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  128842. /**
  128843. * Defines if WebXR should be used instead of WebVR (if available)
  128844. */
  128845. useXR?: boolean;
  128846. }
  128847. /**
  128848. * Event containing information after VR has been entered
  128849. */
  128850. export class OnAfterEnteringVRObservableEvent {
  128851. /**
  128852. * If entering vr was successful
  128853. */
  128854. success: boolean;
  128855. }
  128856. /**
  128857. * Helps to quickly add VR support to an existing scene.
  128858. * See https://doc.babylonjs.com/how_to/webvr_helper
  128859. */
  128860. export class VRExperienceHelper {
  128861. /** Options to modify the vr experience helper's behavior. */
  128862. webVROptions: VRExperienceHelperOptions;
  128863. private _scene;
  128864. private _position;
  128865. private _btnVR;
  128866. private _btnVRDisplayed;
  128867. private _webVRsupported;
  128868. private _webVRready;
  128869. private _webVRrequesting;
  128870. private _webVRpresenting;
  128871. private _hasEnteredVR;
  128872. private _fullscreenVRpresenting;
  128873. private _inputElement;
  128874. private _webVRCamera;
  128875. private _vrDeviceOrientationCamera;
  128876. private _deviceOrientationCamera;
  128877. private _existingCamera;
  128878. private _onKeyDown;
  128879. private _onVrDisplayPresentChange;
  128880. private _onVRDisplayChanged;
  128881. private _onVRRequestPresentStart;
  128882. private _onVRRequestPresentComplete;
  128883. /**
  128884. * 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)
  128885. */
  128886. enableGazeEvenWhenNoPointerLock: boolean;
  128887. /**
  128888. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  128889. */
  128890. exitVROnDoubleTap: boolean;
  128891. /**
  128892. * Observable raised right before entering VR.
  128893. */
  128894. onEnteringVRObservable: Observable<VRExperienceHelper>;
  128895. /**
  128896. * Observable raised when entering VR has completed.
  128897. */
  128898. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  128899. /**
  128900. * Observable raised when exiting VR.
  128901. */
  128902. onExitingVRObservable: Observable<VRExperienceHelper>;
  128903. /**
  128904. * Observable raised when controller mesh is loaded.
  128905. */
  128906. onControllerMeshLoadedObservable: Observable<WebVRController>;
  128907. /** Return this.onEnteringVRObservable
  128908. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  128909. */
  128910. get onEnteringVR(): Observable<VRExperienceHelper>;
  128911. /** Return this.onExitingVRObservable
  128912. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  128913. */
  128914. get onExitingVR(): Observable<VRExperienceHelper>;
  128915. /** Return this.onControllerMeshLoadedObservable
  128916. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  128917. */
  128918. get onControllerMeshLoaded(): Observable<WebVRController>;
  128919. private _rayLength;
  128920. private _useCustomVRButton;
  128921. private _teleportationRequested;
  128922. private _teleportActive;
  128923. private _floorMeshName;
  128924. private _floorMeshesCollection;
  128925. private _teleportationMode;
  128926. private _teleportationTime;
  128927. private _teleportationSpeed;
  128928. private _teleportationEasing;
  128929. private _rotationAllowed;
  128930. private _teleportBackwardsVector;
  128931. private _teleportationTarget;
  128932. private _isDefaultTeleportationTarget;
  128933. private _postProcessMove;
  128934. private _teleportationFillColor;
  128935. private _teleportationBorderColor;
  128936. private _rotationAngle;
  128937. private _haloCenter;
  128938. private _cameraGazer;
  128939. private _padSensibilityUp;
  128940. private _padSensibilityDown;
  128941. private _leftController;
  128942. private _rightController;
  128943. private _gazeColor;
  128944. private _laserColor;
  128945. private _pickedLaserColor;
  128946. private _pickedGazeColor;
  128947. /**
  128948. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  128949. */
  128950. onNewMeshSelected: Observable<AbstractMesh>;
  128951. /**
  128952. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  128953. * This observable will provide the mesh and the controller used to select the mesh
  128954. */
  128955. onMeshSelectedWithController: Observable<{
  128956. mesh: AbstractMesh;
  128957. controller: WebVRController;
  128958. }>;
  128959. /**
  128960. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  128961. */
  128962. onNewMeshPicked: Observable<PickingInfo>;
  128963. private _circleEase;
  128964. /**
  128965. * Observable raised before camera teleportation
  128966. */
  128967. onBeforeCameraTeleport: Observable<Vector3>;
  128968. /**
  128969. * Observable raised after camera teleportation
  128970. */
  128971. onAfterCameraTeleport: Observable<Vector3>;
  128972. /**
  128973. * Observable raised when current selected mesh gets unselected
  128974. */
  128975. onSelectedMeshUnselected: Observable<AbstractMesh>;
  128976. private _raySelectionPredicate;
  128977. /**
  128978. * To be optionaly changed by user to define custom ray selection
  128979. */
  128980. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  128981. /**
  128982. * To be optionaly changed by user to define custom selection logic (after ray selection)
  128983. */
  128984. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  128985. /**
  128986. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  128987. */
  128988. teleportationEnabled: boolean;
  128989. private _defaultHeight;
  128990. private _teleportationInitialized;
  128991. private _interactionsEnabled;
  128992. private _interactionsRequested;
  128993. private _displayGaze;
  128994. private _displayLaserPointer;
  128995. /**
  128996. * The mesh used to display where the user is going to teleport.
  128997. */
  128998. get teleportationTarget(): Mesh;
  128999. /**
  129000. * Sets the mesh to be used to display where the user is going to teleport.
  129001. */
  129002. set teleportationTarget(value: Mesh);
  129003. /**
  129004. * 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
  129005. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  129006. * See https://doc.babylonjs.com/resources/baking_transformations
  129007. */
  129008. get gazeTrackerMesh(): Mesh;
  129009. set gazeTrackerMesh(value: Mesh);
  129010. /**
  129011. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  129012. */
  129013. updateGazeTrackerScale: boolean;
  129014. /**
  129015. * If the gaze trackers color should be updated when selecting meshes
  129016. */
  129017. updateGazeTrackerColor: boolean;
  129018. /**
  129019. * If the controller laser color should be updated when selecting meshes
  129020. */
  129021. updateControllerLaserColor: boolean;
  129022. /**
  129023. * The gaze tracking mesh corresponding to the left controller
  129024. */
  129025. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  129026. /**
  129027. * The gaze tracking mesh corresponding to the right controller
  129028. */
  129029. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  129030. /**
  129031. * If the ray of the gaze should be displayed.
  129032. */
  129033. get displayGaze(): boolean;
  129034. /**
  129035. * Sets if the ray of the gaze should be displayed.
  129036. */
  129037. set displayGaze(value: boolean);
  129038. /**
  129039. * If the ray of the LaserPointer should be displayed.
  129040. */
  129041. get displayLaserPointer(): boolean;
  129042. /**
  129043. * Sets if the ray of the LaserPointer should be displayed.
  129044. */
  129045. set displayLaserPointer(value: boolean);
  129046. /**
  129047. * The deviceOrientationCamera used as the camera when not in VR.
  129048. */
  129049. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  129050. /**
  129051. * Based on the current WebVR support, returns the current VR camera used.
  129052. */
  129053. get currentVRCamera(): Nullable<Camera>;
  129054. /**
  129055. * The webVRCamera which is used when in VR.
  129056. */
  129057. get webVRCamera(): WebVRFreeCamera;
  129058. /**
  129059. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  129060. */
  129061. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  129062. /**
  129063. * The html button that is used to trigger entering into VR.
  129064. */
  129065. get vrButton(): Nullable<HTMLButtonElement>;
  129066. private get _teleportationRequestInitiated();
  129067. /**
  129068. * Defines whether or not Pointer lock should be requested when switching to
  129069. * full screen.
  129070. */
  129071. requestPointerLockOnFullScreen: boolean;
  129072. /**
  129073. * If asking to force XR, this will be populated with the default xr experience
  129074. */
  129075. xr: WebXRDefaultExperience;
  129076. /**
  129077. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  129078. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  129079. */
  129080. xrTestDone: boolean;
  129081. /**
  129082. * Instantiates a VRExperienceHelper.
  129083. * Helps to quickly add VR support to an existing scene.
  129084. * @param scene The scene the VRExperienceHelper belongs to.
  129085. * @param webVROptions Options to modify the vr experience helper's behavior.
  129086. */
  129087. constructor(scene: Scene,
  129088. /** Options to modify the vr experience helper's behavior. */
  129089. webVROptions?: VRExperienceHelperOptions);
  129090. private completeVRInit;
  129091. private _onDefaultMeshLoaded;
  129092. private _onResize;
  129093. private _onFullscreenChange;
  129094. /**
  129095. * Gets a value indicating if we are currently in VR mode.
  129096. */
  129097. get isInVRMode(): boolean;
  129098. private onVrDisplayPresentChange;
  129099. private onVRDisplayChanged;
  129100. private moveButtonToBottomRight;
  129101. private displayVRButton;
  129102. private updateButtonVisibility;
  129103. private _cachedAngularSensibility;
  129104. /**
  129105. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  129106. * Otherwise, will use the fullscreen API.
  129107. */
  129108. enterVR(): void;
  129109. /**
  129110. * Attempt to exit VR, or fullscreen.
  129111. */
  129112. exitVR(): void;
  129113. /**
  129114. * The position of the vr experience helper.
  129115. */
  129116. get position(): Vector3;
  129117. /**
  129118. * Sets the position of the vr experience helper.
  129119. */
  129120. set position(value: Vector3);
  129121. /**
  129122. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  129123. */
  129124. enableInteractions(): void;
  129125. private get _noControllerIsActive();
  129126. private beforeRender;
  129127. private _isTeleportationFloor;
  129128. /**
  129129. * Adds a floor mesh to be used for teleportation.
  129130. * @param floorMesh the mesh to be used for teleportation.
  129131. */
  129132. addFloorMesh(floorMesh: Mesh): void;
  129133. /**
  129134. * Removes a floor mesh from being used for teleportation.
  129135. * @param floorMesh the mesh to be removed.
  129136. */
  129137. removeFloorMesh(floorMesh: Mesh): void;
  129138. /**
  129139. * Enables interactions and teleportation using the VR controllers and gaze.
  129140. * @param vrTeleportationOptions options to modify teleportation behavior.
  129141. */
  129142. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  129143. private _onNewGamepadConnected;
  129144. private _tryEnableInteractionOnController;
  129145. private _onNewGamepadDisconnected;
  129146. private _enableInteractionOnController;
  129147. private _checkTeleportWithRay;
  129148. private _checkRotate;
  129149. private _checkTeleportBackwards;
  129150. private _enableTeleportationOnController;
  129151. private _createTeleportationCircles;
  129152. private _displayTeleportationTarget;
  129153. private _hideTeleportationTarget;
  129154. private _rotateCamera;
  129155. private _moveTeleportationSelectorTo;
  129156. private _workingVector;
  129157. private _workingQuaternion;
  129158. private _workingMatrix;
  129159. /**
  129160. * Time Constant Teleportation Mode
  129161. */
  129162. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  129163. /**
  129164. * Speed Constant Teleportation Mode
  129165. */
  129166. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  129167. /**
  129168. * Teleports the users feet to the desired location
  129169. * @param location The location where the user's feet should be placed
  129170. */
  129171. teleportCamera(location: Vector3): void;
  129172. private _convertNormalToDirectionOfRay;
  129173. private _castRayAndSelectObject;
  129174. private _notifySelectedMeshUnselected;
  129175. /**
  129176. * Permanently set new colors for the laser pointer
  129177. * @param color the new laser color
  129178. * @param pickedColor the new laser color when picked mesh detected
  129179. */
  129180. setLaserColor(color: Color3, pickedColor?: Color3): void;
  129181. /**
  129182. * Set lighting enabled / disabled on the laser pointer of both controllers
  129183. * @param enabled should the lighting be enabled on the laser pointer
  129184. */
  129185. setLaserLightingState(enabled?: boolean): void;
  129186. /**
  129187. * Permanently set new colors for the gaze pointer
  129188. * @param color the new gaze color
  129189. * @param pickedColor the new gaze color when picked mesh detected
  129190. */
  129191. setGazeColor(color: Color3, pickedColor?: Color3): void;
  129192. /**
  129193. * Sets the color of the laser ray from the vr controllers.
  129194. * @param color new color for the ray.
  129195. */
  129196. changeLaserColor(color: Color3): void;
  129197. /**
  129198. * Sets the color of the ray from the vr headsets gaze.
  129199. * @param color new color for the ray.
  129200. */
  129201. changeGazeColor(color: Color3): void;
  129202. /**
  129203. * Exits VR and disposes of the vr experience helper
  129204. */
  129205. dispose(): void;
  129206. /**
  129207. * Gets the name of the VRExperienceHelper class
  129208. * @returns "VRExperienceHelper"
  129209. */
  129210. getClassName(): string;
  129211. }
  129212. }
  129213. declare module BABYLON {
  129214. /**
  129215. * Contains an array of blocks representing the octree
  129216. */
  129217. export interface IOctreeContainer<T> {
  129218. /**
  129219. * Blocks within the octree
  129220. */
  129221. blocks: Array<OctreeBlock<T>>;
  129222. }
  129223. /**
  129224. * Class used to store a cell in an octree
  129225. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  129226. */
  129227. export class OctreeBlock<T> {
  129228. /**
  129229. * Gets the content of the current block
  129230. */
  129231. entries: T[];
  129232. /**
  129233. * Gets the list of block children
  129234. */
  129235. blocks: Array<OctreeBlock<T>>;
  129236. private _depth;
  129237. private _maxDepth;
  129238. private _capacity;
  129239. private _minPoint;
  129240. private _maxPoint;
  129241. private _boundingVectors;
  129242. private _creationFunc;
  129243. /**
  129244. * Creates a new block
  129245. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  129246. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  129247. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  129248. * @param depth defines the current depth of this block in the octree
  129249. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  129250. * @param creationFunc defines a callback to call when an element is added to the block
  129251. */
  129252. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  129253. /**
  129254. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  129255. */
  129256. get capacity(): number;
  129257. /**
  129258. * Gets the minimum vector (in world space) of the block's bounding box
  129259. */
  129260. get minPoint(): Vector3;
  129261. /**
  129262. * Gets the maximum vector (in world space) of the block's bounding box
  129263. */
  129264. get maxPoint(): Vector3;
  129265. /**
  129266. * Add a new element to this block
  129267. * @param entry defines the element to add
  129268. */
  129269. addEntry(entry: T): void;
  129270. /**
  129271. * Remove an element from this block
  129272. * @param entry defines the element to remove
  129273. */
  129274. removeEntry(entry: T): void;
  129275. /**
  129276. * Add an array of elements to this block
  129277. * @param entries defines the array of elements to add
  129278. */
  129279. addEntries(entries: T[]): void;
  129280. /**
  129281. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  129282. * @param frustumPlanes defines the frustum planes to test
  129283. * @param selection defines the array to store current content if selection is positive
  129284. * @param allowDuplicate defines if the selection array can contains duplicated entries
  129285. */
  129286. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  129287. /**
  129288. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  129289. * @param sphereCenter defines the bounding sphere center
  129290. * @param sphereRadius defines the bounding sphere radius
  129291. * @param selection defines the array to store current content if selection is positive
  129292. * @param allowDuplicate defines if the selection array can contains duplicated entries
  129293. */
  129294. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  129295. /**
  129296. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  129297. * @param ray defines the ray to test with
  129298. * @param selection defines the array to store current content if selection is positive
  129299. */
  129300. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  129301. /**
  129302. * Subdivide the content into child blocks (this block will then be empty)
  129303. */
  129304. createInnerBlocks(): void;
  129305. /**
  129306. * @hidden
  129307. */
  129308. 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;
  129309. }
  129310. }
  129311. declare module BABYLON {
  129312. /**
  129313. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  129314. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  129315. */
  129316. export class Octree<T> {
  129317. /** 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.) */
  129318. maxDepth: number;
  129319. /**
  129320. * Blocks within the octree containing objects
  129321. */
  129322. blocks: Array<OctreeBlock<T>>;
  129323. /**
  129324. * Content stored in the octree
  129325. */
  129326. dynamicContent: T[];
  129327. private _maxBlockCapacity;
  129328. private _selectionContent;
  129329. private _creationFunc;
  129330. /**
  129331. * Creates a octree
  129332. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  129333. * @param creationFunc function to be used to instatiate the octree
  129334. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  129335. * @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.)
  129336. */
  129337. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  129338. /** 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.) */
  129339. maxDepth?: number);
  129340. /**
  129341. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  129342. * @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);
  129343. * @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);
  129344. * @param entries meshes to be added to the octree blocks
  129345. */
  129346. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  129347. /**
  129348. * Adds a mesh to the octree
  129349. * @param entry Mesh to add to the octree
  129350. */
  129351. addMesh(entry: T): void;
  129352. /**
  129353. * Remove an element from the octree
  129354. * @param entry defines the element to remove
  129355. */
  129356. removeMesh(entry: T): void;
  129357. /**
  129358. * Selects an array of meshes within the frustum
  129359. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  129360. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  129361. * @returns array of meshes within the frustum
  129362. */
  129363. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  129364. /**
  129365. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  129366. * @param sphereCenter defines the bounding sphere center
  129367. * @param sphereRadius defines the bounding sphere radius
  129368. * @param allowDuplicate defines if the selection array can contains duplicated entries
  129369. * @returns an array of objects that intersect the sphere
  129370. */
  129371. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  129372. /**
  129373. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  129374. * @param ray defines the ray to test with
  129375. * @returns array of intersected objects
  129376. */
  129377. intersectsRay(ray: Ray): SmartArray<T>;
  129378. /**
  129379. * Adds a mesh into the octree block if it intersects the block
  129380. */
  129381. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  129382. /**
  129383. * Adds a submesh into the octree block if it intersects the block
  129384. */
  129385. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  129386. }
  129387. }
  129388. declare module BABYLON {
  129389. interface Scene {
  129390. /**
  129391. * @hidden
  129392. * Backing Filed
  129393. */
  129394. _selectionOctree: Octree<AbstractMesh>;
  129395. /**
  129396. * Gets the octree used to boost mesh selection (picking)
  129397. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  129398. */
  129399. selectionOctree: Octree<AbstractMesh>;
  129400. /**
  129401. * Creates or updates the octree used to boost selection (picking)
  129402. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  129403. * @param maxCapacity defines the maximum capacity per leaf
  129404. * @param maxDepth defines the maximum depth of the octree
  129405. * @returns an octree of AbstractMesh
  129406. */
  129407. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  129408. }
  129409. interface AbstractMesh {
  129410. /**
  129411. * @hidden
  129412. * Backing Field
  129413. */
  129414. _submeshesOctree: Octree<SubMesh>;
  129415. /**
  129416. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  129417. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  129418. * @param maxCapacity defines the maximum size of each block (64 by default)
  129419. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  129420. * @returns the new octree
  129421. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  129422. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  129423. */
  129424. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  129425. }
  129426. /**
  129427. * Defines the octree scene component responsible to manage any octrees
  129428. * in a given scene.
  129429. */
  129430. export class OctreeSceneComponent {
  129431. /**
  129432. * The component name help to identify the component in the list of scene components.
  129433. */
  129434. readonly name: string;
  129435. /**
  129436. * The scene the component belongs to.
  129437. */
  129438. scene: Scene;
  129439. /**
  129440. * Indicates if the meshes have been checked to make sure they are isEnabled()
  129441. */
  129442. readonly checksIsEnabled: boolean;
  129443. /**
  129444. * Creates a new instance of the component for the given scene
  129445. * @param scene Defines the scene to register the component in
  129446. */
  129447. constructor(scene: Scene);
  129448. /**
  129449. * Registers the component in a given scene
  129450. */
  129451. register(): void;
  129452. /**
  129453. * Return the list of active meshes
  129454. * @returns the list of active meshes
  129455. */
  129456. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  129457. /**
  129458. * Return the list of active sub meshes
  129459. * @param mesh The mesh to get the candidates sub meshes from
  129460. * @returns the list of active sub meshes
  129461. */
  129462. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  129463. private _tempRay;
  129464. /**
  129465. * Return the list of sub meshes intersecting with a given local ray
  129466. * @param mesh defines the mesh to find the submesh for
  129467. * @param localRay defines the ray in local space
  129468. * @returns the list of intersecting sub meshes
  129469. */
  129470. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  129471. /**
  129472. * Return the list of sub meshes colliding with a collider
  129473. * @param mesh defines the mesh to find the submesh for
  129474. * @param collider defines the collider to evaluate the collision against
  129475. * @returns the list of colliding sub meshes
  129476. */
  129477. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  129478. /**
  129479. * Rebuilds the elements related to this component in case of
  129480. * context lost for instance.
  129481. */
  129482. rebuild(): void;
  129483. /**
  129484. * Disposes the component and the associated ressources.
  129485. */
  129486. dispose(): void;
  129487. }
  129488. }
  129489. declare module BABYLON {
  129490. /**
  129491. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  129492. */
  129493. export class Gizmo implements IDisposable {
  129494. /** The utility layer the gizmo will be added to */
  129495. gizmoLayer: UtilityLayerRenderer;
  129496. /**
  129497. * The root mesh of the gizmo
  129498. */
  129499. _rootMesh: Mesh;
  129500. private _attachedMesh;
  129501. private _attachedNode;
  129502. /**
  129503. * Ratio for the scale of the gizmo (Default: 1)
  129504. */
  129505. scaleRatio: number;
  129506. /**
  129507. * If a custom mesh has been set (Default: false)
  129508. */
  129509. protected _customMeshSet: boolean;
  129510. /**
  129511. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  129512. * * When set, interactions will be enabled
  129513. */
  129514. get attachedMesh(): Nullable<AbstractMesh>;
  129515. set attachedMesh(value: Nullable<AbstractMesh>);
  129516. /**
  129517. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  129518. * * When set, interactions will be enabled
  129519. */
  129520. get attachedNode(): Nullable<Node>;
  129521. set attachedNode(value: Nullable<Node>);
  129522. /**
  129523. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  129524. * @param mesh The mesh to replace the default mesh of the gizmo
  129525. */
  129526. setCustomMesh(mesh: Mesh): void;
  129527. /**
  129528. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  129529. */
  129530. updateGizmoRotationToMatchAttachedMesh: boolean;
  129531. /**
  129532. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  129533. */
  129534. updateGizmoPositionToMatchAttachedMesh: boolean;
  129535. /**
  129536. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  129537. */
  129538. updateScale: boolean;
  129539. protected _interactionsEnabled: boolean;
  129540. protected _attachedNodeChanged(value: Nullable<Node>): void;
  129541. private _beforeRenderObserver;
  129542. private _tempQuaternion;
  129543. private _tempVector;
  129544. private _tempVector2;
  129545. /**
  129546. * Creates a gizmo
  129547. * @param gizmoLayer The utility layer the gizmo will be added to
  129548. */
  129549. constructor(
  129550. /** The utility layer the gizmo will be added to */
  129551. gizmoLayer?: UtilityLayerRenderer);
  129552. /**
  129553. * Updates the gizmo to match the attached mesh's position/rotation
  129554. */
  129555. protected _update(): void;
  129556. /**
  129557. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  129558. * @param value Node, TransformNode or mesh
  129559. */
  129560. protected _matrixChanged(): void;
  129561. /**
  129562. * Disposes of the gizmo
  129563. */
  129564. dispose(): void;
  129565. }
  129566. }
  129567. declare module BABYLON {
  129568. /**
  129569. * Single plane drag gizmo
  129570. */
  129571. export class PlaneDragGizmo extends Gizmo {
  129572. /**
  129573. * Drag behavior responsible for the gizmos dragging interactions
  129574. */
  129575. dragBehavior: PointerDragBehavior;
  129576. private _pointerObserver;
  129577. /**
  129578. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  129579. */
  129580. snapDistance: number;
  129581. /**
  129582. * Event that fires each time the gizmo snaps to a new location.
  129583. * * snapDistance is the the change in distance
  129584. */
  129585. onSnapObservable: Observable<{
  129586. snapDistance: number;
  129587. }>;
  129588. private _plane;
  129589. private _coloredMaterial;
  129590. private _hoverMaterial;
  129591. private _isEnabled;
  129592. private _parent;
  129593. /** @hidden */
  129594. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  129595. /** @hidden */
  129596. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  129597. /**
  129598. * Creates a PlaneDragGizmo
  129599. * @param gizmoLayer The utility layer the gizmo will be added to
  129600. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  129601. * @param color The color of the gizmo
  129602. */
  129603. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  129604. protected _attachedNodeChanged(value: Nullable<Node>): void;
  129605. /**
  129606. * If the gizmo is enabled
  129607. */
  129608. set isEnabled(value: boolean);
  129609. get isEnabled(): boolean;
  129610. /**
  129611. * Disposes of the gizmo
  129612. */
  129613. dispose(): void;
  129614. }
  129615. }
  129616. declare module BABYLON {
  129617. /**
  129618. * Gizmo that enables dragging a mesh along 3 axis
  129619. */
  129620. export class PositionGizmo extends Gizmo {
  129621. /**
  129622. * Internal gizmo used for interactions on the x axis
  129623. */
  129624. xGizmo: AxisDragGizmo;
  129625. /**
  129626. * Internal gizmo used for interactions on the y axis
  129627. */
  129628. yGizmo: AxisDragGizmo;
  129629. /**
  129630. * Internal gizmo used for interactions on the z axis
  129631. */
  129632. zGizmo: AxisDragGizmo;
  129633. /**
  129634. * Internal gizmo used for interactions on the yz plane
  129635. */
  129636. xPlaneGizmo: PlaneDragGizmo;
  129637. /**
  129638. * Internal gizmo used for interactions on the xz plane
  129639. */
  129640. yPlaneGizmo: PlaneDragGizmo;
  129641. /**
  129642. * Internal gizmo used for interactions on the xy plane
  129643. */
  129644. zPlaneGizmo: PlaneDragGizmo;
  129645. /**
  129646. * private variables
  129647. */
  129648. private _meshAttached;
  129649. private _nodeAttached;
  129650. private _updateGizmoRotationToMatchAttachedMesh;
  129651. private _snapDistance;
  129652. private _scaleRatio;
  129653. /** Fires an event when any of it's sub gizmos are dragged */
  129654. onDragStartObservable: Observable<unknown>;
  129655. /** Fires an event when any of it's sub gizmos are released from dragging */
  129656. onDragEndObservable: Observable<unknown>;
  129657. /**
  129658. * If set to true, planar drag is enabled
  129659. */
  129660. private _planarGizmoEnabled;
  129661. get attachedMesh(): Nullable<AbstractMesh>;
  129662. set attachedMesh(mesh: Nullable<AbstractMesh>);
  129663. get attachedNode(): Nullable<Node>;
  129664. set attachedNode(node: Nullable<Node>);
  129665. /**
  129666. * Creates a PositionGizmo
  129667. * @param gizmoLayer The utility layer the gizmo will be added to
  129668. @param thickness display gizmo axis thickness
  129669. */
  129670. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  129671. /**
  129672. * If the planar drag gizmo is enabled
  129673. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  129674. */
  129675. set planarGizmoEnabled(value: boolean);
  129676. get planarGizmoEnabled(): boolean;
  129677. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  129678. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  129679. /**
  129680. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  129681. */
  129682. set snapDistance(value: number);
  129683. get snapDistance(): number;
  129684. /**
  129685. * Ratio for the scale of the gizmo (Default: 1)
  129686. */
  129687. set scaleRatio(value: number);
  129688. get scaleRatio(): number;
  129689. /**
  129690. * Disposes of the gizmo
  129691. */
  129692. dispose(): void;
  129693. /**
  129694. * CustomMeshes are not supported by this gizmo
  129695. * @param mesh The mesh to replace the default mesh of the gizmo
  129696. */
  129697. setCustomMesh(mesh: Mesh): void;
  129698. }
  129699. }
  129700. declare module BABYLON {
  129701. /**
  129702. * Single axis drag gizmo
  129703. */
  129704. export class AxisDragGizmo extends Gizmo {
  129705. /**
  129706. * Drag behavior responsible for the gizmos dragging interactions
  129707. */
  129708. dragBehavior: PointerDragBehavior;
  129709. private _pointerObserver;
  129710. /**
  129711. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  129712. */
  129713. snapDistance: number;
  129714. /**
  129715. * Event that fires each time the gizmo snaps to a new location.
  129716. * * snapDistance is the the change in distance
  129717. */
  129718. onSnapObservable: Observable<{
  129719. snapDistance: number;
  129720. }>;
  129721. private _isEnabled;
  129722. private _parent;
  129723. private _arrow;
  129724. private _coloredMaterial;
  129725. private _hoverMaterial;
  129726. /** @hidden */
  129727. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  129728. /** @hidden */
  129729. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  129730. /**
  129731. * Creates an AxisDragGizmo
  129732. * @param gizmoLayer The utility layer the gizmo will be added to
  129733. * @param dragAxis The axis which the gizmo will be able to drag on
  129734. * @param color The color of the gizmo
  129735. * @param thickness display gizmo axis thickness
  129736. */
  129737. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  129738. protected _attachedNodeChanged(value: Nullable<Node>): void;
  129739. /**
  129740. * If the gizmo is enabled
  129741. */
  129742. set isEnabled(value: boolean);
  129743. get isEnabled(): boolean;
  129744. /**
  129745. * Disposes of the gizmo
  129746. */
  129747. dispose(): void;
  129748. }
  129749. }
  129750. declare module BABYLON.Debug {
  129751. /**
  129752. * The Axes viewer will show 3 axes in a specific point in space
  129753. */
  129754. export class AxesViewer {
  129755. private _xAxis;
  129756. private _yAxis;
  129757. private _zAxis;
  129758. private _scaleLinesFactor;
  129759. private _instanced;
  129760. /**
  129761. * Gets the hosting scene
  129762. */
  129763. scene: Scene;
  129764. /**
  129765. * Gets or sets a number used to scale line length
  129766. */
  129767. scaleLines: number;
  129768. /** Gets the node hierarchy used to render x-axis */
  129769. get xAxis(): TransformNode;
  129770. /** Gets the node hierarchy used to render y-axis */
  129771. get yAxis(): TransformNode;
  129772. /** Gets the node hierarchy used to render z-axis */
  129773. get zAxis(): TransformNode;
  129774. /**
  129775. * Creates a new AxesViewer
  129776. * @param scene defines the hosting scene
  129777. * @param scaleLines defines a number used to scale line length (1 by default)
  129778. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  129779. * @param xAxis defines the node hierarchy used to render the x-axis
  129780. * @param yAxis defines the node hierarchy used to render the y-axis
  129781. * @param zAxis defines the node hierarchy used to render the z-axis
  129782. */
  129783. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  129784. /**
  129785. * Force the viewer to update
  129786. * @param position defines the position of the viewer
  129787. * @param xaxis defines the x axis of the viewer
  129788. * @param yaxis defines the y axis of the viewer
  129789. * @param zaxis defines the z axis of the viewer
  129790. */
  129791. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  129792. /**
  129793. * Creates an instance of this axes viewer.
  129794. * @returns a new axes viewer with instanced meshes
  129795. */
  129796. createInstance(): AxesViewer;
  129797. /** Releases resources */
  129798. dispose(): void;
  129799. private static _SetRenderingGroupId;
  129800. }
  129801. }
  129802. declare module BABYLON.Debug {
  129803. /**
  129804. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  129805. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  129806. */
  129807. export class BoneAxesViewer extends AxesViewer {
  129808. /**
  129809. * Gets or sets the target mesh where to display the axes viewer
  129810. */
  129811. mesh: Nullable<Mesh>;
  129812. /**
  129813. * Gets or sets the target bone where to display the axes viewer
  129814. */
  129815. bone: Nullable<Bone>;
  129816. /** Gets current position */
  129817. pos: Vector3;
  129818. /** Gets direction of X axis */
  129819. xaxis: Vector3;
  129820. /** Gets direction of Y axis */
  129821. yaxis: Vector3;
  129822. /** Gets direction of Z axis */
  129823. zaxis: Vector3;
  129824. /**
  129825. * Creates a new BoneAxesViewer
  129826. * @param scene defines the hosting scene
  129827. * @param bone defines the target bone
  129828. * @param mesh defines the target mesh
  129829. * @param scaleLines defines a scaling factor for line length (1 by default)
  129830. */
  129831. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  129832. /**
  129833. * Force the viewer to update
  129834. */
  129835. update(): void;
  129836. /** Releases resources */
  129837. dispose(): void;
  129838. }
  129839. }
  129840. declare module BABYLON {
  129841. /**
  129842. * Interface used to define scene explorer extensibility option
  129843. */
  129844. export interface IExplorerExtensibilityOption {
  129845. /**
  129846. * Define the option label
  129847. */
  129848. label: string;
  129849. /**
  129850. * Defines the action to execute on click
  129851. */
  129852. action: (entity: any) => void;
  129853. }
  129854. /**
  129855. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  129856. */
  129857. export interface IExplorerExtensibilityGroup {
  129858. /**
  129859. * Defines a predicate to test if a given type mut be extended
  129860. */
  129861. predicate: (entity: any) => boolean;
  129862. /**
  129863. * Gets the list of options added to a type
  129864. */
  129865. entries: IExplorerExtensibilityOption[];
  129866. }
  129867. /**
  129868. * Interface used to define the options to use to create the Inspector
  129869. */
  129870. export interface IInspectorOptions {
  129871. /**
  129872. * Display in overlay mode (default: false)
  129873. */
  129874. overlay?: boolean;
  129875. /**
  129876. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  129877. */
  129878. globalRoot?: HTMLElement;
  129879. /**
  129880. * Display the Scene explorer
  129881. */
  129882. showExplorer?: boolean;
  129883. /**
  129884. * Display the property inspector
  129885. */
  129886. showInspector?: boolean;
  129887. /**
  129888. * Display in embed mode (both panes on the right)
  129889. */
  129890. embedMode?: boolean;
  129891. /**
  129892. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  129893. */
  129894. handleResize?: boolean;
  129895. /**
  129896. * Allow the panes to popup (default: true)
  129897. */
  129898. enablePopup?: boolean;
  129899. /**
  129900. * Allow the panes to be closed by users (default: true)
  129901. */
  129902. enableClose?: boolean;
  129903. /**
  129904. * Optional list of extensibility entries
  129905. */
  129906. explorerExtensibility?: IExplorerExtensibilityGroup[];
  129907. /**
  129908. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  129909. */
  129910. inspectorURL?: string;
  129911. /**
  129912. * Optional initial tab (default to DebugLayerTab.Properties)
  129913. */
  129914. initialTab?: DebugLayerTab;
  129915. }
  129916. interface Scene {
  129917. /**
  129918. * @hidden
  129919. * Backing field
  129920. */
  129921. _debugLayer: DebugLayer;
  129922. /**
  129923. * Gets the debug layer (aka Inspector) associated with the scene
  129924. * @see https://doc.babylonjs.com/features/playground_debuglayer
  129925. */
  129926. debugLayer: DebugLayer;
  129927. }
  129928. /**
  129929. * Enum of inspector action tab
  129930. */
  129931. export enum DebugLayerTab {
  129932. /**
  129933. * Properties tag (default)
  129934. */
  129935. Properties = 0,
  129936. /**
  129937. * Debug tab
  129938. */
  129939. Debug = 1,
  129940. /**
  129941. * Statistics tab
  129942. */
  129943. Statistics = 2,
  129944. /**
  129945. * Tools tab
  129946. */
  129947. Tools = 3,
  129948. /**
  129949. * Settings tab
  129950. */
  129951. Settings = 4
  129952. }
  129953. /**
  129954. * The debug layer (aka Inspector) is the go to tool in order to better understand
  129955. * what is happening in your scene
  129956. * @see https://doc.babylonjs.com/features/playground_debuglayer
  129957. */
  129958. export class DebugLayer {
  129959. /**
  129960. * Define the url to get the inspector script from.
  129961. * By default it uses the babylonjs CDN.
  129962. * @ignoreNaming
  129963. */
  129964. static InspectorURL: string;
  129965. private _scene;
  129966. private BJSINSPECTOR;
  129967. private _onPropertyChangedObservable?;
  129968. /**
  129969. * Observable triggered when a property is changed through the inspector.
  129970. */
  129971. get onPropertyChangedObservable(): any;
  129972. /**
  129973. * Instantiates a new debug layer.
  129974. * The debug layer (aka Inspector) is the go to tool in order to better understand
  129975. * what is happening in your scene
  129976. * @see https://doc.babylonjs.com/features/playground_debuglayer
  129977. * @param scene Defines the scene to inspect
  129978. */
  129979. constructor(scene: Scene);
  129980. /** Creates the inspector window. */
  129981. private _createInspector;
  129982. /**
  129983. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  129984. * @param entity defines the entity to select
  129985. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  129986. */
  129987. select(entity: any, lineContainerTitles?: string | string[]): void;
  129988. /** Get the inspector from bundle or global */
  129989. private _getGlobalInspector;
  129990. /**
  129991. * Get if the inspector is visible or not.
  129992. * @returns true if visible otherwise, false
  129993. */
  129994. isVisible(): boolean;
  129995. /**
  129996. * Hide the inspector and close its window.
  129997. */
  129998. hide(): void;
  129999. /**
  130000. * Update the scene in the inspector
  130001. */
  130002. setAsActiveScene(): void;
  130003. /**
  130004. * Launch the debugLayer.
  130005. * @param config Define the configuration of the inspector
  130006. * @return a promise fulfilled when the debug layer is visible
  130007. */
  130008. show(config?: IInspectorOptions): Promise<DebugLayer>;
  130009. }
  130010. }
  130011. declare module BABYLON {
  130012. /**
  130013. * Class containing static functions to help procedurally build meshes
  130014. */
  130015. export class BoxBuilder {
  130016. /**
  130017. * Creates a box mesh
  130018. * * The parameter `size` sets the size (float) of each box side (default 1)
  130019. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  130020. * * 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)
  130021. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  130022. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130023. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130024. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130025. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  130026. * @param name defines the name of the mesh
  130027. * @param options defines the options used to create the mesh
  130028. * @param scene defines the hosting scene
  130029. * @returns the box mesh
  130030. */
  130031. static CreateBox(name: string, options: {
  130032. size?: number;
  130033. width?: number;
  130034. height?: number;
  130035. depth?: number;
  130036. faceUV?: Vector4[];
  130037. faceColors?: Color4[];
  130038. sideOrientation?: number;
  130039. frontUVs?: Vector4;
  130040. backUVs?: Vector4;
  130041. wrap?: boolean;
  130042. topBaseAt?: number;
  130043. bottomBaseAt?: number;
  130044. updatable?: boolean;
  130045. }, scene?: Nullable<Scene>): Mesh;
  130046. }
  130047. }
  130048. declare module BABYLON.Debug {
  130049. /**
  130050. * Used to show the physics impostor around the specific mesh
  130051. */
  130052. export class PhysicsViewer {
  130053. /** @hidden */
  130054. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  130055. /** @hidden */
  130056. protected _meshes: Array<Nullable<AbstractMesh>>;
  130057. /** @hidden */
  130058. protected _scene: Nullable<Scene>;
  130059. /** @hidden */
  130060. protected _numMeshes: number;
  130061. /** @hidden */
  130062. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  130063. private _renderFunction;
  130064. private _utilityLayer;
  130065. private _debugBoxMesh;
  130066. private _debugSphereMesh;
  130067. private _debugCylinderMesh;
  130068. private _debugMaterial;
  130069. private _debugMeshMeshes;
  130070. /**
  130071. * Creates a new PhysicsViewer
  130072. * @param scene defines the hosting scene
  130073. */
  130074. constructor(scene: Scene);
  130075. /** @hidden */
  130076. protected _updateDebugMeshes(): void;
  130077. /**
  130078. * Renders a specified physic impostor
  130079. * @param impostor defines the impostor to render
  130080. * @param targetMesh defines the mesh represented by the impostor
  130081. * @returns the new debug mesh used to render the impostor
  130082. */
  130083. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  130084. /**
  130085. * Hides a specified physic impostor
  130086. * @param impostor defines the impostor to hide
  130087. */
  130088. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  130089. private _getDebugMaterial;
  130090. private _getDebugBoxMesh;
  130091. private _getDebugSphereMesh;
  130092. private _getDebugCylinderMesh;
  130093. private _getDebugMeshMesh;
  130094. private _getDebugMesh;
  130095. /** Releases all resources */
  130096. dispose(): void;
  130097. }
  130098. }
  130099. declare module BABYLON {
  130100. /**
  130101. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  130102. * in order to better appreciate the issue one might have.
  130103. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  130104. */
  130105. export class RayHelper {
  130106. /**
  130107. * Defines the ray we are currently tryin to visualize.
  130108. */
  130109. ray: Nullable<Ray>;
  130110. private _renderPoints;
  130111. private _renderLine;
  130112. private _renderFunction;
  130113. private _scene;
  130114. private _onAfterRenderObserver;
  130115. private _onAfterStepObserver;
  130116. private _attachedToMesh;
  130117. private _meshSpaceDirection;
  130118. private _meshSpaceOrigin;
  130119. /**
  130120. * Helper function to create a colored helper in a scene in one line.
  130121. * @param ray Defines the ray we are currently tryin to visualize
  130122. * @param scene Defines the scene the ray is used in
  130123. * @param color Defines the color we want to see the ray in
  130124. * @returns The newly created ray helper.
  130125. */
  130126. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  130127. /**
  130128. * Instantiate a new ray helper.
  130129. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  130130. * in order to better appreciate the issue one might have.
  130131. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  130132. * @param ray Defines the ray we are currently tryin to visualize
  130133. */
  130134. constructor(ray: Ray);
  130135. /**
  130136. * Shows the ray we are willing to debug.
  130137. * @param scene Defines the scene the ray needs to be rendered in
  130138. * @param color Defines the color the ray needs to be rendered in
  130139. */
  130140. show(scene: Scene, color?: Color3): void;
  130141. /**
  130142. * Hides the ray we are debugging.
  130143. */
  130144. hide(): void;
  130145. private _render;
  130146. /**
  130147. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  130148. * @param mesh Defines the mesh we want the helper attached to
  130149. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  130150. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  130151. * @param length Defines the length of the ray
  130152. */
  130153. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  130154. /**
  130155. * Detach the ray helper from the mesh it has previously been attached to.
  130156. */
  130157. detachFromMesh(): void;
  130158. private _updateToMesh;
  130159. /**
  130160. * Dispose the helper and release its associated resources.
  130161. */
  130162. dispose(): void;
  130163. }
  130164. }
  130165. declare module BABYLON {
  130166. /**
  130167. * Defines the options associated with the creation of a SkeletonViewer.
  130168. */
  130169. export interface ISkeletonViewerOptions {
  130170. /** Should the system pause animations before building the Viewer? */
  130171. pauseAnimations: boolean;
  130172. /** Should the system return the skeleton to rest before building? */
  130173. returnToRest: boolean;
  130174. /** public Display Mode of the Viewer */
  130175. displayMode: number;
  130176. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  130177. displayOptions: ISkeletonViewerDisplayOptions;
  130178. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  130179. computeBonesUsingShaders: boolean;
  130180. }
  130181. /**
  130182. * Defines how to display the various bone meshes for the viewer.
  130183. */
  130184. export interface ISkeletonViewerDisplayOptions {
  130185. /** How far down to start tapering the bone spurs */
  130186. midStep?: number;
  130187. /** How big is the midStep? */
  130188. midStepFactor?: number;
  130189. /** Base for the Sphere Size */
  130190. sphereBaseSize?: number;
  130191. /** The ratio of the sphere to the longest bone in units */
  130192. sphereScaleUnit?: number;
  130193. /** Ratio for the Sphere Size */
  130194. sphereFactor?: number;
  130195. }
  130196. }
  130197. declare module BABYLON {
  130198. /**
  130199. * Class containing static functions to help procedurally build meshes
  130200. */
  130201. export class RibbonBuilder {
  130202. /**
  130203. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  130204. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  130205. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  130206. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  130207. * * 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
  130208. * * 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
  130209. * * 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
  130210. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130211. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130212. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  130213. * * 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
  130214. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  130215. * * 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
  130216. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  130217. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130218. * @param name defines the name of the mesh
  130219. * @param options defines the options used to create the mesh
  130220. * @param scene defines the hosting scene
  130221. * @returns the ribbon mesh
  130222. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  130223. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  130224. */
  130225. static CreateRibbon(name: string, options: {
  130226. pathArray: Vector3[][];
  130227. closeArray?: boolean;
  130228. closePath?: boolean;
  130229. offset?: number;
  130230. updatable?: boolean;
  130231. sideOrientation?: number;
  130232. frontUVs?: Vector4;
  130233. backUVs?: Vector4;
  130234. instance?: Mesh;
  130235. invertUV?: boolean;
  130236. uvs?: Vector2[];
  130237. colors?: Color4[];
  130238. }, scene?: Nullable<Scene>): Mesh;
  130239. }
  130240. }
  130241. declare module BABYLON {
  130242. /**
  130243. * Class containing static functions to help procedurally build meshes
  130244. */
  130245. export class ShapeBuilder {
  130246. /**
  130247. * 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.
  130248. * * 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.
  130249. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  130250. * * 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.
  130251. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  130252. * * 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
  130253. * * 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
  130254. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  130255. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130256. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130257. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  130258. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130259. * @param name defines the name of the mesh
  130260. * @param options defines the options used to create the mesh
  130261. * @param scene defines the hosting scene
  130262. * @returns the extruded shape mesh
  130263. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  130264. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  130265. */
  130266. static ExtrudeShape(name: string, options: {
  130267. shape: Vector3[];
  130268. path: Vector3[];
  130269. scale?: number;
  130270. rotation?: number;
  130271. cap?: number;
  130272. updatable?: boolean;
  130273. sideOrientation?: number;
  130274. frontUVs?: Vector4;
  130275. backUVs?: Vector4;
  130276. instance?: Mesh;
  130277. invertUV?: boolean;
  130278. }, scene?: Nullable<Scene>): Mesh;
  130279. /**
  130280. * Creates an custom extruded shape mesh.
  130281. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  130282. * * 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.
  130283. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  130284. * * 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
  130285. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  130286. * * 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
  130287. * * It must returns a float value that will be the scale value applied to the shape on each path point
  130288. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  130289. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  130290. * * 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
  130291. * * 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
  130292. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  130293. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130294. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130295. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  130296. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130297. * @param name defines the name of the mesh
  130298. * @param options defines the options used to create the mesh
  130299. * @param scene defines the hosting scene
  130300. * @returns the custom extruded shape mesh
  130301. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  130302. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  130303. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  130304. */
  130305. static ExtrudeShapeCustom(name: string, options: {
  130306. shape: Vector3[];
  130307. path: Vector3[];
  130308. scaleFunction?: any;
  130309. rotationFunction?: any;
  130310. ribbonCloseArray?: boolean;
  130311. ribbonClosePath?: boolean;
  130312. cap?: number;
  130313. updatable?: boolean;
  130314. sideOrientation?: number;
  130315. frontUVs?: Vector4;
  130316. backUVs?: Vector4;
  130317. instance?: Mesh;
  130318. invertUV?: boolean;
  130319. }, scene?: Nullable<Scene>): Mesh;
  130320. private static _ExtrudeShapeGeneric;
  130321. }
  130322. }
  130323. declare module BABYLON.Debug {
  130324. /**
  130325. * Class used to render a debug view of a given skeleton
  130326. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  130327. */
  130328. export class SkeletonViewer {
  130329. /** defines the skeleton to render */
  130330. skeleton: Skeleton;
  130331. /** defines the mesh attached to the skeleton */
  130332. mesh: AbstractMesh;
  130333. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  130334. autoUpdateBonesMatrices: boolean;
  130335. /** defines the rendering group id to use with the viewer */
  130336. renderingGroupId: number;
  130337. /** is the options for the viewer */
  130338. options: Partial<ISkeletonViewerOptions>;
  130339. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  130340. static readonly DISPLAY_LINES: number;
  130341. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  130342. static readonly DISPLAY_SPHERES: number;
  130343. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  130344. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  130345. /** If SkeletonViewer scene scope. */
  130346. private _scene;
  130347. /** Gets or sets the color used to render the skeleton */
  130348. color: Color3;
  130349. /** Array of the points of the skeleton fo the line view. */
  130350. private _debugLines;
  130351. /** The SkeletonViewers Mesh. */
  130352. private _debugMesh;
  130353. /** If SkeletonViewer is enabled. */
  130354. private _isEnabled;
  130355. /** If SkeletonViewer is ready. */
  130356. private _ready;
  130357. /** SkeletonViewer render observable. */
  130358. private _obs;
  130359. /** The Utility Layer to render the gizmos in. */
  130360. private _utilityLayer;
  130361. private _boneIndices;
  130362. /** Gets the Scene. */
  130363. get scene(): Scene;
  130364. /** Gets the utilityLayer. */
  130365. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  130366. /** Checks Ready Status. */
  130367. get isReady(): Boolean;
  130368. /** Sets Ready Status. */
  130369. set ready(value: boolean);
  130370. /** Gets the debugMesh */
  130371. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  130372. /** Sets the debugMesh */
  130373. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  130374. /** Gets the material */
  130375. get material(): StandardMaterial;
  130376. /** Sets the material */
  130377. set material(value: StandardMaterial);
  130378. /** Gets the material */
  130379. get displayMode(): number;
  130380. /** Sets the material */
  130381. set displayMode(value: number);
  130382. /**
  130383. * Creates a new SkeletonViewer
  130384. * @param skeleton defines the skeleton to render
  130385. * @param mesh defines the mesh attached to the skeleton
  130386. * @param scene defines the hosting scene
  130387. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  130388. * @param renderingGroupId defines the rendering group id to use with the viewer
  130389. * @param options All of the extra constructor options for the SkeletonViewer
  130390. */
  130391. constructor(
  130392. /** defines the skeleton to render */
  130393. skeleton: Skeleton,
  130394. /** defines the mesh attached to the skeleton */
  130395. mesh: AbstractMesh,
  130396. /** The Scene scope*/
  130397. scene: Scene,
  130398. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  130399. autoUpdateBonesMatrices?: boolean,
  130400. /** defines the rendering group id to use with the viewer */
  130401. renderingGroupId?: number,
  130402. /** is the options for the viewer */
  130403. options?: Partial<ISkeletonViewerOptions>);
  130404. /** The Dynamic bindings for the update functions */
  130405. private _bindObs;
  130406. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  130407. update(): void;
  130408. /** Gets or sets a boolean indicating if the viewer is enabled */
  130409. set isEnabled(value: boolean);
  130410. get isEnabled(): boolean;
  130411. private _getBonePosition;
  130412. private _getLinesForBonesWithLength;
  130413. private _getLinesForBonesNoLength;
  130414. /** function to revert the mesh and scene back to the initial state. */
  130415. private _revert;
  130416. /** function to build and bind sphere joint points and spur bone representations. */
  130417. private _buildSpheresAndSpurs;
  130418. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  130419. private _displayLinesUpdate;
  130420. /** Changes the displayMode of the skeleton viewer
  130421. * @param mode The displayMode numerical value
  130422. */
  130423. changeDisplayMode(mode: number): void;
  130424. /** Changes the displayMode of the skeleton viewer
  130425. * @param option String of the option name
  130426. * @param value The numerical option value
  130427. */
  130428. changeDisplayOptions(option: string, value: number): void;
  130429. /** Release associated resources */
  130430. dispose(): void;
  130431. }
  130432. }
  130433. declare module BABYLON {
  130434. /**
  130435. * Enum for Device Types
  130436. */
  130437. export enum DeviceType {
  130438. /** Generic */
  130439. Generic = 0,
  130440. /** Keyboard */
  130441. Keyboard = 1,
  130442. /** Mouse */
  130443. Mouse = 2,
  130444. /** Touch Pointers */
  130445. Touch = 3,
  130446. /** PS4 Dual Shock */
  130447. DualShock = 4,
  130448. /** Xbox */
  130449. Xbox = 5,
  130450. /** Switch Controller */
  130451. Switch = 6
  130452. }
  130453. /**
  130454. * Enum for All Pointers (Touch/Mouse)
  130455. */
  130456. export enum PointerInput {
  130457. /** Horizontal Axis */
  130458. Horizontal = 0,
  130459. /** Vertical Axis */
  130460. Vertical = 1,
  130461. /** Left Click or Touch */
  130462. LeftClick = 2,
  130463. /** Middle Click */
  130464. MiddleClick = 3,
  130465. /** Right Click */
  130466. RightClick = 4,
  130467. /** Browser Back */
  130468. BrowserBack = 5,
  130469. /** Browser Forward */
  130470. BrowserForward = 6
  130471. }
  130472. /**
  130473. * Enum for Dual Shock Gamepad
  130474. */
  130475. export enum DualShockInput {
  130476. /** Cross */
  130477. Cross = 0,
  130478. /** Circle */
  130479. Circle = 1,
  130480. /** Square */
  130481. Square = 2,
  130482. /** Triangle */
  130483. Triangle = 3,
  130484. /** L1 */
  130485. L1 = 4,
  130486. /** R1 */
  130487. R1 = 5,
  130488. /** L2 */
  130489. L2 = 6,
  130490. /** R2 */
  130491. R2 = 7,
  130492. /** Share */
  130493. Share = 8,
  130494. /** Options */
  130495. Options = 9,
  130496. /** L3 */
  130497. L3 = 10,
  130498. /** R3 */
  130499. R3 = 11,
  130500. /** DPadUp */
  130501. DPadUp = 12,
  130502. /** DPadDown */
  130503. DPadDown = 13,
  130504. /** DPadLeft */
  130505. DPadLeft = 14,
  130506. /** DRight */
  130507. DPadRight = 15,
  130508. /** Home */
  130509. Home = 16,
  130510. /** TouchPad */
  130511. TouchPad = 17,
  130512. /** LStickXAxis */
  130513. LStickXAxis = 18,
  130514. /** LStickYAxis */
  130515. LStickYAxis = 19,
  130516. /** RStickXAxis */
  130517. RStickXAxis = 20,
  130518. /** RStickYAxis */
  130519. RStickYAxis = 21
  130520. }
  130521. /**
  130522. * Enum for Xbox Gamepad
  130523. */
  130524. export enum XboxInput {
  130525. /** A */
  130526. A = 0,
  130527. /** B */
  130528. B = 1,
  130529. /** X */
  130530. X = 2,
  130531. /** Y */
  130532. Y = 3,
  130533. /** LB */
  130534. LB = 4,
  130535. /** RB */
  130536. RB = 5,
  130537. /** LT */
  130538. LT = 6,
  130539. /** RT */
  130540. RT = 7,
  130541. /** Back */
  130542. Back = 8,
  130543. /** Start */
  130544. Start = 9,
  130545. /** LS */
  130546. LS = 10,
  130547. /** RS */
  130548. RS = 11,
  130549. /** DPadUp */
  130550. DPadUp = 12,
  130551. /** DPadDown */
  130552. DPadDown = 13,
  130553. /** DPadLeft */
  130554. DPadLeft = 14,
  130555. /** DRight */
  130556. DPadRight = 15,
  130557. /** Home */
  130558. Home = 16,
  130559. /** LStickXAxis */
  130560. LStickXAxis = 17,
  130561. /** LStickYAxis */
  130562. LStickYAxis = 18,
  130563. /** RStickXAxis */
  130564. RStickXAxis = 19,
  130565. /** RStickYAxis */
  130566. RStickYAxis = 20
  130567. }
  130568. /**
  130569. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  130570. */
  130571. export enum SwitchInput {
  130572. /** B */
  130573. B = 0,
  130574. /** A */
  130575. A = 1,
  130576. /** Y */
  130577. Y = 2,
  130578. /** X */
  130579. X = 3,
  130580. /** L */
  130581. L = 4,
  130582. /** R */
  130583. R = 5,
  130584. /** ZL */
  130585. ZL = 6,
  130586. /** ZR */
  130587. ZR = 7,
  130588. /** Minus */
  130589. Minus = 8,
  130590. /** Plus */
  130591. Plus = 9,
  130592. /** LS */
  130593. LS = 10,
  130594. /** RS */
  130595. RS = 11,
  130596. /** DPadUp */
  130597. DPadUp = 12,
  130598. /** DPadDown */
  130599. DPadDown = 13,
  130600. /** DPadLeft */
  130601. DPadLeft = 14,
  130602. /** DRight */
  130603. DPadRight = 15,
  130604. /** Home */
  130605. Home = 16,
  130606. /** Capture */
  130607. Capture = 17,
  130608. /** LStickXAxis */
  130609. LStickXAxis = 18,
  130610. /** LStickYAxis */
  130611. LStickYAxis = 19,
  130612. /** RStickXAxis */
  130613. RStickXAxis = 20,
  130614. /** RStickYAxis */
  130615. RStickYAxis = 21
  130616. }
  130617. }
  130618. declare module BABYLON {
  130619. /**
  130620. * This class will take all inputs from Keyboard, Pointer, and
  130621. * any Gamepads and provide a polling system that all devices
  130622. * will use. This class assumes that there will only be one
  130623. * pointer device and one keyboard.
  130624. */
  130625. export class DeviceInputSystem implements IDisposable {
  130626. /**
  130627. * Callback to be triggered when a device is connected
  130628. */
  130629. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  130630. /**
  130631. * Callback to be triggered when a device is disconnected
  130632. */
  130633. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  130634. /**
  130635. * Callback to be triggered when event driven input is updated
  130636. */
  130637. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  130638. private _inputs;
  130639. private _gamepads;
  130640. private _keyboardActive;
  130641. private _pointerActive;
  130642. private _elementToAttachTo;
  130643. private _keyboardDownEvent;
  130644. private _keyboardUpEvent;
  130645. private _pointerMoveEvent;
  130646. private _pointerDownEvent;
  130647. private _pointerUpEvent;
  130648. private _gamepadConnectedEvent;
  130649. private _gamepadDisconnectedEvent;
  130650. private static _MAX_KEYCODES;
  130651. private static _MAX_POINTER_INPUTS;
  130652. private constructor();
  130653. /**
  130654. * Creates a new DeviceInputSystem instance
  130655. * @param engine Engine to pull input element from
  130656. * @returns The new instance
  130657. */
  130658. static Create(engine: Engine): DeviceInputSystem;
  130659. /**
  130660. * Checks for current device input value, given an id and input index
  130661. * @param deviceName Id of connected device
  130662. * @param inputIndex Index of device input
  130663. * @returns Current value of input
  130664. */
  130665. /**
  130666. * Checks for current device input value, given an id and input index
  130667. * @param deviceType Enum specifiying device type
  130668. * @param deviceSlot "Slot" or index that device is referenced in
  130669. * @param inputIndex Id of input to be checked
  130670. * @returns Current value of input
  130671. */
  130672. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  130673. /**
  130674. * Dispose of all the eventlisteners
  130675. */
  130676. dispose(): void;
  130677. /**
  130678. * Add device and inputs to device array
  130679. * @param deviceType Enum specifiying device type
  130680. * @param deviceSlot "Slot" or index that device is referenced in
  130681. * @param numberOfInputs Number of input entries to create for given device
  130682. */
  130683. private _registerDevice;
  130684. /**
  130685. * Given a specific device name, remove that device from the device map
  130686. * @param deviceType Enum specifiying device type
  130687. * @param deviceSlot "Slot" or index that device is referenced in
  130688. */
  130689. private _unregisterDevice;
  130690. /**
  130691. * Handle all actions that come from keyboard interaction
  130692. */
  130693. private _handleKeyActions;
  130694. /**
  130695. * Handle all actions that come from pointer interaction
  130696. */
  130697. private _handlePointerActions;
  130698. /**
  130699. * Handle all actions that come from gamepad interaction
  130700. */
  130701. private _handleGamepadActions;
  130702. /**
  130703. * Update all non-event based devices with each frame
  130704. * @param deviceType Enum specifiying device type
  130705. * @param deviceSlot "Slot" or index that device is referenced in
  130706. * @param inputIndex Id of input to be checked
  130707. */
  130708. private _updateDevice;
  130709. /**
  130710. * Gets DeviceType from the device name
  130711. * @param deviceName Name of Device from DeviceInputSystem
  130712. * @returns DeviceType enum value
  130713. */
  130714. private _getGamepadDeviceType;
  130715. }
  130716. }
  130717. declare module BABYLON {
  130718. /**
  130719. * Type to handle enforcement of inputs
  130720. */
  130721. 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;
  130722. }
  130723. declare module BABYLON {
  130724. /**
  130725. * Class that handles all input for a specific device
  130726. */
  130727. export class DeviceSource<T extends DeviceType> {
  130728. /** Type of device */
  130729. readonly deviceType: DeviceType;
  130730. /** "Slot" or index that device is referenced in */
  130731. readonly deviceSlot: number;
  130732. /**
  130733. * Observable to handle device input changes per device
  130734. */
  130735. readonly onInputChangedObservable: Observable<{
  130736. inputIndex: DeviceInput<T>;
  130737. previousState: Nullable<number>;
  130738. currentState: Nullable<number>;
  130739. }>;
  130740. private readonly _deviceInputSystem;
  130741. /**
  130742. * Default Constructor
  130743. * @param deviceInputSystem Reference to DeviceInputSystem
  130744. * @param deviceType Type of device
  130745. * @param deviceSlot "Slot" or index that device is referenced in
  130746. */
  130747. constructor(deviceInputSystem: DeviceInputSystem,
  130748. /** Type of device */
  130749. deviceType: DeviceType,
  130750. /** "Slot" or index that device is referenced in */
  130751. deviceSlot?: number);
  130752. /**
  130753. * Get input for specific input
  130754. * @param inputIndex index of specific input on device
  130755. * @returns Input value from DeviceInputSystem
  130756. */
  130757. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  130758. }
  130759. /**
  130760. * Class to keep track of devices
  130761. */
  130762. export class DeviceSourceManager implements IDisposable {
  130763. /**
  130764. * Observable to be triggered when before a device is connected
  130765. */
  130766. readonly onBeforeDeviceConnectedObservable: Observable<{
  130767. deviceType: DeviceType;
  130768. deviceSlot: number;
  130769. }>;
  130770. /**
  130771. * Observable to be triggered when before a device is disconnected
  130772. */
  130773. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  130774. deviceType: DeviceType;
  130775. deviceSlot: number;
  130776. }>;
  130777. /**
  130778. * Observable to be triggered when after a device is connected
  130779. */
  130780. readonly onAfterDeviceConnectedObservable: Observable<{
  130781. deviceType: DeviceType;
  130782. deviceSlot: number;
  130783. }>;
  130784. /**
  130785. * Observable to be triggered when after a device is disconnected
  130786. */
  130787. readonly onAfterDeviceDisconnectedObservable: Observable<{
  130788. deviceType: DeviceType;
  130789. deviceSlot: number;
  130790. }>;
  130791. private readonly _devices;
  130792. private readonly _firstDevice;
  130793. private readonly _deviceInputSystem;
  130794. /**
  130795. * Default Constructor
  130796. * @param engine engine to pull input element from
  130797. */
  130798. constructor(engine: Engine);
  130799. /**
  130800. * Gets a DeviceSource, given a type and slot
  130801. * @param deviceType Enum specifying device type
  130802. * @param deviceSlot "Slot" or index that device is referenced in
  130803. * @returns DeviceSource object
  130804. */
  130805. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  130806. /**
  130807. * Gets an array of DeviceSource objects for a given device type
  130808. * @param deviceType Enum specifying device type
  130809. * @returns Array of DeviceSource objects
  130810. */
  130811. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  130812. /**
  130813. * Dispose of DeviceInputSystem and other parts
  130814. */
  130815. dispose(): void;
  130816. /**
  130817. * Function to add device name to device list
  130818. * @param deviceType Enum specifying device type
  130819. * @param deviceSlot "Slot" or index that device is referenced in
  130820. */
  130821. private _addDevice;
  130822. /**
  130823. * Function to remove device name to device list
  130824. * @param deviceType Enum specifying device type
  130825. * @param deviceSlot "Slot" or index that device is referenced in
  130826. */
  130827. private _removeDevice;
  130828. /**
  130829. * Updates array storing first connected device of each type
  130830. * @param type Type of Device
  130831. */
  130832. private _updateFirstDevices;
  130833. }
  130834. }
  130835. declare module BABYLON {
  130836. /**
  130837. * Options to create the null engine
  130838. */
  130839. export class NullEngineOptions {
  130840. /**
  130841. * Render width (Default: 512)
  130842. */
  130843. renderWidth: number;
  130844. /**
  130845. * Render height (Default: 256)
  130846. */
  130847. renderHeight: number;
  130848. /**
  130849. * Texture size (Default: 512)
  130850. */
  130851. textureSize: number;
  130852. /**
  130853. * If delta time between frames should be constant
  130854. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  130855. */
  130856. deterministicLockstep: boolean;
  130857. /**
  130858. * Maximum about of steps between frames (Default: 4)
  130859. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  130860. */
  130861. lockstepMaxSteps: number;
  130862. /**
  130863. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  130864. */
  130865. useHighPrecisionMatrix?: boolean;
  130866. }
  130867. /**
  130868. * The null engine class provides support for headless version of babylon.js.
  130869. * This can be used in server side scenario or for testing purposes
  130870. */
  130871. export class NullEngine extends Engine {
  130872. private _options;
  130873. /**
  130874. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  130875. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  130876. * @returns true if engine is in deterministic lock step mode
  130877. */
  130878. isDeterministicLockStep(): boolean;
  130879. /**
  130880. * Gets the max steps when engine is running in deterministic lock step
  130881. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  130882. * @returns the max steps
  130883. */
  130884. getLockstepMaxSteps(): number;
  130885. /**
  130886. * Gets the current hardware scaling level.
  130887. * By default the hardware scaling level is computed from the window device ratio.
  130888. * 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.
  130889. * @returns a number indicating the current hardware scaling level
  130890. */
  130891. getHardwareScalingLevel(): number;
  130892. constructor(options?: NullEngineOptions);
  130893. /**
  130894. * Creates a vertex buffer
  130895. * @param vertices the data for the vertex buffer
  130896. * @returns the new WebGL static buffer
  130897. */
  130898. createVertexBuffer(vertices: FloatArray): DataBuffer;
  130899. /**
  130900. * Creates a new index buffer
  130901. * @param indices defines the content of the index buffer
  130902. * @param updatable defines if the index buffer must be updatable
  130903. * @returns a new webGL buffer
  130904. */
  130905. createIndexBuffer(indices: IndicesArray): DataBuffer;
  130906. /**
  130907. * Clear the current render buffer or the current render target (if any is set up)
  130908. * @param color defines the color to use
  130909. * @param backBuffer defines if the back buffer must be cleared
  130910. * @param depth defines if the depth buffer must be cleared
  130911. * @param stencil defines if the stencil buffer must be cleared
  130912. */
  130913. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  130914. /**
  130915. * Gets the current render width
  130916. * @param useScreen defines if screen size must be used (or the current render target if any)
  130917. * @returns a number defining the current render width
  130918. */
  130919. getRenderWidth(useScreen?: boolean): number;
  130920. /**
  130921. * Gets the current render height
  130922. * @param useScreen defines if screen size must be used (or the current render target if any)
  130923. * @returns a number defining the current render height
  130924. */
  130925. getRenderHeight(useScreen?: boolean): number;
  130926. /**
  130927. * Set the WebGL's viewport
  130928. * @param viewport defines the viewport element to be used
  130929. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  130930. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  130931. */
  130932. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  130933. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  130934. /**
  130935. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  130936. * @param pipelineContext defines the pipeline context to use
  130937. * @param uniformsNames defines the list of uniform names
  130938. * @returns an array of webGL uniform locations
  130939. */
  130940. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  130941. /**
  130942. * Gets the lsit of active attributes for a given webGL program
  130943. * @param pipelineContext defines the pipeline context to use
  130944. * @param attributesNames defines the list of attribute names to get
  130945. * @returns an array of indices indicating the offset of each attribute
  130946. */
  130947. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  130948. /**
  130949. * Binds an effect to the webGL context
  130950. * @param effect defines the effect to bind
  130951. */
  130952. bindSamplers(effect: Effect): void;
  130953. /**
  130954. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  130955. * @param effect defines the effect to activate
  130956. */
  130957. enableEffect(effect: Effect): void;
  130958. /**
  130959. * Set various states to the webGL context
  130960. * @param culling defines backface culling state
  130961. * @param zOffset defines the value to apply to zOffset (0 by default)
  130962. * @param force defines if states must be applied even if cache is up to date
  130963. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  130964. */
  130965. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  130966. /**
  130967. * Set the value of an uniform to an array of int32
  130968. * @param uniform defines the webGL uniform location where to store the value
  130969. * @param array defines the array of int32 to store
  130970. */
  130971. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  130972. /**
  130973. * Set the value of an uniform to an array of int32 (stored as vec2)
  130974. * @param uniform defines the webGL uniform location where to store the value
  130975. * @param array defines the array of int32 to store
  130976. */
  130977. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  130978. /**
  130979. * Set the value of an uniform to an array of int32 (stored as vec3)
  130980. * @param uniform defines the webGL uniform location where to store the value
  130981. * @param array defines the array of int32 to store
  130982. */
  130983. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  130984. /**
  130985. * Set the value of an uniform to an array of int32 (stored as vec4)
  130986. * @param uniform defines the webGL uniform location where to store the value
  130987. * @param array defines the array of int32 to store
  130988. */
  130989. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  130990. /**
  130991. * Set the value of an uniform to an array of float32
  130992. * @param uniform defines the webGL uniform location where to store the value
  130993. * @param array defines the array of float32 to store
  130994. */
  130995. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  130996. /**
  130997. * Set the value of an uniform to an array of float32 (stored as vec2)
  130998. * @param uniform defines the webGL uniform location where to store the value
  130999. * @param array defines the array of float32 to store
  131000. */
  131001. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  131002. /**
  131003. * Set the value of an uniform to an array of float32 (stored as vec3)
  131004. * @param uniform defines the webGL uniform location where to store the value
  131005. * @param array defines the array of float32 to store
  131006. */
  131007. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  131008. /**
  131009. * Set the value of an uniform to an array of float32 (stored as vec4)
  131010. * @param uniform defines the webGL uniform location where to store the value
  131011. * @param array defines the array of float32 to store
  131012. */
  131013. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  131014. /**
  131015. * Set the value of an uniform to an array of number
  131016. * @param uniform defines the webGL uniform location where to store the value
  131017. * @param array defines the array of number to store
  131018. */
  131019. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  131020. /**
  131021. * Set the value of an uniform to an array of number (stored as vec2)
  131022. * @param uniform defines the webGL uniform location where to store the value
  131023. * @param array defines the array of number to store
  131024. */
  131025. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  131026. /**
  131027. * Set the value of an uniform to an array of number (stored as vec3)
  131028. * @param uniform defines the webGL uniform location where to store the value
  131029. * @param array defines the array of number to store
  131030. */
  131031. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  131032. /**
  131033. * Set the value of an uniform to an array of number (stored as vec4)
  131034. * @param uniform defines the webGL uniform location where to store the value
  131035. * @param array defines the array of number to store
  131036. */
  131037. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  131038. /**
  131039. * Set the value of an uniform to an array of float32 (stored as matrices)
  131040. * @param uniform defines the webGL uniform location where to store the value
  131041. * @param matrices defines the array of float32 to store
  131042. */
  131043. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  131044. /**
  131045. * Set the value of an uniform to a matrix (3x3)
  131046. * @param uniform defines the webGL uniform location where to store the value
  131047. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  131048. */
  131049. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  131050. /**
  131051. * Set the value of an uniform to a matrix (2x2)
  131052. * @param uniform defines the webGL uniform location where to store the value
  131053. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  131054. */
  131055. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  131056. /**
  131057. * Set the value of an uniform to a number (float)
  131058. * @param uniform defines the webGL uniform location where to store the value
  131059. * @param value defines the float number to store
  131060. */
  131061. setFloat(uniform: WebGLUniformLocation, value: number): void;
  131062. /**
  131063. * Set the value of an uniform to a vec2
  131064. * @param uniform defines the webGL uniform location where to store the value
  131065. * @param x defines the 1st component of the value
  131066. * @param y defines the 2nd component of the value
  131067. */
  131068. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  131069. /**
  131070. * Set the value of an uniform to a vec3
  131071. * @param uniform defines the webGL uniform location where to store the value
  131072. * @param x defines the 1st component of the value
  131073. * @param y defines the 2nd component of the value
  131074. * @param z defines the 3rd component of the value
  131075. */
  131076. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  131077. /**
  131078. * Set the value of an uniform to a boolean
  131079. * @param uniform defines the webGL uniform location where to store the value
  131080. * @param bool defines the boolean to store
  131081. */
  131082. setBool(uniform: WebGLUniformLocation, bool: number): void;
  131083. /**
  131084. * Set the value of an uniform to a vec4
  131085. * @param uniform defines the webGL uniform location where to store the value
  131086. * @param x defines the 1st component of the value
  131087. * @param y defines the 2nd component of the value
  131088. * @param z defines the 3rd component of the value
  131089. * @param w defines the 4th component of the value
  131090. */
  131091. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  131092. /**
  131093. * Sets the current alpha mode
  131094. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  131095. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  131096. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  131097. */
  131098. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  131099. /**
  131100. * Bind webGl buffers directly to the webGL context
  131101. * @param vertexBuffers defines the vertex buffer to bind
  131102. * @param indexBuffer defines the index buffer to bind
  131103. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  131104. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  131105. * @param effect defines the effect associated with the vertex buffer
  131106. */
  131107. bindBuffers(vertexBuffers: {
  131108. [key: string]: VertexBuffer;
  131109. }, indexBuffer: DataBuffer, effect: Effect): void;
  131110. /**
  131111. * Force the entire cache to be cleared
  131112. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  131113. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  131114. */
  131115. wipeCaches(bruteForce?: boolean): void;
  131116. /**
  131117. * Send a draw order
  131118. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  131119. * @param indexStart defines the starting index
  131120. * @param indexCount defines the number of index to draw
  131121. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  131122. */
  131123. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  131124. /**
  131125. * Draw a list of indexed primitives
  131126. * @param fillMode defines the primitive to use
  131127. * @param indexStart defines the starting index
  131128. * @param indexCount defines the number of index to draw
  131129. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  131130. */
  131131. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  131132. /**
  131133. * Draw a list of unindexed primitives
  131134. * @param fillMode defines the primitive to use
  131135. * @param verticesStart defines the index of first vertex to draw
  131136. * @param verticesCount defines the count of vertices to draw
  131137. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  131138. */
  131139. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  131140. /** @hidden */
  131141. _createTexture(): WebGLTexture;
  131142. /** @hidden */
  131143. _releaseTexture(texture: InternalTexture): void;
  131144. /**
  131145. * Usually called from Texture.ts.
  131146. * Passed information to create a WebGLTexture
  131147. * @param urlArg defines a value which contains one of the following:
  131148. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  131149. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  131150. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  131151. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  131152. * @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)
  131153. * @param scene needed for loading to the correct scene
  131154. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  131155. * @param onLoad optional callback to be called upon successful completion
  131156. * @param onError optional callback to be called upon failure
  131157. * @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
  131158. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  131159. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  131160. * @param forcedExtension defines the extension to use to pick the right loader
  131161. * @param mimeType defines an optional mime type
  131162. * @returns a InternalTexture for assignment back into BABYLON.Texture
  131163. */
  131164. 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;
  131165. /**
  131166. * Creates a new render target texture
  131167. * @param size defines the size of the texture
  131168. * @param options defines the options used to create the texture
  131169. * @returns a new render target texture stored in an InternalTexture
  131170. */
  131171. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  131172. /**
  131173. * Update the sampling mode of a given texture
  131174. * @param samplingMode defines the required sampling mode
  131175. * @param texture defines the texture to update
  131176. */
  131177. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  131178. /**
  131179. * Binds the frame buffer to the specified texture.
  131180. * @param texture The texture to render to or null for the default canvas
  131181. * @param faceIndex The face of the texture to render to in case of cube texture
  131182. * @param requiredWidth The width of the target to render to
  131183. * @param requiredHeight The height of the target to render to
  131184. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  131185. * @param lodLevel defines le lod level to bind to the frame buffer
  131186. */
  131187. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  131188. /**
  131189. * Unbind the current render target texture from the webGL context
  131190. * @param texture defines the render target texture to unbind
  131191. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  131192. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  131193. */
  131194. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  131195. /**
  131196. * Creates a dynamic vertex buffer
  131197. * @param vertices the data for the dynamic vertex buffer
  131198. * @returns the new WebGL dynamic buffer
  131199. */
  131200. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  131201. /**
  131202. * Update the content of a dynamic texture
  131203. * @param texture defines the texture to update
  131204. * @param canvas defines the canvas containing the source
  131205. * @param invertY defines if data must be stored with Y axis inverted
  131206. * @param premulAlpha defines if alpha is stored as premultiplied
  131207. * @param format defines the format of the data
  131208. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  131209. */
  131210. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  131211. /**
  131212. * Gets a boolean indicating if all created effects are ready
  131213. * @returns true if all effects are ready
  131214. */
  131215. areAllEffectsReady(): boolean;
  131216. /**
  131217. * @hidden
  131218. * Get the current error code of the webGL context
  131219. * @returns the error code
  131220. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  131221. */
  131222. getError(): number;
  131223. /** @hidden */
  131224. _getUnpackAlignement(): number;
  131225. /** @hidden */
  131226. _unpackFlipY(value: boolean): void;
  131227. /**
  131228. * Update a dynamic index buffer
  131229. * @param indexBuffer defines the target index buffer
  131230. * @param indices defines the data to update
  131231. * @param offset defines the offset in the target index buffer where update should start
  131232. */
  131233. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  131234. /**
  131235. * Updates a dynamic vertex buffer.
  131236. * @param vertexBuffer the vertex buffer to update
  131237. * @param vertices the data used to update the vertex buffer
  131238. * @param byteOffset the byte offset of the data (optional)
  131239. * @param byteLength the byte length of the data (optional)
  131240. */
  131241. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  131242. /** @hidden */
  131243. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  131244. /** @hidden */
  131245. _bindTexture(channel: number, texture: InternalTexture): void;
  131246. protected _deleteBuffer(buffer: WebGLBuffer): void;
  131247. /**
  131248. * 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
  131249. */
  131250. releaseEffects(): void;
  131251. displayLoadingUI(): void;
  131252. hideLoadingUI(): void;
  131253. /** @hidden */
  131254. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  131255. /** @hidden */
  131256. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  131257. /** @hidden */
  131258. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  131259. /** @hidden */
  131260. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  131261. }
  131262. }
  131263. declare module BABYLON {
  131264. /**
  131265. * @hidden
  131266. **/
  131267. export class _TimeToken {
  131268. _startTimeQuery: Nullable<WebGLQuery>;
  131269. _endTimeQuery: Nullable<WebGLQuery>;
  131270. _timeElapsedQuery: Nullable<WebGLQuery>;
  131271. _timeElapsedQueryEnded: boolean;
  131272. }
  131273. }
  131274. declare module BABYLON {
  131275. /** @hidden */
  131276. export class _OcclusionDataStorage {
  131277. /** @hidden */
  131278. occlusionInternalRetryCounter: number;
  131279. /** @hidden */
  131280. isOcclusionQueryInProgress: boolean;
  131281. /** @hidden */
  131282. isOccluded: boolean;
  131283. /** @hidden */
  131284. occlusionRetryCount: number;
  131285. /** @hidden */
  131286. occlusionType: number;
  131287. /** @hidden */
  131288. occlusionQueryAlgorithmType: number;
  131289. }
  131290. interface Engine {
  131291. /**
  131292. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  131293. * @return the new query
  131294. */
  131295. createQuery(): WebGLQuery;
  131296. /**
  131297. * Delete and release a webGL query
  131298. * @param query defines the query to delete
  131299. * @return the current engine
  131300. */
  131301. deleteQuery(query: WebGLQuery): Engine;
  131302. /**
  131303. * Check if a given query has resolved and got its value
  131304. * @param query defines the query to check
  131305. * @returns true if the query got its value
  131306. */
  131307. isQueryResultAvailable(query: WebGLQuery): boolean;
  131308. /**
  131309. * Gets the value of a given query
  131310. * @param query defines the query to check
  131311. * @returns the value of the query
  131312. */
  131313. getQueryResult(query: WebGLQuery): number;
  131314. /**
  131315. * Initiates an occlusion query
  131316. * @param algorithmType defines the algorithm to use
  131317. * @param query defines the query to use
  131318. * @returns the current engine
  131319. * @see https://doc.babylonjs.com/features/occlusionquery
  131320. */
  131321. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  131322. /**
  131323. * Ends an occlusion query
  131324. * @see https://doc.babylonjs.com/features/occlusionquery
  131325. * @param algorithmType defines the algorithm to use
  131326. * @returns the current engine
  131327. */
  131328. endOcclusionQuery(algorithmType: number): Engine;
  131329. /**
  131330. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  131331. * Please note that only one query can be issued at a time
  131332. * @returns a time token used to track the time span
  131333. */
  131334. startTimeQuery(): Nullable<_TimeToken>;
  131335. /**
  131336. * Ends a time query
  131337. * @param token defines the token used to measure the time span
  131338. * @returns the time spent (in ns)
  131339. */
  131340. endTimeQuery(token: _TimeToken): int;
  131341. /** @hidden */
  131342. _currentNonTimestampToken: Nullable<_TimeToken>;
  131343. /** @hidden */
  131344. _createTimeQuery(): WebGLQuery;
  131345. /** @hidden */
  131346. _deleteTimeQuery(query: WebGLQuery): void;
  131347. /** @hidden */
  131348. _getGlAlgorithmType(algorithmType: number): number;
  131349. /** @hidden */
  131350. _getTimeQueryResult(query: WebGLQuery): any;
  131351. /** @hidden */
  131352. _getTimeQueryAvailability(query: WebGLQuery): any;
  131353. }
  131354. interface AbstractMesh {
  131355. /**
  131356. * Backing filed
  131357. * @hidden
  131358. */
  131359. __occlusionDataStorage: _OcclusionDataStorage;
  131360. /**
  131361. * Access property
  131362. * @hidden
  131363. */
  131364. _occlusionDataStorage: _OcclusionDataStorage;
  131365. /**
  131366. * 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.
  131367. * The default value is -1 which means don't break the query and wait till the result
  131368. * @see https://doc.babylonjs.com/features/occlusionquery
  131369. */
  131370. occlusionRetryCount: number;
  131371. /**
  131372. * 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:
  131373. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  131374. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  131375. * * 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.
  131376. * @see https://doc.babylonjs.com/features/occlusionquery
  131377. */
  131378. occlusionType: number;
  131379. /**
  131380. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  131381. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  131382. * * 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.
  131383. * @see https://doc.babylonjs.com/features/occlusionquery
  131384. */
  131385. occlusionQueryAlgorithmType: number;
  131386. /**
  131387. * 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
  131388. * @see https://doc.babylonjs.com/features/occlusionquery
  131389. */
  131390. isOccluded: boolean;
  131391. /**
  131392. * Flag to check the progress status of the query
  131393. * @see https://doc.babylonjs.com/features/occlusionquery
  131394. */
  131395. isOcclusionQueryInProgress: boolean;
  131396. }
  131397. }
  131398. declare module BABYLON {
  131399. /** @hidden */
  131400. export var _forceTransformFeedbackToBundle: boolean;
  131401. interface Engine {
  131402. /**
  131403. * Creates a webGL transform feedback object
  131404. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  131405. * @returns the webGL transform feedback object
  131406. */
  131407. createTransformFeedback(): WebGLTransformFeedback;
  131408. /**
  131409. * Delete a webGL transform feedback object
  131410. * @param value defines the webGL transform feedback object to delete
  131411. */
  131412. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  131413. /**
  131414. * Bind a webGL transform feedback object to the webgl context
  131415. * @param value defines the webGL transform feedback object to bind
  131416. */
  131417. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  131418. /**
  131419. * Begins a transform feedback operation
  131420. * @param usePoints defines if points or triangles must be used
  131421. */
  131422. beginTransformFeedback(usePoints: boolean): void;
  131423. /**
  131424. * Ends a transform feedback operation
  131425. */
  131426. endTransformFeedback(): void;
  131427. /**
  131428. * Specify the varyings to use with transform feedback
  131429. * @param program defines the associated webGL program
  131430. * @param value defines the list of strings representing the varying names
  131431. */
  131432. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  131433. /**
  131434. * Bind a webGL buffer for a transform feedback operation
  131435. * @param value defines the webGL buffer to bind
  131436. */
  131437. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  131438. }
  131439. }
  131440. declare module BABYLON {
  131441. /**
  131442. * Class used to define an additional view for the engine
  131443. * @see https://doc.babylonjs.com/how_to/multi_canvases
  131444. */
  131445. export class EngineView {
  131446. /** Defines the canvas where to render the view */
  131447. target: HTMLCanvasElement;
  131448. /** Defines an optional camera used to render the view (will use active camera else) */
  131449. camera?: Camera;
  131450. }
  131451. interface Engine {
  131452. /**
  131453. * Gets or sets the HTML element to use for attaching events
  131454. */
  131455. inputElement: Nullable<HTMLElement>;
  131456. /**
  131457. * Gets the current engine view
  131458. * @see https://doc.babylonjs.com/how_to/multi_canvases
  131459. */
  131460. activeView: Nullable<EngineView>;
  131461. /** Gets or sets the list of views */
  131462. views: EngineView[];
  131463. /**
  131464. * Register a new child canvas
  131465. * @param canvas defines the canvas to register
  131466. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  131467. * @returns the associated view
  131468. */
  131469. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  131470. /**
  131471. * Remove a registered child canvas
  131472. * @param canvas defines the canvas to remove
  131473. * @returns the current engine
  131474. */
  131475. unRegisterView(canvas: HTMLCanvasElement): Engine;
  131476. }
  131477. }
  131478. declare module BABYLON {
  131479. interface Engine {
  131480. /** @hidden */
  131481. _excludedCompressedTextures: string[];
  131482. /** @hidden */
  131483. _textureFormatInUse: string;
  131484. /**
  131485. * Gets the list of texture formats supported
  131486. */
  131487. readonly texturesSupported: Array<string>;
  131488. /**
  131489. * Gets the texture format in use
  131490. */
  131491. readonly textureFormatInUse: Nullable<string>;
  131492. /**
  131493. * Set the compressed texture extensions or file names to skip.
  131494. *
  131495. * @param skippedFiles defines the list of those texture files you want to skip
  131496. * Example: [".dds", ".env", "myfile.png"]
  131497. */
  131498. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  131499. /**
  131500. * Set the compressed texture format to use, based on the formats you have, and the formats
  131501. * supported by the hardware / browser.
  131502. *
  131503. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  131504. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  131505. * to API arguments needed to compressed textures. This puts the burden on the container
  131506. * generator to house the arcane code for determining these for current & future formats.
  131507. *
  131508. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  131509. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  131510. *
  131511. * Note: The result of this call is not taken into account when a texture is base64.
  131512. *
  131513. * @param formatsAvailable defines the list of those format families you have created
  131514. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  131515. *
  131516. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  131517. * @returns The extension selected.
  131518. */
  131519. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  131520. }
  131521. }
  131522. declare module BABYLON {
  131523. /**
  131524. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  131525. */
  131526. export interface CubeMapInfo {
  131527. /**
  131528. * The pixel array for the front face.
  131529. * This is stored in format, left to right, up to down format.
  131530. */
  131531. front: Nullable<ArrayBufferView>;
  131532. /**
  131533. * The pixel array for the back face.
  131534. * This is stored in format, left to right, up to down format.
  131535. */
  131536. back: Nullable<ArrayBufferView>;
  131537. /**
  131538. * The pixel array for the left face.
  131539. * This is stored in format, left to right, up to down format.
  131540. */
  131541. left: Nullable<ArrayBufferView>;
  131542. /**
  131543. * The pixel array for the right face.
  131544. * This is stored in format, left to right, up to down format.
  131545. */
  131546. right: Nullable<ArrayBufferView>;
  131547. /**
  131548. * The pixel array for the up face.
  131549. * This is stored in format, left to right, up to down format.
  131550. */
  131551. up: Nullable<ArrayBufferView>;
  131552. /**
  131553. * The pixel array for the down face.
  131554. * This is stored in format, left to right, up to down format.
  131555. */
  131556. down: Nullable<ArrayBufferView>;
  131557. /**
  131558. * The size of the cubemap stored.
  131559. *
  131560. * Each faces will be size * size pixels.
  131561. */
  131562. size: number;
  131563. /**
  131564. * The format of the texture.
  131565. *
  131566. * RGBA, RGB.
  131567. */
  131568. format: number;
  131569. /**
  131570. * The type of the texture data.
  131571. *
  131572. * UNSIGNED_INT, FLOAT.
  131573. */
  131574. type: number;
  131575. /**
  131576. * Specifies whether the texture is in gamma space.
  131577. */
  131578. gammaSpace: boolean;
  131579. }
  131580. /**
  131581. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  131582. */
  131583. export class PanoramaToCubeMapTools {
  131584. private static FACE_LEFT;
  131585. private static FACE_RIGHT;
  131586. private static FACE_FRONT;
  131587. private static FACE_BACK;
  131588. private static FACE_DOWN;
  131589. private static FACE_UP;
  131590. /**
  131591. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  131592. *
  131593. * @param float32Array The source data.
  131594. * @param inputWidth The width of the input panorama.
  131595. * @param inputHeight The height of the input panorama.
  131596. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  131597. * @return The cubemap data
  131598. */
  131599. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  131600. private static CreateCubemapTexture;
  131601. private static CalcProjectionSpherical;
  131602. }
  131603. }
  131604. declare module BABYLON {
  131605. /**
  131606. * Helper class dealing with the extraction of spherical polynomial dataArray
  131607. * from a cube map.
  131608. */
  131609. export class CubeMapToSphericalPolynomialTools {
  131610. private static FileFaces;
  131611. /**
  131612. * Converts a texture to the according Spherical Polynomial data.
  131613. * This extracts the first 3 orders only as they are the only one used in the lighting.
  131614. *
  131615. * @param texture The texture to extract the information from.
  131616. * @return The Spherical Polynomial data.
  131617. */
  131618. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  131619. /**
  131620. * Converts a cubemap to the according Spherical Polynomial data.
  131621. * This extracts the first 3 orders only as they are the only one used in the lighting.
  131622. *
  131623. * @param cubeInfo The Cube map to extract the information from.
  131624. * @return The Spherical Polynomial data.
  131625. */
  131626. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  131627. }
  131628. }
  131629. declare module BABYLON {
  131630. interface BaseTexture {
  131631. /**
  131632. * Get the polynomial representation of the texture data.
  131633. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  131634. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  131635. */
  131636. sphericalPolynomial: Nullable<SphericalPolynomial>;
  131637. }
  131638. }
  131639. declare module BABYLON {
  131640. /** @hidden */
  131641. export var rgbdEncodePixelShader: {
  131642. name: string;
  131643. shader: string;
  131644. };
  131645. }
  131646. declare module BABYLON {
  131647. /** @hidden */
  131648. export var rgbdDecodePixelShader: {
  131649. name: string;
  131650. shader: string;
  131651. };
  131652. }
  131653. declare module BABYLON {
  131654. /**
  131655. * Raw texture data and descriptor sufficient for WebGL texture upload
  131656. */
  131657. export interface EnvironmentTextureInfo {
  131658. /**
  131659. * Version of the environment map
  131660. */
  131661. version: number;
  131662. /**
  131663. * Width of image
  131664. */
  131665. width: number;
  131666. /**
  131667. * Irradiance information stored in the file.
  131668. */
  131669. irradiance: any;
  131670. /**
  131671. * Specular information stored in the file.
  131672. */
  131673. specular: any;
  131674. }
  131675. /**
  131676. * Defines One Image in the file. It requires only the position in the file
  131677. * as well as the length.
  131678. */
  131679. interface BufferImageData {
  131680. /**
  131681. * Length of the image data.
  131682. */
  131683. length: number;
  131684. /**
  131685. * Position of the data from the null terminator delimiting the end of the JSON.
  131686. */
  131687. position: number;
  131688. }
  131689. /**
  131690. * Defines the specular data enclosed in the file.
  131691. * This corresponds to the version 1 of the data.
  131692. */
  131693. export interface EnvironmentTextureSpecularInfoV1 {
  131694. /**
  131695. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  131696. */
  131697. specularDataPosition?: number;
  131698. /**
  131699. * This contains all the images data needed to reconstruct the cubemap.
  131700. */
  131701. mipmaps: Array<BufferImageData>;
  131702. /**
  131703. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  131704. */
  131705. lodGenerationScale: number;
  131706. }
  131707. /**
  131708. * Sets of helpers addressing the serialization and deserialization of environment texture
  131709. * stored in a BabylonJS env file.
  131710. * Those files are usually stored as .env files.
  131711. */
  131712. export class EnvironmentTextureTools {
  131713. /**
  131714. * Magic number identifying the env file.
  131715. */
  131716. private static _MagicBytes;
  131717. /**
  131718. * Gets the environment info from an env file.
  131719. * @param data The array buffer containing the .env bytes.
  131720. * @returns the environment file info (the json header) if successfully parsed.
  131721. */
  131722. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  131723. /**
  131724. * Creates an environment texture from a loaded cube texture.
  131725. * @param texture defines the cube texture to convert in env file
  131726. * @return a promise containing the environment data if succesfull.
  131727. */
  131728. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  131729. /**
  131730. * Creates a JSON representation of the spherical data.
  131731. * @param texture defines the texture containing the polynomials
  131732. * @return the JSON representation of the spherical info
  131733. */
  131734. private static _CreateEnvTextureIrradiance;
  131735. /**
  131736. * Creates the ArrayBufferViews used for initializing environment texture image data.
  131737. * @param data the image data
  131738. * @param info parameters that determine what views will be created for accessing the underlying buffer
  131739. * @return the views described by info providing access to the underlying buffer
  131740. */
  131741. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  131742. /**
  131743. * Uploads the texture info contained in the env file to the GPU.
  131744. * @param texture defines the internal texture to upload to
  131745. * @param data defines the data to load
  131746. * @param info defines the texture info retrieved through the GetEnvInfo method
  131747. * @returns a promise
  131748. */
  131749. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  131750. private static _OnImageReadyAsync;
  131751. /**
  131752. * Uploads the levels of image data to the GPU.
  131753. * @param texture defines the internal texture to upload to
  131754. * @param imageData defines the array buffer views of image data [mipmap][face]
  131755. * @returns a promise
  131756. */
  131757. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  131758. /**
  131759. * Uploads spherical polynomials information to the texture.
  131760. * @param texture defines the texture we are trying to upload the information to
  131761. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  131762. */
  131763. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  131764. /** @hidden */
  131765. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  131766. }
  131767. }
  131768. declare module BABYLON {
  131769. /**
  131770. * Class used to inline functions in shader code
  131771. */
  131772. export class ShaderCodeInliner {
  131773. private static readonly _RegexpFindFunctionNameAndType;
  131774. private _sourceCode;
  131775. private _functionDescr;
  131776. private _numMaxIterations;
  131777. /** Gets or sets the token used to mark the functions to inline */
  131778. inlineToken: string;
  131779. /** Gets or sets the debug mode */
  131780. debug: boolean;
  131781. /** Gets the code after the inlining process */
  131782. get code(): string;
  131783. /**
  131784. * Initializes the inliner
  131785. * @param sourceCode shader code source to inline
  131786. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  131787. */
  131788. constructor(sourceCode: string, numMaxIterations?: number);
  131789. /**
  131790. * Start the processing of the shader code
  131791. */
  131792. processCode(): void;
  131793. private _collectFunctions;
  131794. private _processInlining;
  131795. private _extractBetweenMarkers;
  131796. private _skipWhitespaces;
  131797. private _removeComments;
  131798. private _replaceFunctionCallsByCode;
  131799. private _findBackward;
  131800. private _escapeRegExp;
  131801. private _replaceNames;
  131802. }
  131803. }
  131804. declare module BABYLON {
  131805. /**
  131806. * Container for accessors for natively-stored mesh data buffers.
  131807. */
  131808. class NativeDataBuffer extends DataBuffer {
  131809. /**
  131810. * Accessor value used to identify/retrieve a natively-stored index buffer.
  131811. */
  131812. nativeIndexBuffer?: any;
  131813. /**
  131814. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  131815. */
  131816. nativeVertexBuffer?: any;
  131817. }
  131818. /** @hidden */
  131819. class NativeTexture extends InternalTexture {
  131820. getInternalTexture(): InternalTexture;
  131821. getViewCount(): number;
  131822. }
  131823. /** @hidden */
  131824. export class NativeEngine extends Engine {
  131825. private readonly _native;
  131826. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  131827. private readonly INVALID_HANDLE;
  131828. private _boundBuffersVertexArray;
  131829. getHardwareScalingLevel(): number;
  131830. constructor();
  131831. dispose(): void;
  131832. /**
  131833. * Can be used to override the current requestAnimationFrame requester.
  131834. * @hidden
  131835. */
  131836. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  131837. /**
  131838. * Override default engine behavior.
  131839. * @param color
  131840. * @param backBuffer
  131841. * @param depth
  131842. * @param stencil
  131843. */
  131844. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  131845. /**
  131846. * Gets host document
  131847. * @returns the host document object
  131848. */
  131849. getHostDocument(): Nullable<Document>;
  131850. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  131851. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  131852. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  131853. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  131854. [key: string]: VertexBuffer;
  131855. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  131856. bindBuffers(vertexBuffers: {
  131857. [key: string]: VertexBuffer;
  131858. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  131859. recordVertexArrayObject(vertexBuffers: {
  131860. [key: string]: VertexBuffer;
  131861. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  131862. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  131863. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  131864. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  131865. /**
  131866. * Draw a list of indexed primitives
  131867. * @param fillMode defines the primitive to use
  131868. * @param indexStart defines the starting index
  131869. * @param indexCount defines the number of index to draw
  131870. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  131871. */
  131872. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  131873. /**
  131874. * Draw a list of unindexed primitives
  131875. * @param fillMode defines the primitive to use
  131876. * @param verticesStart defines the index of first vertex to draw
  131877. * @param verticesCount defines the count of vertices to draw
  131878. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  131879. */
  131880. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  131881. createPipelineContext(): IPipelineContext;
  131882. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  131883. /** @hidden */
  131884. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  131885. /** @hidden */
  131886. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  131887. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  131888. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  131889. protected _setProgram(program: WebGLProgram): void;
  131890. _releaseEffect(effect: Effect): void;
  131891. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  131892. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  131893. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  131894. bindSamplers(effect: Effect): void;
  131895. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  131896. getRenderWidth(useScreen?: boolean): number;
  131897. getRenderHeight(useScreen?: boolean): number;
  131898. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  131899. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  131900. /**
  131901. * Set the z offset to apply to current rendering
  131902. * @param value defines the offset to apply
  131903. */
  131904. setZOffset(value: number): void;
  131905. /**
  131906. * Gets the current value of the zOffset
  131907. * @returns the current zOffset state
  131908. */
  131909. getZOffset(): number;
  131910. /**
  131911. * Enable or disable depth buffering
  131912. * @param enable defines the state to set
  131913. */
  131914. setDepthBuffer(enable: boolean): void;
  131915. /**
  131916. * Gets a boolean indicating if depth writing is enabled
  131917. * @returns the current depth writing state
  131918. */
  131919. getDepthWrite(): boolean;
  131920. /**
  131921. * Enable or disable depth writing
  131922. * @param enable defines the state to set
  131923. */
  131924. setDepthWrite(enable: boolean): void;
  131925. /**
  131926. * Enable or disable color writing
  131927. * @param enable defines the state to set
  131928. */
  131929. setColorWrite(enable: boolean): void;
  131930. /**
  131931. * Gets a boolean indicating if color writing is enabled
  131932. * @returns the current color writing state
  131933. */
  131934. getColorWrite(): boolean;
  131935. /**
  131936. * Sets alpha constants used by some alpha blending modes
  131937. * @param r defines the red component
  131938. * @param g defines the green component
  131939. * @param b defines the blue component
  131940. * @param a defines the alpha component
  131941. */
  131942. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  131943. /**
  131944. * Sets the current alpha mode
  131945. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  131946. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  131947. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  131948. */
  131949. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  131950. /**
  131951. * Gets the current alpha mode
  131952. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  131953. * @returns the current alpha mode
  131954. */
  131955. getAlphaMode(): number;
  131956. setInt(uniform: WebGLUniformLocation, int: number): void;
  131957. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  131958. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  131959. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  131960. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  131961. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  131962. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  131963. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  131964. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  131965. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  131966. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  131967. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  131968. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  131969. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  131970. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  131971. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  131972. setFloat(uniform: WebGLUniformLocation, value: number): void;
  131973. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  131974. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  131975. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  131976. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  131977. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  131978. wipeCaches(bruteForce?: boolean): void;
  131979. _createTexture(): WebGLTexture;
  131980. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  131981. /**
  131982. * Usually called from Texture.ts.
  131983. * Passed information to create a WebGLTexture
  131984. * @param url defines a value which contains one of the following:
  131985. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  131986. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  131987. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  131988. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  131989. * @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)
  131990. * @param scene needed for loading to the correct scene
  131991. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  131992. * @param onLoad optional callback to be called upon successful completion
  131993. * @param onError optional callback to be called upon failure
  131994. * @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
  131995. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  131996. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  131997. * @param forcedExtension defines the extension to use to pick the right loader
  131998. * @param mimeType defines an optional mime type
  131999. * @returns a InternalTexture for assignment back into BABYLON.Texture
  132000. */
  132001. 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;
  132002. /**
  132003. * Creates a cube texture
  132004. * @param rootUrl defines the url where the files to load is located
  132005. * @param scene defines the current scene
  132006. * @param files defines the list of files to load (1 per face)
  132007. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  132008. * @param onLoad defines an optional callback raised when the texture is loaded
  132009. * @param onError defines an optional callback raised if there is an issue to load the texture
  132010. * @param format defines the format of the data
  132011. * @param forcedExtension defines the extension to use to pick the right loader
  132012. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  132013. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  132014. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  132015. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  132016. * @returns the cube texture as an InternalTexture
  132017. */
  132018. 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;
  132019. private _getSamplingFilter;
  132020. private static _GetNativeTextureFormat;
  132021. createRenderTargetTexture(size: number | {
  132022. width: number;
  132023. height: number;
  132024. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  132025. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  132026. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  132027. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  132028. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  132029. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  132030. /**
  132031. * Updates a dynamic vertex buffer.
  132032. * @param vertexBuffer the vertex buffer to update
  132033. * @param data the data used to update the vertex buffer
  132034. * @param byteOffset the byte offset of the data (optional)
  132035. * @param byteLength the byte length of the data (optional)
  132036. */
  132037. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  132038. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  132039. private _updateAnisotropicLevel;
  132040. private _getAddressMode;
  132041. /** @hidden */
  132042. _bindTexture(channel: number, texture: InternalTexture): void;
  132043. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  132044. releaseEffects(): void;
  132045. /** @hidden */
  132046. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  132047. /** @hidden */
  132048. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  132049. /** @hidden */
  132050. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  132051. /** @hidden */
  132052. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  132053. }
  132054. }
  132055. declare module BABYLON {
  132056. /**
  132057. * Gather the list of clipboard event types as constants.
  132058. */
  132059. export class ClipboardEventTypes {
  132060. /**
  132061. * The clipboard event is fired when a copy command is active (pressed).
  132062. */
  132063. static readonly COPY: number;
  132064. /**
  132065. * The clipboard event is fired when a cut command is active (pressed).
  132066. */
  132067. static readonly CUT: number;
  132068. /**
  132069. * The clipboard event is fired when a paste command is active (pressed).
  132070. */
  132071. static readonly PASTE: number;
  132072. }
  132073. /**
  132074. * This class is used to store clipboard related info for the onClipboardObservable event.
  132075. */
  132076. export class ClipboardInfo {
  132077. /**
  132078. * Defines the type of event (BABYLON.ClipboardEventTypes)
  132079. */
  132080. type: number;
  132081. /**
  132082. * Defines the related dom event
  132083. */
  132084. event: ClipboardEvent;
  132085. /**
  132086. *Creates an instance of ClipboardInfo.
  132087. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  132088. * @param event Defines the related dom event
  132089. */
  132090. constructor(
  132091. /**
  132092. * Defines the type of event (BABYLON.ClipboardEventTypes)
  132093. */
  132094. type: number,
  132095. /**
  132096. * Defines the related dom event
  132097. */
  132098. event: ClipboardEvent);
  132099. /**
  132100. * Get the clipboard event's type from the keycode.
  132101. * @param keyCode Defines the keyCode for the current keyboard event.
  132102. * @return {number}
  132103. */
  132104. static GetTypeFromCharacter(keyCode: number): number;
  132105. }
  132106. }
  132107. declare module BABYLON {
  132108. /**
  132109. * Google Daydream controller
  132110. */
  132111. export class DaydreamController extends WebVRController {
  132112. /**
  132113. * Base Url for the controller model.
  132114. */
  132115. static MODEL_BASE_URL: string;
  132116. /**
  132117. * File name for the controller model.
  132118. */
  132119. static MODEL_FILENAME: string;
  132120. /**
  132121. * Gamepad Id prefix used to identify Daydream Controller.
  132122. */
  132123. static readonly GAMEPAD_ID_PREFIX: string;
  132124. /**
  132125. * Creates a new DaydreamController from a gamepad
  132126. * @param vrGamepad the gamepad that the controller should be created from
  132127. */
  132128. constructor(vrGamepad: any);
  132129. /**
  132130. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  132131. * @param scene scene in which to add meshes
  132132. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  132133. */
  132134. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  132135. /**
  132136. * Called once for each button that changed state since the last frame
  132137. * @param buttonIdx Which button index changed
  132138. * @param state New state of the button
  132139. * @param changes Which properties on the state changed since last frame
  132140. */
  132141. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  132142. }
  132143. }
  132144. declare module BABYLON {
  132145. /**
  132146. * Gear VR Controller
  132147. */
  132148. export class GearVRController extends WebVRController {
  132149. /**
  132150. * Base Url for the controller model.
  132151. */
  132152. static MODEL_BASE_URL: string;
  132153. /**
  132154. * File name for the controller model.
  132155. */
  132156. static MODEL_FILENAME: string;
  132157. /**
  132158. * Gamepad Id prefix used to identify this controller.
  132159. */
  132160. static readonly GAMEPAD_ID_PREFIX: string;
  132161. private readonly _buttonIndexToObservableNameMap;
  132162. /**
  132163. * Creates a new GearVRController from a gamepad
  132164. * @param vrGamepad the gamepad that the controller should be created from
  132165. */
  132166. constructor(vrGamepad: any);
  132167. /**
  132168. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  132169. * @param scene scene in which to add meshes
  132170. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  132171. */
  132172. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  132173. /**
  132174. * Called once for each button that changed state since the last frame
  132175. * @param buttonIdx Which button index changed
  132176. * @param state New state of the button
  132177. * @param changes Which properties on the state changed since last frame
  132178. */
  132179. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  132180. }
  132181. }
  132182. declare module BABYLON {
  132183. /**
  132184. * Generic Controller
  132185. */
  132186. export class GenericController extends WebVRController {
  132187. /**
  132188. * Base Url for the controller model.
  132189. */
  132190. static readonly MODEL_BASE_URL: string;
  132191. /**
  132192. * File name for the controller model.
  132193. */
  132194. static readonly MODEL_FILENAME: string;
  132195. /**
  132196. * Creates a new GenericController from a gamepad
  132197. * @param vrGamepad the gamepad that the controller should be created from
  132198. */
  132199. constructor(vrGamepad: any);
  132200. /**
  132201. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  132202. * @param scene scene in which to add meshes
  132203. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  132204. */
  132205. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  132206. /**
  132207. * Called once for each button that changed state since the last frame
  132208. * @param buttonIdx Which button index changed
  132209. * @param state New state of the button
  132210. * @param changes Which properties on the state changed since last frame
  132211. */
  132212. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  132213. }
  132214. }
  132215. declare module BABYLON {
  132216. /**
  132217. * Oculus Touch Controller
  132218. */
  132219. export class OculusTouchController extends WebVRController {
  132220. /**
  132221. * Base Url for the controller model.
  132222. */
  132223. static MODEL_BASE_URL: string;
  132224. /**
  132225. * File name for the left controller model.
  132226. */
  132227. static MODEL_LEFT_FILENAME: string;
  132228. /**
  132229. * File name for the right controller model.
  132230. */
  132231. static MODEL_RIGHT_FILENAME: string;
  132232. /**
  132233. * Base Url for the Quest controller model.
  132234. */
  132235. static QUEST_MODEL_BASE_URL: string;
  132236. /**
  132237. * @hidden
  132238. * If the controllers are running on a device that needs the updated Quest controller models
  132239. */
  132240. static _IsQuest: boolean;
  132241. /**
  132242. * Fired when the secondary trigger on this controller is modified
  132243. */
  132244. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  132245. /**
  132246. * Fired when the thumb rest on this controller is modified
  132247. */
  132248. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  132249. /**
  132250. * Creates a new OculusTouchController from a gamepad
  132251. * @param vrGamepad the gamepad that the controller should be created from
  132252. */
  132253. constructor(vrGamepad: any);
  132254. /**
  132255. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  132256. * @param scene scene in which to add meshes
  132257. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  132258. */
  132259. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  132260. /**
  132261. * Fired when the A button on this controller is modified
  132262. */
  132263. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132264. /**
  132265. * Fired when the B button on this controller is modified
  132266. */
  132267. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132268. /**
  132269. * Fired when the X button on this controller is modified
  132270. */
  132271. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132272. /**
  132273. * Fired when the Y button on this controller is modified
  132274. */
  132275. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132276. /**
  132277. * Called once for each button that changed state since the last frame
  132278. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  132279. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  132280. * 2) secondary trigger (same)
  132281. * 3) A (right) X (left), touch, pressed = value
  132282. * 4) B / Y
  132283. * 5) thumb rest
  132284. * @param buttonIdx Which button index changed
  132285. * @param state New state of the button
  132286. * @param changes Which properties on the state changed since last frame
  132287. */
  132288. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  132289. }
  132290. }
  132291. declare module BABYLON {
  132292. /**
  132293. * Vive Controller
  132294. */
  132295. export class ViveController extends WebVRController {
  132296. /**
  132297. * Base Url for the controller model.
  132298. */
  132299. static MODEL_BASE_URL: string;
  132300. /**
  132301. * File name for the controller model.
  132302. */
  132303. static MODEL_FILENAME: string;
  132304. /**
  132305. * Creates a new ViveController from a gamepad
  132306. * @param vrGamepad the gamepad that the controller should be created from
  132307. */
  132308. constructor(vrGamepad: any);
  132309. /**
  132310. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  132311. * @param scene scene in which to add meshes
  132312. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  132313. */
  132314. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  132315. /**
  132316. * Fired when the left button on this controller is modified
  132317. */
  132318. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132319. /**
  132320. * Fired when the right button on this controller is modified
  132321. */
  132322. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132323. /**
  132324. * Fired when the menu button on this controller is modified
  132325. */
  132326. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132327. /**
  132328. * Called once for each button that changed state since the last frame
  132329. * Vive mapping:
  132330. * 0: touchpad
  132331. * 1: trigger
  132332. * 2: left AND right buttons
  132333. * 3: menu button
  132334. * @param buttonIdx Which button index changed
  132335. * @param state New state of the button
  132336. * @param changes Which properties on the state changed since last frame
  132337. */
  132338. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  132339. }
  132340. }
  132341. declare module BABYLON {
  132342. /**
  132343. * Defines the WindowsMotionController object that the state of the windows motion controller
  132344. */
  132345. export class WindowsMotionController extends WebVRController {
  132346. /**
  132347. * The base url used to load the left and right controller models
  132348. */
  132349. static MODEL_BASE_URL: string;
  132350. /**
  132351. * The name of the left controller model file
  132352. */
  132353. static MODEL_LEFT_FILENAME: string;
  132354. /**
  132355. * The name of the right controller model file
  132356. */
  132357. static MODEL_RIGHT_FILENAME: string;
  132358. /**
  132359. * The controller name prefix for this controller type
  132360. */
  132361. static readonly GAMEPAD_ID_PREFIX: string;
  132362. /**
  132363. * The controller id pattern for this controller type
  132364. */
  132365. private static readonly GAMEPAD_ID_PATTERN;
  132366. private _loadedMeshInfo;
  132367. protected readonly _mapping: {
  132368. buttons: string[];
  132369. buttonMeshNames: {
  132370. trigger: string;
  132371. menu: string;
  132372. grip: string;
  132373. thumbstick: string;
  132374. trackpad: string;
  132375. };
  132376. buttonObservableNames: {
  132377. trigger: string;
  132378. menu: string;
  132379. grip: string;
  132380. thumbstick: string;
  132381. trackpad: string;
  132382. };
  132383. axisMeshNames: string[];
  132384. pointingPoseMeshName: string;
  132385. };
  132386. /**
  132387. * Fired when the trackpad on this controller is clicked
  132388. */
  132389. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  132390. /**
  132391. * Fired when the trackpad on this controller is modified
  132392. */
  132393. onTrackpadValuesChangedObservable: Observable<StickValues>;
  132394. /**
  132395. * The current x and y values of this controller's trackpad
  132396. */
  132397. trackpad: StickValues;
  132398. /**
  132399. * Creates a new WindowsMotionController from a gamepad
  132400. * @param vrGamepad the gamepad that the controller should be created from
  132401. */
  132402. constructor(vrGamepad: any);
  132403. /**
  132404. * Fired when the trigger on this controller is modified
  132405. */
  132406. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132407. /**
  132408. * Fired when the menu button on this controller is modified
  132409. */
  132410. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132411. /**
  132412. * Fired when the grip button on this controller is modified
  132413. */
  132414. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132415. /**
  132416. * Fired when the thumbstick button on this controller is modified
  132417. */
  132418. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132419. /**
  132420. * Fired when the touchpad button on this controller is modified
  132421. */
  132422. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132423. /**
  132424. * Fired when the touchpad values on this controller are modified
  132425. */
  132426. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  132427. protected _updateTrackpad(): void;
  132428. /**
  132429. * Called once per frame by the engine.
  132430. */
  132431. update(): void;
  132432. /**
  132433. * Called once for each button that changed state since the last frame
  132434. * @param buttonIdx Which button index changed
  132435. * @param state New state of the button
  132436. * @param changes Which properties on the state changed since last frame
  132437. */
  132438. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  132439. /**
  132440. * Moves the buttons on the controller mesh based on their current state
  132441. * @param buttonName the name of the button to move
  132442. * @param buttonValue the value of the button which determines the buttons new position
  132443. */
  132444. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  132445. /**
  132446. * Moves the axis on the controller mesh based on its current state
  132447. * @param axis the index of the axis
  132448. * @param axisValue the value of the axis which determines the meshes new position
  132449. * @hidden
  132450. */
  132451. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  132452. /**
  132453. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  132454. * @param scene scene in which to add meshes
  132455. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  132456. */
  132457. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  132458. /**
  132459. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  132460. * can be transformed by button presses and axes values, based on this._mapping.
  132461. *
  132462. * @param scene scene in which the meshes exist
  132463. * @param meshes list of meshes that make up the controller model to process
  132464. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  132465. */
  132466. private processModel;
  132467. private createMeshInfo;
  132468. /**
  132469. * Gets the ray of the controller in the direction the controller is pointing
  132470. * @param length the length the resulting ray should be
  132471. * @returns a ray in the direction the controller is pointing
  132472. */
  132473. getForwardRay(length?: number): Ray;
  132474. /**
  132475. * Disposes of the controller
  132476. */
  132477. dispose(): void;
  132478. }
  132479. /**
  132480. * This class represents a new windows motion controller in XR.
  132481. */
  132482. export class XRWindowsMotionController extends WindowsMotionController {
  132483. /**
  132484. * Changing the original WIndowsMotionController mapping to fir the new mapping
  132485. */
  132486. protected readonly _mapping: {
  132487. buttons: string[];
  132488. buttonMeshNames: {
  132489. trigger: string;
  132490. menu: string;
  132491. grip: string;
  132492. thumbstick: string;
  132493. trackpad: string;
  132494. };
  132495. buttonObservableNames: {
  132496. trigger: string;
  132497. menu: string;
  132498. grip: string;
  132499. thumbstick: string;
  132500. trackpad: string;
  132501. };
  132502. axisMeshNames: string[];
  132503. pointingPoseMeshName: string;
  132504. };
  132505. /**
  132506. * Construct a new XR-Based windows motion controller
  132507. *
  132508. * @param gamepadInfo the gamepad object from the browser
  132509. */
  132510. constructor(gamepadInfo: any);
  132511. /**
  132512. * holds the thumbstick values (X,Y)
  132513. */
  132514. thumbstickValues: StickValues;
  132515. /**
  132516. * Fired when the thumbstick on this controller is clicked
  132517. */
  132518. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  132519. /**
  132520. * Fired when the thumbstick on this controller is modified
  132521. */
  132522. onThumbstickValuesChangedObservable: Observable<StickValues>;
  132523. /**
  132524. * Fired when the touchpad button on this controller is modified
  132525. */
  132526. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  132527. /**
  132528. * Fired when the touchpad values on this controller are modified
  132529. */
  132530. onTrackpadValuesChangedObservable: Observable<StickValues>;
  132531. /**
  132532. * Fired when the thumbstick button on this controller is modified
  132533. * here to prevent breaking changes
  132534. */
  132535. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132536. /**
  132537. * updating the thumbstick(!) and not the trackpad.
  132538. * This is named this way due to the difference between WebVR and XR and to avoid
  132539. * changing the parent class.
  132540. */
  132541. protected _updateTrackpad(): void;
  132542. /**
  132543. * Disposes the class with joy
  132544. */
  132545. dispose(): void;
  132546. }
  132547. }
  132548. declare module BABYLON {
  132549. /**
  132550. * Class containing static functions to help procedurally build meshes
  132551. */
  132552. export class PolyhedronBuilder {
  132553. /**
  132554. * Creates a polyhedron mesh
  132555. * * 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
  132556. * * The parameter `size` (positive float, default 1) sets the polygon size
  132557. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  132558. * * 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`
  132559. * * 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
  132560. * * 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)`)
  132561. * * 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
  132562. * * 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
  132563. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  132564. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  132565. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  132566. * @param name defines the name of the mesh
  132567. * @param options defines the options used to create the mesh
  132568. * @param scene defines the hosting scene
  132569. * @returns the polyhedron mesh
  132570. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  132571. */
  132572. static CreatePolyhedron(name: string, options: {
  132573. type?: number;
  132574. size?: number;
  132575. sizeX?: number;
  132576. sizeY?: number;
  132577. sizeZ?: number;
  132578. custom?: any;
  132579. faceUV?: Vector4[];
  132580. faceColors?: Color4[];
  132581. flat?: boolean;
  132582. updatable?: boolean;
  132583. sideOrientation?: number;
  132584. frontUVs?: Vector4;
  132585. backUVs?: Vector4;
  132586. }, scene?: Nullable<Scene>): Mesh;
  132587. }
  132588. }
  132589. declare module BABYLON {
  132590. /**
  132591. * Gizmo that enables scaling a mesh along 3 axis
  132592. */
  132593. export class ScaleGizmo extends Gizmo {
  132594. /**
  132595. * Internal gizmo used for interactions on the x axis
  132596. */
  132597. xGizmo: AxisScaleGizmo;
  132598. /**
  132599. * Internal gizmo used for interactions on the y axis
  132600. */
  132601. yGizmo: AxisScaleGizmo;
  132602. /**
  132603. * Internal gizmo used for interactions on the z axis
  132604. */
  132605. zGizmo: AxisScaleGizmo;
  132606. /**
  132607. * Internal gizmo used to scale all axis equally
  132608. */
  132609. uniformScaleGizmo: AxisScaleGizmo;
  132610. private _meshAttached;
  132611. private _nodeAttached;
  132612. private _updateGizmoRotationToMatchAttachedMesh;
  132613. private _snapDistance;
  132614. private _scaleRatio;
  132615. private _uniformScalingMesh;
  132616. private _octahedron;
  132617. private _sensitivity;
  132618. /** Fires an event when any of it's sub gizmos are dragged */
  132619. onDragStartObservable: Observable<unknown>;
  132620. /** Fires an event when any of it's sub gizmos are released from dragging */
  132621. onDragEndObservable: Observable<unknown>;
  132622. get attachedMesh(): Nullable<AbstractMesh>;
  132623. set attachedMesh(mesh: Nullable<AbstractMesh>);
  132624. get attachedNode(): Nullable<Node>;
  132625. set attachedNode(node: Nullable<Node>);
  132626. /**
  132627. * Creates a ScaleGizmo
  132628. * @param gizmoLayer The utility layer the gizmo will be added to
  132629. * @param thickness display gizmo axis thickness
  132630. */
  132631. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  132632. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  132633. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  132634. /**
  132635. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  132636. */
  132637. set snapDistance(value: number);
  132638. get snapDistance(): number;
  132639. /**
  132640. * Ratio for the scale of the gizmo (Default: 1)
  132641. */
  132642. set scaleRatio(value: number);
  132643. get scaleRatio(): number;
  132644. /**
  132645. * Sensitivity factor for dragging (Default: 1)
  132646. */
  132647. set sensitivity(value: number);
  132648. get sensitivity(): number;
  132649. /**
  132650. * Disposes of the gizmo
  132651. */
  132652. dispose(): void;
  132653. }
  132654. }
  132655. declare module BABYLON {
  132656. /**
  132657. * Single axis scale gizmo
  132658. */
  132659. export class AxisScaleGizmo extends Gizmo {
  132660. /**
  132661. * Drag behavior responsible for the gizmos dragging interactions
  132662. */
  132663. dragBehavior: PointerDragBehavior;
  132664. private _pointerObserver;
  132665. /**
  132666. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  132667. */
  132668. snapDistance: number;
  132669. /**
  132670. * Event that fires each time the gizmo snaps to a new location.
  132671. * * snapDistance is the the change in distance
  132672. */
  132673. onSnapObservable: Observable<{
  132674. snapDistance: number;
  132675. }>;
  132676. /**
  132677. * If the scaling operation should be done on all axis (default: false)
  132678. */
  132679. uniformScaling: boolean;
  132680. /**
  132681. * Custom sensitivity value for the drag strength
  132682. */
  132683. sensitivity: number;
  132684. private _isEnabled;
  132685. private _parent;
  132686. private _arrow;
  132687. private _coloredMaterial;
  132688. private _hoverMaterial;
  132689. /**
  132690. * Creates an AxisScaleGizmo
  132691. * @param gizmoLayer The utility layer the gizmo will be added to
  132692. * @param dragAxis The axis which the gizmo will be able to scale on
  132693. * @param color The color of the gizmo
  132694. * @param thickness display gizmo axis thickness
  132695. */
  132696. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  132697. protected _attachedNodeChanged(value: Nullable<Node>): void;
  132698. /**
  132699. * If the gizmo is enabled
  132700. */
  132701. set isEnabled(value: boolean);
  132702. get isEnabled(): boolean;
  132703. /**
  132704. * Disposes of the gizmo
  132705. */
  132706. dispose(): void;
  132707. /**
  132708. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  132709. * @param mesh The mesh to replace the default mesh of the gizmo
  132710. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  132711. */
  132712. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  132713. }
  132714. }
  132715. declare module BABYLON {
  132716. /**
  132717. * Bounding box gizmo
  132718. */
  132719. export class BoundingBoxGizmo extends Gizmo {
  132720. private _lineBoundingBox;
  132721. private _rotateSpheresParent;
  132722. private _scaleBoxesParent;
  132723. private _boundingDimensions;
  132724. private _renderObserver;
  132725. private _pointerObserver;
  132726. private _scaleDragSpeed;
  132727. private _tmpQuaternion;
  132728. private _tmpVector;
  132729. private _tmpRotationMatrix;
  132730. /**
  132731. * 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)
  132732. */
  132733. ignoreChildren: boolean;
  132734. /**
  132735. * 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)
  132736. */
  132737. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  132738. /**
  132739. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  132740. */
  132741. rotationSphereSize: number;
  132742. /**
  132743. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  132744. */
  132745. scaleBoxSize: number;
  132746. /**
  132747. * 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)
  132748. */
  132749. fixedDragMeshScreenSize: boolean;
  132750. /**
  132751. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  132752. */
  132753. fixedDragMeshScreenSizeDistanceFactor: number;
  132754. /**
  132755. * Fired when a rotation sphere or scale box is dragged
  132756. */
  132757. onDragStartObservable: Observable<{}>;
  132758. /**
  132759. * Fired when a scale box is dragged
  132760. */
  132761. onScaleBoxDragObservable: Observable<{}>;
  132762. /**
  132763. * Fired when a scale box drag is ended
  132764. */
  132765. onScaleBoxDragEndObservable: Observable<{}>;
  132766. /**
  132767. * Fired when a rotation sphere is dragged
  132768. */
  132769. onRotationSphereDragObservable: Observable<{}>;
  132770. /**
  132771. * Fired when a rotation sphere drag is ended
  132772. */
  132773. onRotationSphereDragEndObservable: Observable<{}>;
  132774. /**
  132775. * 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)
  132776. */
  132777. scalePivot: Nullable<Vector3>;
  132778. /**
  132779. * Mesh used as a pivot to rotate the attached node
  132780. */
  132781. private _anchorMesh;
  132782. private _existingMeshScale;
  132783. private _dragMesh;
  132784. private pointerDragBehavior;
  132785. private coloredMaterial;
  132786. private hoverColoredMaterial;
  132787. /**
  132788. * Sets the color of the bounding box gizmo
  132789. * @param color the color to set
  132790. */
  132791. setColor(color: Color3): void;
  132792. /**
  132793. * Creates an BoundingBoxGizmo
  132794. * @param gizmoLayer The utility layer the gizmo will be added to
  132795. * @param color The color of the gizmo
  132796. */
  132797. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  132798. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  132799. private _selectNode;
  132800. /**
  132801. * Updates the bounding box information for the Gizmo
  132802. */
  132803. updateBoundingBox(): void;
  132804. private _updateRotationSpheres;
  132805. private _updateScaleBoxes;
  132806. /**
  132807. * Enables rotation on the specified axis and disables rotation on the others
  132808. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  132809. */
  132810. setEnabledRotationAxis(axis: string): void;
  132811. /**
  132812. * Enables/disables scaling
  132813. * @param enable if scaling should be enabled
  132814. * @param homogeneousScaling defines if scaling should only be homogeneous
  132815. */
  132816. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  132817. private _updateDummy;
  132818. /**
  132819. * Enables a pointer drag behavior on the bounding box of the gizmo
  132820. */
  132821. enableDragBehavior(): void;
  132822. /**
  132823. * Disposes of the gizmo
  132824. */
  132825. dispose(): void;
  132826. /**
  132827. * 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)
  132828. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  132829. * @returns the bounding box mesh with the passed in mesh as a child
  132830. */
  132831. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  132832. /**
  132833. * CustomMeshes are not supported by this gizmo
  132834. * @param mesh The mesh to replace the default mesh of the gizmo
  132835. */
  132836. setCustomMesh(mesh: Mesh): void;
  132837. }
  132838. }
  132839. declare module BABYLON {
  132840. /**
  132841. * Single plane rotation gizmo
  132842. */
  132843. export class PlaneRotationGizmo extends Gizmo {
  132844. /**
  132845. * Drag behavior responsible for the gizmos dragging interactions
  132846. */
  132847. dragBehavior: PointerDragBehavior;
  132848. private _pointerObserver;
  132849. /**
  132850. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  132851. */
  132852. snapDistance: number;
  132853. /**
  132854. * Event that fires each time the gizmo snaps to a new location.
  132855. * * snapDistance is the the change in distance
  132856. */
  132857. onSnapObservable: Observable<{
  132858. snapDistance: number;
  132859. }>;
  132860. private _isEnabled;
  132861. private _parent;
  132862. /**
  132863. * Creates a PlaneRotationGizmo
  132864. * @param gizmoLayer The utility layer the gizmo will be added to
  132865. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  132866. * @param color The color of the gizmo
  132867. * @param tessellation Amount of tessellation to be used when creating rotation circles
  132868. * @param useEulerRotation Use and update Euler angle instead of quaternion
  132869. * @param thickness display gizmo axis thickness
  132870. */
  132871. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  132872. protected _attachedNodeChanged(value: Nullable<Node>): void;
  132873. /**
  132874. * If the gizmo is enabled
  132875. */
  132876. set isEnabled(value: boolean);
  132877. get isEnabled(): boolean;
  132878. /**
  132879. * Disposes of the gizmo
  132880. */
  132881. dispose(): void;
  132882. }
  132883. }
  132884. declare module BABYLON {
  132885. /**
  132886. * Gizmo that enables rotating a mesh along 3 axis
  132887. */
  132888. export class RotationGizmo extends Gizmo {
  132889. /**
  132890. * Internal gizmo used for interactions on the x axis
  132891. */
  132892. xGizmo: PlaneRotationGizmo;
  132893. /**
  132894. * Internal gizmo used for interactions on the y axis
  132895. */
  132896. yGizmo: PlaneRotationGizmo;
  132897. /**
  132898. * Internal gizmo used for interactions on the z axis
  132899. */
  132900. zGizmo: PlaneRotationGizmo;
  132901. /** Fires an event when any of it's sub gizmos are dragged */
  132902. onDragStartObservable: Observable<unknown>;
  132903. /** Fires an event when any of it's sub gizmos are released from dragging */
  132904. onDragEndObservable: Observable<unknown>;
  132905. private _meshAttached;
  132906. private _nodeAttached;
  132907. get attachedMesh(): Nullable<AbstractMesh>;
  132908. set attachedMesh(mesh: Nullable<AbstractMesh>);
  132909. get attachedNode(): Nullable<Node>;
  132910. set attachedNode(node: Nullable<Node>);
  132911. /**
  132912. * Creates a RotationGizmo
  132913. * @param gizmoLayer The utility layer the gizmo will be added to
  132914. * @param tessellation Amount of tessellation to be used when creating rotation circles
  132915. * @param useEulerRotation Use and update Euler angle instead of quaternion
  132916. * @param thickness display gizmo axis thickness
  132917. */
  132918. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  132919. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  132920. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  132921. /**
  132922. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  132923. */
  132924. set snapDistance(value: number);
  132925. get snapDistance(): number;
  132926. /**
  132927. * Ratio for the scale of the gizmo (Default: 1)
  132928. */
  132929. set scaleRatio(value: number);
  132930. get scaleRatio(): number;
  132931. /**
  132932. * Disposes of the gizmo
  132933. */
  132934. dispose(): void;
  132935. /**
  132936. * CustomMeshes are not supported by this gizmo
  132937. * @param mesh The mesh to replace the default mesh of the gizmo
  132938. */
  132939. setCustomMesh(mesh: Mesh): void;
  132940. }
  132941. }
  132942. declare module BABYLON {
  132943. /**
  132944. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  132945. */
  132946. export class GizmoManager implements IDisposable {
  132947. private scene;
  132948. /**
  132949. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  132950. */
  132951. gizmos: {
  132952. positionGizmo: Nullable<PositionGizmo>;
  132953. rotationGizmo: Nullable<RotationGizmo>;
  132954. scaleGizmo: Nullable<ScaleGizmo>;
  132955. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  132956. };
  132957. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  132958. clearGizmoOnEmptyPointerEvent: boolean;
  132959. /** Fires an event when the manager is attached to a mesh */
  132960. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  132961. /** Fires an event when the manager is attached to a node */
  132962. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  132963. private _gizmosEnabled;
  132964. private _pointerObserver;
  132965. private _attachedMesh;
  132966. private _attachedNode;
  132967. private _boundingBoxColor;
  132968. private _defaultUtilityLayer;
  132969. private _defaultKeepDepthUtilityLayer;
  132970. private _thickness;
  132971. /**
  132972. * When bounding box gizmo is enabled, this can be used to track drag/end events
  132973. */
  132974. boundingBoxDragBehavior: SixDofDragBehavior;
  132975. /**
  132976. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  132977. */
  132978. attachableMeshes: Nullable<Array<AbstractMesh>>;
  132979. /**
  132980. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  132981. */
  132982. attachableNodes: Nullable<Array<Node>>;
  132983. /**
  132984. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  132985. */
  132986. usePointerToAttachGizmos: boolean;
  132987. /**
  132988. * Utility layer that the bounding box gizmo belongs to
  132989. */
  132990. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  132991. /**
  132992. * Utility layer that all gizmos besides bounding box belong to
  132993. */
  132994. get utilityLayer(): UtilityLayerRenderer;
  132995. /**
  132996. * Instatiates a gizmo manager
  132997. * @param scene the scene to overlay the gizmos on top of
  132998. * @param thickness display gizmo axis thickness
  132999. */
  133000. constructor(scene: Scene, thickness?: number);
  133001. /**
  133002. * Attaches a set of gizmos to the specified mesh
  133003. * @param mesh The mesh the gizmo's should be attached to
  133004. */
  133005. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  133006. /**
  133007. * Attaches a set of gizmos to the specified node
  133008. * @param node The node the gizmo's should be attached to
  133009. */
  133010. attachToNode(node: Nullable<Node>): void;
  133011. /**
  133012. * If the position gizmo is enabled
  133013. */
  133014. set positionGizmoEnabled(value: boolean);
  133015. get positionGizmoEnabled(): boolean;
  133016. /**
  133017. * If the rotation gizmo is enabled
  133018. */
  133019. set rotationGizmoEnabled(value: boolean);
  133020. get rotationGizmoEnabled(): boolean;
  133021. /**
  133022. * If the scale gizmo is enabled
  133023. */
  133024. set scaleGizmoEnabled(value: boolean);
  133025. get scaleGizmoEnabled(): boolean;
  133026. /**
  133027. * If the boundingBox gizmo is enabled
  133028. */
  133029. set boundingBoxGizmoEnabled(value: boolean);
  133030. get boundingBoxGizmoEnabled(): boolean;
  133031. /**
  133032. * Disposes of the gizmo manager
  133033. */
  133034. dispose(): void;
  133035. }
  133036. }
  133037. declare module BABYLON {
  133038. /**
  133039. * A directional light is defined by a direction (what a surprise!).
  133040. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  133041. * 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.
  133042. * Documentation: https://doc.babylonjs.com/babylon101/lights
  133043. */
  133044. export class DirectionalLight extends ShadowLight {
  133045. private _shadowFrustumSize;
  133046. /**
  133047. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  133048. */
  133049. get shadowFrustumSize(): number;
  133050. /**
  133051. * Specifies a fix frustum size for the shadow generation.
  133052. */
  133053. set shadowFrustumSize(value: number);
  133054. private _shadowOrthoScale;
  133055. /**
  133056. * Gets the shadow projection scale against the optimal computed one.
  133057. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  133058. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  133059. */
  133060. get shadowOrthoScale(): number;
  133061. /**
  133062. * Sets the shadow projection scale against the optimal computed one.
  133063. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  133064. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  133065. */
  133066. set shadowOrthoScale(value: number);
  133067. /**
  133068. * Automatically compute the projection matrix to best fit (including all the casters)
  133069. * on each frame.
  133070. */
  133071. autoUpdateExtends: boolean;
  133072. /**
  133073. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  133074. * on each frame. autoUpdateExtends must be set to true for this to work
  133075. */
  133076. autoCalcShadowZBounds: boolean;
  133077. private _orthoLeft;
  133078. private _orthoRight;
  133079. private _orthoTop;
  133080. private _orthoBottom;
  133081. /**
  133082. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  133083. * The directional light is emitted from everywhere in the given direction.
  133084. * It can cast shadows.
  133085. * Documentation : https://doc.babylonjs.com/babylon101/lights
  133086. * @param name The friendly name of the light
  133087. * @param direction The direction of the light
  133088. * @param scene The scene the light belongs to
  133089. */
  133090. constructor(name: string, direction: Vector3, scene: Scene);
  133091. /**
  133092. * Returns the string "DirectionalLight".
  133093. * @return The class name
  133094. */
  133095. getClassName(): string;
  133096. /**
  133097. * Returns the integer 1.
  133098. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  133099. */
  133100. getTypeID(): number;
  133101. /**
  133102. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  133103. * Returns the DirectionalLight Shadow projection matrix.
  133104. */
  133105. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  133106. /**
  133107. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  133108. * Returns the DirectionalLight Shadow projection matrix.
  133109. */
  133110. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  133111. /**
  133112. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  133113. * Returns the DirectionalLight Shadow projection matrix.
  133114. */
  133115. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  133116. protected _buildUniformLayout(): void;
  133117. /**
  133118. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  133119. * @param effect The effect to update
  133120. * @param lightIndex The index of the light in the effect to update
  133121. * @returns The directional light
  133122. */
  133123. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  133124. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  133125. /**
  133126. * Gets the minZ used for shadow according to both the scene and the light.
  133127. *
  133128. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  133129. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  133130. * @param activeCamera The camera we are returning the min for
  133131. * @returns the depth min z
  133132. */
  133133. getDepthMinZ(activeCamera: Camera): number;
  133134. /**
  133135. * Gets the maxZ used for shadow according to both the scene and the light.
  133136. *
  133137. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  133138. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  133139. * @param activeCamera The camera we are returning the max for
  133140. * @returns the depth max z
  133141. */
  133142. getDepthMaxZ(activeCamera: Camera): number;
  133143. /**
  133144. * Prepares the list of defines specific to the light type.
  133145. * @param defines the list of defines
  133146. * @param lightIndex defines the index of the light for the effect
  133147. */
  133148. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  133149. }
  133150. }
  133151. declare module BABYLON {
  133152. /**
  133153. * Class containing static functions to help procedurally build meshes
  133154. */
  133155. export class HemisphereBuilder {
  133156. /**
  133157. * Creates a hemisphere mesh
  133158. * @param name defines the name of the mesh
  133159. * @param options defines the options used to create the mesh
  133160. * @param scene defines the hosting scene
  133161. * @returns the hemisphere mesh
  133162. */
  133163. static CreateHemisphere(name: string, options: {
  133164. segments?: number;
  133165. diameter?: number;
  133166. sideOrientation?: number;
  133167. }, scene: any): Mesh;
  133168. }
  133169. }
  133170. declare module BABYLON {
  133171. /**
  133172. * A spot light is defined by a position, a direction, an angle, and an exponent.
  133173. * These values define a cone of light starting from the position, emitting toward the direction.
  133174. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  133175. * and the exponent defines the speed of the decay of the light with distance (reach).
  133176. * Documentation: https://doc.babylonjs.com/babylon101/lights
  133177. */
  133178. export class SpotLight extends ShadowLight {
  133179. private _angle;
  133180. private _innerAngle;
  133181. private _cosHalfAngle;
  133182. private _lightAngleScale;
  133183. private _lightAngleOffset;
  133184. /**
  133185. * Gets the cone angle of the spot light in Radians.
  133186. */
  133187. get angle(): number;
  133188. /**
  133189. * Sets the cone angle of the spot light in Radians.
  133190. */
  133191. set angle(value: number);
  133192. /**
  133193. * Only used in gltf falloff mode, this defines the angle where
  133194. * the directional falloff will start before cutting at angle which could be seen
  133195. * as outer angle.
  133196. */
  133197. get innerAngle(): number;
  133198. /**
  133199. * Only used in gltf falloff mode, this defines the angle where
  133200. * the directional falloff will start before cutting at angle which could be seen
  133201. * as outer angle.
  133202. */
  133203. set innerAngle(value: number);
  133204. private _shadowAngleScale;
  133205. /**
  133206. * Allows scaling the angle of the light for shadow generation only.
  133207. */
  133208. get shadowAngleScale(): number;
  133209. /**
  133210. * Allows scaling the angle of the light for shadow generation only.
  133211. */
  133212. set shadowAngleScale(value: number);
  133213. /**
  133214. * The light decay speed with the distance from the emission spot.
  133215. */
  133216. exponent: number;
  133217. private _projectionTextureMatrix;
  133218. /**
  133219. * Allows reading the projecton texture
  133220. */
  133221. get projectionTextureMatrix(): Matrix;
  133222. protected _projectionTextureLightNear: number;
  133223. /**
  133224. * Gets the near clip of the Spotlight for texture projection.
  133225. */
  133226. get projectionTextureLightNear(): number;
  133227. /**
  133228. * Sets the near clip of the Spotlight for texture projection.
  133229. */
  133230. set projectionTextureLightNear(value: number);
  133231. protected _projectionTextureLightFar: number;
  133232. /**
  133233. * Gets the far clip of the Spotlight for texture projection.
  133234. */
  133235. get projectionTextureLightFar(): number;
  133236. /**
  133237. * Sets the far clip of the Spotlight for texture projection.
  133238. */
  133239. set projectionTextureLightFar(value: number);
  133240. protected _projectionTextureUpDirection: Vector3;
  133241. /**
  133242. * Gets the Up vector of the Spotlight for texture projection.
  133243. */
  133244. get projectionTextureUpDirection(): Vector3;
  133245. /**
  133246. * Sets the Up vector of the Spotlight for texture projection.
  133247. */
  133248. set projectionTextureUpDirection(value: Vector3);
  133249. private _projectionTexture;
  133250. /**
  133251. * Gets the projection texture of the light.
  133252. */
  133253. get projectionTexture(): Nullable<BaseTexture>;
  133254. /**
  133255. * Sets the projection texture of the light.
  133256. */
  133257. set projectionTexture(value: Nullable<BaseTexture>);
  133258. private _projectionTextureViewLightDirty;
  133259. private _projectionTextureProjectionLightDirty;
  133260. private _projectionTextureDirty;
  133261. private _projectionTextureViewTargetVector;
  133262. private _projectionTextureViewLightMatrix;
  133263. private _projectionTextureProjectionLightMatrix;
  133264. private _projectionTextureScalingMatrix;
  133265. /**
  133266. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  133267. * It can cast shadows.
  133268. * Documentation : https://doc.babylonjs.com/babylon101/lights
  133269. * @param name The light friendly name
  133270. * @param position The position of the spot light in the scene
  133271. * @param direction The direction of the light in the scene
  133272. * @param angle The cone angle of the light in Radians
  133273. * @param exponent The light decay speed with the distance from the emission spot
  133274. * @param scene The scene the lights belongs to
  133275. */
  133276. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  133277. /**
  133278. * Returns the string "SpotLight".
  133279. * @returns the class name
  133280. */
  133281. getClassName(): string;
  133282. /**
  133283. * Returns the integer 2.
  133284. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  133285. */
  133286. getTypeID(): number;
  133287. /**
  133288. * Overrides the direction setter to recompute the projection texture view light Matrix.
  133289. */
  133290. protected _setDirection(value: Vector3): void;
  133291. /**
  133292. * Overrides the position setter to recompute the projection texture view light Matrix.
  133293. */
  133294. protected _setPosition(value: Vector3): void;
  133295. /**
  133296. * 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.
  133297. * Returns the SpotLight.
  133298. */
  133299. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  133300. protected _computeProjectionTextureViewLightMatrix(): void;
  133301. protected _computeProjectionTextureProjectionLightMatrix(): void;
  133302. /**
  133303. * Main function for light texture projection matrix computing.
  133304. */
  133305. protected _computeProjectionTextureMatrix(): void;
  133306. protected _buildUniformLayout(): void;
  133307. private _computeAngleValues;
  133308. /**
  133309. * Sets the passed Effect "effect" with the Light textures.
  133310. * @param effect The effect to update
  133311. * @param lightIndex The index of the light in the effect to update
  133312. * @returns The light
  133313. */
  133314. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  133315. /**
  133316. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  133317. * @param effect The effect to update
  133318. * @param lightIndex The index of the light in the effect to update
  133319. * @returns The spot light
  133320. */
  133321. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  133322. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  133323. /**
  133324. * Disposes the light and the associated resources.
  133325. */
  133326. dispose(): void;
  133327. /**
  133328. * Prepares the list of defines specific to the light type.
  133329. * @param defines the list of defines
  133330. * @param lightIndex defines the index of the light for the effect
  133331. */
  133332. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  133333. }
  133334. }
  133335. declare module BABYLON {
  133336. /**
  133337. * Gizmo that enables viewing a light
  133338. */
  133339. export class LightGizmo extends Gizmo {
  133340. private _lightMesh;
  133341. private _material;
  133342. private _cachedPosition;
  133343. private _cachedForward;
  133344. private _attachedMeshParent;
  133345. /**
  133346. * Creates a LightGizmo
  133347. * @param gizmoLayer The utility layer the gizmo will be added to
  133348. */
  133349. constructor(gizmoLayer?: UtilityLayerRenderer);
  133350. private _light;
  133351. /**
  133352. * The light that the gizmo is attached to
  133353. */
  133354. set light(light: Nullable<Light>);
  133355. get light(): Nullable<Light>;
  133356. /**
  133357. * Gets the material used to render the light gizmo
  133358. */
  133359. get material(): StandardMaterial;
  133360. /**
  133361. * @hidden
  133362. * Updates the gizmo to match the attached mesh's position/rotation
  133363. */
  133364. protected _update(): void;
  133365. private static _Scale;
  133366. /**
  133367. * Creates the lines for a light mesh
  133368. */
  133369. private static _CreateLightLines;
  133370. /**
  133371. * Disposes of the light gizmo
  133372. */
  133373. dispose(): void;
  133374. private static _CreateHemisphericLightMesh;
  133375. private static _CreatePointLightMesh;
  133376. private static _CreateSpotLightMesh;
  133377. private static _CreateDirectionalLightMesh;
  133378. }
  133379. }
  133380. declare module BABYLON {
  133381. /**
  133382. * Gizmo that enables viewing a camera
  133383. */
  133384. export class CameraGizmo extends Gizmo {
  133385. private _cameraMesh;
  133386. private _cameraLinesMesh;
  133387. private _material;
  133388. /**
  133389. * Creates a CameraGizmo
  133390. * @param gizmoLayer The utility layer the gizmo will be added to
  133391. */
  133392. constructor(gizmoLayer?: UtilityLayerRenderer);
  133393. private _camera;
  133394. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  133395. get displayFrustum(): boolean;
  133396. set displayFrustum(value: boolean);
  133397. /**
  133398. * The camera that the gizmo is attached to
  133399. */
  133400. set camera(camera: Nullable<Camera>);
  133401. get camera(): Nullable<Camera>;
  133402. /**
  133403. * Gets the material used to render the camera gizmo
  133404. */
  133405. get material(): StandardMaterial;
  133406. /**
  133407. * @hidden
  133408. * Updates the gizmo to match the attached mesh's position/rotation
  133409. */
  133410. protected _update(): void;
  133411. private static _Scale;
  133412. private _invProjection;
  133413. /**
  133414. * Disposes of the camera gizmo
  133415. */
  133416. dispose(): void;
  133417. private static _CreateCameraMesh;
  133418. private static _CreateCameraFrustum;
  133419. }
  133420. }
  133421. declare module BABYLON {
  133422. /** @hidden */
  133423. export var backgroundFragmentDeclaration: {
  133424. name: string;
  133425. shader: string;
  133426. };
  133427. }
  133428. declare module BABYLON {
  133429. /** @hidden */
  133430. export var backgroundUboDeclaration: {
  133431. name: string;
  133432. shader: string;
  133433. };
  133434. }
  133435. declare module BABYLON {
  133436. /** @hidden */
  133437. export var backgroundPixelShader: {
  133438. name: string;
  133439. shader: string;
  133440. };
  133441. }
  133442. declare module BABYLON {
  133443. /** @hidden */
  133444. export var backgroundVertexDeclaration: {
  133445. name: string;
  133446. shader: string;
  133447. };
  133448. }
  133449. declare module BABYLON {
  133450. /** @hidden */
  133451. export var backgroundVertexShader: {
  133452. name: string;
  133453. shader: string;
  133454. };
  133455. }
  133456. declare module BABYLON {
  133457. /**
  133458. * Background material used to create an efficient environement around your scene.
  133459. */
  133460. export class BackgroundMaterial extends PushMaterial {
  133461. /**
  133462. * Standard reflectance value at parallel view angle.
  133463. */
  133464. static StandardReflectance0: number;
  133465. /**
  133466. * Standard reflectance value at grazing angle.
  133467. */
  133468. static StandardReflectance90: number;
  133469. protected _primaryColor: Color3;
  133470. /**
  133471. * Key light Color (multiply against the environement texture)
  133472. */
  133473. primaryColor: Color3;
  133474. protected __perceptualColor: Nullable<Color3>;
  133475. /**
  133476. * Experimental Internal Use Only.
  133477. *
  133478. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  133479. * This acts as a helper to set the primary color to a more "human friendly" value.
  133480. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  133481. * output color as close as possible from the chosen value.
  133482. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  133483. * part of lighting setup.)
  133484. */
  133485. get _perceptualColor(): Nullable<Color3>;
  133486. set _perceptualColor(value: Nullable<Color3>);
  133487. protected _primaryColorShadowLevel: float;
  133488. /**
  133489. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  133490. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  133491. */
  133492. get primaryColorShadowLevel(): float;
  133493. set primaryColorShadowLevel(value: float);
  133494. protected _primaryColorHighlightLevel: float;
  133495. /**
  133496. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  133497. * The primary color is used at the level chosen to define what the white area would look.
  133498. */
  133499. get primaryColorHighlightLevel(): float;
  133500. set primaryColorHighlightLevel(value: float);
  133501. protected _reflectionTexture: Nullable<BaseTexture>;
  133502. /**
  133503. * Reflection Texture used in the material.
  133504. * Should be author in a specific way for the best result (refer to the documentation).
  133505. */
  133506. reflectionTexture: Nullable<BaseTexture>;
  133507. protected _reflectionBlur: float;
  133508. /**
  133509. * Reflection Texture level of blur.
  133510. *
  133511. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  133512. * texture twice.
  133513. */
  133514. reflectionBlur: float;
  133515. protected _diffuseTexture: Nullable<BaseTexture>;
  133516. /**
  133517. * Diffuse Texture used in the material.
  133518. * Should be author in a specific way for the best result (refer to the documentation).
  133519. */
  133520. diffuseTexture: Nullable<BaseTexture>;
  133521. protected _shadowLights: Nullable<IShadowLight[]>;
  133522. /**
  133523. * Specify the list of lights casting shadow on the material.
  133524. * All scene shadow lights will be included if null.
  133525. */
  133526. shadowLights: Nullable<IShadowLight[]>;
  133527. protected _shadowLevel: float;
  133528. /**
  133529. * Helps adjusting the shadow to a softer level if required.
  133530. * 0 means black shadows and 1 means no shadows.
  133531. */
  133532. shadowLevel: float;
  133533. protected _sceneCenter: Vector3;
  133534. /**
  133535. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  133536. * It is usually zero but might be interesting to modify according to your setup.
  133537. */
  133538. sceneCenter: Vector3;
  133539. protected _opacityFresnel: boolean;
  133540. /**
  133541. * This helps specifying that the material is falling off to the sky box at grazing angle.
  133542. * This helps ensuring a nice transition when the camera goes under the ground.
  133543. */
  133544. opacityFresnel: boolean;
  133545. protected _reflectionFresnel: boolean;
  133546. /**
  133547. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  133548. * This helps adding a mirror texture on the ground.
  133549. */
  133550. reflectionFresnel: boolean;
  133551. protected _reflectionFalloffDistance: number;
  133552. /**
  133553. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  133554. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  133555. */
  133556. reflectionFalloffDistance: number;
  133557. protected _reflectionAmount: number;
  133558. /**
  133559. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  133560. */
  133561. reflectionAmount: number;
  133562. protected _reflectionReflectance0: number;
  133563. /**
  133564. * This specifies the weight of the reflection at grazing angle.
  133565. */
  133566. reflectionReflectance0: number;
  133567. protected _reflectionReflectance90: number;
  133568. /**
  133569. * This specifies the weight of the reflection at a perpendicular point of view.
  133570. */
  133571. reflectionReflectance90: number;
  133572. /**
  133573. * Sets the reflection reflectance fresnel values according to the default standard
  133574. * empirically know to work well :-)
  133575. */
  133576. set reflectionStandardFresnelWeight(value: number);
  133577. protected _useRGBColor: boolean;
  133578. /**
  133579. * Helps to directly use the maps channels instead of their level.
  133580. */
  133581. useRGBColor: boolean;
  133582. protected _enableNoise: boolean;
  133583. /**
  133584. * This helps reducing the banding effect that could occur on the background.
  133585. */
  133586. enableNoise: boolean;
  133587. /**
  133588. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  133589. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  133590. * Recommended to be keep at 1.0 except for special cases.
  133591. */
  133592. get fovMultiplier(): number;
  133593. set fovMultiplier(value: number);
  133594. private _fovMultiplier;
  133595. /**
  133596. * Enable the FOV adjustment feature controlled by fovMultiplier.
  133597. */
  133598. useEquirectangularFOV: boolean;
  133599. private _maxSimultaneousLights;
  133600. /**
  133601. * Number of Simultaneous lights allowed on the material.
  133602. */
  133603. maxSimultaneousLights: int;
  133604. private _shadowOnly;
  133605. /**
  133606. * Make the material only render shadows
  133607. */
  133608. shadowOnly: boolean;
  133609. /**
  133610. * Default configuration related to image processing available in the Background Material.
  133611. */
  133612. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  133613. /**
  133614. * Keep track of the image processing observer to allow dispose and replace.
  133615. */
  133616. private _imageProcessingObserver;
  133617. /**
  133618. * Attaches a new image processing configuration to the PBR Material.
  133619. * @param configuration (if null the scene configuration will be use)
  133620. */
  133621. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  133622. /**
  133623. * Gets the image processing configuration used either in this material.
  133624. */
  133625. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  133626. /**
  133627. * Sets the Default image processing configuration used either in the this material.
  133628. *
  133629. * If sets to null, the scene one is in use.
  133630. */
  133631. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  133632. /**
  133633. * Gets wether the color curves effect is enabled.
  133634. */
  133635. get cameraColorCurvesEnabled(): boolean;
  133636. /**
  133637. * Sets wether the color curves effect is enabled.
  133638. */
  133639. set cameraColorCurvesEnabled(value: boolean);
  133640. /**
  133641. * Gets wether the color grading effect is enabled.
  133642. */
  133643. get cameraColorGradingEnabled(): boolean;
  133644. /**
  133645. * Gets wether the color grading effect is enabled.
  133646. */
  133647. set cameraColorGradingEnabled(value: boolean);
  133648. /**
  133649. * Gets wether tonemapping is enabled or not.
  133650. */
  133651. get cameraToneMappingEnabled(): boolean;
  133652. /**
  133653. * Sets wether tonemapping is enabled or not
  133654. */
  133655. set cameraToneMappingEnabled(value: boolean);
  133656. /**
  133657. * The camera exposure used on this material.
  133658. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  133659. * This corresponds to a photographic exposure.
  133660. */
  133661. get cameraExposure(): float;
  133662. /**
  133663. * The camera exposure used on this material.
  133664. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  133665. * This corresponds to a photographic exposure.
  133666. */
  133667. set cameraExposure(value: float);
  133668. /**
  133669. * Gets The camera contrast used on this material.
  133670. */
  133671. get cameraContrast(): float;
  133672. /**
  133673. * Sets The camera contrast used on this material.
  133674. */
  133675. set cameraContrast(value: float);
  133676. /**
  133677. * Gets the Color Grading 2D Lookup Texture.
  133678. */
  133679. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  133680. /**
  133681. * Sets the Color Grading 2D Lookup Texture.
  133682. */
  133683. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  133684. /**
  133685. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  133686. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  133687. * 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;
  133688. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  133689. */
  133690. get cameraColorCurves(): Nullable<ColorCurves>;
  133691. /**
  133692. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  133693. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  133694. * 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;
  133695. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  133696. */
  133697. set cameraColorCurves(value: Nullable<ColorCurves>);
  133698. /**
  133699. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  133700. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  133701. */
  133702. switchToBGR: boolean;
  133703. private _renderTargets;
  133704. private _reflectionControls;
  133705. private _white;
  133706. private _primaryShadowColor;
  133707. private _primaryHighlightColor;
  133708. /**
  133709. * Instantiates a Background Material in the given scene
  133710. * @param name The friendly name of the material
  133711. * @param scene The scene to add the material to
  133712. */
  133713. constructor(name: string, scene: Scene);
  133714. /**
  133715. * Gets a boolean indicating that current material needs to register RTT
  133716. */
  133717. get hasRenderTargetTextures(): boolean;
  133718. /**
  133719. * The entire material has been created in order to prevent overdraw.
  133720. * @returns false
  133721. */
  133722. needAlphaTesting(): boolean;
  133723. /**
  133724. * The entire material has been created in order to prevent overdraw.
  133725. * @returns true if blending is enable
  133726. */
  133727. needAlphaBlending(): boolean;
  133728. /**
  133729. * Checks wether the material is ready to be rendered for a given mesh.
  133730. * @param mesh The mesh to render
  133731. * @param subMesh The submesh to check against
  133732. * @param useInstances Specify wether or not the material is used with instances
  133733. * @returns true if all the dependencies are ready (Textures, Effects...)
  133734. */
  133735. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  133736. /**
  133737. * Compute the primary color according to the chosen perceptual color.
  133738. */
  133739. private _computePrimaryColorFromPerceptualColor;
  133740. /**
  133741. * Compute the highlights and shadow colors according to their chosen levels.
  133742. */
  133743. private _computePrimaryColors;
  133744. /**
  133745. * Build the uniform buffer used in the material.
  133746. */
  133747. buildUniformLayout(): void;
  133748. /**
  133749. * Unbind the material.
  133750. */
  133751. unbind(): void;
  133752. /**
  133753. * Bind only the world matrix to the material.
  133754. * @param world The world matrix to bind.
  133755. */
  133756. bindOnlyWorldMatrix(world: Matrix): void;
  133757. /**
  133758. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  133759. * @param world The world matrix to bind.
  133760. * @param subMesh The submesh to bind for.
  133761. */
  133762. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  133763. /**
  133764. * Checks to see if a texture is used in the material.
  133765. * @param texture - Base texture to use.
  133766. * @returns - Boolean specifying if a texture is used in the material.
  133767. */
  133768. hasTexture(texture: BaseTexture): boolean;
  133769. /**
  133770. * Dispose the material.
  133771. * @param forceDisposeEffect Force disposal of the associated effect.
  133772. * @param forceDisposeTextures Force disposal of the associated textures.
  133773. */
  133774. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  133775. /**
  133776. * Clones the material.
  133777. * @param name The cloned name.
  133778. * @returns The cloned material.
  133779. */
  133780. clone(name: string): BackgroundMaterial;
  133781. /**
  133782. * Serializes the current material to its JSON representation.
  133783. * @returns The JSON representation.
  133784. */
  133785. serialize(): any;
  133786. /**
  133787. * Gets the class name of the material
  133788. * @returns "BackgroundMaterial"
  133789. */
  133790. getClassName(): string;
  133791. /**
  133792. * Parse a JSON input to create back a background material.
  133793. * @param source The JSON data to parse
  133794. * @param scene The scene to create the parsed material in
  133795. * @param rootUrl The root url of the assets the material depends upon
  133796. * @returns the instantiated BackgroundMaterial.
  133797. */
  133798. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  133799. }
  133800. }
  133801. declare module BABYLON {
  133802. /**
  133803. * Represents the different options available during the creation of
  133804. * a Environment helper.
  133805. *
  133806. * This can control the default ground, skybox and image processing setup of your scene.
  133807. */
  133808. export interface IEnvironmentHelperOptions {
  133809. /**
  133810. * Specifies whether or not to create a ground.
  133811. * True by default.
  133812. */
  133813. createGround: boolean;
  133814. /**
  133815. * Specifies the ground size.
  133816. * 15 by default.
  133817. */
  133818. groundSize: number;
  133819. /**
  133820. * The texture used on the ground for the main color.
  133821. * Comes from the BabylonJS CDN by default.
  133822. *
  133823. * Remarks: Can be either a texture or a url.
  133824. */
  133825. groundTexture: string | BaseTexture;
  133826. /**
  133827. * The color mixed in the ground texture by default.
  133828. * BabylonJS clearColor by default.
  133829. */
  133830. groundColor: Color3;
  133831. /**
  133832. * Specifies the ground opacity.
  133833. * 1 by default.
  133834. */
  133835. groundOpacity: number;
  133836. /**
  133837. * Enables the ground to receive shadows.
  133838. * True by default.
  133839. */
  133840. enableGroundShadow: boolean;
  133841. /**
  133842. * Helps preventing the shadow to be fully black on the ground.
  133843. * 0.5 by default.
  133844. */
  133845. groundShadowLevel: number;
  133846. /**
  133847. * Creates a mirror texture attach to the ground.
  133848. * false by default.
  133849. */
  133850. enableGroundMirror: boolean;
  133851. /**
  133852. * Specifies the ground mirror size ratio.
  133853. * 0.3 by default as the default kernel is 64.
  133854. */
  133855. groundMirrorSizeRatio: number;
  133856. /**
  133857. * Specifies the ground mirror blur kernel size.
  133858. * 64 by default.
  133859. */
  133860. groundMirrorBlurKernel: number;
  133861. /**
  133862. * Specifies the ground mirror visibility amount.
  133863. * 1 by default
  133864. */
  133865. groundMirrorAmount: number;
  133866. /**
  133867. * Specifies the ground mirror reflectance weight.
  133868. * This uses the standard weight of the background material to setup the fresnel effect
  133869. * of the mirror.
  133870. * 1 by default.
  133871. */
  133872. groundMirrorFresnelWeight: number;
  133873. /**
  133874. * Specifies the ground mirror Falloff distance.
  133875. * This can helps reducing the size of the reflection.
  133876. * 0 by Default.
  133877. */
  133878. groundMirrorFallOffDistance: number;
  133879. /**
  133880. * Specifies the ground mirror texture type.
  133881. * Unsigned Int by Default.
  133882. */
  133883. groundMirrorTextureType: number;
  133884. /**
  133885. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  133886. * the shown objects.
  133887. */
  133888. groundYBias: number;
  133889. /**
  133890. * Specifies whether or not to create a skybox.
  133891. * True by default.
  133892. */
  133893. createSkybox: boolean;
  133894. /**
  133895. * Specifies the skybox size.
  133896. * 20 by default.
  133897. */
  133898. skyboxSize: number;
  133899. /**
  133900. * The texture used on the skybox for the main color.
  133901. * Comes from the BabylonJS CDN by default.
  133902. *
  133903. * Remarks: Can be either a texture or a url.
  133904. */
  133905. skyboxTexture: string | BaseTexture;
  133906. /**
  133907. * The color mixed in the skybox texture by default.
  133908. * BabylonJS clearColor by default.
  133909. */
  133910. skyboxColor: Color3;
  133911. /**
  133912. * The background rotation around the Y axis of the scene.
  133913. * This helps aligning the key lights of your scene with the background.
  133914. * 0 by default.
  133915. */
  133916. backgroundYRotation: number;
  133917. /**
  133918. * Compute automatically the size of the elements to best fit with the scene.
  133919. */
  133920. sizeAuto: boolean;
  133921. /**
  133922. * Default position of the rootMesh if autoSize is not true.
  133923. */
  133924. rootPosition: Vector3;
  133925. /**
  133926. * Sets up the image processing in the scene.
  133927. * true by default.
  133928. */
  133929. setupImageProcessing: boolean;
  133930. /**
  133931. * The texture used as your environment texture in the scene.
  133932. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  133933. *
  133934. * Remarks: Can be either a texture or a url.
  133935. */
  133936. environmentTexture: string | BaseTexture;
  133937. /**
  133938. * The value of the exposure to apply to the scene.
  133939. * 0.6 by default if setupImageProcessing is true.
  133940. */
  133941. cameraExposure: number;
  133942. /**
  133943. * The value of the contrast to apply to the scene.
  133944. * 1.6 by default if setupImageProcessing is true.
  133945. */
  133946. cameraContrast: number;
  133947. /**
  133948. * Specifies whether or not tonemapping should be enabled in the scene.
  133949. * true by default if setupImageProcessing is true.
  133950. */
  133951. toneMappingEnabled: boolean;
  133952. }
  133953. /**
  133954. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  133955. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  133956. * It also helps with the default setup of your imageProcessing configuration.
  133957. */
  133958. export class EnvironmentHelper {
  133959. /**
  133960. * Default ground texture URL.
  133961. */
  133962. private static _groundTextureCDNUrl;
  133963. /**
  133964. * Default skybox texture URL.
  133965. */
  133966. private static _skyboxTextureCDNUrl;
  133967. /**
  133968. * Default environment texture URL.
  133969. */
  133970. private static _environmentTextureCDNUrl;
  133971. /**
  133972. * Creates the default options for the helper.
  133973. */
  133974. private static _getDefaultOptions;
  133975. private _rootMesh;
  133976. /**
  133977. * Gets the root mesh created by the helper.
  133978. */
  133979. get rootMesh(): Mesh;
  133980. private _skybox;
  133981. /**
  133982. * Gets the skybox created by the helper.
  133983. */
  133984. get skybox(): Nullable<Mesh>;
  133985. private _skyboxTexture;
  133986. /**
  133987. * Gets the skybox texture created by the helper.
  133988. */
  133989. get skyboxTexture(): Nullable<BaseTexture>;
  133990. private _skyboxMaterial;
  133991. /**
  133992. * Gets the skybox material created by the helper.
  133993. */
  133994. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  133995. private _ground;
  133996. /**
  133997. * Gets the ground mesh created by the helper.
  133998. */
  133999. get ground(): Nullable<Mesh>;
  134000. private _groundTexture;
  134001. /**
  134002. * Gets the ground texture created by the helper.
  134003. */
  134004. get groundTexture(): Nullable<BaseTexture>;
  134005. private _groundMirror;
  134006. /**
  134007. * Gets the ground mirror created by the helper.
  134008. */
  134009. get groundMirror(): Nullable<MirrorTexture>;
  134010. /**
  134011. * Gets the ground mirror render list to helps pushing the meshes
  134012. * you wish in the ground reflection.
  134013. */
  134014. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  134015. private _groundMaterial;
  134016. /**
  134017. * Gets the ground material created by the helper.
  134018. */
  134019. get groundMaterial(): Nullable<BackgroundMaterial>;
  134020. /**
  134021. * Stores the creation options.
  134022. */
  134023. private readonly _scene;
  134024. private _options;
  134025. /**
  134026. * This observable will be notified with any error during the creation of the environment,
  134027. * mainly texture creation errors.
  134028. */
  134029. onErrorObservable: Observable<{
  134030. message?: string;
  134031. exception?: any;
  134032. }>;
  134033. /**
  134034. * constructor
  134035. * @param options Defines the options we want to customize the helper
  134036. * @param scene The scene to add the material to
  134037. */
  134038. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  134039. /**
  134040. * Updates the background according to the new options
  134041. * @param options
  134042. */
  134043. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  134044. /**
  134045. * Sets the primary color of all the available elements.
  134046. * @param color the main color to affect to the ground and the background
  134047. */
  134048. setMainColor(color: Color3): void;
  134049. /**
  134050. * Setup the image processing according to the specified options.
  134051. */
  134052. private _setupImageProcessing;
  134053. /**
  134054. * Setup the environment texture according to the specified options.
  134055. */
  134056. private _setupEnvironmentTexture;
  134057. /**
  134058. * Setup the background according to the specified options.
  134059. */
  134060. private _setupBackground;
  134061. /**
  134062. * Get the scene sizes according to the setup.
  134063. */
  134064. private _getSceneSize;
  134065. /**
  134066. * Setup the ground according to the specified options.
  134067. */
  134068. private _setupGround;
  134069. /**
  134070. * Setup the ground material according to the specified options.
  134071. */
  134072. private _setupGroundMaterial;
  134073. /**
  134074. * Setup the ground diffuse texture according to the specified options.
  134075. */
  134076. private _setupGroundDiffuseTexture;
  134077. /**
  134078. * Setup the ground mirror texture according to the specified options.
  134079. */
  134080. private _setupGroundMirrorTexture;
  134081. /**
  134082. * Setup the ground to receive the mirror texture.
  134083. */
  134084. private _setupMirrorInGroundMaterial;
  134085. /**
  134086. * Setup the skybox according to the specified options.
  134087. */
  134088. private _setupSkybox;
  134089. /**
  134090. * Setup the skybox material according to the specified options.
  134091. */
  134092. private _setupSkyboxMaterial;
  134093. /**
  134094. * Setup the skybox reflection texture according to the specified options.
  134095. */
  134096. private _setupSkyboxReflectionTexture;
  134097. private _errorHandler;
  134098. /**
  134099. * Dispose all the elements created by the Helper.
  134100. */
  134101. dispose(): void;
  134102. }
  134103. }
  134104. declare module BABYLON {
  134105. /**
  134106. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  134107. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  134108. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  134109. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  134110. */
  134111. export class PhotoDome extends TransformNode {
  134112. /**
  134113. * Define the image as a Monoscopic panoramic 360 image.
  134114. */
  134115. static readonly MODE_MONOSCOPIC: number;
  134116. /**
  134117. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  134118. */
  134119. static readonly MODE_TOPBOTTOM: number;
  134120. /**
  134121. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  134122. */
  134123. static readonly MODE_SIDEBYSIDE: number;
  134124. private _useDirectMapping;
  134125. /**
  134126. * The texture being displayed on the sphere
  134127. */
  134128. protected _photoTexture: Texture;
  134129. /**
  134130. * Gets or sets the texture being displayed on the sphere
  134131. */
  134132. get photoTexture(): Texture;
  134133. set photoTexture(value: Texture);
  134134. /**
  134135. * Observable raised when an error occured while loading the 360 image
  134136. */
  134137. onLoadErrorObservable: Observable<string>;
  134138. /**
  134139. * The skybox material
  134140. */
  134141. protected _material: BackgroundMaterial;
  134142. /**
  134143. * The surface used for the skybox
  134144. */
  134145. protected _mesh: Mesh;
  134146. /**
  134147. * Gets the mesh used for the skybox.
  134148. */
  134149. get mesh(): Mesh;
  134150. /**
  134151. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  134152. * Also see the options.resolution property.
  134153. */
  134154. get fovMultiplier(): number;
  134155. set fovMultiplier(value: number);
  134156. private _imageMode;
  134157. /**
  134158. * Gets or set the current video mode for the video. It can be:
  134159. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  134160. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  134161. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  134162. */
  134163. get imageMode(): number;
  134164. set imageMode(value: number);
  134165. /**
  134166. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  134167. * @param name Element's name, child elements will append suffixes for their own names.
  134168. * @param urlsOfPhoto defines the url of the photo to display
  134169. * @param options defines an object containing optional or exposed sub element properties
  134170. * @param onError defines a callback called when an error occured while loading the texture
  134171. */
  134172. constructor(name: string, urlOfPhoto: string, options: {
  134173. resolution?: number;
  134174. size?: number;
  134175. useDirectMapping?: boolean;
  134176. faceForward?: boolean;
  134177. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  134178. private _onBeforeCameraRenderObserver;
  134179. private _changeImageMode;
  134180. /**
  134181. * Releases resources associated with this node.
  134182. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  134183. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  134184. */
  134185. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  134186. }
  134187. }
  134188. declare module BABYLON {
  134189. /**
  134190. * Class used to host RGBD texture specific utilities
  134191. */
  134192. export class RGBDTextureTools {
  134193. /**
  134194. * Expand the RGBD Texture from RGBD to Half Float if possible.
  134195. * @param texture the texture to expand.
  134196. */
  134197. static ExpandRGBDTexture(texture: Texture): void;
  134198. }
  134199. }
  134200. declare module BABYLON {
  134201. /**
  134202. * Class used to host texture specific utilities
  134203. */
  134204. export class BRDFTextureTools {
  134205. /**
  134206. * Prevents texture cache collision
  134207. */
  134208. private static _instanceNumber;
  134209. /**
  134210. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  134211. * @param scene defines the hosting scene
  134212. * @returns the environment BRDF texture
  134213. */
  134214. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  134215. private static _environmentBRDFBase64Texture;
  134216. }
  134217. }
  134218. declare module BABYLON {
  134219. /**
  134220. * @hidden
  134221. */
  134222. export interface IMaterialClearCoatDefines {
  134223. CLEARCOAT: boolean;
  134224. CLEARCOAT_DEFAULTIOR: boolean;
  134225. CLEARCOAT_TEXTURE: boolean;
  134226. CLEARCOAT_TEXTUREDIRECTUV: number;
  134227. CLEARCOAT_BUMP: boolean;
  134228. CLEARCOAT_BUMPDIRECTUV: number;
  134229. CLEARCOAT_TINT: boolean;
  134230. CLEARCOAT_TINT_TEXTURE: boolean;
  134231. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  134232. /** @hidden */
  134233. _areTexturesDirty: boolean;
  134234. }
  134235. /**
  134236. * Define the code related to the clear coat parameters of the pbr material.
  134237. */
  134238. export class PBRClearCoatConfiguration {
  134239. /**
  134240. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  134241. * The default fits with a polyurethane material.
  134242. */
  134243. private static readonly _DefaultIndexOfRefraction;
  134244. private _isEnabled;
  134245. /**
  134246. * Defines if the clear coat is enabled in the material.
  134247. */
  134248. isEnabled: boolean;
  134249. /**
  134250. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  134251. */
  134252. intensity: number;
  134253. /**
  134254. * Defines the clear coat layer roughness.
  134255. */
  134256. roughness: number;
  134257. private _indexOfRefraction;
  134258. /**
  134259. * Defines the index of refraction of the clear coat.
  134260. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  134261. * The default fits with a polyurethane material.
  134262. * Changing the default value is more performance intensive.
  134263. */
  134264. indexOfRefraction: number;
  134265. private _texture;
  134266. /**
  134267. * Stores the clear coat values in a texture.
  134268. */
  134269. texture: Nullable<BaseTexture>;
  134270. private _bumpTexture;
  134271. /**
  134272. * Define the clear coat specific bump texture.
  134273. */
  134274. bumpTexture: Nullable<BaseTexture>;
  134275. private _isTintEnabled;
  134276. /**
  134277. * Defines if the clear coat tint is enabled in the material.
  134278. */
  134279. isTintEnabled: boolean;
  134280. /**
  134281. * Defines the clear coat tint of the material.
  134282. * This is only use if tint is enabled
  134283. */
  134284. tintColor: Color3;
  134285. /**
  134286. * Defines the distance at which the tint color should be found in the
  134287. * clear coat media.
  134288. * This is only use if tint is enabled
  134289. */
  134290. tintColorAtDistance: number;
  134291. /**
  134292. * Defines the clear coat layer thickness.
  134293. * This is only use if tint is enabled
  134294. */
  134295. tintThickness: number;
  134296. private _tintTexture;
  134297. /**
  134298. * Stores the clear tint values in a texture.
  134299. * rgb is tint
  134300. * a is a thickness factor
  134301. */
  134302. tintTexture: Nullable<BaseTexture>;
  134303. /** @hidden */
  134304. private _internalMarkAllSubMeshesAsTexturesDirty;
  134305. /** @hidden */
  134306. _markAllSubMeshesAsTexturesDirty(): void;
  134307. /**
  134308. * Instantiate a new istance of clear coat configuration.
  134309. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  134310. */
  134311. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  134312. /**
  134313. * Gets wehter the submesh is ready to be used or not.
  134314. * @param defines the list of "defines" to update.
  134315. * @param scene defines the scene the material belongs to.
  134316. * @param engine defines the engine the material belongs to.
  134317. * @param disableBumpMap defines wether the material disables bump or not.
  134318. * @returns - boolean indicating that the submesh is ready or not.
  134319. */
  134320. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  134321. /**
  134322. * Checks to see if a texture is used in the material.
  134323. * @param defines the list of "defines" to update.
  134324. * @param scene defines the scene to the material belongs to.
  134325. */
  134326. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  134327. /**
  134328. * Binds the material data.
  134329. * @param uniformBuffer defines the Uniform buffer to fill in.
  134330. * @param scene defines the scene the material belongs to.
  134331. * @param engine defines the engine the material belongs to.
  134332. * @param disableBumpMap defines wether the material disables bump or not.
  134333. * @param isFrozen defines wether the material is frozen or not.
  134334. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  134335. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  134336. */
  134337. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  134338. /**
  134339. * Checks to see if a texture is used in the material.
  134340. * @param texture - Base texture to use.
  134341. * @returns - Boolean specifying if a texture is used in the material.
  134342. */
  134343. hasTexture(texture: BaseTexture): boolean;
  134344. /**
  134345. * Returns an array of the actively used textures.
  134346. * @param activeTextures Array of BaseTextures
  134347. */
  134348. getActiveTextures(activeTextures: BaseTexture[]): void;
  134349. /**
  134350. * Returns the animatable textures.
  134351. * @param animatables Array of animatable textures.
  134352. */
  134353. getAnimatables(animatables: IAnimatable[]): void;
  134354. /**
  134355. * Disposes the resources of the material.
  134356. * @param forceDisposeTextures - Forces the disposal of all textures.
  134357. */
  134358. dispose(forceDisposeTextures?: boolean): void;
  134359. /**
  134360. * Get the current class name of the texture useful for serialization or dynamic coding.
  134361. * @returns "PBRClearCoatConfiguration"
  134362. */
  134363. getClassName(): string;
  134364. /**
  134365. * Add fallbacks to the effect fallbacks list.
  134366. * @param defines defines the Base texture to use.
  134367. * @param fallbacks defines the current fallback list.
  134368. * @param currentRank defines the current fallback rank.
  134369. * @returns the new fallback rank.
  134370. */
  134371. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  134372. /**
  134373. * Add the required uniforms to the current list.
  134374. * @param uniforms defines the current uniform list.
  134375. */
  134376. static AddUniforms(uniforms: string[]): void;
  134377. /**
  134378. * Add the required samplers to the current list.
  134379. * @param samplers defines the current sampler list.
  134380. */
  134381. static AddSamplers(samplers: string[]): void;
  134382. /**
  134383. * Add the required uniforms to the current buffer.
  134384. * @param uniformBuffer defines the current uniform buffer.
  134385. */
  134386. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  134387. /**
  134388. * Makes a duplicate of the current configuration into another one.
  134389. * @param clearCoatConfiguration define the config where to copy the info
  134390. */
  134391. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  134392. /**
  134393. * Serializes this clear coat configuration.
  134394. * @returns - An object with the serialized config.
  134395. */
  134396. serialize(): any;
  134397. /**
  134398. * Parses a anisotropy Configuration from a serialized object.
  134399. * @param source - Serialized object.
  134400. * @param scene Defines the scene we are parsing for
  134401. * @param rootUrl Defines the rootUrl to load from
  134402. */
  134403. parse(source: any, scene: Scene, rootUrl: string): void;
  134404. }
  134405. }
  134406. declare module BABYLON {
  134407. /**
  134408. * @hidden
  134409. */
  134410. export interface IMaterialAnisotropicDefines {
  134411. ANISOTROPIC: boolean;
  134412. ANISOTROPIC_TEXTURE: boolean;
  134413. ANISOTROPIC_TEXTUREDIRECTUV: number;
  134414. MAINUV1: boolean;
  134415. _areTexturesDirty: boolean;
  134416. _needUVs: boolean;
  134417. }
  134418. /**
  134419. * Define the code related to the anisotropic parameters of the pbr material.
  134420. */
  134421. export class PBRAnisotropicConfiguration {
  134422. private _isEnabled;
  134423. /**
  134424. * Defines if the anisotropy is enabled in the material.
  134425. */
  134426. isEnabled: boolean;
  134427. /**
  134428. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  134429. */
  134430. intensity: number;
  134431. /**
  134432. * Defines if the effect is along the tangents, bitangents or in between.
  134433. * By default, the effect is "strectching" the highlights along the tangents.
  134434. */
  134435. direction: Vector2;
  134436. private _texture;
  134437. /**
  134438. * Stores the anisotropy values in a texture.
  134439. * rg is direction (like normal from -1 to 1)
  134440. * b is a intensity
  134441. */
  134442. texture: Nullable<BaseTexture>;
  134443. /** @hidden */
  134444. private _internalMarkAllSubMeshesAsTexturesDirty;
  134445. /** @hidden */
  134446. _markAllSubMeshesAsTexturesDirty(): void;
  134447. /**
  134448. * Instantiate a new istance of anisotropy configuration.
  134449. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  134450. */
  134451. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  134452. /**
  134453. * Specifies that the submesh is ready to be used.
  134454. * @param defines the list of "defines" to update.
  134455. * @param scene defines the scene the material belongs to.
  134456. * @returns - boolean indicating that the submesh is ready or not.
  134457. */
  134458. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  134459. /**
  134460. * Checks to see if a texture is used in the material.
  134461. * @param defines the list of "defines" to update.
  134462. * @param mesh the mesh we are preparing the defines for.
  134463. * @param scene defines the scene the material belongs to.
  134464. */
  134465. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  134466. /**
  134467. * Binds the material data.
  134468. * @param uniformBuffer defines the Uniform buffer to fill in.
  134469. * @param scene defines the scene the material belongs to.
  134470. * @param isFrozen defines wether the material is frozen or not.
  134471. */
  134472. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  134473. /**
  134474. * Checks to see if a texture is used in the material.
  134475. * @param texture - Base texture to use.
  134476. * @returns - Boolean specifying if a texture is used in the material.
  134477. */
  134478. hasTexture(texture: BaseTexture): boolean;
  134479. /**
  134480. * Returns an array of the actively used textures.
  134481. * @param activeTextures Array of BaseTextures
  134482. */
  134483. getActiveTextures(activeTextures: BaseTexture[]): void;
  134484. /**
  134485. * Returns the animatable textures.
  134486. * @param animatables Array of animatable textures.
  134487. */
  134488. getAnimatables(animatables: IAnimatable[]): void;
  134489. /**
  134490. * Disposes the resources of the material.
  134491. * @param forceDisposeTextures - Forces the disposal of all textures.
  134492. */
  134493. dispose(forceDisposeTextures?: boolean): void;
  134494. /**
  134495. * Get the current class name of the texture useful for serialization or dynamic coding.
  134496. * @returns "PBRAnisotropicConfiguration"
  134497. */
  134498. getClassName(): string;
  134499. /**
  134500. * Add fallbacks to the effect fallbacks list.
  134501. * @param defines defines the Base texture to use.
  134502. * @param fallbacks defines the current fallback list.
  134503. * @param currentRank defines the current fallback rank.
  134504. * @returns the new fallback rank.
  134505. */
  134506. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  134507. /**
  134508. * Add the required uniforms to the current list.
  134509. * @param uniforms defines the current uniform list.
  134510. */
  134511. static AddUniforms(uniforms: string[]): void;
  134512. /**
  134513. * Add the required uniforms to the current buffer.
  134514. * @param uniformBuffer defines the current uniform buffer.
  134515. */
  134516. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  134517. /**
  134518. * Add the required samplers to the current list.
  134519. * @param samplers defines the current sampler list.
  134520. */
  134521. static AddSamplers(samplers: string[]): void;
  134522. /**
  134523. * Makes a duplicate of the current configuration into another one.
  134524. * @param anisotropicConfiguration define the config where to copy the info
  134525. */
  134526. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  134527. /**
  134528. * Serializes this anisotropy configuration.
  134529. * @returns - An object with the serialized config.
  134530. */
  134531. serialize(): any;
  134532. /**
  134533. * Parses a anisotropy Configuration from a serialized object.
  134534. * @param source - Serialized object.
  134535. * @param scene Defines the scene we are parsing for
  134536. * @param rootUrl Defines the rootUrl to load from
  134537. */
  134538. parse(source: any, scene: Scene, rootUrl: string): void;
  134539. }
  134540. }
  134541. declare module BABYLON {
  134542. /**
  134543. * @hidden
  134544. */
  134545. export interface IMaterialBRDFDefines {
  134546. BRDF_V_HEIGHT_CORRELATED: boolean;
  134547. MS_BRDF_ENERGY_CONSERVATION: boolean;
  134548. SPHERICAL_HARMONICS: boolean;
  134549. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  134550. /** @hidden */
  134551. _areMiscDirty: boolean;
  134552. }
  134553. /**
  134554. * Define the code related to the BRDF parameters of the pbr material.
  134555. */
  134556. export class PBRBRDFConfiguration {
  134557. /**
  134558. * Default value used for the energy conservation.
  134559. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  134560. */
  134561. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  134562. /**
  134563. * Default value used for the Smith Visibility Height Correlated mode.
  134564. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  134565. */
  134566. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  134567. /**
  134568. * Default value used for the IBL diffuse part.
  134569. * This can help switching back to the polynomials mode globally which is a tiny bit
  134570. * less GPU intensive at the drawback of a lower quality.
  134571. */
  134572. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  134573. /**
  134574. * Default value used for activating energy conservation for the specular workflow.
  134575. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  134576. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  134577. */
  134578. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  134579. private _useEnergyConservation;
  134580. /**
  134581. * Defines if the material uses energy conservation.
  134582. */
  134583. useEnergyConservation: boolean;
  134584. private _useSmithVisibilityHeightCorrelated;
  134585. /**
  134586. * LEGACY Mode set to false
  134587. * Defines if the material uses height smith correlated visibility term.
  134588. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  134589. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  134590. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  134591. * Not relying on height correlated will also disable energy conservation.
  134592. */
  134593. useSmithVisibilityHeightCorrelated: boolean;
  134594. private _useSphericalHarmonics;
  134595. /**
  134596. * LEGACY Mode set to false
  134597. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  134598. * diffuse part of the IBL.
  134599. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  134600. * to the ground truth.
  134601. */
  134602. useSphericalHarmonics: boolean;
  134603. private _useSpecularGlossinessInputEnergyConservation;
  134604. /**
  134605. * Defines if the material uses energy conservation, when the specular workflow is active.
  134606. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  134607. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  134608. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  134609. */
  134610. useSpecularGlossinessInputEnergyConservation: boolean;
  134611. /** @hidden */
  134612. private _internalMarkAllSubMeshesAsMiscDirty;
  134613. /** @hidden */
  134614. _markAllSubMeshesAsMiscDirty(): void;
  134615. /**
  134616. * Instantiate a new istance of clear coat configuration.
  134617. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  134618. */
  134619. constructor(markAllSubMeshesAsMiscDirty: () => void);
  134620. /**
  134621. * Checks to see if a texture is used in the material.
  134622. * @param defines the list of "defines" to update.
  134623. */
  134624. prepareDefines(defines: IMaterialBRDFDefines): void;
  134625. /**
  134626. * Get the current class name of the texture useful for serialization or dynamic coding.
  134627. * @returns "PBRClearCoatConfiguration"
  134628. */
  134629. getClassName(): string;
  134630. /**
  134631. * Makes a duplicate of the current configuration into another one.
  134632. * @param brdfConfiguration define the config where to copy the info
  134633. */
  134634. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  134635. /**
  134636. * Serializes this BRDF configuration.
  134637. * @returns - An object with the serialized config.
  134638. */
  134639. serialize(): any;
  134640. /**
  134641. * Parses a anisotropy Configuration from a serialized object.
  134642. * @param source - Serialized object.
  134643. * @param scene Defines the scene we are parsing for
  134644. * @param rootUrl Defines the rootUrl to load from
  134645. */
  134646. parse(source: any, scene: Scene, rootUrl: string): void;
  134647. }
  134648. }
  134649. declare module BABYLON {
  134650. /**
  134651. * @hidden
  134652. */
  134653. export interface IMaterialSheenDefines {
  134654. SHEEN: boolean;
  134655. SHEEN_TEXTURE: boolean;
  134656. SHEEN_TEXTUREDIRECTUV: number;
  134657. SHEEN_LINKWITHALBEDO: boolean;
  134658. SHEEN_ROUGHNESS: boolean;
  134659. SHEEN_ALBEDOSCALING: boolean;
  134660. /** @hidden */
  134661. _areTexturesDirty: boolean;
  134662. }
  134663. /**
  134664. * Define the code related to the Sheen parameters of the pbr material.
  134665. */
  134666. export class PBRSheenConfiguration {
  134667. private _isEnabled;
  134668. /**
  134669. * Defines if the material uses sheen.
  134670. */
  134671. isEnabled: boolean;
  134672. private _linkSheenWithAlbedo;
  134673. /**
  134674. * Defines if the sheen is linked to the sheen color.
  134675. */
  134676. linkSheenWithAlbedo: boolean;
  134677. /**
  134678. * Defines the sheen intensity.
  134679. */
  134680. intensity: number;
  134681. /**
  134682. * Defines the sheen color.
  134683. */
  134684. color: Color3;
  134685. private _texture;
  134686. /**
  134687. * Stores the sheen tint values in a texture.
  134688. * rgb is tint
  134689. * a is a intensity or roughness if roughness has been defined
  134690. */
  134691. texture: Nullable<BaseTexture>;
  134692. private _roughness;
  134693. /**
  134694. * Defines the sheen roughness.
  134695. * It is not taken into account if linkSheenWithAlbedo is true.
  134696. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  134697. */
  134698. roughness: Nullable<number>;
  134699. private _albedoScaling;
  134700. /**
  134701. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  134702. * It allows the strength of the sheen effect to not depend on the base color of the material,
  134703. * making it easier to setup and tweak the effect
  134704. */
  134705. albedoScaling: boolean;
  134706. /** @hidden */
  134707. private _internalMarkAllSubMeshesAsTexturesDirty;
  134708. /** @hidden */
  134709. _markAllSubMeshesAsTexturesDirty(): void;
  134710. /**
  134711. * Instantiate a new istance of clear coat configuration.
  134712. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  134713. */
  134714. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  134715. /**
  134716. * Specifies that the submesh is ready to be used.
  134717. * @param defines the list of "defines" to update.
  134718. * @param scene defines the scene the material belongs to.
  134719. * @returns - boolean indicating that the submesh is ready or not.
  134720. */
  134721. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  134722. /**
  134723. * Checks to see if a texture is used in the material.
  134724. * @param defines the list of "defines" to update.
  134725. * @param scene defines the scene the material belongs to.
  134726. */
  134727. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  134728. /**
  134729. * Binds the material data.
  134730. * @param uniformBuffer defines the Uniform buffer to fill in.
  134731. * @param scene defines the scene the material belongs to.
  134732. * @param isFrozen defines wether the material is frozen or not.
  134733. */
  134734. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  134735. /**
  134736. * Checks to see if a texture is used in the material.
  134737. * @param texture - Base texture to use.
  134738. * @returns - Boolean specifying if a texture is used in the material.
  134739. */
  134740. hasTexture(texture: BaseTexture): boolean;
  134741. /**
  134742. * Returns an array of the actively used textures.
  134743. * @param activeTextures Array of BaseTextures
  134744. */
  134745. getActiveTextures(activeTextures: BaseTexture[]): void;
  134746. /**
  134747. * Returns the animatable textures.
  134748. * @param animatables Array of animatable textures.
  134749. */
  134750. getAnimatables(animatables: IAnimatable[]): void;
  134751. /**
  134752. * Disposes the resources of the material.
  134753. * @param forceDisposeTextures - Forces the disposal of all textures.
  134754. */
  134755. dispose(forceDisposeTextures?: boolean): void;
  134756. /**
  134757. * Get the current class name of the texture useful for serialization or dynamic coding.
  134758. * @returns "PBRSheenConfiguration"
  134759. */
  134760. getClassName(): string;
  134761. /**
  134762. * Add fallbacks to the effect fallbacks list.
  134763. * @param defines defines the Base texture to use.
  134764. * @param fallbacks defines the current fallback list.
  134765. * @param currentRank defines the current fallback rank.
  134766. * @returns the new fallback rank.
  134767. */
  134768. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  134769. /**
  134770. * Add the required uniforms to the current list.
  134771. * @param uniforms defines the current uniform list.
  134772. */
  134773. static AddUniforms(uniforms: string[]): void;
  134774. /**
  134775. * Add the required uniforms to the current buffer.
  134776. * @param uniformBuffer defines the current uniform buffer.
  134777. */
  134778. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  134779. /**
  134780. * Add the required samplers to the current list.
  134781. * @param samplers defines the current sampler list.
  134782. */
  134783. static AddSamplers(samplers: string[]): void;
  134784. /**
  134785. * Makes a duplicate of the current configuration into another one.
  134786. * @param sheenConfiguration define the config where to copy the info
  134787. */
  134788. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  134789. /**
  134790. * Serializes this BRDF configuration.
  134791. * @returns - An object with the serialized config.
  134792. */
  134793. serialize(): any;
  134794. /**
  134795. * Parses a anisotropy Configuration from a serialized object.
  134796. * @param source - Serialized object.
  134797. * @param scene Defines the scene we are parsing for
  134798. * @param rootUrl Defines the rootUrl to load from
  134799. */
  134800. parse(source: any, scene: Scene, rootUrl: string): void;
  134801. }
  134802. }
  134803. declare module BABYLON {
  134804. /**
  134805. * @hidden
  134806. */
  134807. export interface IMaterialSubSurfaceDefines {
  134808. SUBSURFACE: boolean;
  134809. SS_REFRACTION: boolean;
  134810. SS_TRANSLUCENCY: boolean;
  134811. SS_SCATTERING: boolean;
  134812. SS_THICKNESSANDMASK_TEXTURE: boolean;
  134813. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  134814. SS_REFRACTIONMAP_3D: boolean;
  134815. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  134816. SS_LODINREFRACTIONALPHA: boolean;
  134817. SS_GAMMAREFRACTION: boolean;
  134818. SS_RGBDREFRACTION: boolean;
  134819. SS_LINEARSPECULARREFRACTION: boolean;
  134820. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  134821. SS_ALBEDOFORREFRACTIONTINT: boolean;
  134822. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  134823. /** @hidden */
  134824. _areTexturesDirty: boolean;
  134825. }
  134826. /**
  134827. * Define the code related to the sub surface parameters of the pbr material.
  134828. */
  134829. export class PBRSubSurfaceConfiguration {
  134830. private _isRefractionEnabled;
  134831. /**
  134832. * Defines if the refraction is enabled in the material.
  134833. */
  134834. isRefractionEnabled: boolean;
  134835. private _isTranslucencyEnabled;
  134836. /**
  134837. * Defines if the translucency is enabled in the material.
  134838. */
  134839. isTranslucencyEnabled: boolean;
  134840. private _isScatteringEnabled;
  134841. /**
  134842. * Defines if the sub surface scattering is enabled in the material.
  134843. */
  134844. isScatteringEnabled: boolean;
  134845. private _scatteringDiffusionProfileIndex;
  134846. /**
  134847. * Diffusion profile for subsurface scattering.
  134848. * Useful for better scattering in the skins or foliages.
  134849. */
  134850. get scatteringDiffusionProfile(): Nullable<Color3>;
  134851. set scatteringDiffusionProfile(c: Nullable<Color3>);
  134852. /**
  134853. * Defines the refraction intensity of the material.
  134854. * The refraction when enabled replaces the Diffuse part of the material.
  134855. * The intensity helps transitionning between diffuse and refraction.
  134856. */
  134857. refractionIntensity: number;
  134858. /**
  134859. * Defines the translucency intensity of the material.
  134860. * When translucency has been enabled, this defines how much of the "translucency"
  134861. * is addded to the diffuse part of the material.
  134862. */
  134863. translucencyIntensity: number;
  134864. /**
  134865. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  134866. */
  134867. useAlbedoToTintRefraction: boolean;
  134868. private _thicknessTexture;
  134869. /**
  134870. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  134871. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  134872. * 0 would mean minimumThickness
  134873. * 1 would mean maximumThickness
  134874. * The other channels might be use as a mask to vary the different effects intensity.
  134875. */
  134876. thicknessTexture: Nullable<BaseTexture>;
  134877. private _refractionTexture;
  134878. /**
  134879. * Defines the texture to use for refraction.
  134880. */
  134881. refractionTexture: Nullable<BaseTexture>;
  134882. private _indexOfRefraction;
  134883. /**
  134884. * Index of refraction of the material base layer.
  134885. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  134886. *
  134887. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  134888. *
  134889. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  134890. */
  134891. indexOfRefraction: number;
  134892. private _volumeIndexOfRefraction;
  134893. /**
  134894. * Index of refraction of the material's volume.
  134895. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  134896. *
  134897. * This ONLY impacts refraction. If not provided or given a non-valid value,
  134898. * the volume will use the same IOR as the surface.
  134899. */
  134900. get volumeIndexOfRefraction(): number;
  134901. set volumeIndexOfRefraction(value: number);
  134902. private _invertRefractionY;
  134903. /**
  134904. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  134905. */
  134906. invertRefractionY: boolean;
  134907. private _linkRefractionWithTransparency;
  134908. /**
  134909. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  134910. * Materials half opaque for instance using refraction could benefit from this control.
  134911. */
  134912. linkRefractionWithTransparency: boolean;
  134913. /**
  134914. * Defines the minimum thickness stored in the thickness map.
  134915. * If no thickness map is defined, this value will be used to simulate thickness.
  134916. */
  134917. minimumThickness: number;
  134918. /**
  134919. * Defines the maximum thickness stored in the thickness map.
  134920. */
  134921. maximumThickness: number;
  134922. /**
  134923. * Defines the volume tint of the material.
  134924. * This is used for both translucency and scattering.
  134925. */
  134926. tintColor: Color3;
  134927. /**
  134928. * Defines the distance at which the tint color should be found in the media.
  134929. * This is used for refraction only.
  134930. */
  134931. tintColorAtDistance: number;
  134932. /**
  134933. * Defines how far each channel transmit through the media.
  134934. * It is defined as a color to simplify it selection.
  134935. */
  134936. diffusionDistance: Color3;
  134937. private _useMaskFromThicknessTexture;
  134938. /**
  134939. * Stores the intensity of the different subsurface effects in the thickness texture.
  134940. * * the green channel is the translucency intensity.
  134941. * * the blue channel is the scattering intensity.
  134942. * * the alpha channel is the refraction intensity.
  134943. */
  134944. useMaskFromThicknessTexture: boolean;
  134945. private _scene;
  134946. /** @hidden */
  134947. private _internalMarkAllSubMeshesAsTexturesDirty;
  134948. private _internalMarkScenePrePassDirty;
  134949. /** @hidden */
  134950. _markAllSubMeshesAsTexturesDirty(): void;
  134951. /** @hidden */
  134952. _markScenePrePassDirty(): void;
  134953. /**
  134954. * Instantiate a new istance of sub surface configuration.
  134955. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  134956. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  134957. * @param scene The scene
  134958. */
  134959. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  134960. /**
  134961. * Gets wehter the submesh is ready to be used or not.
  134962. * @param defines the list of "defines" to update.
  134963. * @param scene defines the scene the material belongs to.
  134964. * @returns - boolean indicating that the submesh is ready or not.
  134965. */
  134966. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  134967. /**
  134968. * Checks to see if a texture is used in the material.
  134969. * @param defines the list of "defines" to update.
  134970. * @param scene defines the scene to the material belongs to.
  134971. */
  134972. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  134973. /**
  134974. * Binds the material data.
  134975. * @param uniformBuffer defines the Uniform buffer to fill in.
  134976. * @param scene defines the scene the material belongs to.
  134977. * @param engine defines the engine the material belongs to.
  134978. * @param isFrozen defines whether the material is frozen or not.
  134979. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  134980. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  134981. */
  134982. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  134983. /**
  134984. * Unbinds the material from the mesh.
  134985. * @param activeEffect defines the effect that should be unbound from.
  134986. * @returns true if unbound, otherwise false
  134987. */
  134988. unbind(activeEffect: Effect): boolean;
  134989. /**
  134990. * Returns the texture used for refraction or null if none is used.
  134991. * @param scene defines the scene the material belongs to.
  134992. * @returns - Refraction texture if present. If no refraction texture and refraction
  134993. * is linked with transparency, returns environment texture. Otherwise, returns null.
  134994. */
  134995. private _getRefractionTexture;
  134996. /**
  134997. * Returns true if alpha blending should be disabled.
  134998. */
  134999. get disableAlphaBlending(): boolean;
  135000. /**
  135001. * Fills the list of render target textures.
  135002. * @param renderTargets the list of render targets to update
  135003. */
  135004. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  135005. /**
  135006. * Checks to see if a texture is used in the material.
  135007. * @param texture - Base texture to use.
  135008. * @returns - Boolean specifying if a texture is used in the material.
  135009. */
  135010. hasTexture(texture: BaseTexture): boolean;
  135011. /**
  135012. * Gets a boolean indicating that current material needs to register RTT
  135013. * @returns true if this uses a render target otherwise false.
  135014. */
  135015. hasRenderTargetTextures(): boolean;
  135016. /**
  135017. * Returns an array of the actively used textures.
  135018. * @param activeTextures Array of BaseTextures
  135019. */
  135020. getActiveTextures(activeTextures: BaseTexture[]): void;
  135021. /**
  135022. * Returns the animatable textures.
  135023. * @param animatables Array of animatable textures.
  135024. */
  135025. getAnimatables(animatables: IAnimatable[]): void;
  135026. /**
  135027. * Disposes the resources of the material.
  135028. * @param forceDisposeTextures - Forces the disposal of all textures.
  135029. */
  135030. dispose(forceDisposeTextures?: boolean): void;
  135031. /**
  135032. * Get the current class name of the texture useful for serialization or dynamic coding.
  135033. * @returns "PBRSubSurfaceConfiguration"
  135034. */
  135035. getClassName(): string;
  135036. /**
  135037. * Add fallbacks to the effect fallbacks list.
  135038. * @param defines defines the Base texture to use.
  135039. * @param fallbacks defines the current fallback list.
  135040. * @param currentRank defines the current fallback rank.
  135041. * @returns the new fallback rank.
  135042. */
  135043. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  135044. /**
  135045. * Add the required uniforms to the current list.
  135046. * @param uniforms defines the current uniform list.
  135047. */
  135048. static AddUniforms(uniforms: string[]): void;
  135049. /**
  135050. * Add the required samplers to the current list.
  135051. * @param samplers defines the current sampler list.
  135052. */
  135053. static AddSamplers(samplers: string[]): void;
  135054. /**
  135055. * Add the required uniforms to the current buffer.
  135056. * @param uniformBuffer defines the current uniform buffer.
  135057. */
  135058. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  135059. /**
  135060. * Makes a duplicate of the current configuration into another one.
  135061. * @param configuration define the config where to copy the info
  135062. */
  135063. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  135064. /**
  135065. * Serializes this Sub Surface configuration.
  135066. * @returns - An object with the serialized config.
  135067. */
  135068. serialize(): any;
  135069. /**
  135070. * Parses a anisotropy Configuration from a serialized object.
  135071. * @param source - Serialized object.
  135072. * @param scene Defines the scene we are parsing for
  135073. * @param rootUrl Defines the rootUrl to load from
  135074. */
  135075. parse(source: any, scene: Scene, rootUrl: string): void;
  135076. }
  135077. }
  135078. declare module BABYLON {
  135079. /** @hidden */
  135080. export var pbrFragmentDeclaration: {
  135081. name: string;
  135082. shader: string;
  135083. };
  135084. }
  135085. declare module BABYLON {
  135086. /** @hidden */
  135087. export var pbrUboDeclaration: {
  135088. name: string;
  135089. shader: string;
  135090. };
  135091. }
  135092. declare module BABYLON {
  135093. /** @hidden */
  135094. export var pbrFragmentExtraDeclaration: {
  135095. name: string;
  135096. shader: string;
  135097. };
  135098. }
  135099. declare module BABYLON {
  135100. /** @hidden */
  135101. export var pbrFragmentSamplersDeclaration: {
  135102. name: string;
  135103. shader: string;
  135104. };
  135105. }
  135106. declare module BABYLON {
  135107. /** @hidden */
  135108. export var importanceSampling: {
  135109. name: string;
  135110. shader: string;
  135111. };
  135112. }
  135113. declare module BABYLON {
  135114. /** @hidden */
  135115. export var pbrHelperFunctions: {
  135116. name: string;
  135117. shader: string;
  135118. };
  135119. }
  135120. declare module BABYLON {
  135121. /** @hidden */
  135122. export var harmonicsFunctions: {
  135123. name: string;
  135124. shader: string;
  135125. };
  135126. }
  135127. declare module BABYLON {
  135128. /** @hidden */
  135129. export var pbrDirectLightingSetupFunctions: {
  135130. name: string;
  135131. shader: string;
  135132. };
  135133. }
  135134. declare module BABYLON {
  135135. /** @hidden */
  135136. export var pbrDirectLightingFalloffFunctions: {
  135137. name: string;
  135138. shader: string;
  135139. };
  135140. }
  135141. declare module BABYLON {
  135142. /** @hidden */
  135143. export var pbrBRDFFunctions: {
  135144. name: string;
  135145. shader: string;
  135146. };
  135147. }
  135148. declare module BABYLON {
  135149. /** @hidden */
  135150. export var hdrFilteringFunctions: {
  135151. name: string;
  135152. shader: string;
  135153. };
  135154. }
  135155. declare module BABYLON {
  135156. /** @hidden */
  135157. export var pbrDirectLightingFunctions: {
  135158. name: string;
  135159. shader: string;
  135160. };
  135161. }
  135162. declare module BABYLON {
  135163. /** @hidden */
  135164. export var pbrIBLFunctions: {
  135165. name: string;
  135166. shader: string;
  135167. };
  135168. }
  135169. declare module BABYLON {
  135170. /** @hidden */
  135171. export var pbrBlockAlbedoOpacity: {
  135172. name: string;
  135173. shader: string;
  135174. };
  135175. }
  135176. declare module BABYLON {
  135177. /** @hidden */
  135178. export var pbrBlockReflectivity: {
  135179. name: string;
  135180. shader: string;
  135181. };
  135182. }
  135183. declare module BABYLON {
  135184. /** @hidden */
  135185. export var pbrBlockAmbientOcclusion: {
  135186. name: string;
  135187. shader: string;
  135188. };
  135189. }
  135190. declare module BABYLON {
  135191. /** @hidden */
  135192. export var pbrBlockAlphaFresnel: {
  135193. name: string;
  135194. shader: string;
  135195. };
  135196. }
  135197. declare module BABYLON {
  135198. /** @hidden */
  135199. export var pbrBlockAnisotropic: {
  135200. name: string;
  135201. shader: string;
  135202. };
  135203. }
  135204. declare module BABYLON {
  135205. /** @hidden */
  135206. export var pbrBlockReflection: {
  135207. name: string;
  135208. shader: string;
  135209. };
  135210. }
  135211. declare module BABYLON {
  135212. /** @hidden */
  135213. export var pbrBlockSheen: {
  135214. name: string;
  135215. shader: string;
  135216. };
  135217. }
  135218. declare module BABYLON {
  135219. /** @hidden */
  135220. export var pbrBlockClearcoat: {
  135221. name: string;
  135222. shader: string;
  135223. };
  135224. }
  135225. declare module BABYLON {
  135226. /** @hidden */
  135227. export var pbrBlockSubSurface: {
  135228. name: string;
  135229. shader: string;
  135230. };
  135231. }
  135232. declare module BABYLON {
  135233. /** @hidden */
  135234. export var pbrBlockNormalGeometric: {
  135235. name: string;
  135236. shader: string;
  135237. };
  135238. }
  135239. declare module BABYLON {
  135240. /** @hidden */
  135241. export var pbrBlockNormalFinal: {
  135242. name: string;
  135243. shader: string;
  135244. };
  135245. }
  135246. declare module BABYLON {
  135247. /** @hidden */
  135248. export var pbrBlockLightmapInit: {
  135249. name: string;
  135250. shader: string;
  135251. };
  135252. }
  135253. declare module BABYLON {
  135254. /** @hidden */
  135255. export var pbrBlockGeometryInfo: {
  135256. name: string;
  135257. shader: string;
  135258. };
  135259. }
  135260. declare module BABYLON {
  135261. /** @hidden */
  135262. export var pbrBlockReflectance0: {
  135263. name: string;
  135264. shader: string;
  135265. };
  135266. }
  135267. declare module BABYLON {
  135268. /** @hidden */
  135269. export var pbrBlockReflectance: {
  135270. name: string;
  135271. shader: string;
  135272. };
  135273. }
  135274. declare module BABYLON {
  135275. /** @hidden */
  135276. export var pbrBlockDirectLighting: {
  135277. name: string;
  135278. shader: string;
  135279. };
  135280. }
  135281. declare module BABYLON {
  135282. /** @hidden */
  135283. export var pbrBlockFinalLitComponents: {
  135284. name: string;
  135285. shader: string;
  135286. };
  135287. }
  135288. declare module BABYLON {
  135289. /** @hidden */
  135290. export var pbrBlockFinalUnlitComponents: {
  135291. name: string;
  135292. shader: string;
  135293. };
  135294. }
  135295. declare module BABYLON {
  135296. /** @hidden */
  135297. export var pbrBlockFinalColorComposition: {
  135298. name: string;
  135299. shader: string;
  135300. };
  135301. }
  135302. declare module BABYLON {
  135303. /** @hidden */
  135304. export var pbrBlockImageProcessing: {
  135305. name: string;
  135306. shader: string;
  135307. };
  135308. }
  135309. declare module BABYLON {
  135310. /** @hidden */
  135311. export var pbrDebug: {
  135312. name: string;
  135313. shader: string;
  135314. };
  135315. }
  135316. declare module BABYLON {
  135317. /** @hidden */
  135318. export var pbrPixelShader: {
  135319. name: string;
  135320. shader: string;
  135321. };
  135322. }
  135323. declare module BABYLON {
  135324. /** @hidden */
  135325. export var pbrVertexDeclaration: {
  135326. name: string;
  135327. shader: string;
  135328. };
  135329. }
  135330. declare module BABYLON {
  135331. /** @hidden */
  135332. export var pbrVertexShader: {
  135333. name: string;
  135334. shader: string;
  135335. };
  135336. }
  135337. declare module BABYLON {
  135338. /**
  135339. * Manages the defines for the PBR Material.
  135340. * @hidden
  135341. */
  135342. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  135343. PBR: boolean;
  135344. NUM_SAMPLES: string;
  135345. REALTIME_FILTERING: boolean;
  135346. MAINUV1: boolean;
  135347. MAINUV2: boolean;
  135348. UV1: boolean;
  135349. UV2: boolean;
  135350. ALBEDO: boolean;
  135351. GAMMAALBEDO: boolean;
  135352. ALBEDODIRECTUV: number;
  135353. VERTEXCOLOR: boolean;
  135354. DETAIL: boolean;
  135355. DETAILDIRECTUV: number;
  135356. DETAIL_NORMALBLENDMETHOD: number;
  135357. AMBIENT: boolean;
  135358. AMBIENTDIRECTUV: number;
  135359. AMBIENTINGRAYSCALE: boolean;
  135360. OPACITY: boolean;
  135361. VERTEXALPHA: boolean;
  135362. OPACITYDIRECTUV: number;
  135363. OPACITYRGB: boolean;
  135364. ALPHATEST: boolean;
  135365. DEPTHPREPASS: boolean;
  135366. ALPHABLEND: boolean;
  135367. ALPHAFROMALBEDO: boolean;
  135368. ALPHATESTVALUE: string;
  135369. SPECULAROVERALPHA: boolean;
  135370. RADIANCEOVERALPHA: boolean;
  135371. ALPHAFRESNEL: boolean;
  135372. LINEARALPHAFRESNEL: boolean;
  135373. PREMULTIPLYALPHA: boolean;
  135374. EMISSIVE: boolean;
  135375. EMISSIVEDIRECTUV: number;
  135376. REFLECTIVITY: boolean;
  135377. REFLECTIVITYDIRECTUV: number;
  135378. SPECULARTERM: boolean;
  135379. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  135380. MICROSURFACEAUTOMATIC: boolean;
  135381. LODBASEDMICROSFURACE: boolean;
  135382. MICROSURFACEMAP: boolean;
  135383. MICROSURFACEMAPDIRECTUV: number;
  135384. METALLICWORKFLOW: boolean;
  135385. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  135386. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  135387. METALLNESSSTOREINMETALMAPBLUE: boolean;
  135388. AOSTOREINMETALMAPRED: boolean;
  135389. METALLIC_REFLECTANCE: boolean;
  135390. METALLIC_REFLECTANCEDIRECTUV: number;
  135391. ENVIRONMENTBRDF: boolean;
  135392. ENVIRONMENTBRDF_RGBD: boolean;
  135393. NORMAL: boolean;
  135394. TANGENT: boolean;
  135395. BUMP: boolean;
  135396. BUMPDIRECTUV: number;
  135397. OBJECTSPACE_NORMALMAP: boolean;
  135398. PARALLAX: boolean;
  135399. PARALLAXOCCLUSION: boolean;
  135400. NORMALXYSCALE: boolean;
  135401. LIGHTMAP: boolean;
  135402. LIGHTMAPDIRECTUV: number;
  135403. USELIGHTMAPASSHADOWMAP: boolean;
  135404. GAMMALIGHTMAP: boolean;
  135405. RGBDLIGHTMAP: boolean;
  135406. REFLECTION: boolean;
  135407. REFLECTIONMAP_3D: boolean;
  135408. REFLECTIONMAP_SPHERICAL: boolean;
  135409. REFLECTIONMAP_PLANAR: boolean;
  135410. REFLECTIONMAP_CUBIC: boolean;
  135411. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  135412. REFLECTIONMAP_PROJECTION: boolean;
  135413. REFLECTIONMAP_SKYBOX: boolean;
  135414. REFLECTIONMAP_EXPLICIT: boolean;
  135415. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  135416. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  135417. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  135418. INVERTCUBICMAP: boolean;
  135419. USESPHERICALFROMREFLECTIONMAP: boolean;
  135420. USEIRRADIANCEMAP: boolean;
  135421. SPHERICAL_HARMONICS: boolean;
  135422. USESPHERICALINVERTEX: boolean;
  135423. REFLECTIONMAP_OPPOSITEZ: boolean;
  135424. LODINREFLECTIONALPHA: boolean;
  135425. GAMMAREFLECTION: boolean;
  135426. RGBDREFLECTION: boolean;
  135427. LINEARSPECULARREFLECTION: boolean;
  135428. RADIANCEOCCLUSION: boolean;
  135429. HORIZONOCCLUSION: boolean;
  135430. INSTANCES: boolean;
  135431. THIN_INSTANCES: boolean;
  135432. PREPASS: boolean;
  135433. SCENE_MRT_COUNT: number;
  135434. NUM_BONE_INFLUENCERS: number;
  135435. BonesPerMesh: number;
  135436. BONETEXTURE: boolean;
  135437. NONUNIFORMSCALING: boolean;
  135438. MORPHTARGETS: boolean;
  135439. MORPHTARGETS_NORMAL: boolean;
  135440. MORPHTARGETS_TANGENT: boolean;
  135441. MORPHTARGETS_UV: boolean;
  135442. NUM_MORPH_INFLUENCERS: number;
  135443. IMAGEPROCESSING: boolean;
  135444. VIGNETTE: boolean;
  135445. VIGNETTEBLENDMODEMULTIPLY: boolean;
  135446. VIGNETTEBLENDMODEOPAQUE: boolean;
  135447. TONEMAPPING: boolean;
  135448. TONEMAPPING_ACES: boolean;
  135449. CONTRAST: boolean;
  135450. COLORCURVES: boolean;
  135451. COLORGRADING: boolean;
  135452. COLORGRADING3D: boolean;
  135453. SAMPLER3DGREENDEPTH: boolean;
  135454. SAMPLER3DBGRMAP: boolean;
  135455. IMAGEPROCESSINGPOSTPROCESS: boolean;
  135456. EXPOSURE: boolean;
  135457. MULTIVIEW: boolean;
  135458. USEPHYSICALLIGHTFALLOFF: boolean;
  135459. USEGLTFLIGHTFALLOFF: boolean;
  135460. TWOSIDEDLIGHTING: boolean;
  135461. SHADOWFLOAT: boolean;
  135462. CLIPPLANE: boolean;
  135463. CLIPPLANE2: boolean;
  135464. CLIPPLANE3: boolean;
  135465. CLIPPLANE4: boolean;
  135466. CLIPPLANE5: boolean;
  135467. CLIPPLANE6: boolean;
  135468. POINTSIZE: boolean;
  135469. FOG: boolean;
  135470. LOGARITHMICDEPTH: boolean;
  135471. FORCENORMALFORWARD: boolean;
  135472. SPECULARAA: boolean;
  135473. CLEARCOAT: boolean;
  135474. CLEARCOAT_DEFAULTIOR: boolean;
  135475. CLEARCOAT_TEXTURE: boolean;
  135476. CLEARCOAT_TEXTUREDIRECTUV: number;
  135477. CLEARCOAT_BUMP: boolean;
  135478. CLEARCOAT_BUMPDIRECTUV: number;
  135479. CLEARCOAT_TINT: boolean;
  135480. CLEARCOAT_TINT_TEXTURE: boolean;
  135481. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  135482. ANISOTROPIC: boolean;
  135483. ANISOTROPIC_TEXTURE: boolean;
  135484. ANISOTROPIC_TEXTUREDIRECTUV: number;
  135485. BRDF_V_HEIGHT_CORRELATED: boolean;
  135486. MS_BRDF_ENERGY_CONSERVATION: boolean;
  135487. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  135488. SHEEN: boolean;
  135489. SHEEN_TEXTURE: boolean;
  135490. SHEEN_TEXTUREDIRECTUV: number;
  135491. SHEEN_LINKWITHALBEDO: boolean;
  135492. SHEEN_ROUGHNESS: boolean;
  135493. SHEEN_ALBEDOSCALING: boolean;
  135494. SUBSURFACE: boolean;
  135495. SS_REFRACTION: boolean;
  135496. SS_TRANSLUCENCY: boolean;
  135497. SS_SCATTERING: boolean;
  135498. SS_THICKNESSANDMASK_TEXTURE: boolean;
  135499. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  135500. SS_REFRACTIONMAP_3D: boolean;
  135501. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  135502. SS_LODINREFRACTIONALPHA: boolean;
  135503. SS_GAMMAREFRACTION: boolean;
  135504. SS_RGBDREFRACTION: boolean;
  135505. SS_LINEARSPECULARREFRACTION: boolean;
  135506. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  135507. SS_ALBEDOFORREFRACTIONTINT: boolean;
  135508. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  135509. UNLIT: boolean;
  135510. DEBUGMODE: number;
  135511. /**
  135512. * Initializes the PBR Material defines.
  135513. */
  135514. constructor();
  135515. /**
  135516. * Resets the PBR Material defines.
  135517. */
  135518. reset(): void;
  135519. }
  135520. /**
  135521. * The Physically based material base class of BJS.
  135522. *
  135523. * This offers the main features of a standard PBR material.
  135524. * For more information, please refer to the documentation :
  135525. * https://doc.babylonjs.com/how_to/physically_based_rendering
  135526. */
  135527. export abstract class PBRBaseMaterial extends PushMaterial {
  135528. /**
  135529. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  135530. */
  135531. static readonly PBRMATERIAL_OPAQUE: number;
  135532. /**
  135533. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  135534. */
  135535. static readonly PBRMATERIAL_ALPHATEST: number;
  135536. /**
  135537. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  135538. */
  135539. static readonly PBRMATERIAL_ALPHABLEND: number;
  135540. /**
  135541. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  135542. * They are also discarded below the alpha cutoff threshold to improve performances.
  135543. */
  135544. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  135545. /**
  135546. * Defines the default value of how much AO map is occluding the analytical lights
  135547. * (point spot...).
  135548. */
  135549. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  135550. /**
  135551. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  135552. */
  135553. static readonly LIGHTFALLOFF_PHYSICAL: number;
  135554. /**
  135555. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  135556. * to enhance interoperability with other engines.
  135557. */
  135558. static readonly LIGHTFALLOFF_GLTF: number;
  135559. /**
  135560. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  135561. * to enhance interoperability with other materials.
  135562. */
  135563. static readonly LIGHTFALLOFF_STANDARD: number;
  135564. /**
  135565. * Intensity of the direct lights e.g. the four lights available in your scene.
  135566. * This impacts both the direct diffuse and specular highlights.
  135567. */
  135568. protected _directIntensity: number;
  135569. /**
  135570. * Intensity of the emissive part of the material.
  135571. * This helps controlling the emissive effect without modifying the emissive color.
  135572. */
  135573. protected _emissiveIntensity: number;
  135574. /**
  135575. * Intensity of the environment e.g. how much the environment will light the object
  135576. * either through harmonics for rough material or through the refelction for shiny ones.
  135577. */
  135578. protected _environmentIntensity: number;
  135579. /**
  135580. * This is a special control allowing the reduction of the specular highlights coming from the
  135581. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  135582. */
  135583. protected _specularIntensity: number;
  135584. /**
  135585. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  135586. */
  135587. private _lightingInfos;
  135588. /**
  135589. * Debug Control allowing disabling the bump map on this material.
  135590. */
  135591. protected _disableBumpMap: boolean;
  135592. /**
  135593. * AKA Diffuse Texture in standard nomenclature.
  135594. */
  135595. protected _albedoTexture: Nullable<BaseTexture>;
  135596. /**
  135597. * AKA Occlusion Texture in other nomenclature.
  135598. */
  135599. protected _ambientTexture: Nullable<BaseTexture>;
  135600. /**
  135601. * AKA Occlusion Texture Intensity in other nomenclature.
  135602. */
  135603. protected _ambientTextureStrength: number;
  135604. /**
  135605. * Defines how much the AO map is occluding the analytical lights (point spot...).
  135606. * 1 means it completely occludes it
  135607. * 0 mean it has no impact
  135608. */
  135609. protected _ambientTextureImpactOnAnalyticalLights: number;
  135610. /**
  135611. * Stores the alpha values in a texture.
  135612. */
  135613. protected _opacityTexture: Nullable<BaseTexture>;
  135614. /**
  135615. * Stores the reflection values in a texture.
  135616. */
  135617. protected _reflectionTexture: Nullable<BaseTexture>;
  135618. /**
  135619. * Stores the emissive values in a texture.
  135620. */
  135621. protected _emissiveTexture: Nullable<BaseTexture>;
  135622. /**
  135623. * AKA Specular texture in other nomenclature.
  135624. */
  135625. protected _reflectivityTexture: Nullable<BaseTexture>;
  135626. /**
  135627. * Used to switch from specular/glossiness to metallic/roughness workflow.
  135628. */
  135629. protected _metallicTexture: Nullable<BaseTexture>;
  135630. /**
  135631. * Specifies the metallic scalar of the metallic/roughness workflow.
  135632. * Can also be used to scale the metalness values of the metallic texture.
  135633. */
  135634. protected _metallic: Nullable<number>;
  135635. /**
  135636. * Specifies the roughness scalar of the metallic/roughness workflow.
  135637. * Can also be used to scale the roughness values of the metallic texture.
  135638. */
  135639. protected _roughness: Nullable<number>;
  135640. /**
  135641. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  135642. * By default the indexOfrefraction is used to compute F0;
  135643. *
  135644. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  135645. *
  135646. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  135647. * F90 = metallicReflectanceColor;
  135648. */
  135649. protected _metallicF0Factor: number;
  135650. /**
  135651. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  135652. * By default the F90 is always 1;
  135653. *
  135654. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  135655. *
  135656. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  135657. * F90 = metallicReflectanceColor;
  135658. */
  135659. protected _metallicReflectanceColor: Color3;
  135660. /**
  135661. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  135662. * This is multiply against the scalar values defined in the material.
  135663. */
  135664. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  135665. /**
  135666. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  135667. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  135668. */
  135669. protected _microSurfaceTexture: Nullable<BaseTexture>;
  135670. /**
  135671. * Stores surface normal data used to displace a mesh in a texture.
  135672. */
  135673. protected _bumpTexture: Nullable<BaseTexture>;
  135674. /**
  135675. * Stores the pre-calculated light information of a mesh in a texture.
  135676. */
  135677. protected _lightmapTexture: Nullable<BaseTexture>;
  135678. /**
  135679. * The color of a material in ambient lighting.
  135680. */
  135681. protected _ambientColor: Color3;
  135682. /**
  135683. * AKA Diffuse Color in other nomenclature.
  135684. */
  135685. protected _albedoColor: Color3;
  135686. /**
  135687. * AKA Specular Color in other nomenclature.
  135688. */
  135689. protected _reflectivityColor: Color3;
  135690. /**
  135691. * The color applied when light is reflected from a material.
  135692. */
  135693. protected _reflectionColor: Color3;
  135694. /**
  135695. * The color applied when light is emitted from a material.
  135696. */
  135697. protected _emissiveColor: Color3;
  135698. /**
  135699. * AKA Glossiness in other nomenclature.
  135700. */
  135701. protected _microSurface: number;
  135702. /**
  135703. * Specifies that the material will use the light map as a show map.
  135704. */
  135705. protected _useLightmapAsShadowmap: boolean;
  135706. /**
  135707. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  135708. * makes the reflect vector face the model (under horizon).
  135709. */
  135710. protected _useHorizonOcclusion: boolean;
  135711. /**
  135712. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  135713. * too much the area relying on ambient texture to define their ambient occlusion.
  135714. */
  135715. protected _useRadianceOcclusion: boolean;
  135716. /**
  135717. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  135718. */
  135719. protected _useAlphaFromAlbedoTexture: boolean;
  135720. /**
  135721. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  135722. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  135723. */
  135724. protected _useSpecularOverAlpha: boolean;
  135725. /**
  135726. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  135727. */
  135728. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  135729. /**
  135730. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  135731. */
  135732. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  135733. /**
  135734. * Specifies if the metallic texture contains the roughness information in its green channel.
  135735. */
  135736. protected _useRoughnessFromMetallicTextureGreen: boolean;
  135737. /**
  135738. * Specifies if the metallic texture contains the metallness information in its blue channel.
  135739. */
  135740. protected _useMetallnessFromMetallicTextureBlue: boolean;
  135741. /**
  135742. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  135743. */
  135744. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  135745. /**
  135746. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  135747. */
  135748. protected _useAmbientInGrayScale: boolean;
  135749. /**
  135750. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  135751. * The material will try to infer what glossiness each pixel should be.
  135752. */
  135753. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  135754. /**
  135755. * Defines the falloff type used in this material.
  135756. * It by default is Physical.
  135757. */
  135758. protected _lightFalloff: number;
  135759. /**
  135760. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  135761. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  135762. */
  135763. protected _useRadianceOverAlpha: boolean;
  135764. /**
  135765. * Allows using an object space normal map (instead of tangent space).
  135766. */
  135767. protected _useObjectSpaceNormalMap: boolean;
  135768. /**
  135769. * Allows using the bump map in parallax mode.
  135770. */
  135771. protected _useParallax: boolean;
  135772. /**
  135773. * Allows using the bump map in parallax occlusion mode.
  135774. */
  135775. protected _useParallaxOcclusion: boolean;
  135776. /**
  135777. * Controls the scale bias of the parallax mode.
  135778. */
  135779. protected _parallaxScaleBias: number;
  135780. /**
  135781. * If sets to true, disables all the lights affecting the material.
  135782. */
  135783. protected _disableLighting: boolean;
  135784. /**
  135785. * Number of Simultaneous lights allowed on the material.
  135786. */
  135787. protected _maxSimultaneousLights: number;
  135788. /**
  135789. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  135790. */
  135791. protected _invertNormalMapX: boolean;
  135792. /**
  135793. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  135794. */
  135795. protected _invertNormalMapY: boolean;
  135796. /**
  135797. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  135798. */
  135799. protected _twoSidedLighting: boolean;
  135800. /**
  135801. * Defines the alpha limits in alpha test mode.
  135802. */
  135803. protected _alphaCutOff: number;
  135804. /**
  135805. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  135806. */
  135807. protected _forceAlphaTest: boolean;
  135808. /**
  135809. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  135810. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  135811. */
  135812. protected _useAlphaFresnel: boolean;
  135813. /**
  135814. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  135815. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  135816. */
  135817. protected _useLinearAlphaFresnel: boolean;
  135818. /**
  135819. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  135820. * from cos thetav and roughness:
  135821. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  135822. */
  135823. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  135824. /**
  135825. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  135826. */
  135827. protected _forceIrradianceInFragment: boolean;
  135828. private _realTimeFiltering;
  135829. /**
  135830. * Enables realtime filtering on the texture.
  135831. */
  135832. get realTimeFiltering(): boolean;
  135833. set realTimeFiltering(b: boolean);
  135834. private _realTimeFilteringQuality;
  135835. /**
  135836. * Quality switch for realtime filtering
  135837. */
  135838. get realTimeFilteringQuality(): number;
  135839. set realTimeFilteringQuality(n: number);
  135840. /**
  135841. * Can this material render to several textures at once
  135842. */
  135843. get canRenderToMRT(): boolean;
  135844. /**
  135845. * Force normal to face away from face.
  135846. */
  135847. protected _forceNormalForward: boolean;
  135848. /**
  135849. * Enables specular anti aliasing in the PBR shader.
  135850. * It will both interacts on the Geometry for analytical and IBL lighting.
  135851. * It also prefilter the roughness map based on the bump values.
  135852. */
  135853. protected _enableSpecularAntiAliasing: boolean;
  135854. /**
  135855. * Default configuration related to image processing available in the PBR Material.
  135856. */
  135857. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  135858. /**
  135859. * Keep track of the image processing observer to allow dispose and replace.
  135860. */
  135861. private _imageProcessingObserver;
  135862. /**
  135863. * Attaches a new image processing configuration to the PBR Material.
  135864. * @param configuration
  135865. */
  135866. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  135867. /**
  135868. * Stores the available render targets.
  135869. */
  135870. private _renderTargets;
  135871. /**
  135872. * Sets the global ambient color for the material used in lighting calculations.
  135873. */
  135874. private _globalAmbientColor;
  135875. /**
  135876. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  135877. */
  135878. private _useLogarithmicDepth;
  135879. /**
  135880. * If set to true, no lighting calculations will be applied.
  135881. */
  135882. private _unlit;
  135883. private _debugMode;
  135884. /**
  135885. * @hidden
  135886. * This is reserved for the inspector.
  135887. * Defines the material debug mode.
  135888. * It helps seeing only some components of the material while troubleshooting.
  135889. */
  135890. debugMode: number;
  135891. /**
  135892. * @hidden
  135893. * This is reserved for the inspector.
  135894. * Specify from where on screen the debug mode should start.
  135895. * The value goes from -1 (full screen) to 1 (not visible)
  135896. * It helps with side by side comparison against the final render
  135897. * This defaults to -1
  135898. */
  135899. private debugLimit;
  135900. /**
  135901. * @hidden
  135902. * This is reserved for the inspector.
  135903. * As the default viewing range might not be enough (if the ambient is really small for instance)
  135904. * You can use the factor to better multiply the final value.
  135905. */
  135906. private debugFactor;
  135907. /**
  135908. * Defines the clear coat layer parameters for the material.
  135909. */
  135910. readonly clearCoat: PBRClearCoatConfiguration;
  135911. /**
  135912. * Defines the anisotropic parameters for the material.
  135913. */
  135914. readonly anisotropy: PBRAnisotropicConfiguration;
  135915. /**
  135916. * Defines the BRDF parameters for the material.
  135917. */
  135918. readonly brdf: PBRBRDFConfiguration;
  135919. /**
  135920. * Defines the Sheen parameters for the material.
  135921. */
  135922. readonly sheen: PBRSheenConfiguration;
  135923. /**
  135924. * Defines the SubSurface parameters for the material.
  135925. */
  135926. readonly subSurface: PBRSubSurfaceConfiguration;
  135927. /**
  135928. * Defines the detail map parameters for the material.
  135929. */
  135930. readonly detailMap: DetailMapConfiguration;
  135931. protected _rebuildInParallel: boolean;
  135932. /**
  135933. * Instantiates a new PBRMaterial instance.
  135934. *
  135935. * @param name The material name
  135936. * @param scene The scene the material will be use in.
  135937. */
  135938. constructor(name: string, scene: Scene);
  135939. /**
  135940. * Gets a boolean indicating that current material needs to register RTT
  135941. */
  135942. get hasRenderTargetTextures(): boolean;
  135943. /**
  135944. * Gets the name of the material class.
  135945. */
  135946. getClassName(): string;
  135947. /**
  135948. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  135949. */
  135950. get useLogarithmicDepth(): boolean;
  135951. /**
  135952. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  135953. */
  135954. set useLogarithmicDepth(value: boolean);
  135955. /**
  135956. * Returns true if alpha blending should be disabled.
  135957. */
  135958. protected get _disableAlphaBlending(): boolean;
  135959. /**
  135960. * Specifies whether or not this material should be rendered in alpha blend mode.
  135961. */
  135962. needAlphaBlending(): boolean;
  135963. /**
  135964. * Specifies whether or not this material should be rendered in alpha test mode.
  135965. */
  135966. needAlphaTesting(): boolean;
  135967. /**
  135968. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  135969. */
  135970. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  135971. /**
  135972. * Gets the texture used for the alpha test.
  135973. */
  135974. getAlphaTestTexture(): Nullable<BaseTexture>;
  135975. /**
  135976. * Specifies that the submesh is ready to be used.
  135977. * @param mesh - BJS mesh.
  135978. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  135979. * @param useInstances - Specifies that instances should be used.
  135980. * @returns - boolean indicating that the submesh is ready or not.
  135981. */
  135982. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  135983. /**
  135984. * Specifies if the material uses metallic roughness workflow.
  135985. * @returns boolean specifiying if the material uses metallic roughness workflow.
  135986. */
  135987. isMetallicWorkflow(): boolean;
  135988. private _prepareEffect;
  135989. private _prepareDefines;
  135990. /**
  135991. * Force shader compilation
  135992. */
  135993. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  135994. /**
  135995. * Initializes the uniform buffer layout for the shader.
  135996. */
  135997. buildUniformLayout(): void;
  135998. /**
  135999. * Unbinds the material from the mesh
  136000. */
  136001. unbind(): void;
  136002. /**
  136003. * Binds the submesh data.
  136004. * @param world - The world matrix.
  136005. * @param mesh - The BJS mesh.
  136006. * @param subMesh - A submesh of the BJS mesh.
  136007. */
  136008. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  136009. /**
  136010. * Returns the animatable textures.
  136011. * @returns - Array of animatable textures.
  136012. */
  136013. getAnimatables(): IAnimatable[];
  136014. /**
  136015. * Returns the texture used for reflections.
  136016. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  136017. */
  136018. private _getReflectionTexture;
  136019. /**
  136020. * Returns an array of the actively used textures.
  136021. * @returns - Array of BaseTextures
  136022. */
  136023. getActiveTextures(): BaseTexture[];
  136024. /**
  136025. * Checks to see if a texture is used in the material.
  136026. * @param texture - Base texture to use.
  136027. * @returns - Boolean specifying if a texture is used in the material.
  136028. */
  136029. hasTexture(texture: BaseTexture): boolean;
  136030. /**
  136031. * Sets the required values to the prepass renderer.
  136032. * @param prePassRenderer defines the prepass renderer to setup
  136033. */
  136034. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  136035. /**
  136036. * Disposes the resources of the material.
  136037. * @param forceDisposeEffect - Forces the disposal of effects.
  136038. * @param forceDisposeTextures - Forces the disposal of all textures.
  136039. */
  136040. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  136041. }
  136042. }
  136043. declare module BABYLON {
  136044. /**
  136045. * The Physically based material of BJS.
  136046. *
  136047. * This offers the main features of a standard PBR material.
  136048. * For more information, please refer to the documentation :
  136049. * https://doc.babylonjs.com/how_to/physically_based_rendering
  136050. */
  136051. export class PBRMaterial extends PBRBaseMaterial {
  136052. /**
  136053. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  136054. */
  136055. static readonly PBRMATERIAL_OPAQUE: number;
  136056. /**
  136057. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  136058. */
  136059. static readonly PBRMATERIAL_ALPHATEST: number;
  136060. /**
  136061. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  136062. */
  136063. static readonly PBRMATERIAL_ALPHABLEND: number;
  136064. /**
  136065. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  136066. * They are also discarded below the alpha cutoff threshold to improve performances.
  136067. */
  136068. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  136069. /**
  136070. * Defines the default value of how much AO map is occluding the analytical lights
  136071. * (point spot...).
  136072. */
  136073. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  136074. /**
  136075. * Intensity of the direct lights e.g. the four lights available in your scene.
  136076. * This impacts both the direct diffuse and specular highlights.
  136077. */
  136078. directIntensity: number;
  136079. /**
  136080. * Intensity of the emissive part of the material.
  136081. * This helps controlling the emissive effect without modifying the emissive color.
  136082. */
  136083. emissiveIntensity: number;
  136084. /**
  136085. * Intensity of the environment e.g. how much the environment will light the object
  136086. * either through harmonics for rough material or through the refelction for shiny ones.
  136087. */
  136088. environmentIntensity: number;
  136089. /**
  136090. * This is a special control allowing the reduction of the specular highlights coming from the
  136091. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  136092. */
  136093. specularIntensity: number;
  136094. /**
  136095. * Debug Control allowing disabling the bump map on this material.
  136096. */
  136097. disableBumpMap: boolean;
  136098. /**
  136099. * AKA Diffuse Texture in standard nomenclature.
  136100. */
  136101. albedoTexture: BaseTexture;
  136102. /**
  136103. * AKA Occlusion Texture in other nomenclature.
  136104. */
  136105. ambientTexture: BaseTexture;
  136106. /**
  136107. * AKA Occlusion Texture Intensity in other nomenclature.
  136108. */
  136109. ambientTextureStrength: number;
  136110. /**
  136111. * Defines how much the AO map is occluding the analytical lights (point spot...).
  136112. * 1 means it completely occludes it
  136113. * 0 mean it has no impact
  136114. */
  136115. ambientTextureImpactOnAnalyticalLights: number;
  136116. /**
  136117. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  136118. */
  136119. opacityTexture: BaseTexture;
  136120. /**
  136121. * Stores the reflection values in a texture.
  136122. */
  136123. reflectionTexture: Nullable<BaseTexture>;
  136124. /**
  136125. * Stores the emissive values in a texture.
  136126. */
  136127. emissiveTexture: BaseTexture;
  136128. /**
  136129. * AKA Specular texture in other nomenclature.
  136130. */
  136131. reflectivityTexture: BaseTexture;
  136132. /**
  136133. * Used to switch from specular/glossiness to metallic/roughness workflow.
  136134. */
  136135. metallicTexture: BaseTexture;
  136136. /**
  136137. * Specifies the metallic scalar of the metallic/roughness workflow.
  136138. * Can also be used to scale the metalness values of the metallic texture.
  136139. */
  136140. metallic: Nullable<number>;
  136141. /**
  136142. * Specifies the roughness scalar of the metallic/roughness workflow.
  136143. * Can also be used to scale the roughness values of the metallic texture.
  136144. */
  136145. roughness: Nullable<number>;
  136146. /**
  136147. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  136148. * By default the indexOfrefraction is used to compute F0;
  136149. *
  136150. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  136151. *
  136152. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  136153. * F90 = metallicReflectanceColor;
  136154. */
  136155. metallicF0Factor: number;
  136156. /**
  136157. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  136158. * By default the F90 is always 1;
  136159. *
  136160. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  136161. *
  136162. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  136163. * F90 = metallicReflectanceColor;
  136164. */
  136165. metallicReflectanceColor: Color3;
  136166. /**
  136167. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  136168. * This is multiply against the scalar values defined in the material.
  136169. */
  136170. metallicReflectanceTexture: Nullable<BaseTexture>;
  136171. /**
  136172. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  136173. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  136174. */
  136175. microSurfaceTexture: BaseTexture;
  136176. /**
  136177. * Stores surface normal data used to displace a mesh in a texture.
  136178. */
  136179. bumpTexture: BaseTexture;
  136180. /**
  136181. * Stores the pre-calculated light information of a mesh in a texture.
  136182. */
  136183. lightmapTexture: BaseTexture;
  136184. /**
  136185. * Stores the refracted light information in a texture.
  136186. */
  136187. get refractionTexture(): Nullable<BaseTexture>;
  136188. set refractionTexture(value: Nullable<BaseTexture>);
  136189. /**
  136190. * The color of a material in ambient lighting.
  136191. */
  136192. ambientColor: Color3;
  136193. /**
  136194. * AKA Diffuse Color in other nomenclature.
  136195. */
  136196. albedoColor: Color3;
  136197. /**
  136198. * AKA Specular Color in other nomenclature.
  136199. */
  136200. reflectivityColor: Color3;
  136201. /**
  136202. * The color reflected from the material.
  136203. */
  136204. reflectionColor: Color3;
  136205. /**
  136206. * The color emitted from the material.
  136207. */
  136208. emissiveColor: Color3;
  136209. /**
  136210. * AKA Glossiness in other nomenclature.
  136211. */
  136212. microSurface: number;
  136213. /**
  136214. * Index of refraction of the material base layer.
  136215. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  136216. *
  136217. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  136218. *
  136219. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  136220. */
  136221. get indexOfRefraction(): number;
  136222. set indexOfRefraction(value: number);
  136223. /**
  136224. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  136225. */
  136226. get invertRefractionY(): boolean;
  136227. set invertRefractionY(value: boolean);
  136228. /**
  136229. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  136230. * Materials half opaque for instance using refraction could benefit from this control.
  136231. */
  136232. get linkRefractionWithTransparency(): boolean;
  136233. set linkRefractionWithTransparency(value: boolean);
  136234. /**
  136235. * If true, the light map contains occlusion information instead of lighting info.
  136236. */
  136237. useLightmapAsShadowmap: boolean;
  136238. /**
  136239. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  136240. */
  136241. useAlphaFromAlbedoTexture: boolean;
  136242. /**
  136243. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  136244. */
  136245. forceAlphaTest: boolean;
  136246. /**
  136247. * Defines the alpha limits in alpha test mode.
  136248. */
  136249. alphaCutOff: number;
  136250. /**
  136251. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  136252. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  136253. */
  136254. useSpecularOverAlpha: boolean;
  136255. /**
  136256. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  136257. */
  136258. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  136259. /**
  136260. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  136261. */
  136262. useRoughnessFromMetallicTextureAlpha: boolean;
  136263. /**
  136264. * Specifies if the metallic texture contains the roughness information in its green channel.
  136265. */
  136266. useRoughnessFromMetallicTextureGreen: boolean;
  136267. /**
  136268. * Specifies if the metallic texture contains the metallness information in its blue channel.
  136269. */
  136270. useMetallnessFromMetallicTextureBlue: boolean;
  136271. /**
  136272. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  136273. */
  136274. useAmbientOcclusionFromMetallicTextureRed: boolean;
  136275. /**
  136276. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  136277. */
  136278. useAmbientInGrayScale: boolean;
  136279. /**
  136280. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  136281. * The material will try to infer what glossiness each pixel should be.
  136282. */
  136283. useAutoMicroSurfaceFromReflectivityMap: boolean;
  136284. /**
  136285. * BJS is using an harcoded light falloff based on a manually sets up range.
  136286. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  136287. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  136288. */
  136289. get usePhysicalLightFalloff(): boolean;
  136290. /**
  136291. * BJS is using an harcoded light falloff based on a manually sets up range.
  136292. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  136293. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  136294. */
  136295. set usePhysicalLightFalloff(value: boolean);
  136296. /**
  136297. * In order to support the falloff compatibility with gltf, a special mode has been added
  136298. * to reproduce the gltf light falloff.
  136299. */
  136300. get useGLTFLightFalloff(): boolean;
  136301. /**
  136302. * In order to support the falloff compatibility with gltf, a special mode has been added
  136303. * to reproduce the gltf light falloff.
  136304. */
  136305. set useGLTFLightFalloff(value: boolean);
  136306. /**
  136307. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  136308. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  136309. */
  136310. useRadianceOverAlpha: boolean;
  136311. /**
  136312. * Allows using an object space normal map (instead of tangent space).
  136313. */
  136314. useObjectSpaceNormalMap: boolean;
  136315. /**
  136316. * Allows using the bump map in parallax mode.
  136317. */
  136318. useParallax: boolean;
  136319. /**
  136320. * Allows using the bump map in parallax occlusion mode.
  136321. */
  136322. useParallaxOcclusion: boolean;
  136323. /**
  136324. * Controls the scale bias of the parallax mode.
  136325. */
  136326. parallaxScaleBias: number;
  136327. /**
  136328. * If sets to true, disables all the lights affecting the material.
  136329. */
  136330. disableLighting: boolean;
  136331. /**
  136332. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  136333. */
  136334. forceIrradianceInFragment: boolean;
  136335. /**
  136336. * Number of Simultaneous lights allowed on the material.
  136337. */
  136338. maxSimultaneousLights: number;
  136339. /**
  136340. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  136341. */
  136342. invertNormalMapX: boolean;
  136343. /**
  136344. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  136345. */
  136346. invertNormalMapY: boolean;
  136347. /**
  136348. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  136349. */
  136350. twoSidedLighting: boolean;
  136351. /**
  136352. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  136353. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  136354. */
  136355. useAlphaFresnel: boolean;
  136356. /**
  136357. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  136358. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  136359. */
  136360. useLinearAlphaFresnel: boolean;
  136361. /**
  136362. * Let user defines the brdf lookup texture used for IBL.
  136363. * A default 8bit version is embedded but you could point at :
  136364. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  136365. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  136366. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  136367. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  136368. */
  136369. environmentBRDFTexture: Nullable<BaseTexture>;
  136370. /**
  136371. * Force normal to face away from face.
  136372. */
  136373. forceNormalForward: boolean;
  136374. /**
  136375. * Enables specular anti aliasing in the PBR shader.
  136376. * It will both interacts on the Geometry for analytical and IBL lighting.
  136377. * It also prefilter the roughness map based on the bump values.
  136378. */
  136379. enableSpecularAntiAliasing: boolean;
  136380. /**
  136381. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  136382. * makes the reflect vector face the model (under horizon).
  136383. */
  136384. useHorizonOcclusion: boolean;
  136385. /**
  136386. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  136387. * too much the area relying on ambient texture to define their ambient occlusion.
  136388. */
  136389. useRadianceOcclusion: boolean;
  136390. /**
  136391. * If set to true, no lighting calculations will be applied.
  136392. */
  136393. unlit: boolean;
  136394. /**
  136395. * Gets the image processing configuration used either in this material.
  136396. */
  136397. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  136398. /**
  136399. * Sets the Default image processing configuration used either in the this material.
  136400. *
  136401. * If sets to null, the scene one is in use.
  136402. */
  136403. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  136404. /**
  136405. * Gets wether the color curves effect is enabled.
  136406. */
  136407. get cameraColorCurvesEnabled(): boolean;
  136408. /**
  136409. * Sets wether the color curves effect is enabled.
  136410. */
  136411. set cameraColorCurvesEnabled(value: boolean);
  136412. /**
  136413. * Gets wether the color grading effect is enabled.
  136414. */
  136415. get cameraColorGradingEnabled(): boolean;
  136416. /**
  136417. * Gets wether the color grading effect is enabled.
  136418. */
  136419. set cameraColorGradingEnabled(value: boolean);
  136420. /**
  136421. * Gets wether tonemapping is enabled or not.
  136422. */
  136423. get cameraToneMappingEnabled(): boolean;
  136424. /**
  136425. * Sets wether tonemapping is enabled or not
  136426. */
  136427. set cameraToneMappingEnabled(value: boolean);
  136428. /**
  136429. * The camera exposure used on this material.
  136430. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  136431. * This corresponds to a photographic exposure.
  136432. */
  136433. get cameraExposure(): number;
  136434. /**
  136435. * The camera exposure used on this material.
  136436. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  136437. * This corresponds to a photographic exposure.
  136438. */
  136439. set cameraExposure(value: number);
  136440. /**
  136441. * Gets The camera contrast used on this material.
  136442. */
  136443. get cameraContrast(): number;
  136444. /**
  136445. * Sets The camera contrast used on this material.
  136446. */
  136447. set cameraContrast(value: number);
  136448. /**
  136449. * Gets the Color Grading 2D Lookup Texture.
  136450. */
  136451. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  136452. /**
  136453. * Sets the Color Grading 2D Lookup Texture.
  136454. */
  136455. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  136456. /**
  136457. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  136458. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  136459. * 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;
  136460. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  136461. */
  136462. get cameraColorCurves(): Nullable<ColorCurves>;
  136463. /**
  136464. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  136465. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  136466. * 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;
  136467. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  136468. */
  136469. set cameraColorCurves(value: Nullable<ColorCurves>);
  136470. /**
  136471. * Instantiates a new PBRMaterial instance.
  136472. *
  136473. * @param name The material name
  136474. * @param scene The scene the material will be use in.
  136475. */
  136476. constructor(name: string, scene: Scene);
  136477. /**
  136478. * Returns the name of this material class.
  136479. */
  136480. getClassName(): string;
  136481. /**
  136482. * Makes a duplicate of the current material.
  136483. * @param name - name to use for the new material.
  136484. */
  136485. clone(name: string): PBRMaterial;
  136486. /**
  136487. * Serializes this PBR Material.
  136488. * @returns - An object with the serialized material.
  136489. */
  136490. serialize(): any;
  136491. /**
  136492. * Parses a PBR Material from a serialized object.
  136493. * @param source - Serialized object.
  136494. * @param scene - BJS scene instance.
  136495. * @param rootUrl - url for the scene object
  136496. * @returns - PBRMaterial
  136497. */
  136498. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  136499. }
  136500. }
  136501. declare module BABYLON {
  136502. /**
  136503. * Direct draw surface info
  136504. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  136505. */
  136506. export interface DDSInfo {
  136507. /**
  136508. * Width of the texture
  136509. */
  136510. width: number;
  136511. /**
  136512. * Width of the texture
  136513. */
  136514. height: number;
  136515. /**
  136516. * Number of Mipmaps for the texture
  136517. * @see https://en.wikipedia.org/wiki/Mipmap
  136518. */
  136519. mipmapCount: number;
  136520. /**
  136521. * If the textures format is a known fourCC format
  136522. * @see https://www.fourcc.org/
  136523. */
  136524. isFourCC: boolean;
  136525. /**
  136526. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  136527. */
  136528. isRGB: boolean;
  136529. /**
  136530. * If the texture is a lumincance format
  136531. */
  136532. isLuminance: boolean;
  136533. /**
  136534. * If this is a cube texture
  136535. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  136536. */
  136537. isCube: boolean;
  136538. /**
  136539. * If the texture is a compressed format eg. FOURCC_DXT1
  136540. */
  136541. isCompressed: boolean;
  136542. /**
  136543. * The dxgiFormat of the texture
  136544. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  136545. */
  136546. dxgiFormat: number;
  136547. /**
  136548. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  136549. */
  136550. textureType: number;
  136551. /**
  136552. * Sphericle polynomial created for the dds texture
  136553. */
  136554. sphericalPolynomial?: SphericalPolynomial;
  136555. }
  136556. /**
  136557. * Class used to provide DDS decompression tools
  136558. */
  136559. export class DDSTools {
  136560. /**
  136561. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  136562. */
  136563. static StoreLODInAlphaChannel: boolean;
  136564. /**
  136565. * Gets DDS information from an array buffer
  136566. * @param data defines the array buffer view to read data from
  136567. * @returns the DDS information
  136568. */
  136569. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  136570. private static _FloatView;
  136571. private static _Int32View;
  136572. private static _ToHalfFloat;
  136573. private static _FromHalfFloat;
  136574. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  136575. private static _GetHalfFloatRGBAArrayBuffer;
  136576. private static _GetFloatRGBAArrayBuffer;
  136577. private static _GetFloatAsUIntRGBAArrayBuffer;
  136578. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  136579. private static _GetRGBAArrayBuffer;
  136580. private static _ExtractLongWordOrder;
  136581. private static _GetRGBArrayBuffer;
  136582. private static _GetLuminanceArrayBuffer;
  136583. /**
  136584. * Uploads DDS Levels to a Babylon Texture
  136585. * @hidden
  136586. */
  136587. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  136588. }
  136589. interface ThinEngine {
  136590. /**
  136591. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  136592. * @param rootUrl defines the url where the file to load is located
  136593. * @param scene defines the current scene
  136594. * @param lodScale defines scale to apply to the mip map selection
  136595. * @param lodOffset defines offset to apply to the mip map selection
  136596. * @param onLoad defines an optional callback raised when the texture is loaded
  136597. * @param onError defines an optional callback raised if there is an issue to load the texture
  136598. * @param format defines the format of the data
  136599. * @param forcedExtension defines the extension to use to pick the right loader
  136600. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  136601. * @returns the cube texture as an InternalTexture
  136602. */
  136603. 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;
  136604. }
  136605. }
  136606. declare module BABYLON {
  136607. /**
  136608. * Implementation of the DDS Texture Loader.
  136609. * @hidden
  136610. */
  136611. export class _DDSTextureLoader implements IInternalTextureLoader {
  136612. /**
  136613. * Defines wether the loader supports cascade loading the different faces.
  136614. */
  136615. readonly supportCascades: boolean;
  136616. /**
  136617. * This returns if the loader support the current file information.
  136618. * @param extension defines the file extension of the file being loaded
  136619. * @returns true if the loader can load the specified file
  136620. */
  136621. canLoad(extension: string): boolean;
  136622. /**
  136623. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  136624. * @param data contains the texture data
  136625. * @param texture defines the BabylonJS internal texture
  136626. * @param createPolynomials will be true if polynomials have been requested
  136627. * @param onLoad defines the callback to trigger once the texture is ready
  136628. * @param onError defines the callback to trigger in case of error
  136629. */
  136630. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  136631. /**
  136632. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  136633. * @param data contains the texture data
  136634. * @param texture defines the BabylonJS internal texture
  136635. * @param callback defines the method to call once ready to upload
  136636. */
  136637. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  136638. }
  136639. }
  136640. declare module BABYLON {
  136641. /**
  136642. * Implementation of the ENV Texture Loader.
  136643. * @hidden
  136644. */
  136645. export class _ENVTextureLoader implements IInternalTextureLoader {
  136646. /**
  136647. * Defines wether the loader supports cascade loading the different faces.
  136648. */
  136649. readonly supportCascades: boolean;
  136650. /**
  136651. * This returns if the loader support the current file information.
  136652. * @param extension defines the file extension of the file being loaded
  136653. * @returns true if the loader can load the specified file
  136654. */
  136655. canLoad(extension: string): boolean;
  136656. /**
  136657. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  136658. * @param data contains the texture data
  136659. * @param texture defines the BabylonJS internal texture
  136660. * @param createPolynomials will be true if polynomials have been requested
  136661. * @param onLoad defines the callback to trigger once the texture is ready
  136662. * @param onError defines the callback to trigger in case of error
  136663. */
  136664. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  136665. /**
  136666. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  136667. * @param data contains the texture data
  136668. * @param texture defines the BabylonJS internal texture
  136669. * @param callback defines the method to call once ready to upload
  136670. */
  136671. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  136672. }
  136673. }
  136674. declare module BABYLON {
  136675. /**
  136676. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  136677. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  136678. */
  136679. export class KhronosTextureContainer {
  136680. /** contents of the KTX container file */
  136681. data: ArrayBufferView;
  136682. private static HEADER_LEN;
  136683. private static COMPRESSED_2D;
  136684. private static COMPRESSED_3D;
  136685. private static TEX_2D;
  136686. private static TEX_3D;
  136687. /**
  136688. * Gets the openGL type
  136689. */
  136690. glType: number;
  136691. /**
  136692. * Gets the openGL type size
  136693. */
  136694. glTypeSize: number;
  136695. /**
  136696. * Gets the openGL format
  136697. */
  136698. glFormat: number;
  136699. /**
  136700. * Gets the openGL internal format
  136701. */
  136702. glInternalFormat: number;
  136703. /**
  136704. * Gets the base internal format
  136705. */
  136706. glBaseInternalFormat: number;
  136707. /**
  136708. * Gets image width in pixel
  136709. */
  136710. pixelWidth: number;
  136711. /**
  136712. * Gets image height in pixel
  136713. */
  136714. pixelHeight: number;
  136715. /**
  136716. * Gets image depth in pixels
  136717. */
  136718. pixelDepth: number;
  136719. /**
  136720. * Gets the number of array elements
  136721. */
  136722. numberOfArrayElements: number;
  136723. /**
  136724. * Gets the number of faces
  136725. */
  136726. numberOfFaces: number;
  136727. /**
  136728. * Gets the number of mipmap levels
  136729. */
  136730. numberOfMipmapLevels: number;
  136731. /**
  136732. * Gets the bytes of key value data
  136733. */
  136734. bytesOfKeyValueData: number;
  136735. /**
  136736. * Gets the load type
  136737. */
  136738. loadType: number;
  136739. /**
  136740. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  136741. */
  136742. isInvalid: boolean;
  136743. /**
  136744. * Creates a new KhronosTextureContainer
  136745. * @param data contents of the KTX container file
  136746. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  136747. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  136748. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  136749. */
  136750. constructor(
  136751. /** contents of the KTX container file */
  136752. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  136753. /**
  136754. * Uploads KTX content to a Babylon Texture.
  136755. * It is assumed that the texture has already been created & is currently bound
  136756. * @hidden
  136757. */
  136758. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  136759. private _upload2DCompressedLevels;
  136760. /**
  136761. * Checks if the given data starts with a KTX file identifier.
  136762. * @param data the data to check
  136763. * @returns true if the data is a KTX file or false otherwise
  136764. */
  136765. static IsValid(data: ArrayBufferView): boolean;
  136766. }
  136767. }
  136768. declare module BABYLON {
  136769. /**
  136770. * Class for loading KTX2 files
  136771. * !!! Experimental Extension Subject to Changes !!!
  136772. * @hidden
  136773. */
  136774. export class KhronosTextureContainer2 {
  136775. private static _ModulePromise;
  136776. private static _TranscodeFormat;
  136777. constructor(engine: ThinEngine);
  136778. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  136779. private _determineTranscodeFormat;
  136780. /**
  136781. * Checks if the given data starts with a KTX2 file identifier.
  136782. * @param data the data to check
  136783. * @returns true if the data is a KTX2 file or false otherwise
  136784. */
  136785. static IsValid(data: ArrayBufferView): boolean;
  136786. }
  136787. }
  136788. declare module BABYLON {
  136789. /**
  136790. * Implementation of the KTX Texture Loader.
  136791. * @hidden
  136792. */
  136793. export class _KTXTextureLoader implements IInternalTextureLoader {
  136794. /**
  136795. * Defines wether the loader supports cascade loading the different faces.
  136796. */
  136797. readonly supportCascades: boolean;
  136798. /**
  136799. * This returns if the loader support the current file information.
  136800. * @param extension defines the file extension of the file being loaded
  136801. * @param mimeType defines the optional mime type of the file being loaded
  136802. * @returns true if the loader can load the specified file
  136803. */
  136804. canLoad(extension: string, mimeType?: string): boolean;
  136805. /**
  136806. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  136807. * @param data contains the texture data
  136808. * @param texture defines the BabylonJS internal texture
  136809. * @param createPolynomials will be true if polynomials have been requested
  136810. * @param onLoad defines the callback to trigger once the texture is ready
  136811. * @param onError defines the callback to trigger in case of error
  136812. */
  136813. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  136814. /**
  136815. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  136816. * @param data contains the texture data
  136817. * @param texture defines the BabylonJS internal texture
  136818. * @param callback defines the method to call once ready to upload
  136819. */
  136820. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  136821. }
  136822. }
  136823. declare module BABYLON {
  136824. /** @hidden */
  136825. export var _forceSceneHelpersToBundle: boolean;
  136826. interface Scene {
  136827. /**
  136828. * Creates a default light for the scene.
  136829. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  136830. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  136831. */
  136832. createDefaultLight(replace?: boolean): void;
  136833. /**
  136834. * Creates a default camera for the scene.
  136835. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  136836. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  136837. * @param replace has default false, when true replaces the active camera in the scene
  136838. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  136839. */
  136840. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  136841. /**
  136842. * Creates a default camera and a default light.
  136843. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  136844. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  136845. * @param replace has the default false, when true replaces the active camera/light in the scene
  136846. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  136847. */
  136848. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  136849. /**
  136850. * Creates a new sky box
  136851. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  136852. * @param environmentTexture defines the texture to use as environment texture
  136853. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  136854. * @param scale defines the overall scale of the skybox
  136855. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  136856. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  136857. * @returns a new mesh holding the sky box
  136858. */
  136859. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  136860. /**
  136861. * Creates a new environment
  136862. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  136863. * @param options defines the options you can use to configure the environment
  136864. * @returns the new EnvironmentHelper
  136865. */
  136866. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  136867. /**
  136868. * Creates a new VREXperienceHelper
  136869. * @see https://doc.babylonjs.com/how_to/webvr_helper
  136870. * @param webVROptions defines the options used to create the new VREXperienceHelper
  136871. * @returns a new VREXperienceHelper
  136872. */
  136873. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  136874. /**
  136875. * Creates a new WebXRDefaultExperience
  136876. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  136877. * @param options experience options
  136878. * @returns a promise for a new WebXRDefaultExperience
  136879. */
  136880. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  136881. }
  136882. }
  136883. declare module BABYLON {
  136884. /**
  136885. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  136886. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  136887. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  136888. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  136889. */
  136890. export class VideoDome extends TransformNode {
  136891. /**
  136892. * Define the video source as a Monoscopic panoramic 360 video.
  136893. */
  136894. static readonly MODE_MONOSCOPIC: number;
  136895. /**
  136896. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  136897. */
  136898. static readonly MODE_TOPBOTTOM: number;
  136899. /**
  136900. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  136901. */
  136902. static readonly MODE_SIDEBYSIDE: number;
  136903. private _halfDome;
  136904. private _useDirectMapping;
  136905. /**
  136906. * The video texture being displayed on the sphere
  136907. */
  136908. protected _videoTexture: VideoTexture;
  136909. /**
  136910. * Gets the video texture being displayed on the sphere
  136911. */
  136912. get videoTexture(): VideoTexture;
  136913. /**
  136914. * The skybox material
  136915. */
  136916. protected _material: BackgroundMaterial;
  136917. /**
  136918. * The surface used for the video dome
  136919. */
  136920. protected _mesh: Mesh;
  136921. /**
  136922. * Gets the mesh used for the video dome.
  136923. */
  136924. get mesh(): Mesh;
  136925. /**
  136926. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  136927. */
  136928. private _halfDomeMask;
  136929. /**
  136930. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  136931. * Also see the options.resolution property.
  136932. */
  136933. get fovMultiplier(): number;
  136934. set fovMultiplier(value: number);
  136935. private _videoMode;
  136936. /**
  136937. * Gets or set the current video mode for the video. It can be:
  136938. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  136939. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  136940. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  136941. */
  136942. get videoMode(): number;
  136943. set videoMode(value: number);
  136944. /**
  136945. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  136946. *
  136947. */
  136948. get halfDome(): boolean;
  136949. /**
  136950. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  136951. */
  136952. set halfDome(enabled: boolean);
  136953. /**
  136954. * Oberserver used in Stereoscopic VR Mode.
  136955. */
  136956. private _onBeforeCameraRenderObserver;
  136957. /**
  136958. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  136959. * @param name Element's name, child elements will append suffixes for their own names.
  136960. * @param urlsOrVideo defines the url(s) or the video element to use
  136961. * @param options An object containing optional or exposed sub element properties
  136962. */
  136963. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  136964. resolution?: number;
  136965. clickToPlay?: boolean;
  136966. autoPlay?: boolean;
  136967. loop?: boolean;
  136968. size?: number;
  136969. poster?: string;
  136970. faceForward?: boolean;
  136971. useDirectMapping?: boolean;
  136972. halfDomeMode?: boolean;
  136973. }, scene: Scene);
  136974. private _changeVideoMode;
  136975. /**
  136976. * Releases resources associated with this node.
  136977. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  136978. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  136979. */
  136980. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  136981. }
  136982. }
  136983. declare module BABYLON {
  136984. /**
  136985. * This class can be used to get instrumentation data from a Babylon engine
  136986. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  136987. */
  136988. export class EngineInstrumentation implements IDisposable {
  136989. /**
  136990. * Define the instrumented engine.
  136991. */
  136992. engine: Engine;
  136993. private _captureGPUFrameTime;
  136994. private _gpuFrameTimeToken;
  136995. private _gpuFrameTime;
  136996. private _captureShaderCompilationTime;
  136997. private _shaderCompilationTime;
  136998. private _onBeginFrameObserver;
  136999. private _onEndFrameObserver;
  137000. private _onBeforeShaderCompilationObserver;
  137001. private _onAfterShaderCompilationObserver;
  137002. /**
  137003. * Gets the perf counter used for GPU frame time
  137004. */
  137005. get gpuFrameTimeCounter(): PerfCounter;
  137006. /**
  137007. * Gets the GPU frame time capture status
  137008. */
  137009. get captureGPUFrameTime(): boolean;
  137010. /**
  137011. * Enable or disable the GPU frame time capture
  137012. */
  137013. set captureGPUFrameTime(value: boolean);
  137014. /**
  137015. * Gets the perf counter used for shader compilation time
  137016. */
  137017. get shaderCompilationTimeCounter(): PerfCounter;
  137018. /**
  137019. * Gets the shader compilation time capture status
  137020. */
  137021. get captureShaderCompilationTime(): boolean;
  137022. /**
  137023. * Enable or disable the shader compilation time capture
  137024. */
  137025. set captureShaderCompilationTime(value: boolean);
  137026. /**
  137027. * Instantiates a new engine instrumentation.
  137028. * This class can be used to get instrumentation data from a Babylon engine
  137029. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  137030. * @param engine Defines the engine to instrument
  137031. */
  137032. constructor(
  137033. /**
  137034. * Define the instrumented engine.
  137035. */
  137036. engine: Engine);
  137037. /**
  137038. * Dispose and release associated resources.
  137039. */
  137040. dispose(): void;
  137041. }
  137042. }
  137043. declare module BABYLON {
  137044. /**
  137045. * This class can be used to get instrumentation data from a Babylon engine
  137046. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  137047. */
  137048. export class SceneInstrumentation implements IDisposable {
  137049. /**
  137050. * Defines the scene to instrument
  137051. */
  137052. scene: Scene;
  137053. private _captureActiveMeshesEvaluationTime;
  137054. private _activeMeshesEvaluationTime;
  137055. private _captureRenderTargetsRenderTime;
  137056. private _renderTargetsRenderTime;
  137057. private _captureFrameTime;
  137058. private _frameTime;
  137059. private _captureRenderTime;
  137060. private _renderTime;
  137061. private _captureInterFrameTime;
  137062. private _interFrameTime;
  137063. private _captureParticlesRenderTime;
  137064. private _particlesRenderTime;
  137065. private _captureSpritesRenderTime;
  137066. private _spritesRenderTime;
  137067. private _capturePhysicsTime;
  137068. private _physicsTime;
  137069. private _captureAnimationsTime;
  137070. private _animationsTime;
  137071. private _captureCameraRenderTime;
  137072. private _cameraRenderTime;
  137073. private _onBeforeActiveMeshesEvaluationObserver;
  137074. private _onAfterActiveMeshesEvaluationObserver;
  137075. private _onBeforeRenderTargetsRenderObserver;
  137076. private _onAfterRenderTargetsRenderObserver;
  137077. private _onAfterRenderObserver;
  137078. private _onBeforeDrawPhaseObserver;
  137079. private _onAfterDrawPhaseObserver;
  137080. private _onBeforeAnimationsObserver;
  137081. private _onBeforeParticlesRenderingObserver;
  137082. private _onAfterParticlesRenderingObserver;
  137083. private _onBeforeSpritesRenderingObserver;
  137084. private _onAfterSpritesRenderingObserver;
  137085. private _onBeforePhysicsObserver;
  137086. private _onAfterPhysicsObserver;
  137087. private _onAfterAnimationsObserver;
  137088. private _onBeforeCameraRenderObserver;
  137089. private _onAfterCameraRenderObserver;
  137090. /**
  137091. * Gets the perf counter used for active meshes evaluation time
  137092. */
  137093. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  137094. /**
  137095. * Gets the active meshes evaluation time capture status
  137096. */
  137097. get captureActiveMeshesEvaluationTime(): boolean;
  137098. /**
  137099. * Enable or disable the active meshes evaluation time capture
  137100. */
  137101. set captureActiveMeshesEvaluationTime(value: boolean);
  137102. /**
  137103. * Gets the perf counter used for render targets render time
  137104. */
  137105. get renderTargetsRenderTimeCounter(): PerfCounter;
  137106. /**
  137107. * Gets the render targets render time capture status
  137108. */
  137109. get captureRenderTargetsRenderTime(): boolean;
  137110. /**
  137111. * Enable or disable the render targets render time capture
  137112. */
  137113. set captureRenderTargetsRenderTime(value: boolean);
  137114. /**
  137115. * Gets the perf counter used for particles render time
  137116. */
  137117. get particlesRenderTimeCounter(): PerfCounter;
  137118. /**
  137119. * Gets the particles render time capture status
  137120. */
  137121. get captureParticlesRenderTime(): boolean;
  137122. /**
  137123. * Enable or disable the particles render time capture
  137124. */
  137125. set captureParticlesRenderTime(value: boolean);
  137126. /**
  137127. * Gets the perf counter used for sprites render time
  137128. */
  137129. get spritesRenderTimeCounter(): PerfCounter;
  137130. /**
  137131. * Gets the sprites render time capture status
  137132. */
  137133. get captureSpritesRenderTime(): boolean;
  137134. /**
  137135. * Enable or disable the sprites render time capture
  137136. */
  137137. set captureSpritesRenderTime(value: boolean);
  137138. /**
  137139. * Gets the perf counter used for physics time
  137140. */
  137141. get physicsTimeCounter(): PerfCounter;
  137142. /**
  137143. * Gets the physics time capture status
  137144. */
  137145. get capturePhysicsTime(): boolean;
  137146. /**
  137147. * Enable or disable the physics time capture
  137148. */
  137149. set capturePhysicsTime(value: boolean);
  137150. /**
  137151. * Gets the perf counter used for animations time
  137152. */
  137153. get animationsTimeCounter(): PerfCounter;
  137154. /**
  137155. * Gets the animations time capture status
  137156. */
  137157. get captureAnimationsTime(): boolean;
  137158. /**
  137159. * Enable or disable the animations time capture
  137160. */
  137161. set captureAnimationsTime(value: boolean);
  137162. /**
  137163. * Gets the perf counter used for frame time capture
  137164. */
  137165. get frameTimeCounter(): PerfCounter;
  137166. /**
  137167. * Gets the frame time capture status
  137168. */
  137169. get captureFrameTime(): boolean;
  137170. /**
  137171. * Enable or disable the frame time capture
  137172. */
  137173. set captureFrameTime(value: boolean);
  137174. /**
  137175. * Gets the perf counter used for inter-frames time capture
  137176. */
  137177. get interFrameTimeCounter(): PerfCounter;
  137178. /**
  137179. * Gets the inter-frames time capture status
  137180. */
  137181. get captureInterFrameTime(): boolean;
  137182. /**
  137183. * Enable or disable the inter-frames time capture
  137184. */
  137185. set captureInterFrameTime(value: boolean);
  137186. /**
  137187. * Gets the perf counter used for render time capture
  137188. */
  137189. get renderTimeCounter(): PerfCounter;
  137190. /**
  137191. * Gets the render time capture status
  137192. */
  137193. get captureRenderTime(): boolean;
  137194. /**
  137195. * Enable or disable the render time capture
  137196. */
  137197. set captureRenderTime(value: boolean);
  137198. /**
  137199. * Gets the perf counter used for camera render time capture
  137200. */
  137201. get cameraRenderTimeCounter(): PerfCounter;
  137202. /**
  137203. * Gets the camera render time capture status
  137204. */
  137205. get captureCameraRenderTime(): boolean;
  137206. /**
  137207. * Enable or disable the camera render time capture
  137208. */
  137209. set captureCameraRenderTime(value: boolean);
  137210. /**
  137211. * Gets the perf counter used for draw calls
  137212. */
  137213. get drawCallsCounter(): PerfCounter;
  137214. /**
  137215. * Instantiates a new scene instrumentation.
  137216. * This class can be used to get instrumentation data from a Babylon engine
  137217. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  137218. * @param scene Defines the scene to instrument
  137219. */
  137220. constructor(
  137221. /**
  137222. * Defines the scene to instrument
  137223. */
  137224. scene: Scene);
  137225. /**
  137226. * Dispose and release associated resources.
  137227. */
  137228. dispose(): void;
  137229. }
  137230. }
  137231. declare module BABYLON {
  137232. /** @hidden */
  137233. export var glowMapGenerationPixelShader: {
  137234. name: string;
  137235. shader: string;
  137236. };
  137237. }
  137238. declare module BABYLON {
  137239. /** @hidden */
  137240. export var glowMapGenerationVertexShader: {
  137241. name: string;
  137242. shader: string;
  137243. };
  137244. }
  137245. declare module BABYLON {
  137246. /**
  137247. * Effect layer options. This helps customizing the behaviour
  137248. * of the effect layer.
  137249. */
  137250. export interface IEffectLayerOptions {
  137251. /**
  137252. * Multiplication factor apply to the canvas size to compute the render target size
  137253. * used to generated the objects (the smaller the faster).
  137254. */
  137255. mainTextureRatio: number;
  137256. /**
  137257. * Enforces a fixed size texture to ensure effect stability across devices.
  137258. */
  137259. mainTextureFixedSize?: number;
  137260. /**
  137261. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  137262. */
  137263. alphaBlendingMode: number;
  137264. /**
  137265. * The camera attached to the layer.
  137266. */
  137267. camera: Nullable<Camera>;
  137268. /**
  137269. * The rendering group to draw the layer in.
  137270. */
  137271. renderingGroupId: number;
  137272. }
  137273. /**
  137274. * The effect layer Helps adding post process effect blended with the main pass.
  137275. *
  137276. * This can be for instance use to generate glow or higlight effects on the scene.
  137277. *
  137278. * The effect layer class can not be used directly and is intented to inherited from to be
  137279. * customized per effects.
  137280. */
  137281. export abstract class EffectLayer {
  137282. private _vertexBuffers;
  137283. private _indexBuffer;
  137284. private _cachedDefines;
  137285. private _effectLayerMapGenerationEffect;
  137286. private _effectLayerOptions;
  137287. private _mergeEffect;
  137288. protected _scene: Scene;
  137289. protected _engine: Engine;
  137290. protected _maxSize: number;
  137291. protected _mainTextureDesiredSize: ISize;
  137292. protected _mainTexture: RenderTargetTexture;
  137293. protected _shouldRender: boolean;
  137294. protected _postProcesses: PostProcess[];
  137295. protected _textures: BaseTexture[];
  137296. protected _emissiveTextureAndColor: {
  137297. texture: Nullable<BaseTexture>;
  137298. color: Color4;
  137299. };
  137300. /**
  137301. * The name of the layer
  137302. */
  137303. name: string;
  137304. /**
  137305. * The clear color of the texture used to generate the glow map.
  137306. */
  137307. neutralColor: Color4;
  137308. /**
  137309. * Specifies whether the highlight layer is enabled or not.
  137310. */
  137311. isEnabled: boolean;
  137312. /**
  137313. * Gets the camera attached to the layer.
  137314. */
  137315. get camera(): Nullable<Camera>;
  137316. /**
  137317. * Gets the rendering group id the layer should render in.
  137318. */
  137319. get renderingGroupId(): number;
  137320. set renderingGroupId(renderingGroupId: number);
  137321. /**
  137322. * An event triggered when the effect layer has been disposed.
  137323. */
  137324. onDisposeObservable: Observable<EffectLayer>;
  137325. /**
  137326. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  137327. */
  137328. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  137329. /**
  137330. * An event triggered when the generated texture is being merged in the scene.
  137331. */
  137332. onBeforeComposeObservable: Observable<EffectLayer>;
  137333. /**
  137334. * An event triggered when the mesh is rendered into the effect render target.
  137335. */
  137336. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  137337. /**
  137338. * An event triggered after the mesh has been rendered into the effect render target.
  137339. */
  137340. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  137341. /**
  137342. * An event triggered when the generated texture has been merged in the scene.
  137343. */
  137344. onAfterComposeObservable: Observable<EffectLayer>;
  137345. /**
  137346. * An event triggered when the efffect layer changes its size.
  137347. */
  137348. onSizeChangedObservable: Observable<EffectLayer>;
  137349. /** @hidden */
  137350. static _SceneComponentInitialization: (scene: Scene) => void;
  137351. /**
  137352. * Instantiates a new effect Layer and references it in the scene.
  137353. * @param name The name of the layer
  137354. * @param scene The scene to use the layer in
  137355. */
  137356. constructor(
  137357. /** The Friendly of the effect in the scene */
  137358. name: string, scene: Scene);
  137359. /**
  137360. * Get the effect name of the layer.
  137361. * @return The effect name
  137362. */
  137363. abstract getEffectName(): string;
  137364. /**
  137365. * Checks for the readiness of the element composing the layer.
  137366. * @param subMesh the mesh to check for
  137367. * @param useInstances specify whether or not to use instances to render the mesh
  137368. * @return true if ready otherwise, false
  137369. */
  137370. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  137371. /**
  137372. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  137373. * @returns true if the effect requires stencil during the main canvas render pass.
  137374. */
  137375. abstract needStencil(): boolean;
  137376. /**
  137377. * Create the merge effect. This is the shader use to blit the information back
  137378. * to the main canvas at the end of the scene rendering.
  137379. * @returns The effect containing the shader used to merge the effect on the main canvas
  137380. */
  137381. protected abstract _createMergeEffect(): Effect;
  137382. /**
  137383. * Creates the render target textures and post processes used in the effect layer.
  137384. */
  137385. protected abstract _createTextureAndPostProcesses(): void;
  137386. /**
  137387. * Implementation specific of rendering the generating effect on the main canvas.
  137388. * @param effect The effect used to render through
  137389. */
  137390. protected abstract _internalRender(effect: Effect): void;
  137391. /**
  137392. * Sets the required values for both the emissive texture and and the main color.
  137393. */
  137394. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  137395. /**
  137396. * Free any resources and references associated to a mesh.
  137397. * Internal use
  137398. * @param mesh The mesh to free.
  137399. */
  137400. abstract _disposeMesh(mesh: Mesh): void;
  137401. /**
  137402. * Serializes this layer (Glow or Highlight for example)
  137403. * @returns a serialized layer object
  137404. */
  137405. abstract serialize?(): any;
  137406. /**
  137407. * Initializes the effect layer with the required options.
  137408. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  137409. */
  137410. protected _init(options: Partial<IEffectLayerOptions>): void;
  137411. /**
  137412. * Generates the index buffer of the full screen quad blending to the main canvas.
  137413. */
  137414. private _generateIndexBuffer;
  137415. /**
  137416. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  137417. */
  137418. private _generateVertexBuffer;
  137419. /**
  137420. * Sets the main texture desired size which is the closest power of two
  137421. * of the engine canvas size.
  137422. */
  137423. private _setMainTextureSize;
  137424. /**
  137425. * Creates the main texture for the effect layer.
  137426. */
  137427. protected _createMainTexture(): void;
  137428. /**
  137429. * Adds specific effects defines.
  137430. * @param defines The defines to add specifics to.
  137431. */
  137432. protected _addCustomEffectDefines(defines: string[]): void;
  137433. /**
  137434. * Checks for the readiness of the element composing the layer.
  137435. * @param subMesh the mesh to check for
  137436. * @param useInstances specify whether or not to use instances to render the mesh
  137437. * @param emissiveTexture the associated emissive texture used to generate the glow
  137438. * @return true if ready otherwise, false
  137439. */
  137440. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  137441. /**
  137442. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  137443. */
  137444. render(): void;
  137445. /**
  137446. * Determine if a given mesh will be used in the current effect.
  137447. * @param mesh mesh to test
  137448. * @returns true if the mesh will be used
  137449. */
  137450. hasMesh(mesh: AbstractMesh): boolean;
  137451. /**
  137452. * Returns true if the layer contains information to display, otherwise false.
  137453. * @returns true if the glow layer should be rendered
  137454. */
  137455. shouldRender(): boolean;
  137456. /**
  137457. * Returns true if the mesh should render, otherwise false.
  137458. * @param mesh The mesh to render
  137459. * @returns true if it should render otherwise false
  137460. */
  137461. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  137462. /**
  137463. * Returns true if the mesh can be rendered, otherwise false.
  137464. * @param mesh The mesh to render
  137465. * @param material The material used on the mesh
  137466. * @returns true if it can be rendered otherwise false
  137467. */
  137468. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  137469. /**
  137470. * Returns true if the mesh should render, otherwise false.
  137471. * @param mesh The mesh to render
  137472. * @returns true if it should render otherwise false
  137473. */
  137474. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  137475. /**
  137476. * Renders the submesh passed in parameter to the generation map.
  137477. */
  137478. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  137479. /**
  137480. * Defines whether the current material of the mesh should be use to render the effect.
  137481. * @param mesh defines the current mesh to render
  137482. */
  137483. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  137484. /**
  137485. * Rebuild the required buffers.
  137486. * @hidden Internal use only.
  137487. */
  137488. _rebuild(): void;
  137489. /**
  137490. * Dispose only the render target textures and post process.
  137491. */
  137492. private _disposeTextureAndPostProcesses;
  137493. /**
  137494. * Dispose the highlight layer and free resources.
  137495. */
  137496. dispose(): void;
  137497. /**
  137498. * Gets the class name of the effect layer
  137499. * @returns the string with the class name of the effect layer
  137500. */
  137501. getClassName(): string;
  137502. /**
  137503. * Creates an effect layer from parsed effect layer data
  137504. * @param parsedEffectLayer defines effect layer data
  137505. * @param scene defines the current scene
  137506. * @param rootUrl defines the root URL containing the effect layer information
  137507. * @returns a parsed effect Layer
  137508. */
  137509. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  137510. }
  137511. }
  137512. declare module BABYLON {
  137513. interface AbstractScene {
  137514. /**
  137515. * The list of effect layers (highlights/glow) added to the scene
  137516. * @see https://doc.babylonjs.com/how_to/highlight_layer
  137517. * @see https://doc.babylonjs.com/how_to/glow_layer
  137518. */
  137519. effectLayers: Array<EffectLayer>;
  137520. /**
  137521. * Removes the given effect layer from this scene.
  137522. * @param toRemove defines the effect layer to remove
  137523. * @returns the index of the removed effect layer
  137524. */
  137525. removeEffectLayer(toRemove: EffectLayer): number;
  137526. /**
  137527. * Adds the given effect layer to this scene
  137528. * @param newEffectLayer defines the effect layer to add
  137529. */
  137530. addEffectLayer(newEffectLayer: EffectLayer): void;
  137531. }
  137532. /**
  137533. * Defines the layer scene component responsible to manage any effect layers
  137534. * in a given scene.
  137535. */
  137536. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  137537. /**
  137538. * The component name helpfull to identify the component in the list of scene components.
  137539. */
  137540. readonly name: string;
  137541. /**
  137542. * The scene the component belongs to.
  137543. */
  137544. scene: Scene;
  137545. private _engine;
  137546. private _renderEffects;
  137547. private _needStencil;
  137548. private _previousStencilState;
  137549. /**
  137550. * Creates a new instance of the component for the given scene
  137551. * @param scene Defines the scene to register the component in
  137552. */
  137553. constructor(scene: Scene);
  137554. /**
  137555. * Registers the component in a given scene
  137556. */
  137557. register(): void;
  137558. /**
  137559. * Rebuilds the elements related to this component in case of
  137560. * context lost for instance.
  137561. */
  137562. rebuild(): void;
  137563. /**
  137564. * Serializes the component data to the specified json object
  137565. * @param serializationObject The object to serialize to
  137566. */
  137567. serialize(serializationObject: any): void;
  137568. /**
  137569. * Adds all the elements from the container to the scene
  137570. * @param container the container holding the elements
  137571. */
  137572. addFromContainer(container: AbstractScene): void;
  137573. /**
  137574. * Removes all the elements in the container from the scene
  137575. * @param container contains the elements to remove
  137576. * @param dispose if the removed element should be disposed (default: false)
  137577. */
  137578. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  137579. /**
  137580. * Disposes the component and the associated ressources.
  137581. */
  137582. dispose(): void;
  137583. private _isReadyForMesh;
  137584. private _renderMainTexture;
  137585. private _setStencil;
  137586. private _setStencilBack;
  137587. private _draw;
  137588. private _drawCamera;
  137589. private _drawRenderingGroup;
  137590. }
  137591. }
  137592. declare module BABYLON {
  137593. /** @hidden */
  137594. export var glowMapMergePixelShader: {
  137595. name: string;
  137596. shader: string;
  137597. };
  137598. }
  137599. declare module BABYLON {
  137600. /** @hidden */
  137601. export var glowMapMergeVertexShader: {
  137602. name: string;
  137603. shader: string;
  137604. };
  137605. }
  137606. declare module BABYLON {
  137607. interface AbstractScene {
  137608. /**
  137609. * Return a the first highlight layer of the scene with a given name.
  137610. * @param name The name of the highlight layer to look for.
  137611. * @return The highlight layer if found otherwise null.
  137612. */
  137613. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  137614. }
  137615. /**
  137616. * Glow layer options. This helps customizing the behaviour
  137617. * of the glow layer.
  137618. */
  137619. export interface IGlowLayerOptions {
  137620. /**
  137621. * Multiplication factor apply to the canvas size to compute the render target size
  137622. * used to generated the glowing objects (the smaller the faster).
  137623. */
  137624. mainTextureRatio: number;
  137625. /**
  137626. * Enforces a fixed size texture to ensure resize independant blur.
  137627. */
  137628. mainTextureFixedSize?: number;
  137629. /**
  137630. * How big is the kernel of the blur texture.
  137631. */
  137632. blurKernelSize: number;
  137633. /**
  137634. * The camera attached to the layer.
  137635. */
  137636. camera: Nullable<Camera>;
  137637. /**
  137638. * Enable MSAA by chosing the number of samples.
  137639. */
  137640. mainTextureSamples?: number;
  137641. /**
  137642. * The rendering group to draw the layer in.
  137643. */
  137644. renderingGroupId: number;
  137645. }
  137646. /**
  137647. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  137648. *
  137649. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  137650. *
  137651. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  137652. */
  137653. export class GlowLayer extends EffectLayer {
  137654. /**
  137655. * Effect Name of the layer.
  137656. */
  137657. static readonly EffectName: string;
  137658. /**
  137659. * The default blur kernel size used for the glow.
  137660. */
  137661. static DefaultBlurKernelSize: number;
  137662. /**
  137663. * The default texture size ratio used for the glow.
  137664. */
  137665. static DefaultTextureRatio: number;
  137666. /**
  137667. * Sets the kernel size of the blur.
  137668. */
  137669. set blurKernelSize(value: number);
  137670. /**
  137671. * Gets the kernel size of the blur.
  137672. */
  137673. get blurKernelSize(): number;
  137674. /**
  137675. * Sets the glow intensity.
  137676. */
  137677. set intensity(value: number);
  137678. /**
  137679. * Gets the glow intensity.
  137680. */
  137681. get intensity(): number;
  137682. private _options;
  137683. private _intensity;
  137684. private _horizontalBlurPostprocess1;
  137685. private _verticalBlurPostprocess1;
  137686. private _horizontalBlurPostprocess2;
  137687. private _verticalBlurPostprocess2;
  137688. private _blurTexture1;
  137689. private _blurTexture2;
  137690. private _postProcesses1;
  137691. private _postProcesses2;
  137692. private _includedOnlyMeshes;
  137693. private _excludedMeshes;
  137694. private _meshesUsingTheirOwnMaterials;
  137695. /**
  137696. * Callback used to let the user override the color selection on a per mesh basis
  137697. */
  137698. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  137699. /**
  137700. * Callback used to let the user override the texture selection on a per mesh basis
  137701. */
  137702. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  137703. /**
  137704. * Instantiates a new glow Layer and references it to the scene.
  137705. * @param name The name of the layer
  137706. * @param scene The scene to use the layer in
  137707. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  137708. */
  137709. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  137710. /**
  137711. * Get the effect name of the layer.
  137712. * @return The effect name
  137713. */
  137714. getEffectName(): string;
  137715. /**
  137716. * Create the merge effect. This is the shader use to blit the information back
  137717. * to the main canvas at the end of the scene rendering.
  137718. */
  137719. protected _createMergeEffect(): Effect;
  137720. /**
  137721. * Creates the render target textures and post processes used in the glow layer.
  137722. */
  137723. protected _createTextureAndPostProcesses(): void;
  137724. /**
  137725. * Checks for the readiness of the element composing the layer.
  137726. * @param subMesh the mesh to check for
  137727. * @param useInstances specify wether or not to use instances to render the mesh
  137728. * @param emissiveTexture the associated emissive texture used to generate the glow
  137729. * @return true if ready otherwise, false
  137730. */
  137731. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  137732. /**
  137733. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  137734. */
  137735. needStencil(): boolean;
  137736. /**
  137737. * Returns true if the mesh can be rendered, otherwise false.
  137738. * @param mesh The mesh to render
  137739. * @param material The material used on the mesh
  137740. * @returns true if it can be rendered otherwise false
  137741. */
  137742. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  137743. /**
  137744. * Implementation specific of rendering the generating effect on the main canvas.
  137745. * @param effect The effect used to render through
  137746. */
  137747. protected _internalRender(effect: Effect): void;
  137748. /**
  137749. * Sets the required values for both the emissive texture and and the main color.
  137750. */
  137751. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  137752. /**
  137753. * Returns true if the mesh should render, otherwise false.
  137754. * @param mesh The mesh to render
  137755. * @returns true if it should render otherwise false
  137756. */
  137757. protected _shouldRenderMesh(mesh: Mesh): boolean;
  137758. /**
  137759. * Adds specific effects defines.
  137760. * @param defines The defines to add specifics to.
  137761. */
  137762. protected _addCustomEffectDefines(defines: string[]): void;
  137763. /**
  137764. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  137765. * @param mesh The mesh to exclude from the glow layer
  137766. */
  137767. addExcludedMesh(mesh: Mesh): void;
  137768. /**
  137769. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  137770. * @param mesh The mesh to remove
  137771. */
  137772. removeExcludedMesh(mesh: Mesh): void;
  137773. /**
  137774. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  137775. * @param mesh The mesh to include in the glow layer
  137776. */
  137777. addIncludedOnlyMesh(mesh: Mesh): void;
  137778. /**
  137779. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  137780. * @param mesh The mesh to remove
  137781. */
  137782. removeIncludedOnlyMesh(mesh: Mesh): void;
  137783. /**
  137784. * Determine if a given mesh will be used in the glow layer
  137785. * @param mesh The mesh to test
  137786. * @returns true if the mesh will be highlighted by the current glow layer
  137787. */
  137788. hasMesh(mesh: AbstractMesh): boolean;
  137789. /**
  137790. * Defines whether the current material of the mesh should be use to render the effect.
  137791. * @param mesh defines the current mesh to render
  137792. */
  137793. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  137794. /**
  137795. * Add a mesh to be rendered through its own material and not with emissive only.
  137796. * @param mesh The mesh for which we need to use its material
  137797. */
  137798. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  137799. /**
  137800. * Remove a mesh from being rendered through its own material and not with emissive only.
  137801. * @param mesh The mesh for which we need to not use its material
  137802. */
  137803. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  137804. /**
  137805. * Free any resources and references associated to a mesh.
  137806. * Internal use
  137807. * @param mesh The mesh to free.
  137808. * @hidden
  137809. */
  137810. _disposeMesh(mesh: Mesh): void;
  137811. /**
  137812. * Gets the class name of the effect layer
  137813. * @returns the string with the class name of the effect layer
  137814. */
  137815. getClassName(): string;
  137816. /**
  137817. * Serializes this glow layer
  137818. * @returns a serialized glow layer object
  137819. */
  137820. serialize(): any;
  137821. /**
  137822. * Creates a Glow Layer from parsed glow layer data
  137823. * @param parsedGlowLayer defines glow layer data
  137824. * @param scene defines the current scene
  137825. * @param rootUrl defines the root URL containing the glow layer information
  137826. * @returns a parsed Glow Layer
  137827. */
  137828. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  137829. }
  137830. }
  137831. declare module BABYLON {
  137832. /** @hidden */
  137833. export var glowBlurPostProcessPixelShader: {
  137834. name: string;
  137835. shader: string;
  137836. };
  137837. }
  137838. declare module BABYLON {
  137839. interface AbstractScene {
  137840. /**
  137841. * Return a the first highlight layer of the scene with a given name.
  137842. * @param name The name of the highlight layer to look for.
  137843. * @return The highlight layer if found otherwise null.
  137844. */
  137845. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  137846. }
  137847. /**
  137848. * Highlight layer options. This helps customizing the behaviour
  137849. * of the highlight layer.
  137850. */
  137851. export interface IHighlightLayerOptions {
  137852. /**
  137853. * Multiplication factor apply to the canvas size to compute the render target size
  137854. * used to generated the glowing objects (the smaller the faster).
  137855. */
  137856. mainTextureRatio: number;
  137857. /**
  137858. * Enforces a fixed size texture to ensure resize independant blur.
  137859. */
  137860. mainTextureFixedSize?: number;
  137861. /**
  137862. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  137863. * of the picture to blur (the smaller the faster).
  137864. */
  137865. blurTextureSizeRatio: number;
  137866. /**
  137867. * How big in texel of the blur texture is the vertical blur.
  137868. */
  137869. blurVerticalSize: number;
  137870. /**
  137871. * How big in texel of the blur texture is the horizontal blur.
  137872. */
  137873. blurHorizontalSize: number;
  137874. /**
  137875. * Alpha blending mode used to apply the blur. Default is combine.
  137876. */
  137877. alphaBlendingMode: number;
  137878. /**
  137879. * The camera attached to the layer.
  137880. */
  137881. camera: Nullable<Camera>;
  137882. /**
  137883. * Should we display highlight as a solid stroke?
  137884. */
  137885. isStroke?: boolean;
  137886. /**
  137887. * The rendering group to draw the layer in.
  137888. */
  137889. renderingGroupId: number;
  137890. }
  137891. /**
  137892. * The highlight layer Helps adding a glow effect around a mesh.
  137893. *
  137894. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  137895. * glowy meshes to your scene.
  137896. *
  137897. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  137898. */
  137899. export class HighlightLayer extends EffectLayer {
  137900. name: string;
  137901. /**
  137902. * Effect Name of the highlight layer.
  137903. */
  137904. static readonly EffectName: string;
  137905. /**
  137906. * The neutral color used during the preparation of the glow effect.
  137907. * This is black by default as the blend operation is a blend operation.
  137908. */
  137909. static NeutralColor: Color4;
  137910. /**
  137911. * Stencil value used for glowing meshes.
  137912. */
  137913. static GlowingMeshStencilReference: number;
  137914. /**
  137915. * Stencil value used for the other meshes in the scene.
  137916. */
  137917. static NormalMeshStencilReference: number;
  137918. /**
  137919. * Specifies whether or not the inner glow is ACTIVE in the layer.
  137920. */
  137921. innerGlow: boolean;
  137922. /**
  137923. * Specifies whether or not the outer glow is ACTIVE in the layer.
  137924. */
  137925. outerGlow: boolean;
  137926. /**
  137927. * Specifies the horizontal size of the blur.
  137928. */
  137929. set blurHorizontalSize(value: number);
  137930. /**
  137931. * Specifies the vertical size of the blur.
  137932. */
  137933. set blurVerticalSize(value: number);
  137934. /**
  137935. * Gets the horizontal size of the blur.
  137936. */
  137937. get blurHorizontalSize(): number;
  137938. /**
  137939. * Gets the vertical size of the blur.
  137940. */
  137941. get blurVerticalSize(): number;
  137942. /**
  137943. * An event triggered when the highlight layer is being blurred.
  137944. */
  137945. onBeforeBlurObservable: Observable<HighlightLayer>;
  137946. /**
  137947. * An event triggered when the highlight layer has been blurred.
  137948. */
  137949. onAfterBlurObservable: Observable<HighlightLayer>;
  137950. private _instanceGlowingMeshStencilReference;
  137951. private _options;
  137952. private _downSamplePostprocess;
  137953. private _horizontalBlurPostprocess;
  137954. private _verticalBlurPostprocess;
  137955. private _blurTexture;
  137956. private _meshes;
  137957. private _excludedMeshes;
  137958. /**
  137959. * Instantiates a new highlight Layer and references it to the scene..
  137960. * @param name The name of the layer
  137961. * @param scene The scene to use the layer in
  137962. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  137963. */
  137964. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  137965. /**
  137966. * Get the effect name of the layer.
  137967. * @return The effect name
  137968. */
  137969. getEffectName(): string;
  137970. /**
  137971. * Create the merge effect. This is the shader use to blit the information back
  137972. * to the main canvas at the end of the scene rendering.
  137973. */
  137974. protected _createMergeEffect(): Effect;
  137975. /**
  137976. * Creates the render target textures and post processes used in the highlight layer.
  137977. */
  137978. protected _createTextureAndPostProcesses(): void;
  137979. /**
  137980. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  137981. */
  137982. needStencil(): boolean;
  137983. /**
  137984. * Checks for the readiness of the element composing the layer.
  137985. * @param subMesh the mesh to check for
  137986. * @param useInstances specify wether or not to use instances to render the mesh
  137987. * @param emissiveTexture the associated emissive texture used to generate the glow
  137988. * @return true if ready otherwise, false
  137989. */
  137990. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  137991. /**
  137992. * Implementation specific of rendering the generating effect on the main canvas.
  137993. * @param effect The effect used to render through
  137994. */
  137995. protected _internalRender(effect: Effect): void;
  137996. /**
  137997. * Returns true if the layer contains information to display, otherwise false.
  137998. */
  137999. shouldRender(): boolean;
  138000. /**
  138001. * Returns true if the mesh should render, otherwise false.
  138002. * @param mesh The mesh to render
  138003. * @returns true if it should render otherwise false
  138004. */
  138005. protected _shouldRenderMesh(mesh: Mesh): boolean;
  138006. /**
  138007. * Returns true if the mesh can be rendered, otherwise false.
  138008. * @param mesh The mesh to render
  138009. * @param material The material used on the mesh
  138010. * @returns true if it can be rendered otherwise false
  138011. */
  138012. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  138013. /**
  138014. * Adds specific effects defines.
  138015. * @param defines The defines to add specifics to.
  138016. */
  138017. protected _addCustomEffectDefines(defines: string[]): void;
  138018. /**
  138019. * Sets the required values for both the emissive texture and and the main color.
  138020. */
  138021. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  138022. /**
  138023. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  138024. * @param mesh The mesh to exclude from the highlight layer
  138025. */
  138026. addExcludedMesh(mesh: Mesh): void;
  138027. /**
  138028. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  138029. * @param mesh The mesh to highlight
  138030. */
  138031. removeExcludedMesh(mesh: Mesh): void;
  138032. /**
  138033. * Determine if a given mesh will be highlighted by the current HighlightLayer
  138034. * @param mesh mesh to test
  138035. * @returns true if the mesh will be highlighted by the current HighlightLayer
  138036. */
  138037. hasMesh(mesh: AbstractMesh): boolean;
  138038. /**
  138039. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  138040. * @param mesh The mesh to highlight
  138041. * @param color The color of the highlight
  138042. * @param glowEmissiveOnly Extract the glow from the emissive texture
  138043. */
  138044. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  138045. /**
  138046. * Remove a mesh from the highlight layer in order to make it stop glowing.
  138047. * @param mesh The mesh to highlight
  138048. */
  138049. removeMesh(mesh: Mesh): void;
  138050. /**
  138051. * Remove all the meshes currently referenced in the highlight layer
  138052. */
  138053. removeAllMeshes(): void;
  138054. /**
  138055. * Force the stencil to the normal expected value for none glowing parts
  138056. */
  138057. private _defaultStencilReference;
  138058. /**
  138059. * Free any resources and references associated to a mesh.
  138060. * Internal use
  138061. * @param mesh The mesh to free.
  138062. * @hidden
  138063. */
  138064. _disposeMesh(mesh: Mesh): void;
  138065. /**
  138066. * Dispose the highlight layer and free resources.
  138067. */
  138068. dispose(): void;
  138069. /**
  138070. * Gets the class name of the effect layer
  138071. * @returns the string with the class name of the effect layer
  138072. */
  138073. getClassName(): string;
  138074. /**
  138075. * Serializes this Highlight layer
  138076. * @returns a serialized Highlight layer object
  138077. */
  138078. serialize(): any;
  138079. /**
  138080. * Creates a Highlight layer from parsed Highlight layer data
  138081. * @param parsedHightlightLayer defines the Highlight layer data
  138082. * @param scene defines the current scene
  138083. * @param rootUrl defines the root URL containing the Highlight layer information
  138084. * @returns a parsed Highlight layer
  138085. */
  138086. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  138087. }
  138088. }
  138089. declare module BABYLON {
  138090. interface AbstractScene {
  138091. /**
  138092. * The list of layers (background and foreground) of the scene
  138093. */
  138094. layers: Array<Layer>;
  138095. }
  138096. /**
  138097. * Defines the layer scene component responsible to manage any layers
  138098. * in a given scene.
  138099. */
  138100. export class LayerSceneComponent implements ISceneComponent {
  138101. /**
  138102. * The component name helpfull to identify the component in the list of scene components.
  138103. */
  138104. readonly name: string;
  138105. /**
  138106. * The scene the component belongs to.
  138107. */
  138108. scene: Scene;
  138109. private _engine;
  138110. /**
  138111. * Creates a new instance of the component for the given scene
  138112. * @param scene Defines the scene to register the component in
  138113. */
  138114. constructor(scene: Scene);
  138115. /**
  138116. * Registers the component in a given scene
  138117. */
  138118. register(): void;
  138119. /**
  138120. * Rebuilds the elements related to this component in case of
  138121. * context lost for instance.
  138122. */
  138123. rebuild(): void;
  138124. /**
  138125. * Disposes the component and the associated ressources.
  138126. */
  138127. dispose(): void;
  138128. private _draw;
  138129. private _drawCameraPredicate;
  138130. private _drawCameraBackground;
  138131. private _drawCameraForeground;
  138132. private _drawRenderTargetPredicate;
  138133. private _drawRenderTargetBackground;
  138134. private _drawRenderTargetForeground;
  138135. /**
  138136. * Adds all the elements from the container to the scene
  138137. * @param container the container holding the elements
  138138. */
  138139. addFromContainer(container: AbstractScene): void;
  138140. /**
  138141. * Removes all the elements in the container from the scene
  138142. * @param container contains the elements to remove
  138143. * @param dispose if the removed element should be disposed (default: false)
  138144. */
  138145. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  138146. }
  138147. }
  138148. declare module BABYLON {
  138149. /** @hidden */
  138150. export var layerPixelShader: {
  138151. name: string;
  138152. shader: string;
  138153. };
  138154. }
  138155. declare module BABYLON {
  138156. /** @hidden */
  138157. export var layerVertexShader: {
  138158. name: string;
  138159. shader: string;
  138160. };
  138161. }
  138162. declare module BABYLON {
  138163. /**
  138164. * This represents a full screen 2d layer.
  138165. * This can be useful to display a picture in the background of your scene for instance.
  138166. * @see https://www.babylonjs-playground.com/#08A2BS#1
  138167. */
  138168. export class Layer {
  138169. /**
  138170. * Define the name of the layer.
  138171. */
  138172. name: string;
  138173. /**
  138174. * Define the texture the layer should display.
  138175. */
  138176. texture: Nullable<Texture>;
  138177. /**
  138178. * Is the layer in background or foreground.
  138179. */
  138180. isBackground: boolean;
  138181. /**
  138182. * Define the color of the layer (instead of texture).
  138183. */
  138184. color: Color4;
  138185. /**
  138186. * Define the scale of the layer in order to zoom in out of the texture.
  138187. */
  138188. scale: Vector2;
  138189. /**
  138190. * Define an offset for the layer in order to shift the texture.
  138191. */
  138192. offset: Vector2;
  138193. /**
  138194. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  138195. */
  138196. alphaBlendingMode: number;
  138197. /**
  138198. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  138199. * Alpha test will not mix with the background color in case of transparency.
  138200. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  138201. */
  138202. alphaTest: boolean;
  138203. /**
  138204. * Define a mask to restrict the layer to only some of the scene cameras.
  138205. */
  138206. layerMask: number;
  138207. /**
  138208. * Define the list of render target the layer is visible into.
  138209. */
  138210. renderTargetTextures: RenderTargetTexture[];
  138211. /**
  138212. * Define if the layer is only used in renderTarget or if it also
  138213. * renders in the main frame buffer of the canvas.
  138214. */
  138215. renderOnlyInRenderTargetTextures: boolean;
  138216. private _scene;
  138217. private _vertexBuffers;
  138218. private _indexBuffer;
  138219. private _effect;
  138220. private _previousDefines;
  138221. /**
  138222. * An event triggered when the layer is disposed.
  138223. */
  138224. onDisposeObservable: Observable<Layer>;
  138225. private _onDisposeObserver;
  138226. /**
  138227. * Back compatibility with callback before the onDisposeObservable existed.
  138228. * The set callback will be triggered when the layer has been disposed.
  138229. */
  138230. set onDispose(callback: () => void);
  138231. /**
  138232. * An event triggered before rendering the scene
  138233. */
  138234. onBeforeRenderObservable: Observable<Layer>;
  138235. private _onBeforeRenderObserver;
  138236. /**
  138237. * Back compatibility with callback before the onBeforeRenderObservable existed.
  138238. * The set callback will be triggered just before rendering the layer.
  138239. */
  138240. set onBeforeRender(callback: () => void);
  138241. /**
  138242. * An event triggered after rendering the scene
  138243. */
  138244. onAfterRenderObservable: Observable<Layer>;
  138245. private _onAfterRenderObserver;
  138246. /**
  138247. * Back compatibility with callback before the onAfterRenderObservable existed.
  138248. * The set callback will be triggered just after rendering the layer.
  138249. */
  138250. set onAfterRender(callback: () => void);
  138251. /**
  138252. * Instantiates a new layer.
  138253. * This represents a full screen 2d layer.
  138254. * This can be useful to display a picture in the background of your scene for instance.
  138255. * @see https://www.babylonjs-playground.com/#08A2BS#1
  138256. * @param name Define the name of the layer in the scene
  138257. * @param imgUrl Define the url of the texture to display in the layer
  138258. * @param scene Define the scene the layer belongs to
  138259. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  138260. * @param color Defines a color for the layer
  138261. */
  138262. constructor(
  138263. /**
  138264. * Define the name of the layer.
  138265. */
  138266. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  138267. private _createIndexBuffer;
  138268. /** @hidden */
  138269. _rebuild(): void;
  138270. /**
  138271. * Renders the layer in the scene.
  138272. */
  138273. render(): void;
  138274. /**
  138275. * Disposes and releases the associated ressources.
  138276. */
  138277. dispose(): void;
  138278. }
  138279. }
  138280. declare module BABYLON {
  138281. /** @hidden */
  138282. export var lensFlarePixelShader: {
  138283. name: string;
  138284. shader: string;
  138285. };
  138286. }
  138287. declare module BABYLON {
  138288. /** @hidden */
  138289. export var lensFlareVertexShader: {
  138290. name: string;
  138291. shader: string;
  138292. };
  138293. }
  138294. declare module BABYLON {
  138295. /**
  138296. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  138297. * It is usually composed of several `lensFlare`.
  138298. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  138299. */
  138300. export class LensFlareSystem {
  138301. /**
  138302. * Define the name of the lens flare system
  138303. */
  138304. name: string;
  138305. /**
  138306. * List of lens flares used in this system.
  138307. */
  138308. lensFlares: LensFlare[];
  138309. /**
  138310. * Define a limit from the border the lens flare can be visible.
  138311. */
  138312. borderLimit: number;
  138313. /**
  138314. * Define a viewport border we do not want to see the lens flare in.
  138315. */
  138316. viewportBorder: number;
  138317. /**
  138318. * Define a predicate which could limit the list of meshes able to occlude the effect.
  138319. */
  138320. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  138321. /**
  138322. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  138323. */
  138324. layerMask: number;
  138325. /**
  138326. * Define the id of the lens flare system in the scene.
  138327. * (equal to name by default)
  138328. */
  138329. id: string;
  138330. private _scene;
  138331. private _emitter;
  138332. private _vertexBuffers;
  138333. private _indexBuffer;
  138334. private _effect;
  138335. private _positionX;
  138336. private _positionY;
  138337. private _isEnabled;
  138338. /** @hidden */
  138339. static _SceneComponentInitialization: (scene: Scene) => void;
  138340. /**
  138341. * Instantiates a lens flare system.
  138342. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  138343. * It is usually composed of several `lensFlare`.
  138344. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  138345. * @param name Define the name of the lens flare system in the scene
  138346. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  138347. * @param scene Define the scene the lens flare system belongs to
  138348. */
  138349. constructor(
  138350. /**
  138351. * Define the name of the lens flare system
  138352. */
  138353. name: string, emitter: any, scene: Scene);
  138354. /**
  138355. * Define if the lens flare system is enabled.
  138356. */
  138357. get isEnabled(): boolean;
  138358. set isEnabled(value: boolean);
  138359. /**
  138360. * Get the scene the effects belongs to.
  138361. * @returns the scene holding the lens flare system
  138362. */
  138363. getScene(): Scene;
  138364. /**
  138365. * Get the emitter of the lens flare system.
  138366. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  138367. * @returns the emitter of the lens flare system
  138368. */
  138369. getEmitter(): any;
  138370. /**
  138371. * Set the emitter of the lens flare system.
  138372. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  138373. * @param newEmitter Define the new emitter of the system
  138374. */
  138375. setEmitter(newEmitter: any): void;
  138376. /**
  138377. * Get the lens flare system emitter position.
  138378. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  138379. * @returns the position
  138380. */
  138381. getEmitterPosition(): Vector3;
  138382. /**
  138383. * @hidden
  138384. */
  138385. computeEffectivePosition(globalViewport: Viewport): boolean;
  138386. /** @hidden */
  138387. _isVisible(): boolean;
  138388. /**
  138389. * @hidden
  138390. */
  138391. render(): boolean;
  138392. /**
  138393. * Dispose and release the lens flare with its associated resources.
  138394. */
  138395. dispose(): void;
  138396. /**
  138397. * Parse a lens flare system from a JSON repressentation
  138398. * @param parsedLensFlareSystem Define the JSON to parse
  138399. * @param scene Define the scene the parsed system should be instantiated in
  138400. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  138401. * @returns the parsed system
  138402. */
  138403. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  138404. /**
  138405. * Serialize the current Lens Flare System into a JSON representation.
  138406. * @returns the serialized JSON
  138407. */
  138408. serialize(): any;
  138409. }
  138410. }
  138411. declare module BABYLON {
  138412. /**
  138413. * This represents one of the lens effect in a `lensFlareSystem`.
  138414. * It controls one of the indiviual texture used in the effect.
  138415. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  138416. */
  138417. export class LensFlare {
  138418. /**
  138419. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  138420. */
  138421. size: number;
  138422. /**
  138423. * 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.
  138424. */
  138425. position: number;
  138426. /**
  138427. * Define the lens color.
  138428. */
  138429. color: Color3;
  138430. /**
  138431. * Define the lens texture.
  138432. */
  138433. texture: Nullable<Texture>;
  138434. /**
  138435. * Define the alpha mode to render this particular lens.
  138436. */
  138437. alphaMode: number;
  138438. private _system;
  138439. /**
  138440. * Creates a new Lens Flare.
  138441. * This represents one of the lens effect in a `lensFlareSystem`.
  138442. * It controls one of the indiviual texture used in the effect.
  138443. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  138444. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  138445. * @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.
  138446. * @param color Define the lens color
  138447. * @param imgUrl Define the lens texture url
  138448. * @param system Define the `lensFlareSystem` this flare is part of
  138449. * @returns The newly created Lens Flare
  138450. */
  138451. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  138452. /**
  138453. * Instantiates a new Lens Flare.
  138454. * This represents one of the lens effect in a `lensFlareSystem`.
  138455. * It controls one of the indiviual texture used in the effect.
  138456. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  138457. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  138458. * @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.
  138459. * @param color Define the lens color
  138460. * @param imgUrl Define the lens texture url
  138461. * @param system Define the `lensFlareSystem` this flare is part of
  138462. */
  138463. constructor(
  138464. /**
  138465. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  138466. */
  138467. size: number,
  138468. /**
  138469. * 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.
  138470. */
  138471. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  138472. /**
  138473. * Dispose and release the lens flare with its associated resources.
  138474. */
  138475. dispose(): void;
  138476. }
  138477. }
  138478. declare module BABYLON {
  138479. interface AbstractScene {
  138480. /**
  138481. * The list of lens flare system added to the scene
  138482. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  138483. */
  138484. lensFlareSystems: Array<LensFlareSystem>;
  138485. /**
  138486. * Removes the given lens flare system from this scene.
  138487. * @param toRemove The lens flare system to remove
  138488. * @returns The index of the removed lens flare system
  138489. */
  138490. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  138491. /**
  138492. * Adds the given lens flare system to this scene
  138493. * @param newLensFlareSystem The lens flare system to add
  138494. */
  138495. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  138496. /**
  138497. * Gets a lens flare system using its name
  138498. * @param name defines the name to look for
  138499. * @returns the lens flare system or null if not found
  138500. */
  138501. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  138502. /**
  138503. * Gets a lens flare system using its id
  138504. * @param id defines the id to look for
  138505. * @returns the lens flare system or null if not found
  138506. */
  138507. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  138508. }
  138509. /**
  138510. * Defines the lens flare scene component responsible to manage any lens flares
  138511. * in a given scene.
  138512. */
  138513. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  138514. /**
  138515. * The component name helpfull to identify the component in the list of scene components.
  138516. */
  138517. readonly name: string;
  138518. /**
  138519. * The scene the component belongs to.
  138520. */
  138521. scene: Scene;
  138522. /**
  138523. * Creates a new instance of the component for the given scene
  138524. * @param scene Defines the scene to register the component in
  138525. */
  138526. constructor(scene: Scene);
  138527. /**
  138528. * Registers the component in a given scene
  138529. */
  138530. register(): void;
  138531. /**
  138532. * Rebuilds the elements related to this component in case of
  138533. * context lost for instance.
  138534. */
  138535. rebuild(): void;
  138536. /**
  138537. * Adds all the elements from the container to the scene
  138538. * @param container the container holding the elements
  138539. */
  138540. addFromContainer(container: AbstractScene): void;
  138541. /**
  138542. * Removes all the elements in the container from the scene
  138543. * @param container contains the elements to remove
  138544. * @param dispose if the removed element should be disposed (default: false)
  138545. */
  138546. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  138547. /**
  138548. * Serializes the component data to the specified json object
  138549. * @param serializationObject The object to serialize to
  138550. */
  138551. serialize(serializationObject: any): void;
  138552. /**
  138553. * Disposes the component and the associated ressources.
  138554. */
  138555. dispose(): void;
  138556. private _draw;
  138557. }
  138558. }
  138559. declare module BABYLON {
  138560. /** @hidden */
  138561. export var depthPixelShader: {
  138562. name: string;
  138563. shader: string;
  138564. };
  138565. }
  138566. declare module BABYLON {
  138567. /** @hidden */
  138568. export var depthVertexShader: {
  138569. name: string;
  138570. shader: string;
  138571. };
  138572. }
  138573. declare module BABYLON {
  138574. /**
  138575. * This represents a depth renderer in Babylon.
  138576. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  138577. */
  138578. export class DepthRenderer {
  138579. private _scene;
  138580. private _depthMap;
  138581. private _effect;
  138582. private readonly _storeNonLinearDepth;
  138583. private readonly _clearColor;
  138584. /** Get if the depth renderer is using packed depth or not */
  138585. readonly isPacked: boolean;
  138586. private _cachedDefines;
  138587. private _camera;
  138588. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  138589. enabled: boolean;
  138590. /**
  138591. * Specifiess that the depth renderer will only be used within
  138592. * the camera it is created for.
  138593. * This can help forcing its rendering during the camera processing.
  138594. */
  138595. useOnlyInActiveCamera: boolean;
  138596. /** @hidden */
  138597. static _SceneComponentInitialization: (scene: Scene) => void;
  138598. /**
  138599. * Instantiates a depth renderer
  138600. * @param scene The scene the renderer belongs to
  138601. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  138602. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  138603. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  138604. */
  138605. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  138606. /**
  138607. * Creates the depth rendering effect and checks if the effect is ready.
  138608. * @param subMesh The submesh to be used to render the depth map of
  138609. * @param useInstances If multiple world instances should be used
  138610. * @returns if the depth renderer is ready to render the depth map
  138611. */
  138612. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  138613. /**
  138614. * Gets the texture which the depth map will be written to.
  138615. * @returns The depth map texture
  138616. */
  138617. getDepthMap(): RenderTargetTexture;
  138618. /**
  138619. * Disposes of the depth renderer.
  138620. */
  138621. dispose(): void;
  138622. }
  138623. }
  138624. declare module BABYLON {
  138625. /** @hidden */
  138626. export var minmaxReduxPixelShader: {
  138627. name: string;
  138628. shader: string;
  138629. };
  138630. }
  138631. declare module BABYLON {
  138632. /**
  138633. * This class computes a min/max reduction from a texture: it means it computes the minimum
  138634. * and maximum values from all values of the texture.
  138635. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  138636. * The source values are read from the red channel of the texture.
  138637. */
  138638. export class MinMaxReducer {
  138639. /**
  138640. * Observable triggered when the computation has been performed
  138641. */
  138642. onAfterReductionPerformed: Observable<{
  138643. min: number;
  138644. max: number;
  138645. }>;
  138646. protected _camera: Camera;
  138647. protected _sourceTexture: Nullable<RenderTargetTexture>;
  138648. protected _reductionSteps: Nullable<Array<PostProcess>>;
  138649. protected _postProcessManager: PostProcessManager;
  138650. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  138651. protected _forceFullscreenViewport: boolean;
  138652. /**
  138653. * Creates a min/max reducer
  138654. * @param camera The camera to use for the post processes
  138655. */
  138656. constructor(camera: Camera);
  138657. /**
  138658. * Gets the texture used to read the values from.
  138659. */
  138660. get sourceTexture(): Nullable<RenderTargetTexture>;
  138661. /**
  138662. * Sets the source texture to read the values from.
  138663. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  138664. * because in such textures '1' value must not be taken into account to compute the maximum
  138665. * as this value is used to clear the texture.
  138666. * Note that the computation is not activated by calling this function, you must call activate() for that!
  138667. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  138668. * @param depthRedux Indicates if the texture is a depth texture or not
  138669. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  138670. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  138671. */
  138672. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  138673. /**
  138674. * Defines the refresh rate of the computation.
  138675. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  138676. */
  138677. get refreshRate(): number;
  138678. set refreshRate(value: number);
  138679. protected _activated: boolean;
  138680. /**
  138681. * Gets the activation status of the reducer
  138682. */
  138683. get activated(): boolean;
  138684. /**
  138685. * Activates the reduction computation.
  138686. * When activated, the observers registered in onAfterReductionPerformed are
  138687. * called after the compuation is performed
  138688. */
  138689. activate(): void;
  138690. /**
  138691. * Deactivates the reduction computation.
  138692. */
  138693. deactivate(): void;
  138694. /**
  138695. * Disposes the min/max reducer
  138696. * @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.
  138697. */
  138698. dispose(disposeAll?: boolean): void;
  138699. }
  138700. }
  138701. declare module BABYLON {
  138702. /**
  138703. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  138704. */
  138705. export class DepthReducer extends MinMaxReducer {
  138706. private _depthRenderer;
  138707. private _depthRendererId;
  138708. /**
  138709. * Gets the depth renderer used for the computation.
  138710. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  138711. */
  138712. get depthRenderer(): Nullable<DepthRenderer>;
  138713. /**
  138714. * Creates a depth reducer
  138715. * @param camera The camera used to render the depth texture
  138716. */
  138717. constructor(camera: Camera);
  138718. /**
  138719. * Sets the depth renderer to use to generate the depth map
  138720. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  138721. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  138722. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  138723. */
  138724. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  138725. /** @hidden */
  138726. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  138727. /**
  138728. * Activates the reduction computation.
  138729. * When activated, the observers registered in onAfterReductionPerformed are
  138730. * called after the compuation is performed
  138731. */
  138732. activate(): void;
  138733. /**
  138734. * Deactivates the reduction computation.
  138735. */
  138736. deactivate(): void;
  138737. /**
  138738. * Disposes the depth reducer
  138739. * @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.
  138740. */
  138741. dispose(disposeAll?: boolean): void;
  138742. }
  138743. }
  138744. declare module BABYLON {
  138745. /**
  138746. * A CSM implementation allowing casting shadows on large scenes.
  138747. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  138748. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  138749. */
  138750. export class CascadedShadowGenerator extends ShadowGenerator {
  138751. private static readonly frustumCornersNDCSpace;
  138752. /**
  138753. * Name of the CSM class
  138754. */
  138755. static CLASSNAME: string;
  138756. /**
  138757. * Defines the default number of cascades used by the CSM.
  138758. */
  138759. static readonly DEFAULT_CASCADES_COUNT: number;
  138760. /**
  138761. * Defines the minimum number of cascades used by the CSM.
  138762. */
  138763. static readonly MIN_CASCADES_COUNT: number;
  138764. /**
  138765. * Defines the maximum number of cascades used by the CSM.
  138766. */
  138767. static readonly MAX_CASCADES_COUNT: number;
  138768. protected _validateFilter(filter: number): number;
  138769. /**
  138770. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  138771. */
  138772. penumbraDarkness: number;
  138773. private _numCascades;
  138774. /**
  138775. * Gets or set the number of cascades used by the CSM.
  138776. */
  138777. get numCascades(): number;
  138778. set numCascades(value: number);
  138779. /**
  138780. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  138781. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  138782. */
  138783. stabilizeCascades: boolean;
  138784. private _freezeShadowCastersBoundingInfo;
  138785. private _freezeShadowCastersBoundingInfoObservable;
  138786. /**
  138787. * Enables or disables the shadow casters bounding info computation.
  138788. * If your shadow casters don't move, you can disable this feature.
  138789. * If it is enabled, the bounding box computation is done every frame.
  138790. */
  138791. get freezeShadowCastersBoundingInfo(): boolean;
  138792. set freezeShadowCastersBoundingInfo(freeze: boolean);
  138793. private _scbiMin;
  138794. private _scbiMax;
  138795. protected _computeShadowCastersBoundingInfo(): void;
  138796. protected _shadowCastersBoundingInfo: BoundingInfo;
  138797. /**
  138798. * Gets or sets the shadow casters bounding info.
  138799. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  138800. * so that the system won't overwrite the bounds you provide
  138801. */
  138802. get shadowCastersBoundingInfo(): BoundingInfo;
  138803. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  138804. protected _breaksAreDirty: boolean;
  138805. protected _minDistance: number;
  138806. protected _maxDistance: number;
  138807. /**
  138808. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  138809. *
  138810. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  138811. * If you don't know these values, simply leave them to their defaults and don't call this function.
  138812. * @param min minimal distance for the breaks (default to 0.)
  138813. * @param max maximal distance for the breaks (default to 1.)
  138814. */
  138815. setMinMaxDistance(min: number, max: number): void;
  138816. /** Gets the minimal distance used in the cascade break computation */
  138817. get minDistance(): number;
  138818. /** Gets the maximal distance used in the cascade break computation */
  138819. get maxDistance(): number;
  138820. /**
  138821. * Gets the class name of that object
  138822. * @returns "CascadedShadowGenerator"
  138823. */
  138824. getClassName(): string;
  138825. private _cascadeMinExtents;
  138826. private _cascadeMaxExtents;
  138827. /**
  138828. * Gets a cascade minimum extents
  138829. * @param cascadeIndex index of the cascade
  138830. * @returns the minimum cascade extents
  138831. */
  138832. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  138833. /**
  138834. * Gets a cascade maximum extents
  138835. * @param cascadeIndex index of the cascade
  138836. * @returns the maximum cascade extents
  138837. */
  138838. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  138839. private _cascades;
  138840. private _currentLayer;
  138841. private _viewSpaceFrustumsZ;
  138842. private _viewMatrices;
  138843. private _projectionMatrices;
  138844. private _transformMatrices;
  138845. private _transformMatricesAsArray;
  138846. private _frustumLengths;
  138847. private _lightSizeUVCorrection;
  138848. private _depthCorrection;
  138849. private _frustumCornersWorldSpace;
  138850. private _frustumCenter;
  138851. private _shadowCameraPos;
  138852. private _shadowMaxZ;
  138853. /**
  138854. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  138855. * It defaults to camera.maxZ
  138856. */
  138857. get shadowMaxZ(): number;
  138858. /**
  138859. * Sets the shadow max z distance.
  138860. */
  138861. set shadowMaxZ(value: number);
  138862. protected _debug: boolean;
  138863. /**
  138864. * Gets or sets the debug flag.
  138865. * When enabled, the cascades are materialized by different colors on the screen.
  138866. */
  138867. get debug(): boolean;
  138868. set debug(dbg: boolean);
  138869. private _depthClamp;
  138870. /**
  138871. * Gets or sets the depth clamping value.
  138872. *
  138873. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  138874. * to account for the shadow casters far away.
  138875. *
  138876. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  138877. */
  138878. get depthClamp(): boolean;
  138879. set depthClamp(value: boolean);
  138880. private _cascadeBlendPercentage;
  138881. /**
  138882. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  138883. * It defaults to 0.1 (10% blending).
  138884. */
  138885. get cascadeBlendPercentage(): number;
  138886. set cascadeBlendPercentage(value: number);
  138887. private _lambda;
  138888. /**
  138889. * Gets or set the lambda parameter.
  138890. * This parameter is used to split the camera frustum and create the cascades.
  138891. * 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.
  138892. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  138893. */
  138894. get lambda(): number;
  138895. set lambda(value: number);
  138896. /**
  138897. * Gets the view matrix corresponding to a given cascade
  138898. * @param cascadeNum cascade to retrieve the view matrix from
  138899. * @returns the cascade view matrix
  138900. */
  138901. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  138902. /**
  138903. * Gets the projection matrix corresponding to a given cascade
  138904. * @param cascadeNum cascade to retrieve the projection matrix from
  138905. * @returns the cascade projection matrix
  138906. */
  138907. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  138908. /**
  138909. * Gets the transformation matrix corresponding to a given cascade
  138910. * @param cascadeNum cascade to retrieve the transformation matrix from
  138911. * @returns the cascade transformation matrix
  138912. */
  138913. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  138914. private _depthRenderer;
  138915. /**
  138916. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  138917. *
  138918. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  138919. *
  138920. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  138921. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  138922. * @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
  138923. */
  138924. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  138925. private _depthReducer;
  138926. private _autoCalcDepthBounds;
  138927. /**
  138928. * Gets or sets the autoCalcDepthBounds property.
  138929. *
  138930. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  138931. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  138932. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  138933. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  138934. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  138935. */
  138936. get autoCalcDepthBounds(): boolean;
  138937. set autoCalcDepthBounds(value: boolean);
  138938. /**
  138939. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  138940. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  138941. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  138942. * for setting the refresh rate on the renderer yourself!
  138943. */
  138944. get autoCalcDepthBoundsRefreshRate(): number;
  138945. set autoCalcDepthBoundsRefreshRate(value: number);
  138946. /**
  138947. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  138948. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  138949. * you change the camera near/far planes!
  138950. */
  138951. splitFrustum(): void;
  138952. private _splitFrustum;
  138953. private _computeMatrices;
  138954. private _computeFrustumInWorldSpace;
  138955. private _computeCascadeFrustum;
  138956. /**
  138957. * Support test.
  138958. */
  138959. static get IsSupported(): boolean;
  138960. /** @hidden */
  138961. static _SceneComponentInitialization: (scene: Scene) => void;
  138962. /**
  138963. * Creates a Cascaded Shadow Generator object.
  138964. * A ShadowGenerator is the required tool to use the shadows.
  138965. * Each directional light casting shadows needs to use its own ShadowGenerator.
  138966. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  138967. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  138968. * @param light The directional light object generating the shadows.
  138969. * @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.
  138970. */
  138971. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  138972. protected _initializeGenerator(): void;
  138973. protected _createTargetRenderTexture(): void;
  138974. protected _initializeShadowMap(): void;
  138975. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  138976. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  138977. /**
  138978. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  138979. * @param defines Defines of the material we want to update
  138980. * @param lightIndex Index of the light in the enabled light list of the material
  138981. */
  138982. prepareDefines(defines: any, lightIndex: number): void;
  138983. /**
  138984. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  138985. * defined in the generator but impacting the effect).
  138986. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  138987. * @param effect The effect we are binfing the information for
  138988. */
  138989. bindShadowLight(lightIndex: string, effect: Effect): void;
  138990. /**
  138991. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  138992. * (eq to view projection * shadow projection matrices)
  138993. * @returns The transform matrix used to create the shadow map
  138994. */
  138995. getTransformMatrix(): Matrix;
  138996. /**
  138997. * Disposes the ShadowGenerator.
  138998. * Returns nothing.
  138999. */
  139000. dispose(): void;
  139001. /**
  139002. * Serializes the shadow generator setup to a json object.
  139003. * @returns The serialized JSON object
  139004. */
  139005. serialize(): any;
  139006. /**
  139007. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  139008. * @param parsedShadowGenerator The JSON object to parse
  139009. * @param scene The scene to create the shadow map for
  139010. * @returns The parsed shadow generator
  139011. */
  139012. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  139013. }
  139014. }
  139015. declare module BABYLON {
  139016. /**
  139017. * Defines the shadow generator component responsible to manage any shadow generators
  139018. * in a given scene.
  139019. */
  139020. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  139021. /**
  139022. * The component name helpfull to identify the component in the list of scene components.
  139023. */
  139024. readonly name: string;
  139025. /**
  139026. * The scene the component belongs to.
  139027. */
  139028. scene: Scene;
  139029. /**
  139030. * Creates a new instance of the component for the given scene
  139031. * @param scene Defines the scene to register the component in
  139032. */
  139033. constructor(scene: Scene);
  139034. /**
  139035. * Registers the component in a given scene
  139036. */
  139037. register(): void;
  139038. /**
  139039. * Rebuilds the elements related to this component in case of
  139040. * context lost for instance.
  139041. */
  139042. rebuild(): void;
  139043. /**
  139044. * Serializes the component data to the specified json object
  139045. * @param serializationObject The object to serialize to
  139046. */
  139047. serialize(serializationObject: any): void;
  139048. /**
  139049. * Adds all the elements from the container to the scene
  139050. * @param container the container holding the elements
  139051. */
  139052. addFromContainer(container: AbstractScene): void;
  139053. /**
  139054. * Removes all the elements in the container from the scene
  139055. * @param container contains the elements to remove
  139056. * @param dispose if the removed element should be disposed (default: false)
  139057. */
  139058. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  139059. /**
  139060. * Rebuilds the elements related to this component in case of
  139061. * context lost for instance.
  139062. */
  139063. dispose(): void;
  139064. private _gatherRenderTargets;
  139065. }
  139066. }
  139067. declare module BABYLON {
  139068. /**
  139069. * A point light is a light defined by an unique point in world space.
  139070. * The light is emitted in every direction from this point.
  139071. * A good example of a point light is a standard light bulb.
  139072. * Documentation: https://doc.babylonjs.com/babylon101/lights
  139073. */
  139074. export class PointLight extends ShadowLight {
  139075. private _shadowAngle;
  139076. /**
  139077. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  139078. * This specifies what angle the shadow will use to be created.
  139079. *
  139080. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  139081. */
  139082. get shadowAngle(): number;
  139083. /**
  139084. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  139085. * This specifies what angle the shadow will use to be created.
  139086. *
  139087. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  139088. */
  139089. set shadowAngle(value: number);
  139090. /**
  139091. * Gets the direction if it has been set.
  139092. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  139093. */
  139094. get direction(): Vector3;
  139095. /**
  139096. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  139097. */
  139098. set direction(value: Vector3);
  139099. /**
  139100. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  139101. * A PointLight emits the light in every direction.
  139102. * It can cast shadows.
  139103. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  139104. * ```javascript
  139105. * var pointLight = new PointLight("pl", camera.position, scene);
  139106. * ```
  139107. * Documentation : https://doc.babylonjs.com/babylon101/lights
  139108. * @param name The light friendly name
  139109. * @param position The position of the point light in the scene
  139110. * @param scene The scene the lights belongs to
  139111. */
  139112. constructor(name: string, position: Vector3, scene: Scene);
  139113. /**
  139114. * Returns the string "PointLight"
  139115. * @returns the class name
  139116. */
  139117. getClassName(): string;
  139118. /**
  139119. * Returns the integer 0.
  139120. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  139121. */
  139122. getTypeID(): number;
  139123. /**
  139124. * Specifies wether or not the shadowmap should be a cube texture.
  139125. * @returns true if the shadowmap needs to be a cube texture.
  139126. */
  139127. needCube(): boolean;
  139128. /**
  139129. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  139130. * @param faceIndex The index of the face we are computed the direction to generate shadow
  139131. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  139132. */
  139133. getShadowDirection(faceIndex?: number): Vector3;
  139134. /**
  139135. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  139136. * - fov = PI / 2
  139137. * - aspect ratio : 1.0
  139138. * - z-near and far equal to the active camera minZ and maxZ.
  139139. * Returns the PointLight.
  139140. */
  139141. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  139142. protected _buildUniformLayout(): void;
  139143. /**
  139144. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  139145. * @param effect The effect to update
  139146. * @param lightIndex The index of the light in the effect to update
  139147. * @returns The point light
  139148. */
  139149. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  139150. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  139151. /**
  139152. * Prepares the list of defines specific to the light type.
  139153. * @param defines the list of defines
  139154. * @param lightIndex defines the index of the light for the effect
  139155. */
  139156. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  139157. }
  139158. }
  139159. declare module BABYLON {
  139160. /**
  139161. * Header information of HDR texture files.
  139162. */
  139163. export interface HDRInfo {
  139164. /**
  139165. * The height of the texture in pixels.
  139166. */
  139167. height: number;
  139168. /**
  139169. * The width of the texture in pixels.
  139170. */
  139171. width: number;
  139172. /**
  139173. * The index of the beginning of the data in the binary file.
  139174. */
  139175. dataPosition: number;
  139176. }
  139177. /**
  139178. * This groups tools to convert HDR texture to native colors array.
  139179. */
  139180. export class HDRTools {
  139181. private static Ldexp;
  139182. private static Rgbe2float;
  139183. private static readStringLine;
  139184. /**
  139185. * Reads header information from an RGBE texture stored in a native array.
  139186. * More information on this format are available here:
  139187. * https://en.wikipedia.org/wiki/RGBE_image_format
  139188. *
  139189. * @param uint8array The binary file stored in native array.
  139190. * @return The header information.
  139191. */
  139192. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  139193. /**
  139194. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  139195. * This RGBE texture needs to store the information as a panorama.
  139196. *
  139197. * More information on this format are available here:
  139198. * https://en.wikipedia.org/wiki/RGBE_image_format
  139199. *
  139200. * @param buffer The binary file stored in an array buffer.
  139201. * @param size The expected size of the extracted cubemap.
  139202. * @return The Cube Map information.
  139203. */
  139204. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  139205. /**
  139206. * Returns the pixels data extracted from an RGBE texture.
  139207. * This pixels will be stored left to right up to down in the R G B order in one array.
  139208. *
  139209. * More information on this format are available here:
  139210. * https://en.wikipedia.org/wiki/RGBE_image_format
  139211. *
  139212. * @param uint8array The binary file stored in an array buffer.
  139213. * @param hdrInfo The header information of the file.
  139214. * @return The pixels data in RGB right to left up to down order.
  139215. */
  139216. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  139217. private static RGBE_ReadPixels_RLE;
  139218. private static RGBE_ReadPixels_NOT_RLE;
  139219. }
  139220. }
  139221. declare module BABYLON {
  139222. /**
  139223. * Effect Render Options
  139224. */
  139225. export interface IEffectRendererOptions {
  139226. /**
  139227. * Defines the vertices positions.
  139228. */
  139229. positions?: number[];
  139230. /**
  139231. * Defines the indices.
  139232. */
  139233. indices?: number[];
  139234. }
  139235. /**
  139236. * Helper class to render one or more effects.
  139237. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  139238. */
  139239. export class EffectRenderer {
  139240. private engine;
  139241. private static _DefaultOptions;
  139242. private _vertexBuffers;
  139243. private _indexBuffer;
  139244. private _fullscreenViewport;
  139245. /**
  139246. * Creates an effect renderer
  139247. * @param engine the engine to use for rendering
  139248. * @param options defines the options of the effect renderer
  139249. */
  139250. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  139251. /**
  139252. * Sets the current viewport in normalized coordinates 0-1
  139253. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  139254. */
  139255. setViewport(viewport?: Viewport): void;
  139256. /**
  139257. * Binds the embedded attributes buffer to the effect.
  139258. * @param effect Defines the effect to bind the attributes for
  139259. */
  139260. bindBuffers(effect: Effect): void;
  139261. /**
  139262. * Sets the current effect wrapper to use during draw.
  139263. * The effect needs to be ready before calling this api.
  139264. * This also sets the default full screen position attribute.
  139265. * @param effectWrapper Defines the effect to draw with
  139266. */
  139267. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  139268. /**
  139269. * Restores engine states
  139270. */
  139271. restoreStates(): void;
  139272. /**
  139273. * Draws a full screen quad.
  139274. */
  139275. draw(): void;
  139276. private isRenderTargetTexture;
  139277. /**
  139278. * renders one or more effects to a specified texture
  139279. * @param effectWrapper the effect to renderer
  139280. * @param outputTexture texture to draw to, if null it will render to the screen.
  139281. */
  139282. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  139283. /**
  139284. * Disposes of the effect renderer
  139285. */
  139286. dispose(): void;
  139287. }
  139288. /**
  139289. * Options to create an EffectWrapper
  139290. */
  139291. interface EffectWrapperCreationOptions {
  139292. /**
  139293. * Engine to use to create the effect
  139294. */
  139295. engine: ThinEngine;
  139296. /**
  139297. * Fragment shader for the effect
  139298. */
  139299. fragmentShader: string;
  139300. /**
  139301. * Use the shader store instead of direct source code
  139302. */
  139303. useShaderStore?: boolean;
  139304. /**
  139305. * Vertex shader for the effect
  139306. */
  139307. vertexShader?: string;
  139308. /**
  139309. * Attributes to use in the shader
  139310. */
  139311. attributeNames?: Array<string>;
  139312. /**
  139313. * Uniforms to use in the shader
  139314. */
  139315. uniformNames?: Array<string>;
  139316. /**
  139317. * Texture sampler names to use in the shader
  139318. */
  139319. samplerNames?: Array<string>;
  139320. /**
  139321. * Defines to use in the shader
  139322. */
  139323. defines?: Array<string>;
  139324. /**
  139325. * Callback when effect is compiled
  139326. */
  139327. onCompiled?: Nullable<(effect: Effect) => void>;
  139328. /**
  139329. * The friendly name of the effect displayed in Spector.
  139330. */
  139331. name?: string;
  139332. }
  139333. /**
  139334. * Wraps an effect to be used for rendering
  139335. */
  139336. export class EffectWrapper {
  139337. /**
  139338. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  139339. */
  139340. onApplyObservable: Observable<{}>;
  139341. /**
  139342. * The underlying effect
  139343. */
  139344. effect: Effect;
  139345. /**
  139346. * Creates an effect to be renderer
  139347. * @param creationOptions options to create the effect
  139348. */
  139349. constructor(creationOptions: EffectWrapperCreationOptions);
  139350. /**
  139351. * Disposes of the effect wrapper
  139352. */
  139353. dispose(): void;
  139354. }
  139355. }
  139356. declare module BABYLON {
  139357. /** @hidden */
  139358. export var hdrFilteringVertexShader: {
  139359. name: string;
  139360. shader: string;
  139361. };
  139362. }
  139363. declare module BABYLON {
  139364. /** @hidden */
  139365. export var hdrFilteringPixelShader: {
  139366. name: string;
  139367. shader: string;
  139368. };
  139369. }
  139370. declare module BABYLON {
  139371. /**
  139372. * Options for texture filtering
  139373. */
  139374. interface IHDRFilteringOptions {
  139375. /**
  139376. * Scales pixel intensity for the input HDR map.
  139377. */
  139378. hdrScale?: number;
  139379. /**
  139380. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  139381. */
  139382. quality?: number;
  139383. }
  139384. /**
  139385. * Filters HDR maps to get correct renderings of PBR reflections
  139386. */
  139387. export class HDRFiltering {
  139388. private _engine;
  139389. private _effectRenderer;
  139390. private _effectWrapper;
  139391. private _lodGenerationOffset;
  139392. private _lodGenerationScale;
  139393. /**
  139394. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  139395. * you care about baking speed.
  139396. */
  139397. quality: number;
  139398. /**
  139399. * Scales pixel intensity for the input HDR map.
  139400. */
  139401. hdrScale: number;
  139402. /**
  139403. * Instantiates HDR filter for reflection maps
  139404. *
  139405. * @param engine Thin engine
  139406. * @param options Options
  139407. */
  139408. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  139409. private _createRenderTarget;
  139410. private _prefilterInternal;
  139411. private _createEffect;
  139412. /**
  139413. * Get a value indicating if the filter is ready to be used
  139414. * @param texture Texture to filter
  139415. * @returns true if the filter is ready
  139416. */
  139417. isReady(texture: BaseTexture): boolean;
  139418. /**
  139419. * Prefilters a cube texture to have mipmap levels representing roughness values.
  139420. * Prefiltering will be invoked at the end of next rendering pass.
  139421. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  139422. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  139423. * @param texture Texture to filter
  139424. * @param onFinished Callback when filtering is done
  139425. * @return Promise called when prefiltering is done
  139426. */
  139427. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  139428. }
  139429. }
  139430. declare module BABYLON {
  139431. /**
  139432. * This represents a texture coming from an HDR input.
  139433. *
  139434. * The only supported format is currently panorama picture stored in RGBE format.
  139435. * Example of such files can be found on HDRLib: http://hdrlib.com/
  139436. */
  139437. export class HDRCubeTexture extends BaseTexture {
  139438. private static _facesMapping;
  139439. private _generateHarmonics;
  139440. private _noMipmap;
  139441. private _prefilterOnLoad;
  139442. private _textureMatrix;
  139443. private _size;
  139444. private _onLoad;
  139445. private _onError;
  139446. /**
  139447. * The texture URL.
  139448. */
  139449. url: string;
  139450. /**
  139451. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  139452. */
  139453. coordinatesMode: number;
  139454. protected _isBlocking: boolean;
  139455. /**
  139456. * Sets wether or not the texture is blocking during loading.
  139457. */
  139458. set isBlocking(value: boolean);
  139459. /**
  139460. * Gets wether or not the texture is blocking during loading.
  139461. */
  139462. get isBlocking(): boolean;
  139463. protected _rotationY: number;
  139464. /**
  139465. * Sets texture matrix rotation angle around Y axis in radians.
  139466. */
  139467. set rotationY(value: number);
  139468. /**
  139469. * Gets texture matrix rotation angle around Y axis radians.
  139470. */
  139471. get rotationY(): number;
  139472. /**
  139473. * Gets or sets the center of the bounding box associated with the cube texture
  139474. * It must define where the camera used to render the texture was set
  139475. */
  139476. boundingBoxPosition: Vector3;
  139477. private _boundingBoxSize;
  139478. /**
  139479. * Gets or sets the size of the bounding box associated with the cube texture
  139480. * When defined, the cubemap will switch to local mode
  139481. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  139482. * @example https://www.babylonjs-playground.com/#RNASML
  139483. */
  139484. set boundingBoxSize(value: Vector3);
  139485. get boundingBoxSize(): Vector3;
  139486. /**
  139487. * Instantiates an HDRTexture from the following parameters.
  139488. *
  139489. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  139490. * @param sceneOrEngine The scene or engine the texture will be used in
  139491. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  139492. * @param noMipmap Forces to not generate the mipmap if true
  139493. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  139494. * @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)
  139495. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  139496. */
  139497. 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>);
  139498. /**
  139499. * Get the current class name of the texture useful for serialization or dynamic coding.
  139500. * @returns "HDRCubeTexture"
  139501. */
  139502. getClassName(): string;
  139503. /**
  139504. * Occurs when the file is raw .hdr file.
  139505. */
  139506. private loadTexture;
  139507. clone(): HDRCubeTexture;
  139508. delayLoad(): void;
  139509. /**
  139510. * Get the texture reflection matrix used to rotate/transform the reflection.
  139511. * @returns the reflection matrix
  139512. */
  139513. getReflectionTextureMatrix(): Matrix;
  139514. /**
  139515. * Set the texture reflection matrix used to rotate/transform the reflection.
  139516. * @param value Define the reflection matrix to set
  139517. */
  139518. setReflectionTextureMatrix(value: Matrix): void;
  139519. /**
  139520. * Parses a JSON representation of an HDR Texture in order to create the texture
  139521. * @param parsedTexture Define the JSON representation
  139522. * @param scene Define the scene the texture should be created in
  139523. * @param rootUrl Define the root url in case we need to load relative dependencies
  139524. * @returns the newly created texture after parsing
  139525. */
  139526. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  139527. serialize(): any;
  139528. }
  139529. }
  139530. declare module BABYLON {
  139531. /**
  139532. * Class used to control physics engine
  139533. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  139534. */
  139535. export class PhysicsEngine implements IPhysicsEngine {
  139536. private _physicsPlugin;
  139537. /**
  139538. * Global value used to control the smallest number supported by the simulation
  139539. */
  139540. static Epsilon: number;
  139541. private _impostors;
  139542. private _joints;
  139543. private _subTimeStep;
  139544. /**
  139545. * Gets the gravity vector used by the simulation
  139546. */
  139547. gravity: Vector3;
  139548. /**
  139549. * Factory used to create the default physics plugin.
  139550. * @returns The default physics plugin
  139551. */
  139552. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  139553. /**
  139554. * Creates a new Physics Engine
  139555. * @param gravity defines the gravity vector used by the simulation
  139556. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  139557. */
  139558. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  139559. /**
  139560. * Sets the gravity vector used by the simulation
  139561. * @param gravity defines the gravity vector to use
  139562. */
  139563. setGravity(gravity: Vector3): void;
  139564. /**
  139565. * Set the time step of the physics engine.
  139566. * Default is 1/60.
  139567. * To slow it down, enter 1/600 for example.
  139568. * To speed it up, 1/30
  139569. * @param newTimeStep defines the new timestep to apply to this world.
  139570. */
  139571. setTimeStep(newTimeStep?: number): void;
  139572. /**
  139573. * Get the time step of the physics engine.
  139574. * @returns the current time step
  139575. */
  139576. getTimeStep(): number;
  139577. /**
  139578. * Set the sub time step of the physics engine.
  139579. * Default is 0 meaning there is no sub steps
  139580. * To increase physics resolution precision, set a small value (like 1 ms)
  139581. * @param subTimeStep defines the new sub timestep used for physics resolution.
  139582. */
  139583. setSubTimeStep(subTimeStep?: number): void;
  139584. /**
  139585. * Get the sub time step of the physics engine.
  139586. * @returns the current sub time step
  139587. */
  139588. getSubTimeStep(): number;
  139589. /**
  139590. * Release all resources
  139591. */
  139592. dispose(): void;
  139593. /**
  139594. * Gets the name of the current physics plugin
  139595. * @returns the name of the plugin
  139596. */
  139597. getPhysicsPluginName(): string;
  139598. /**
  139599. * Adding a new impostor for the impostor tracking.
  139600. * This will be done by the impostor itself.
  139601. * @param impostor the impostor to add
  139602. */
  139603. addImpostor(impostor: PhysicsImpostor): void;
  139604. /**
  139605. * Remove an impostor from the engine.
  139606. * This impostor and its mesh will not longer be updated by the physics engine.
  139607. * @param impostor the impostor to remove
  139608. */
  139609. removeImpostor(impostor: PhysicsImpostor): void;
  139610. /**
  139611. * Add a joint to the physics engine
  139612. * @param mainImpostor defines the main impostor to which the joint is added.
  139613. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  139614. * @param joint defines the joint that will connect both impostors.
  139615. */
  139616. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  139617. /**
  139618. * Removes a joint from the simulation
  139619. * @param mainImpostor defines the impostor used with the joint
  139620. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  139621. * @param joint defines the joint to remove
  139622. */
  139623. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  139624. /**
  139625. * Called by the scene. No need to call it.
  139626. * @param delta defines the timespam between frames
  139627. */
  139628. _step(delta: number): void;
  139629. /**
  139630. * Gets the current plugin used to run the simulation
  139631. * @returns current plugin
  139632. */
  139633. getPhysicsPlugin(): IPhysicsEnginePlugin;
  139634. /**
  139635. * Gets the list of physic impostors
  139636. * @returns an array of PhysicsImpostor
  139637. */
  139638. getImpostors(): Array<PhysicsImpostor>;
  139639. /**
  139640. * Gets the impostor for a physics enabled object
  139641. * @param object defines the object impersonated by the impostor
  139642. * @returns the PhysicsImpostor or null if not found
  139643. */
  139644. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  139645. /**
  139646. * Gets the impostor for a physics body object
  139647. * @param body defines physics body used by the impostor
  139648. * @returns the PhysicsImpostor or null if not found
  139649. */
  139650. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  139651. /**
  139652. * Does a raycast in the physics world
  139653. * @param from when should the ray start?
  139654. * @param to when should the ray end?
  139655. * @returns PhysicsRaycastResult
  139656. */
  139657. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  139658. }
  139659. }
  139660. declare module BABYLON {
  139661. /** @hidden */
  139662. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  139663. private _useDeltaForWorldStep;
  139664. world: any;
  139665. name: string;
  139666. private _physicsMaterials;
  139667. private _fixedTimeStep;
  139668. private _cannonRaycastResult;
  139669. private _raycastResult;
  139670. private _physicsBodysToRemoveAfterStep;
  139671. private _firstFrame;
  139672. BJSCANNON: any;
  139673. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  139674. setGravity(gravity: Vector3): void;
  139675. setTimeStep(timeStep: number): void;
  139676. getTimeStep(): number;
  139677. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  139678. private _removeMarkedPhysicsBodiesFromWorld;
  139679. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  139680. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  139681. generatePhysicsBody(impostor: PhysicsImpostor): void;
  139682. private _processChildMeshes;
  139683. removePhysicsBody(impostor: PhysicsImpostor): void;
  139684. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  139685. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  139686. private _addMaterial;
  139687. private _checkWithEpsilon;
  139688. private _createShape;
  139689. private _createHeightmap;
  139690. private _minus90X;
  139691. private _plus90X;
  139692. private _tmpPosition;
  139693. private _tmpDeltaPosition;
  139694. private _tmpUnityRotation;
  139695. private _updatePhysicsBodyTransformation;
  139696. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  139697. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  139698. isSupported(): boolean;
  139699. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  139700. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  139701. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  139702. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  139703. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  139704. getBodyMass(impostor: PhysicsImpostor): number;
  139705. getBodyFriction(impostor: PhysicsImpostor): number;
  139706. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  139707. getBodyRestitution(impostor: PhysicsImpostor): number;
  139708. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  139709. sleepBody(impostor: PhysicsImpostor): void;
  139710. wakeUpBody(impostor: PhysicsImpostor): void;
  139711. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  139712. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  139713. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  139714. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  139715. getRadius(impostor: PhysicsImpostor): number;
  139716. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  139717. dispose(): void;
  139718. private _extendNamespace;
  139719. /**
  139720. * Does a raycast in the physics world
  139721. * @param from when should the ray start?
  139722. * @param to when should the ray end?
  139723. * @returns PhysicsRaycastResult
  139724. */
  139725. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  139726. }
  139727. }
  139728. declare module BABYLON {
  139729. /** @hidden */
  139730. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  139731. private _useDeltaForWorldStep;
  139732. world: any;
  139733. name: string;
  139734. BJSOIMO: any;
  139735. private _raycastResult;
  139736. private _fixedTimeStep;
  139737. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  139738. setGravity(gravity: Vector3): void;
  139739. setTimeStep(timeStep: number): void;
  139740. getTimeStep(): number;
  139741. private _tmpImpostorsArray;
  139742. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  139743. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  139744. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  139745. generatePhysicsBody(impostor: PhysicsImpostor): void;
  139746. private _tmpPositionVector;
  139747. removePhysicsBody(impostor: PhysicsImpostor): void;
  139748. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  139749. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  139750. isSupported(): boolean;
  139751. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  139752. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  139753. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  139754. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  139755. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  139756. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  139757. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  139758. getBodyMass(impostor: PhysicsImpostor): number;
  139759. getBodyFriction(impostor: PhysicsImpostor): number;
  139760. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  139761. getBodyRestitution(impostor: PhysicsImpostor): number;
  139762. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  139763. sleepBody(impostor: PhysicsImpostor): void;
  139764. wakeUpBody(impostor: PhysicsImpostor): void;
  139765. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  139766. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  139767. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  139768. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  139769. getRadius(impostor: PhysicsImpostor): number;
  139770. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  139771. dispose(): void;
  139772. /**
  139773. * Does a raycast in the physics world
  139774. * @param from when should the ray start?
  139775. * @param to when should the ray end?
  139776. * @returns PhysicsRaycastResult
  139777. */
  139778. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  139779. }
  139780. }
  139781. declare module BABYLON {
  139782. /**
  139783. * AmmoJS Physics plugin
  139784. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  139785. * @see https://github.com/kripken/ammo.js/
  139786. */
  139787. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  139788. private _useDeltaForWorldStep;
  139789. /**
  139790. * Reference to the Ammo library
  139791. */
  139792. bjsAMMO: any;
  139793. /**
  139794. * Created ammoJS world which physics bodies are added to
  139795. */
  139796. world: any;
  139797. /**
  139798. * Name of the plugin
  139799. */
  139800. name: string;
  139801. private _timeStep;
  139802. private _fixedTimeStep;
  139803. private _maxSteps;
  139804. private _tmpQuaternion;
  139805. private _tmpAmmoTransform;
  139806. private _tmpAmmoQuaternion;
  139807. private _tmpAmmoConcreteContactResultCallback;
  139808. private _collisionConfiguration;
  139809. private _dispatcher;
  139810. private _overlappingPairCache;
  139811. private _solver;
  139812. private _softBodySolver;
  139813. private _tmpAmmoVectorA;
  139814. private _tmpAmmoVectorB;
  139815. private _tmpAmmoVectorC;
  139816. private _tmpAmmoVectorD;
  139817. private _tmpContactCallbackResult;
  139818. private _tmpAmmoVectorRCA;
  139819. private _tmpAmmoVectorRCB;
  139820. private _raycastResult;
  139821. private static readonly DISABLE_COLLISION_FLAG;
  139822. private static readonly KINEMATIC_FLAG;
  139823. private static readonly DISABLE_DEACTIVATION_FLAG;
  139824. /**
  139825. * Initializes the ammoJS plugin
  139826. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  139827. * @param ammoInjection can be used to inject your own ammo reference
  139828. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  139829. */
  139830. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  139831. /**
  139832. * Sets the gravity of the physics world (m/(s^2))
  139833. * @param gravity Gravity to set
  139834. */
  139835. setGravity(gravity: Vector3): void;
  139836. /**
  139837. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  139838. * @param timeStep timestep to use in seconds
  139839. */
  139840. setTimeStep(timeStep: number): void;
  139841. /**
  139842. * 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)
  139843. * @param fixedTimeStep fixedTimeStep to use in seconds
  139844. */
  139845. setFixedTimeStep(fixedTimeStep: number): void;
  139846. /**
  139847. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  139848. * @param maxSteps the maximum number of steps by the physics engine per frame
  139849. */
  139850. setMaxSteps(maxSteps: number): void;
  139851. /**
  139852. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  139853. * @returns the current timestep in seconds
  139854. */
  139855. getTimeStep(): number;
  139856. /**
  139857. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  139858. */
  139859. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  139860. private _isImpostorInContact;
  139861. private _isImpostorPairInContact;
  139862. private _stepSimulation;
  139863. /**
  139864. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  139865. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  139866. * After the step the babylon meshes are set to the position of the physics imposters
  139867. * @param delta amount of time to step forward
  139868. * @param impostors array of imposters to update before/after the step
  139869. */
  139870. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  139871. /**
  139872. * Update babylon mesh to match physics world object
  139873. * @param impostor imposter to match
  139874. */
  139875. private _afterSoftStep;
  139876. /**
  139877. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  139878. * @param impostor imposter to match
  139879. */
  139880. private _ropeStep;
  139881. /**
  139882. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  139883. * @param impostor imposter to match
  139884. */
  139885. private _softbodyOrClothStep;
  139886. private _tmpMatrix;
  139887. /**
  139888. * Applies an impulse on the imposter
  139889. * @param impostor imposter to apply impulse to
  139890. * @param force amount of force to be applied to the imposter
  139891. * @param contactPoint the location to apply the impulse on the imposter
  139892. */
  139893. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  139894. /**
  139895. * Applies a force on the imposter
  139896. * @param impostor imposter to apply force
  139897. * @param force amount of force to be applied to the imposter
  139898. * @param contactPoint the location to apply the force on the imposter
  139899. */
  139900. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  139901. /**
  139902. * Creates a physics body using the plugin
  139903. * @param impostor the imposter to create the physics body on
  139904. */
  139905. generatePhysicsBody(impostor: PhysicsImpostor): void;
  139906. /**
  139907. * Removes the physics body from the imposter and disposes of the body's memory
  139908. * @param impostor imposter to remove the physics body from
  139909. */
  139910. removePhysicsBody(impostor: PhysicsImpostor): void;
  139911. /**
  139912. * Generates a joint
  139913. * @param impostorJoint the imposter joint to create the joint with
  139914. */
  139915. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  139916. /**
  139917. * Removes a joint
  139918. * @param impostorJoint the imposter joint to remove the joint from
  139919. */
  139920. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  139921. private _addMeshVerts;
  139922. /**
  139923. * Initialise the soft body vertices to match its object's (mesh) vertices
  139924. * Softbody vertices (nodes) are in world space and to match this
  139925. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  139926. * @param impostor to create the softbody for
  139927. */
  139928. private _softVertexData;
  139929. /**
  139930. * Create an impostor's soft body
  139931. * @param impostor to create the softbody for
  139932. */
  139933. private _createSoftbody;
  139934. /**
  139935. * Create cloth for an impostor
  139936. * @param impostor to create the softbody for
  139937. */
  139938. private _createCloth;
  139939. /**
  139940. * Create rope for an impostor
  139941. * @param impostor to create the softbody for
  139942. */
  139943. private _createRope;
  139944. /**
  139945. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  139946. * @param impostor to create the custom physics shape for
  139947. */
  139948. private _createCustom;
  139949. private _addHullVerts;
  139950. private _createShape;
  139951. /**
  139952. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  139953. * @param impostor imposter containing the physics body and babylon object
  139954. */
  139955. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  139956. /**
  139957. * Sets the babylon object's position/rotation from the physics body's position/rotation
  139958. * @param impostor imposter containing the physics body and babylon object
  139959. * @param newPosition new position
  139960. * @param newRotation new rotation
  139961. */
  139962. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  139963. /**
  139964. * If this plugin is supported
  139965. * @returns true if its supported
  139966. */
  139967. isSupported(): boolean;
  139968. /**
  139969. * Sets the linear velocity of the physics body
  139970. * @param impostor imposter to set the velocity on
  139971. * @param velocity velocity to set
  139972. */
  139973. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  139974. /**
  139975. * Sets the angular velocity of the physics body
  139976. * @param impostor imposter to set the velocity on
  139977. * @param velocity velocity to set
  139978. */
  139979. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  139980. /**
  139981. * gets the linear velocity
  139982. * @param impostor imposter to get linear velocity from
  139983. * @returns linear velocity
  139984. */
  139985. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  139986. /**
  139987. * gets the angular velocity
  139988. * @param impostor imposter to get angular velocity from
  139989. * @returns angular velocity
  139990. */
  139991. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  139992. /**
  139993. * Sets the mass of physics body
  139994. * @param impostor imposter to set the mass on
  139995. * @param mass mass to set
  139996. */
  139997. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  139998. /**
  139999. * Gets the mass of the physics body
  140000. * @param impostor imposter to get the mass from
  140001. * @returns mass
  140002. */
  140003. getBodyMass(impostor: PhysicsImpostor): number;
  140004. /**
  140005. * Gets friction of the impostor
  140006. * @param impostor impostor to get friction from
  140007. * @returns friction value
  140008. */
  140009. getBodyFriction(impostor: PhysicsImpostor): number;
  140010. /**
  140011. * Sets friction of the impostor
  140012. * @param impostor impostor to set friction on
  140013. * @param friction friction value
  140014. */
  140015. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  140016. /**
  140017. * Gets restitution of the impostor
  140018. * @param impostor impostor to get restitution from
  140019. * @returns restitution value
  140020. */
  140021. getBodyRestitution(impostor: PhysicsImpostor): number;
  140022. /**
  140023. * Sets resitution of the impostor
  140024. * @param impostor impostor to set resitution on
  140025. * @param restitution resitution value
  140026. */
  140027. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  140028. /**
  140029. * Gets pressure inside the impostor
  140030. * @param impostor impostor to get pressure from
  140031. * @returns pressure value
  140032. */
  140033. getBodyPressure(impostor: PhysicsImpostor): number;
  140034. /**
  140035. * Sets pressure inside a soft body impostor
  140036. * Cloth and rope must remain 0 pressure
  140037. * @param impostor impostor to set pressure on
  140038. * @param pressure pressure value
  140039. */
  140040. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  140041. /**
  140042. * Gets stiffness of the impostor
  140043. * @param impostor impostor to get stiffness from
  140044. * @returns pressure value
  140045. */
  140046. getBodyStiffness(impostor: PhysicsImpostor): number;
  140047. /**
  140048. * Sets stiffness of the impostor
  140049. * @param impostor impostor to set stiffness on
  140050. * @param stiffness stiffness value from 0 to 1
  140051. */
  140052. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  140053. /**
  140054. * Gets velocityIterations of the impostor
  140055. * @param impostor impostor to get velocity iterations from
  140056. * @returns velocityIterations value
  140057. */
  140058. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  140059. /**
  140060. * Sets velocityIterations of the impostor
  140061. * @param impostor impostor to set velocity iterations on
  140062. * @param velocityIterations velocityIterations value
  140063. */
  140064. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  140065. /**
  140066. * Gets positionIterations of the impostor
  140067. * @param impostor impostor to get position iterations from
  140068. * @returns positionIterations value
  140069. */
  140070. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  140071. /**
  140072. * Sets positionIterations of the impostor
  140073. * @param impostor impostor to set position on
  140074. * @param positionIterations positionIterations value
  140075. */
  140076. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  140077. /**
  140078. * Append an anchor to a cloth object
  140079. * @param impostor is the cloth impostor to add anchor to
  140080. * @param otherImpostor is the rigid impostor to anchor to
  140081. * @param width ratio across width from 0 to 1
  140082. * @param height ratio up height from 0 to 1
  140083. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  140084. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  140085. */
  140086. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  140087. /**
  140088. * Append an hook to a rope object
  140089. * @param impostor is the rope impostor to add hook to
  140090. * @param otherImpostor is the rigid impostor to hook to
  140091. * @param length ratio along the rope from 0 to 1
  140092. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  140093. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  140094. */
  140095. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  140096. /**
  140097. * Sleeps the physics body and stops it from being active
  140098. * @param impostor impostor to sleep
  140099. */
  140100. sleepBody(impostor: PhysicsImpostor): void;
  140101. /**
  140102. * Activates the physics body
  140103. * @param impostor impostor to activate
  140104. */
  140105. wakeUpBody(impostor: PhysicsImpostor): void;
  140106. /**
  140107. * Updates the distance parameters of the joint
  140108. * @param joint joint to update
  140109. * @param maxDistance maximum distance of the joint
  140110. * @param minDistance minimum distance of the joint
  140111. */
  140112. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  140113. /**
  140114. * Sets a motor on the joint
  140115. * @param joint joint to set motor on
  140116. * @param speed speed of the motor
  140117. * @param maxForce maximum force of the motor
  140118. * @param motorIndex index of the motor
  140119. */
  140120. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  140121. /**
  140122. * Sets the motors limit
  140123. * @param joint joint to set limit on
  140124. * @param upperLimit upper limit
  140125. * @param lowerLimit lower limit
  140126. */
  140127. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  140128. /**
  140129. * Syncs the position and rotation of a mesh with the impostor
  140130. * @param mesh mesh to sync
  140131. * @param impostor impostor to update the mesh with
  140132. */
  140133. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  140134. /**
  140135. * Gets the radius of the impostor
  140136. * @param impostor impostor to get radius from
  140137. * @returns the radius
  140138. */
  140139. getRadius(impostor: PhysicsImpostor): number;
  140140. /**
  140141. * Gets the box size of the impostor
  140142. * @param impostor impostor to get box size from
  140143. * @param result the resulting box size
  140144. */
  140145. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  140146. /**
  140147. * Disposes of the impostor
  140148. */
  140149. dispose(): void;
  140150. /**
  140151. * Does a raycast in the physics world
  140152. * @param from when should the ray start?
  140153. * @param to when should the ray end?
  140154. * @returns PhysicsRaycastResult
  140155. */
  140156. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  140157. }
  140158. }
  140159. declare module BABYLON {
  140160. interface AbstractScene {
  140161. /**
  140162. * The list of reflection probes added to the scene
  140163. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  140164. */
  140165. reflectionProbes: Array<ReflectionProbe>;
  140166. /**
  140167. * Removes the given reflection probe from this scene.
  140168. * @param toRemove The reflection probe to remove
  140169. * @returns The index of the removed reflection probe
  140170. */
  140171. removeReflectionProbe(toRemove: ReflectionProbe): number;
  140172. /**
  140173. * Adds the given reflection probe to this scene.
  140174. * @param newReflectionProbe The reflection probe to add
  140175. */
  140176. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  140177. }
  140178. /**
  140179. * Class used to generate realtime reflection / refraction cube textures
  140180. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  140181. */
  140182. export class ReflectionProbe {
  140183. /** defines the name of the probe */
  140184. name: string;
  140185. private _scene;
  140186. private _renderTargetTexture;
  140187. private _projectionMatrix;
  140188. private _viewMatrix;
  140189. private _target;
  140190. private _add;
  140191. private _attachedMesh;
  140192. private _invertYAxis;
  140193. /** Gets or sets probe position (center of the cube map) */
  140194. position: Vector3;
  140195. /**
  140196. * Creates a new reflection probe
  140197. * @param name defines the name of the probe
  140198. * @param size defines the texture resolution (for each face)
  140199. * @param scene defines the hosting scene
  140200. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  140201. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  140202. */
  140203. constructor(
  140204. /** defines the name of the probe */
  140205. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  140206. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  140207. get samples(): number;
  140208. set samples(value: number);
  140209. /** Gets or sets the refresh rate to use (on every frame by default) */
  140210. get refreshRate(): number;
  140211. set refreshRate(value: number);
  140212. /**
  140213. * Gets the hosting scene
  140214. * @returns a Scene
  140215. */
  140216. getScene(): Scene;
  140217. /** Gets the internal CubeTexture used to render to */
  140218. get cubeTexture(): RenderTargetTexture;
  140219. /** Gets the list of meshes to render */
  140220. get renderList(): Nullable<AbstractMesh[]>;
  140221. /**
  140222. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  140223. * @param mesh defines the mesh to attach to
  140224. */
  140225. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  140226. /**
  140227. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  140228. * @param renderingGroupId The rendering group id corresponding to its index
  140229. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  140230. */
  140231. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  140232. /**
  140233. * Clean all associated resources
  140234. */
  140235. dispose(): void;
  140236. /**
  140237. * Converts the reflection probe information to a readable string for debug purpose.
  140238. * @param fullDetails Supports for multiple levels of logging within scene loading
  140239. * @returns the human readable reflection probe info
  140240. */
  140241. toString(fullDetails?: boolean): string;
  140242. /**
  140243. * Get the class name of the relfection probe.
  140244. * @returns "ReflectionProbe"
  140245. */
  140246. getClassName(): string;
  140247. /**
  140248. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  140249. * @returns The JSON representation of the texture
  140250. */
  140251. serialize(): any;
  140252. /**
  140253. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  140254. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  140255. * @param scene Define the scene the parsed reflection probe should be instantiated in
  140256. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  140257. * @returns The parsed reflection probe if successful
  140258. */
  140259. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  140260. }
  140261. }
  140262. declare module BABYLON {
  140263. /** @hidden */
  140264. export var _BabylonLoaderRegistered: boolean;
  140265. /**
  140266. * Helps setting up some configuration for the babylon file loader.
  140267. */
  140268. export class BabylonFileLoaderConfiguration {
  140269. /**
  140270. * The loader does not allow injecting custom physix engine into the plugins.
  140271. * Unfortunately in ES6, we need to manually inject them into the plugin.
  140272. * So you could set this variable to your engine import to make it work.
  140273. */
  140274. static LoaderInjectedPhysicsEngine: any;
  140275. }
  140276. }
  140277. declare module BABYLON {
  140278. /**
  140279. * The Physically based simple base material of BJS.
  140280. *
  140281. * This enables better naming and convention enforcements on top of the pbrMaterial.
  140282. * It is used as the base class for both the specGloss and metalRough conventions.
  140283. */
  140284. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  140285. /**
  140286. * Number of Simultaneous lights allowed on the material.
  140287. */
  140288. maxSimultaneousLights: number;
  140289. /**
  140290. * If sets to true, disables all the lights affecting the material.
  140291. */
  140292. disableLighting: boolean;
  140293. /**
  140294. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  140295. */
  140296. environmentTexture: BaseTexture;
  140297. /**
  140298. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  140299. */
  140300. invertNormalMapX: boolean;
  140301. /**
  140302. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  140303. */
  140304. invertNormalMapY: boolean;
  140305. /**
  140306. * Normal map used in the model.
  140307. */
  140308. normalTexture: BaseTexture;
  140309. /**
  140310. * Emissivie color used to self-illuminate the model.
  140311. */
  140312. emissiveColor: Color3;
  140313. /**
  140314. * Emissivie texture used to self-illuminate the model.
  140315. */
  140316. emissiveTexture: BaseTexture;
  140317. /**
  140318. * Occlusion Channel Strenght.
  140319. */
  140320. occlusionStrength: number;
  140321. /**
  140322. * Occlusion Texture of the material (adding extra occlusion effects).
  140323. */
  140324. occlusionTexture: BaseTexture;
  140325. /**
  140326. * Defines the alpha limits in alpha test mode.
  140327. */
  140328. alphaCutOff: number;
  140329. /**
  140330. * Gets the current double sided mode.
  140331. */
  140332. get doubleSided(): boolean;
  140333. /**
  140334. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  140335. */
  140336. set doubleSided(value: boolean);
  140337. /**
  140338. * Stores the pre-calculated light information of a mesh in a texture.
  140339. */
  140340. lightmapTexture: BaseTexture;
  140341. /**
  140342. * If true, the light map contains occlusion information instead of lighting info.
  140343. */
  140344. useLightmapAsShadowmap: boolean;
  140345. /**
  140346. * Instantiates a new PBRMaterial instance.
  140347. *
  140348. * @param name The material name
  140349. * @param scene The scene the material will be use in.
  140350. */
  140351. constructor(name: string, scene: Scene);
  140352. getClassName(): string;
  140353. }
  140354. }
  140355. declare module BABYLON {
  140356. /**
  140357. * The PBR material of BJS following the metal roughness convention.
  140358. *
  140359. * This fits to the PBR convention in the GLTF definition:
  140360. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  140361. */
  140362. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  140363. /**
  140364. * The base color has two different interpretations depending on the value of metalness.
  140365. * When the material is a metal, the base color is the specific measured reflectance value
  140366. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  140367. * of the material.
  140368. */
  140369. baseColor: Color3;
  140370. /**
  140371. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  140372. * well as opacity information in the alpha channel.
  140373. */
  140374. baseTexture: BaseTexture;
  140375. /**
  140376. * Specifies the metallic scalar value of the material.
  140377. * Can also be used to scale the metalness values of the metallic texture.
  140378. */
  140379. metallic: number;
  140380. /**
  140381. * Specifies the roughness scalar value of the material.
  140382. * Can also be used to scale the roughness values of the metallic texture.
  140383. */
  140384. roughness: number;
  140385. /**
  140386. * Texture containing both the metallic value in the B channel and the
  140387. * roughness value in the G channel to keep better precision.
  140388. */
  140389. metallicRoughnessTexture: BaseTexture;
  140390. /**
  140391. * Instantiates a new PBRMetalRoughnessMaterial instance.
  140392. *
  140393. * @param name The material name
  140394. * @param scene The scene the material will be use in.
  140395. */
  140396. constructor(name: string, scene: Scene);
  140397. /**
  140398. * Return the currrent class name of the material.
  140399. */
  140400. getClassName(): string;
  140401. /**
  140402. * Makes a duplicate of the current material.
  140403. * @param name - name to use for the new material.
  140404. */
  140405. clone(name: string): PBRMetallicRoughnessMaterial;
  140406. /**
  140407. * Serialize the material to a parsable JSON object.
  140408. */
  140409. serialize(): any;
  140410. /**
  140411. * Parses a JSON object correponding to the serialize function.
  140412. */
  140413. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  140414. }
  140415. }
  140416. declare module BABYLON {
  140417. /**
  140418. * The PBR material of BJS following the specular glossiness convention.
  140419. *
  140420. * This fits to the PBR convention in the GLTF definition:
  140421. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  140422. */
  140423. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  140424. /**
  140425. * Specifies the diffuse color of the material.
  140426. */
  140427. diffuseColor: Color3;
  140428. /**
  140429. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  140430. * channel.
  140431. */
  140432. diffuseTexture: BaseTexture;
  140433. /**
  140434. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  140435. */
  140436. specularColor: Color3;
  140437. /**
  140438. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  140439. */
  140440. glossiness: number;
  140441. /**
  140442. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  140443. */
  140444. specularGlossinessTexture: BaseTexture;
  140445. /**
  140446. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  140447. *
  140448. * @param name The material name
  140449. * @param scene The scene the material will be use in.
  140450. */
  140451. constructor(name: string, scene: Scene);
  140452. /**
  140453. * Return the currrent class name of the material.
  140454. */
  140455. getClassName(): string;
  140456. /**
  140457. * Makes a duplicate of the current material.
  140458. * @param name - name to use for the new material.
  140459. */
  140460. clone(name: string): PBRSpecularGlossinessMaterial;
  140461. /**
  140462. * Serialize the material to a parsable JSON object.
  140463. */
  140464. serialize(): any;
  140465. /**
  140466. * Parses a JSON object correponding to the serialize function.
  140467. */
  140468. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  140469. }
  140470. }
  140471. declare module BABYLON {
  140472. /**
  140473. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  140474. * It can help converting any input color in a desired output one. This can then be used to create effects
  140475. * from sepia, black and white to sixties or futuristic rendering...
  140476. *
  140477. * The only supported format is currently 3dl.
  140478. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  140479. */
  140480. export class ColorGradingTexture extends BaseTexture {
  140481. /**
  140482. * The texture URL.
  140483. */
  140484. url: string;
  140485. /**
  140486. * Empty line regex stored for GC.
  140487. */
  140488. private static _noneEmptyLineRegex;
  140489. private _textureMatrix;
  140490. private _onLoad;
  140491. /**
  140492. * Instantiates a ColorGradingTexture from the following parameters.
  140493. *
  140494. * @param url The location of the color gradind data (currently only supporting 3dl)
  140495. * @param sceneOrEngine The scene or engine the texture will be used in
  140496. * @param onLoad defines a callback triggered when the texture has been loaded
  140497. */
  140498. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  140499. /**
  140500. * Fires the onload event from the constructor if requested.
  140501. */
  140502. private _triggerOnLoad;
  140503. /**
  140504. * Returns the texture matrix used in most of the material.
  140505. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  140506. */
  140507. getTextureMatrix(): Matrix;
  140508. /**
  140509. * Occurs when the file being loaded is a .3dl LUT file.
  140510. */
  140511. private load3dlTexture;
  140512. /**
  140513. * Starts the loading process of the texture.
  140514. */
  140515. private loadTexture;
  140516. /**
  140517. * Clones the color gradind texture.
  140518. */
  140519. clone(): ColorGradingTexture;
  140520. /**
  140521. * Called during delayed load for textures.
  140522. */
  140523. delayLoad(): void;
  140524. /**
  140525. * Parses a color grading texture serialized by Babylon.
  140526. * @param parsedTexture The texture information being parsedTexture
  140527. * @param scene The scene to load the texture in
  140528. * @param rootUrl The root url of the data assets to load
  140529. * @return A color gradind texture
  140530. */
  140531. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  140532. /**
  140533. * Serializes the LUT texture to json format.
  140534. */
  140535. serialize(): any;
  140536. }
  140537. }
  140538. declare module BABYLON {
  140539. /**
  140540. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  140541. */
  140542. export class EquiRectangularCubeTexture extends BaseTexture {
  140543. /** The six faces of the cube. */
  140544. private static _FacesMapping;
  140545. private _noMipmap;
  140546. private _onLoad;
  140547. private _onError;
  140548. /** The size of the cubemap. */
  140549. private _size;
  140550. /** The buffer of the image. */
  140551. private _buffer;
  140552. /** The width of the input image. */
  140553. private _width;
  140554. /** The height of the input image. */
  140555. private _height;
  140556. /** The URL to the image. */
  140557. url: string;
  140558. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  140559. coordinatesMode: number;
  140560. /**
  140561. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  140562. * @param url The location of the image
  140563. * @param scene The scene the texture will be used in
  140564. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  140565. * @param noMipmap Forces to not generate the mipmap if true
  140566. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  140567. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  140568. * @param onLoad — defines a callback called when texture is loaded
  140569. * @param onError — defines a callback called if there is an error
  140570. */
  140571. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  140572. /**
  140573. * Load the image data, by putting the image on a canvas and extracting its buffer.
  140574. */
  140575. private loadImage;
  140576. /**
  140577. * Convert the image buffer into a cubemap and create a CubeTexture.
  140578. */
  140579. private loadTexture;
  140580. /**
  140581. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  140582. * @param buffer The ArrayBuffer that should be converted.
  140583. * @returns The buffer as Float32Array.
  140584. */
  140585. private getFloat32ArrayFromArrayBuffer;
  140586. /**
  140587. * Get the current class name of the texture useful for serialization or dynamic coding.
  140588. * @returns "EquiRectangularCubeTexture"
  140589. */
  140590. getClassName(): string;
  140591. /**
  140592. * Create a clone of the current EquiRectangularCubeTexture and return it.
  140593. * @returns A clone of the current EquiRectangularCubeTexture.
  140594. */
  140595. clone(): EquiRectangularCubeTexture;
  140596. }
  140597. }
  140598. declare module BABYLON {
  140599. /**
  140600. * Defines the options related to the creation of an HtmlElementTexture
  140601. */
  140602. export interface IHtmlElementTextureOptions {
  140603. /**
  140604. * Defines wether mip maps should be created or not.
  140605. */
  140606. generateMipMaps?: boolean;
  140607. /**
  140608. * Defines the sampling mode of the texture.
  140609. */
  140610. samplingMode?: number;
  140611. /**
  140612. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  140613. */
  140614. engine: Nullable<ThinEngine>;
  140615. /**
  140616. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  140617. */
  140618. scene: Nullable<Scene>;
  140619. }
  140620. /**
  140621. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  140622. * To be as efficient as possible depending on your constraints nothing aside the first upload
  140623. * is automatically managed.
  140624. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  140625. * in your application.
  140626. *
  140627. * As the update is not automatic, you need to call them manually.
  140628. */
  140629. export class HtmlElementTexture extends BaseTexture {
  140630. /**
  140631. * The texture URL.
  140632. */
  140633. element: HTMLVideoElement | HTMLCanvasElement;
  140634. private static readonly DefaultOptions;
  140635. private _textureMatrix;
  140636. private _isVideo;
  140637. private _generateMipMaps;
  140638. private _samplingMode;
  140639. /**
  140640. * Instantiates a HtmlElementTexture from the following parameters.
  140641. *
  140642. * @param name Defines the name of the texture
  140643. * @param element Defines the video or canvas the texture is filled with
  140644. * @param options Defines the other none mandatory texture creation options
  140645. */
  140646. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  140647. private _createInternalTexture;
  140648. /**
  140649. * Returns the texture matrix used in most of the material.
  140650. */
  140651. getTextureMatrix(): Matrix;
  140652. /**
  140653. * Updates the content of the texture.
  140654. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  140655. */
  140656. update(invertY?: Nullable<boolean>): void;
  140657. }
  140658. }
  140659. declare module BABYLON {
  140660. /**
  140661. * Based on jsTGALoader - Javascript loader for TGA file
  140662. * By Vincent Thibault
  140663. * @see http://blog.robrowser.com/javascript-tga-loader.html
  140664. */
  140665. export class TGATools {
  140666. private static _TYPE_INDEXED;
  140667. private static _TYPE_RGB;
  140668. private static _TYPE_GREY;
  140669. private static _TYPE_RLE_INDEXED;
  140670. private static _TYPE_RLE_RGB;
  140671. private static _TYPE_RLE_GREY;
  140672. private static _ORIGIN_MASK;
  140673. private static _ORIGIN_SHIFT;
  140674. private static _ORIGIN_BL;
  140675. private static _ORIGIN_BR;
  140676. private static _ORIGIN_UL;
  140677. private static _ORIGIN_UR;
  140678. /**
  140679. * Gets the header of a TGA file
  140680. * @param data defines the TGA data
  140681. * @returns the header
  140682. */
  140683. static GetTGAHeader(data: Uint8Array): any;
  140684. /**
  140685. * Uploads TGA content to a Babylon Texture
  140686. * @hidden
  140687. */
  140688. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  140689. /** @hidden */
  140690. 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;
  140691. /** @hidden */
  140692. 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;
  140693. /** @hidden */
  140694. 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;
  140695. /** @hidden */
  140696. 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;
  140697. /** @hidden */
  140698. 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;
  140699. /** @hidden */
  140700. 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;
  140701. }
  140702. }
  140703. declare module BABYLON {
  140704. /**
  140705. * Implementation of the TGA Texture Loader.
  140706. * @hidden
  140707. */
  140708. export class _TGATextureLoader implements IInternalTextureLoader {
  140709. /**
  140710. * Defines wether the loader supports cascade loading the different faces.
  140711. */
  140712. readonly supportCascades: boolean;
  140713. /**
  140714. * This returns if the loader support the current file information.
  140715. * @param extension defines the file extension of the file being loaded
  140716. * @returns true if the loader can load the specified file
  140717. */
  140718. canLoad(extension: string): boolean;
  140719. /**
  140720. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  140721. * @param data contains the texture data
  140722. * @param texture defines the BabylonJS internal texture
  140723. * @param createPolynomials will be true if polynomials have been requested
  140724. * @param onLoad defines the callback to trigger once the texture is ready
  140725. * @param onError defines the callback to trigger in case of error
  140726. */
  140727. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  140728. /**
  140729. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  140730. * @param data contains the texture data
  140731. * @param texture defines the BabylonJS internal texture
  140732. * @param callback defines the method to call once ready to upload
  140733. */
  140734. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  140735. }
  140736. }
  140737. declare module BABYLON {
  140738. /**
  140739. * Info about the .basis files
  140740. */
  140741. class BasisFileInfo {
  140742. /**
  140743. * If the file has alpha
  140744. */
  140745. hasAlpha: boolean;
  140746. /**
  140747. * Info about each image of the basis file
  140748. */
  140749. images: Array<{
  140750. levels: Array<{
  140751. width: number;
  140752. height: number;
  140753. transcodedPixels: ArrayBufferView;
  140754. }>;
  140755. }>;
  140756. }
  140757. /**
  140758. * Result of transcoding a basis file
  140759. */
  140760. class TranscodeResult {
  140761. /**
  140762. * Info about the .basis file
  140763. */
  140764. fileInfo: BasisFileInfo;
  140765. /**
  140766. * Format to use when loading the file
  140767. */
  140768. format: number;
  140769. }
  140770. /**
  140771. * Configuration options for the Basis transcoder
  140772. */
  140773. export class BasisTranscodeConfiguration {
  140774. /**
  140775. * Supported compression formats used to determine the supported output format of the transcoder
  140776. */
  140777. supportedCompressionFormats?: {
  140778. /**
  140779. * etc1 compression format
  140780. */
  140781. etc1?: boolean;
  140782. /**
  140783. * s3tc compression format
  140784. */
  140785. s3tc?: boolean;
  140786. /**
  140787. * pvrtc compression format
  140788. */
  140789. pvrtc?: boolean;
  140790. /**
  140791. * etc2 compression format
  140792. */
  140793. etc2?: boolean;
  140794. };
  140795. /**
  140796. * If mipmap levels should be loaded for transcoded images (Default: true)
  140797. */
  140798. loadMipmapLevels?: boolean;
  140799. /**
  140800. * Index of a single image to load (Default: all images)
  140801. */
  140802. loadSingleImage?: number;
  140803. }
  140804. /**
  140805. * Used to load .Basis files
  140806. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  140807. */
  140808. export class BasisTools {
  140809. private static _IgnoreSupportedFormats;
  140810. /**
  140811. * URL to use when loading the basis transcoder
  140812. */
  140813. static JSModuleURL: string;
  140814. /**
  140815. * URL to use when loading the wasm module for the transcoder
  140816. */
  140817. static WasmModuleURL: string;
  140818. /**
  140819. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  140820. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  140821. * @returns internal format corresponding to the Basis format
  140822. */
  140823. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  140824. private static _WorkerPromise;
  140825. private static _Worker;
  140826. private static _actionId;
  140827. private static _CreateWorkerAsync;
  140828. /**
  140829. * Transcodes a loaded image file to compressed pixel data
  140830. * @param data image data to transcode
  140831. * @param config configuration options for the transcoding
  140832. * @returns a promise resulting in the transcoded image
  140833. */
  140834. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  140835. /**
  140836. * Loads a texture from the transcode result
  140837. * @param texture texture load to
  140838. * @param transcodeResult the result of transcoding the basis file to load from
  140839. */
  140840. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  140841. }
  140842. }
  140843. declare module BABYLON {
  140844. /**
  140845. * Loader for .basis file format
  140846. */
  140847. export class _BasisTextureLoader implements IInternalTextureLoader {
  140848. /**
  140849. * Defines whether the loader supports cascade loading the different faces.
  140850. */
  140851. readonly supportCascades: boolean;
  140852. /**
  140853. * This returns if the loader support the current file information.
  140854. * @param extension defines the file extension of the file being loaded
  140855. * @returns true if the loader can load the specified file
  140856. */
  140857. canLoad(extension: string): boolean;
  140858. /**
  140859. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  140860. * @param data contains the texture data
  140861. * @param texture defines the BabylonJS internal texture
  140862. * @param createPolynomials will be true if polynomials have been requested
  140863. * @param onLoad defines the callback to trigger once the texture is ready
  140864. * @param onError defines the callback to trigger in case of error
  140865. */
  140866. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  140867. /**
  140868. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  140869. * @param data contains the texture data
  140870. * @param texture defines the BabylonJS internal texture
  140871. * @param callback defines the method to call once ready to upload
  140872. */
  140873. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  140874. }
  140875. }
  140876. declare module BABYLON {
  140877. /**
  140878. * Defines the basic options interface of a TexturePacker Frame
  140879. */
  140880. export interface ITexturePackerFrame {
  140881. /**
  140882. * The frame ID
  140883. */
  140884. id: number;
  140885. /**
  140886. * The frames Scale
  140887. */
  140888. scale: Vector2;
  140889. /**
  140890. * The Frames offset
  140891. */
  140892. offset: Vector2;
  140893. }
  140894. /**
  140895. * This is a support class for frame Data on texture packer sets.
  140896. */
  140897. export class TexturePackerFrame implements ITexturePackerFrame {
  140898. /**
  140899. * The frame ID
  140900. */
  140901. id: number;
  140902. /**
  140903. * The frames Scale
  140904. */
  140905. scale: Vector2;
  140906. /**
  140907. * The Frames offset
  140908. */
  140909. offset: Vector2;
  140910. /**
  140911. * Initializes a texture package frame.
  140912. * @param id The numerical frame identifier
  140913. * @param scale Scalar Vector2 for UV frame
  140914. * @param offset Vector2 for the frame position in UV units.
  140915. * @returns TexturePackerFrame
  140916. */
  140917. constructor(id: number, scale: Vector2, offset: Vector2);
  140918. }
  140919. }
  140920. declare module BABYLON {
  140921. /**
  140922. * Defines the basic options interface of a TexturePacker
  140923. */
  140924. export interface ITexturePackerOptions {
  140925. /**
  140926. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  140927. */
  140928. map?: string[];
  140929. /**
  140930. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  140931. */
  140932. uvsIn?: string;
  140933. /**
  140934. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  140935. */
  140936. uvsOut?: string;
  140937. /**
  140938. * number representing the layout style. Defaults to LAYOUT_STRIP
  140939. */
  140940. layout?: number;
  140941. /**
  140942. * number of columns if using custom column count layout(2). This defaults to 4.
  140943. */
  140944. colnum?: number;
  140945. /**
  140946. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  140947. */
  140948. updateInputMeshes?: boolean;
  140949. /**
  140950. * boolean flag to dispose all the source textures. Defaults to true.
  140951. */
  140952. disposeSources?: boolean;
  140953. /**
  140954. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  140955. */
  140956. fillBlanks?: boolean;
  140957. /**
  140958. * string value representing the context fill style color. Defaults to 'black'.
  140959. */
  140960. customFillColor?: string;
  140961. /**
  140962. * Width and Height Value of each Frame in the TexturePacker Sets
  140963. */
  140964. frameSize?: number;
  140965. /**
  140966. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  140967. */
  140968. paddingRatio?: number;
  140969. /**
  140970. * Number that declares the fill method for the padding gutter.
  140971. */
  140972. paddingMode?: number;
  140973. /**
  140974. * If in SUBUV_COLOR padding mode what color to use.
  140975. */
  140976. paddingColor?: Color3 | Color4;
  140977. }
  140978. /**
  140979. * Defines the basic interface of a TexturePacker JSON File
  140980. */
  140981. export interface ITexturePackerJSON {
  140982. /**
  140983. * The frame ID
  140984. */
  140985. name: string;
  140986. /**
  140987. * The base64 channel data
  140988. */
  140989. sets: any;
  140990. /**
  140991. * The options of the Packer
  140992. */
  140993. options: ITexturePackerOptions;
  140994. /**
  140995. * The frame data of the Packer
  140996. */
  140997. frames: Array<number>;
  140998. }
  140999. /**
  141000. * This is a support class that generates a series of packed texture sets.
  141001. * @see https://doc.babylonjs.com/babylon101/materials
  141002. */
  141003. export class TexturePacker {
  141004. /** Packer Layout Constant 0 */
  141005. static readonly LAYOUT_STRIP: number;
  141006. /** Packer Layout Constant 1 */
  141007. static readonly LAYOUT_POWER2: number;
  141008. /** Packer Layout Constant 2 */
  141009. static readonly LAYOUT_COLNUM: number;
  141010. /** Packer Layout Constant 0 */
  141011. static readonly SUBUV_WRAP: number;
  141012. /** Packer Layout Constant 1 */
  141013. static readonly SUBUV_EXTEND: number;
  141014. /** Packer Layout Constant 2 */
  141015. static readonly SUBUV_COLOR: number;
  141016. /** The Name of the Texture Package */
  141017. name: string;
  141018. /** The scene scope of the TexturePacker */
  141019. scene: Scene;
  141020. /** The Meshes to target */
  141021. meshes: AbstractMesh[];
  141022. /** Arguments passed with the Constructor */
  141023. options: ITexturePackerOptions;
  141024. /** The promise that is started upon initialization */
  141025. promise: Nullable<Promise<TexturePacker | string>>;
  141026. /** The Container object for the channel sets that are generated */
  141027. sets: object;
  141028. /** The Container array for the frames that are generated */
  141029. frames: TexturePackerFrame[];
  141030. /** The expected number of textures the system is parsing. */
  141031. private _expecting;
  141032. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  141033. private _paddingValue;
  141034. /**
  141035. * Initializes a texture package series from an array of meshes or a single mesh.
  141036. * @param name The name of the package
  141037. * @param meshes The target meshes to compose the package from
  141038. * @param options The arguments that texture packer should follow while building.
  141039. * @param scene The scene which the textures are scoped to.
  141040. * @returns TexturePacker
  141041. */
  141042. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  141043. /**
  141044. * Starts the package process
  141045. * @param resolve The promises resolution function
  141046. * @returns TexturePacker
  141047. */
  141048. private _createFrames;
  141049. /**
  141050. * Calculates the Size of the Channel Sets
  141051. * @returns Vector2
  141052. */
  141053. private _calculateSize;
  141054. /**
  141055. * Calculates the UV data for the frames.
  141056. * @param baseSize the base frameSize
  141057. * @param padding the base frame padding
  141058. * @param dtSize size of the Dynamic Texture for that channel
  141059. * @param dtUnits is 1/dtSize
  141060. * @param update flag to update the input meshes
  141061. */
  141062. private _calculateMeshUVFrames;
  141063. /**
  141064. * Calculates the frames Offset.
  141065. * @param index of the frame
  141066. * @returns Vector2
  141067. */
  141068. private _getFrameOffset;
  141069. /**
  141070. * Updates a Mesh to the frame data
  141071. * @param mesh that is the target
  141072. * @param frameID or the frame index
  141073. */
  141074. private _updateMeshUV;
  141075. /**
  141076. * Updates a Meshes materials to use the texture packer channels
  141077. * @param m is the mesh to target
  141078. * @param force all channels on the packer to be set.
  141079. */
  141080. private _updateTextureReferences;
  141081. /**
  141082. * Public method to set a Mesh to a frame
  141083. * @param m that is the target
  141084. * @param frameID or the frame index
  141085. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  141086. */
  141087. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  141088. /**
  141089. * Starts the async promise to compile the texture packer.
  141090. * @returns Promise<void>
  141091. */
  141092. processAsync(): Promise<void>;
  141093. /**
  141094. * Disposes all textures associated with this packer
  141095. */
  141096. dispose(): void;
  141097. /**
  141098. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  141099. * @param imageType is the image type to use.
  141100. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  141101. */
  141102. download(imageType?: string, quality?: number): void;
  141103. /**
  141104. * Public method to load a texturePacker JSON file.
  141105. * @param data of the JSON file in string format.
  141106. */
  141107. updateFromJSON(data: string): void;
  141108. }
  141109. }
  141110. declare module BABYLON {
  141111. /**
  141112. * 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.
  141113. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  141114. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  141115. */
  141116. export class CustomProceduralTexture extends ProceduralTexture {
  141117. private _animate;
  141118. private _time;
  141119. private _config;
  141120. private _texturePath;
  141121. /**
  141122. * Instantiates a new Custom Procedural Texture.
  141123. * 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.
  141124. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  141125. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  141126. * @param name Define the name of the texture
  141127. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  141128. * @param size Define the size of the texture to create
  141129. * @param scene Define the scene the texture belongs to
  141130. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  141131. * @param generateMipMaps Define if the texture should creates mip maps or not
  141132. */
  141133. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  141134. private _loadJson;
  141135. /**
  141136. * Is the texture ready to be used ? (rendered at least once)
  141137. * @returns true if ready, otherwise, false.
  141138. */
  141139. isReady(): boolean;
  141140. /**
  141141. * Render the texture to its associated render target.
  141142. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  141143. */
  141144. render(useCameraPostProcess?: boolean): void;
  141145. /**
  141146. * Update the list of dependant textures samplers in the shader.
  141147. */
  141148. updateTextures(): void;
  141149. /**
  141150. * Update the uniform values of the procedural texture in the shader.
  141151. */
  141152. updateShaderUniforms(): void;
  141153. /**
  141154. * Define if the texture animates or not.
  141155. */
  141156. get animate(): boolean;
  141157. set animate(value: boolean);
  141158. }
  141159. }
  141160. declare module BABYLON {
  141161. /** @hidden */
  141162. export var noisePixelShader: {
  141163. name: string;
  141164. shader: string;
  141165. };
  141166. }
  141167. declare module BABYLON {
  141168. /**
  141169. * Class used to generate noise procedural textures
  141170. */
  141171. export class NoiseProceduralTexture extends ProceduralTexture {
  141172. private _time;
  141173. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  141174. brightness: number;
  141175. /** Defines the number of octaves to process */
  141176. octaves: number;
  141177. /** Defines the level of persistence (0.8 by default) */
  141178. persistence: number;
  141179. /** Gets or sets animation speed factor (default is 1) */
  141180. animationSpeedFactor: number;
  141181. /**
  141182. * Creates a new NoiseProceduralTexture
  141183. * @param name defines the name fo the texture
  141184. * @param size defines the size of the texture (default is 256)
  141185. * @param scene defines the hosting scene
  141186. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  141187. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  141188. */
  141189. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  141190. private _updateShaderUniforms;
  141191. protected _getDefines(): string;
  141192. /** Generate the current state of the procedural texture */
  141193. render(useCameraPostProcess?: boolean): void;
  141194. /**
  141195. * Serializes this noise procedural texture
  141196. * @returns a serialized noise procedural texture object
  141197. */
  141198. serialize(): any;
  141199. /**
  141200. * Clone the texture.
  141201. * @returns the cloned texture
  141202. */
  141203. clone(): NoiseProceduralTexture;
  141204. /**
  141205. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  141206. * @param parsedTexture defines parsed texture data
  141207. * @param scene defines the current scene
  141208. * @param rootUrl defines the root URL containing noise procedural texture information
  141209. * @returns a parsed NoiseProceduralTexture
  141210. */
  141211. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  141212. }
  141213. }
  141214. declare module BABYLON {
  141215. /**
  141216. * Raw cube texture where the raw buffers are passed in
  141217. */
  141218. export class RawCubeTexture extends CubeTexture {
  141219. /**
  141220. * Creates a cube texture where the raw buffers are passed in.
  141221. * @param scene defines the scene the texture is attached to
  141222. * @param data defines the array of data to use to create each face
  141223. * @param size defines the size of the textures
  141224. * @param format defines the format of the data
  141225. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  141226. * @param generateMipMaps defines if the engine should generate the mip levels
  141227. * @param invertY defines if data must be stored with Y axis inverted
  141228. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  141229. * @param compression defines the compression used (null by default)
  141230. */
  141231. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  141232. /**
  141233. * Updates the raw cube texture.
  141234. * @param data defines the data to store
  141235. * @param format defines the data format
  141236. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  141237. * @param invertY defines if data must be stored with Y axis inverted
  141238. * @param compression defines the compression used (null by default)
  141239. * @param level defines which level of the texture to update
  141240. */
  141241. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  141242. /**
  141243. * Updates a raw cube texture with RGBD encoded data.
  141244. * @param data defines the array of data [mipmap][face] to use to create each face
  141245. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  141246. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  141247. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  141248. * @returns a promsie that resolves when the operation is complete
  141249. */
  141250. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  141251. /**
  141252. * Clones the raw cube texture.
  141253. * @return a new cube texture
  141254. */
  141255. clone(): CubeTexture;
  141256. /** @hidden */
  141257. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  141258. }
  141259. }
  141260. declare module BABYLON {
  141261. /**
  141262. * Class used to store 2D array textures containing user data
  141263. */
  141264. export class RawTexture2DArray extends Texture {
  141265. /** Gets or sets the texture format to use */
  141266. format: number;
  141267. /**
  141268. * Create a new RawTexture2DArray
  141269. * @param data defines the data of the texture
  141270. * @param width defines the width of the texture
  141271. * @param height defines the height of the texture
  141272. * @param depth defines the number of layers of the texture
  141273. * @param format defines the texture format to use
  141274. * @param scene defines the hosting scene
  141275. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  141276. * @param invertY defines if texture must be stored with Y axis inverted
  141277. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  141278. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  141279. */
  141280. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  141281. /** Gets or sets the texture format to use */
  141282. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  141283. /**
  141284. * Update the texture with new data
  141285. * @param data defines the data to store in the texture
  141286. */
  141287. update(data: ArrayBufferView): void;
  141288. }
  141289. }
  141290. declare module BABYLON {
  141291. /**
  141292. * Class used to store 3D textures containing user data
  141293. */
  141294. export class RawTexture3D extends Texture {
  141295. /** Gets or sets the texture format to use */
  141296. format: number;
  141297. /**
  141298. * Create a new RawTexture3D
  141299. * @param data defines the data of the texture
  141300. * @param width defines the width of the texture
  141301. * @param height defines the height of the texture
  141302. * @param depth defines the depth of the texture
  141303. * @param format defines the texture format to use
  141304. * @param scene defines the hosting scene
  141305. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  141306. * @param invertY defines if texture must be stored with Y axis inverted
  141307. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  141308. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  141309. */
  141310. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  141311. /** Gets or sets the texture format to use */
  141312. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  141313. /**
  141314. * Update the texture with new data
  141315. * @param data defines the data to store in the texture
  141316. */
  141317. update(data: ArrayBufferView): void;
  141318. }
  141319. }
  141320. declare module BABYLON {
  141321. /**
  141322. * Creates a refraction texture used by refraction channel of the standard material.
  141323. * It is like a mirror but to see through a material.
  141324. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  141325. */
  141326. export class RefractionTexture extends RenderTargetTexture {
  141327. /**
  141328. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  141329. * 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.
  141330. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  141331. */
  141332. refractionPlane: Plane;
  141333. /**
  141334. * Define how deep under the surface we should see.
  141335. */
  141336. depth: number;
  141337. /**
  141338. * Creates a refraction texture used by refraction channel of the standard material.
  141339. * It is like a mirror but to see through a material.
  141340. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  141341. * @param name Define the texture name
  141342. * @param size Define the size of the underlying texture
  141343. * @param scene Define the scene the refraction belongs to
  141344. * @param generateMipMaps Define if we need to generate mips level for the refraction
  141345. */
  141346. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  141347. /**
  141348. * Clone the refraction texture.
  141349. * @returns the cloned texture
  141350. */
  141351. clone(): RefractionTexture;
  141352. /**
  141353. * Serialize the texture to a JSON representation you could use in Parse later on
  141354. * @returns the serialized JSON representation
  141355. */
  141356. serialize(): any;
  141357. }
  141358. }
  141359. declare module BABYLON {
  141360. /**
  141361. * Block used to add support for vertex skinning (bones)
  141362. */
  141363. export class BonesBlock extends NodeMaterialBlock {
  141364. /**
  141365. * Creates a new BonesBlock
  141366. * @param name defines the block name
  141367. */
  141368. constructor(name: string);
  141369. /**
  141370. * Initialize the block and prepare the context for build
  141371. * @param state defines the state that will be used for the build
  141372. */
  141373. initialize(state: NodeMaterialBuildState): void;
  141374. /**
  141375. * Gets the current class name
  141376. * @returns the class name
  141377. */
  141378. getClassName(): string;
  141379. /**
  141380. * Gets the matrix indices input component
  141381. */
  141382. get matricesIndices(): NodeMaterialConnectionPoint;
  141383. /**
  141384. * Gets the matrix weights input component
  141385. */
  141386. get matricesWeights(): NodeMaterialConnectionPoint;
  141387. /**
  141388. * Gets the extra matrix indices input component
  141389. */
  141390. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  141391. /**
  141392. * Gets the extra matrix weights input component
  141393. */
  141394. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  141395. /**
  141396. * Gets the world input component
  141397. */
  141398. get world(): NodeMaterialConnectionPoint;
  141399. /**
  141400. * Gets the output component
  141401. */
  141402. get output(): NodeMaterialConnectionPoint;
  141403. autoConfigure(material: NodeMaterial): void;
  141404. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  141405. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  141406. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141407. protected _buildBlock(state: NodeMaterialBuildState): this;
  141408. }
  141409. }
  141410. declare module BABYLON {
  141411. /**
  141412. * Block used to add support for instances
  141413. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  141414. */
  141415. export class InstancesBlock extends NodeMaterialBlock {
  141416. /**
  141417. * Creates a new InstancesBlock
  141418. * @param name defines the block name
  141419. */
  141420. constructor(name: string);
  141421. /**
  141422. * Gets the current class name
  141423. * @returns the class name
  141424. */
  141425. getClassName(): string;
  141426. /**
  141427. * Gets the first world row input component
  141428. */
  141429. get world0(): NodeMaterialConnectionPoint;
  141430. /**
  141431. * Gets the second world row input component
  141432. */
  141433. get world1(): NodeMaterialConnectionPoint;
  141434. /**
  141435. * Gets the third world row input component
  141436. */
  141437. get world2(): NodeMaterialConnectionPoint;
  141438. /**
  141439. * Gets the forth world row input component
  141440. */
  141441. get world3(): NodeMaterialConnectionPoint;
  141442. /**
  141443. * Gets the world input component
  141444. */
  141445. get world(): NodeMaterialConnectionPoint;
  141446. /**
  141447. * Gets the output component
  141448. */
  141449. get output(): NodeMaterialConnectionPoint;
  141450. /**
  141451. * Gets the isntanceID component
  141452. */
  141453. get instanceID(): NodeMaterialConnectionPoint;
  141454. autoConfigure(material: NodeMaterial): void;
  141455. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  141456. protected _buildBlock(state: NodeMaterialBuildState): this;
  141457. }
  141458. }
  141459. declare module BABYLON {
  141460. /**
  141461. * Block used to add morph targets support to vertex shader
  141462. */
  141463. export class MorphTargetsBlock extends NodeMaterialBlock {
  141464. private _repeatableContentAnchor;
  141465. /**
  141466. * Create a new MorphTargetsBlock
  141467. * @param name defines the block name
  141468. */
  141469. constructor(name: string);
  141470. /**
  141471. * Gets the current class name
  141472. * @returns the class name
  141473. */
  141474. getClassName(): string;
  141475. /**
  141476. * Gets the position input component
  141477. */
  141478. get position(): NodeMaterialConnectionPoint;
  141479. /**
  141480. * Gets the normal input component
  141481. */
  141482. get normal(): NodeMaterialConnectionPoint;
  141483. /**
  141484. * Gets the tangent input component
  141485. */
  141486. get tangent(): NodeMaterialConnectionPoint;
  141487. /**
  141488. * Gets the tangent input component
  141489. */
  141490. get uv(): NodeMaterialConnectionPoint;
  141491. /**
  141492. * Gets the position output component
  141493. */
  141494. get positionOutput(): NodeMaterialConnectionPoint;
  141495. /**
  141496. * Gets the normal output component
  141497. */
  141498. get normalOutput(): NodeMaterialConnectionPoint;
  141499. /**
  141500. * Gets the tangent output component
  141501. */
  141502. get tangentOutput(): NodeMaterialConnectionPoint;
  141503. /**
  141504. * Gets the tangent output component
  141505. */
  141506. get uvOutput(): NodeMaterialConnectionPoint;
  141507. initialize(state: NodeMaterialBuildState): void;
  141508. autoConfigure(material: NodeMaterial): void;
  141509. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141510. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  141511. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  141512. protected _buildBlock(state: NodeMaterialBuildState): this;
  141513. }
  141514. }
  141515. declare module BABYLON {
  141516. /**
  141517. * Block used to get data information from a light
  141518. */
  141519. export class LightInformationBlock extends NodeMaterialBlock {
  141520. private _lightDataUniformName;
  141521. private _lightColorUniformName;
  141522. private _lightTypeDefineName;
  141523. /**
  141524. * Gets or sets the light associated with this block
  141525. */
  141526. light: Nullable<Light>;
  141527. /**
  141528. * Creates a new LightInformationBlock
  141529. * @param name defines the block name
  141530. */
  141531. constructor(name: string);
  141532. /**
  141533. * Gets the current class name
  141534. * @returns the class name
  141535. */
  141536. getClassName(): string;
  141537. /**
  141538. * Gets the world position input component
  141539. */
  141540. get worldPosition(): NodeMaterialConnectionPoint;
  141541. /**
  141542. * Gets the direction output component
  141543. */
  141544. get direction(): NodeMaterialConnectionPoint;
  141545. /**
  141546. * Gets the direction output component
  141547. */
  141548. get color(): NodeMaterialConnectionPoint;
  141549. /**
  141550. * Gets the direction output component
  141551. */
  141552. get intensity(): NodeMaterialConnectionPoint;
  141553. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  141554. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141555. protected _buildBlock(state: NodeMaterialBuildState): this;
  141556. serialize(): any;
  141557. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141558. }
  141559. }
  141560. declare module BABYLON {
  141561. /**
  141562. * Block used to add image processing support to fragment shader
  141563. */
  141564. export class ImageProcessingBlock extends NodeMaterialBlock {
  141565. /**
  141566. * Create a new ImageProcessingBlock
  141567. * @param name defines the block name
  141568. */
  141569. constructor(name: string);
  141570. /**
  141571. * Gets the current class name
  141572. * @returns the class name
  141573. */
  141574. getClassName(): string;
  141575. /**
  141576. * Gets the color input component
  141577. */
  141578. get color(): NodeMaterialConnectionPoint;
  141579. /**
  141580. * Gets the output component
  141581. */
  141582. get output(): NodeMaterialConnectionPoint;
  141583. /**
  141584. * Initialize the block and prepare the context for build
  141585. * @param state defines the state that will be used for the build
  141586. */
  141587. initialize(state: NodeMaterialBuildState): void;
  141588. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  141589. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141590. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  141591. protected _buildBlock(state: NodeMaterialBuildState): this;
  141592. }
  141593. }
  141594. declare module BABYLON {
  141595. /**
  141596. * Block used to pertub normals based on a normal map
  141597. */
  141598. export class PerturbNormalBlock extends NodeMaterialBlock {
  141599. private _tangentSpaceParameterName;
  141600. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  141601. invertX: boolean;
  141602. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  141603. invertY: boolean;
  141604. /**
  141605. * Create a new PerturbNormalBlock
  141606. * @param name defines the block name
  141607. */
  141608. constructor(name: string);
  141609. /**
  141610. * Gets the current class name
  141611. * @returns the class name
  141612. */
  141613. getClassName(): string;
  141614. /**
  141615. * Gets the world position input component
  141616. */
  141617. get worldPosition(): NodeMaterialConnectionPoint;
  141618. /**
  141619. * Gets the world normal input component
  141620. */
  141621. get worldNormal(): NodeMaterialConnectionPoint;
  141622. /**
  141623. * Gets the world tangent input component
  141624. */
  141625. get worldTangent(): NodeMaterialConnectionPoint;
  141626. /**
  141627. * Gets the uv input component
  141628. */
  141629. get uv(): NodeMaterialConnectionPoint;
  141630. /**
  141631. * Gets the normal map color input component
  141632. */
  141633. get normalMapColor(): NodeMaterialConnectionPoint;
  141634. /**
  141635. * Gets the strength input component
  141636. */
  141637. get strength(): NodeMaterialConnectionPoint;
  141638. /**
  141639. * Gets the output component
  141640. */
  141641. get output(): NodeMaterialConnectionPoint;
  141642. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141643. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  141644. autoConfigure(material: NodeMaterial): void;
  141645. protected _buildBlock(state: NodeMaterialBuildState): this;
  141646. protected _dumpPropertiesCode(): string;
  141647. serialize(): any;
  141648. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141649. }
  141650. }
  141651. declare module BABYLON {
  141652. /**
  141653. * Block used to discard a pixel if a value is smaller than a cutoff
  141654. */
  141655. export class DiscardBlock extends NodeMaterialBlock {
  141656. /**
  141657. * Create a new DiscardBlock
  141658. * @param name defines the block name
  141659. */
  141660. constructor(name: string);
  141661. /**
  141662. * Gets the current class name
  141663. * @returns the class name
  141664. */
  141665. getClassName(): string;
  141666. /**
  141667. * Gets the color input component
  141668. */
  141669. get value(): NodeMaterialConnectionPoint;
  141670. /**
  141671. * Gets the cutoff input component
  141672. */
  141673. get cutoff(): NodeMaterialConnectionPoint;
  141674. protected _buildBlock(state: NodeMaterialBuildState): this;
  141675. }
  141676. }
  141677. declare module BABYLON {
  141678. /**
  141679. * Block used to test if the fragment shader is front facing
  141680. */
  141681. export class FrontFacingBlock extends NodeMaterialBlock {
  141682. /**
  141683. * Creates a new FrontFacingBlock
  141684. * @param name defines the block name
  141685. */
  141686. constructor(name: string);
  141687. /**
  141688. * Gets the current class name
  141689. * @returns the class name
  141690. */
  141691. getClassName(): string;
  141692. /**
  141693. * Gets the output component
  141694. */
  141695. get output(): NodeMaterialConnectionPoint;
  141696. protected _buildBlock(state: NodeMaterialBuildState): this;
  141697. }
  141698. }
  141699. declare module BABYLON {
  141700. /**
  141701. * Block used to get the derivative value on x and y of a given input
  141702. */
  141703. export class DerivativeBlock extends NodeMaterialBlock {
  141704. /**
  141705. * Create a new DerivativeBlock
  141706. * @param name defines the block name
  141707. */
  141708. constructor(name: string);
  141709. /**
  141710. * Gets the current class name
  141711. * @returns the class name
  141712. */
  141713. getClassName(): string;
  141714. /**
  141715. * Gets the input component
  141716. */
  141717. get input(): NodeMaterialConnectionPoint;
  141718. /**
  141719. * Gets the derivative output on x
  141720. */
  141721. get dx(): NodeMaterialConnectionPoint;
  141722. /**
  141723. * Gets the derivative output on y
  141724. */
  141725. get dy(): NodeMaterialConnectionPoint;
  141726. protected _buildBlock(state: NodeMaterialBuildState): this;
  141727. }
  141728. }
  141729. declare module BABYLON {
  141730. /**
  141731. * Block used to make gl_FragCoord available
  141732. */
  141733. export class FragCoordBlock extends NodeMaterialBlock {
  141734. /**
  141735. * Creates a new FragCoordBlock
  141736. * @param name defines the block name
  141737. */
  141738. constructor(name: string);
  141739. /**
  141740. * Gets the current class name
  141741. * @returns the class name
  141742. */
  141743. getClassName(): string;
  141744. /**
  141745. * Gets the xy component
  141746. */
  141747. get xy(): NodeMaterialConnectionPoint;
  141748. /**
  141749. * Gets the xyz component
  141750. */
  141751. get xyz(): NodeMaterialConnectionPoint;
  141752. /**
  141753. * Gets the xyzw component
  141754. */
  141755. get xyzw(): NodeMaterialConnectionPoint;
  141756. /**
  141757. * Gets the x component
  141758. */
  141759. get x(): NodeMaterialConnectionPoint;
  141760. /**
  141761. * Gets the y component
  141762. */
  141763. get y(): NodeMaterialConnectionPoint;
  141764. /**
  141765. * Gets the z component
  141766. */
  141767. get z(): NodeMaterialConnectionPoint;
  141768. /**
  141769. * Gets the w component
  141770. */
  141771. get output(): NodeMaterialConnectionPoint;
  141772. protected writeOutputs(state: NodeMaterialBuildState): string;
  141773. protected _buildBlock(state: NodeMaterialBuildState): this;
  141774. }
  141775. }
  141776. declare module BABYLON {
  141777. /**
  141778. * Block used to get the screen sizes
  141779. */
  141780. export class ScreenSizeBlock extends NodeMaterialBlock {
  141781. private _varName;
  141782. private _scene;
  141783. /**
  141784. * Creates a new ScreenSizeBlock
  141785. * @param name defines the block name
  141786. */
  141787. constructor(name: string);
  141788. /**
  141789. * Gets the current class name
  141790. * @returns the class name
  141791. */
  141792. getClassName(): string;
  141793. /**
  141794. * Gets the xy component
  141795. */
  141796. get xy(): NodeMaterialConnectionPoint;
  141797. /**
  141798. * Gets the x component
  141799. */
  141800. get x(): NodeMaterialConnectionPoint;
  141801. /**
  141802. * Gets the y component
  141803. */
  141804. get y(): NodeMaterialConnectionPoint;
  141805. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  141806. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  141807. protected _buildBlock(state: NodeMaterialBuildState): this;
  141808. }
  141809. }
  141810. declare module BABYLON {
  141811. /**
  141812. * Block used to add support for scene fog
  141813. */
  141814. export class FogBlock extends NodeMaterialBlock {
  141815. private _fogDistanceName;
  141816. private _fogParameters;
  141817. /**
  141818. * Create a new FogBlock
  141819. * @param name defines the block name
  141820. */
  141821. constructor(name: string);
  141822. /**
  141823. * Gets the current class name
  141824. * @returns the class name
  141825. */
  141826. getClassName(): string;
  141827. /**
  141828. * Gets the world position input component
  141829. */
  141830. get worldPosition(): NodeMaterialConnectionPoint;
  141831. /**
  141832. * Gets the view input component
  141833. */
  141834. get view(): NodeMaterialConnectionPoint;
  141835. /**
  141836. * Gets the color input component
  141837. */
  141838. get input(): NodeMaterialConnectionPoint;
  141839. /**
  141840. * Gets the fog color input component
  141841. */
  141842. get fogColor(): NodeMaterialConnectionPoint;
  141843. /**
  141844. * Gets the output component
  141845. */
  141846. get output(): NodeMaterialConnectionPoint;
  141847. autoConfigure(material: NodeMaterial): void;
  141848. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141849. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  141850. protected _buildBlock(state: NodeMaterialBuildState): this;
  141851. }
  141852. }
  141853. declare module BABYLON {
  141854. /**
  141855. * Block used to add light in the fragment shader
  141856. */
  141857. export class LightBlock extends NodeMaterialBlock {
  141858. private _lightId;
  141859. /**
  141860. * Gets or sets the light associated with this block
  141861. */
  141862. light: Nullable<Light>;
  141863. /**
  141864. * Create a new LightBlock
  141865. * @param name defines the block name
  141866. */
  141867. constructor(name: string);
  141868. /**
  141869. * Gets the current class name
  141870. * @returns the class name
  141871. */
  141872. getClassName(): string;
  141873. /**
  141874. * Gets the world position input component
  141875. */
  141876. get worldPosition(): NodeMaterialConnectionPoint;
  141877. /**
  141878. * Gets the world normal input component
  141879. */
  141880. get worldNormal(): NodeMaterialConnectionPoint;
  141881. /**
  141882. * Gets the camera (or eye) position component
  141883. */
  141884. get cameraPosition(): NodeMaterialConnectionPoint;
  141885. /**
  141886. * Gets the glossiness component
  141887. */
  141888. get glossiness(): NodeMaterialConnectionPoint;
  141889. /**
  141890. * Gets the glossinness power component
  141891. */
  141892. get glossPower(): NodeMaterialConnectionPoint;
  141893. /**
  141894. * Gets the diffuse color component
  141895. */
  141896. get diffuseColor(): NodeMaterialConnectionPoint;
  141897. /**
  141898. * Gets the specular color component
  141899. */
  141900. get specularColor(): NodeMaterialConnectionPoint;
  141901. /**
  141902. * Gets the diffuse output component
  141903. */
  141904. get diffuseOutput(): NodeMaterialConnectionPoint;
  141905. /**
  141906. * Gets the specular output component
  141907. */
  141908. get specularOutput(): NodeMaterialConnectionPoint;
  141909. /**
  141910. * Gets the shadow output component
  141911. */
  141912. get shadow(): NodeMaterialConnectionPoint;
  141913. autoConfigure(material: NodeMaterial): void;
  141914. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141915. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  141916. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  141917. private _injectVertexCode;
  141918. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  141919. serialize(): any;
  141920. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141921. }
  141922. }
  141923. declare module BABYLON {
  141924. /**
  141925. * Block used to read a reflection texture from a sampler
  141926. */
  141927. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  141928. /**
  141929. * Create a new ReflectionTextureBlock
  141930. * @param name defines the block name
  141931. */
  141932. constructor(name: string);
  141933. /**
  141934. * Gets the current class name
  141935. * @returns the class name
  141936. */
  141937. getClassName(): string;
  141938. /**
  141939. * Gets the world position input component
  141940. */
  141941. get position(): NodeMaterialConnectionPoint;
  141942. /**
  141943. * Gets the world position input component
  141944. */
  141945. get worldPosition(): NodeMaterialConnectionPoint;
  141946. /**
  141947. * Gets the world normal input component
  141948. */
  141949. get worldNormal(): NodeMaterialConnectionPoint;
  141950. /**
  141951. * Gets the world input component
  141952. */
  141953. get world(): NodeMaterialConnectionPoint;
  141954. /**
  141955. * Gets the camera (or eye) position component
  141956. */
  141957. get cameraPosition(): NodeMaterialConnectionPoint;
  141958. /**
  141959. * Gets the view input component
  141960. */
  141961. get view(): NodeMaterialConnectionPoint;
  141962. /**
  141963. * Gets the rgb output component
  141964. */
  141965. get rgb(): NodeMaterialConnectionPoint;
  141966. /**
  141967. * Gets the rgba output component
  141968. */
  141969. get rgba(): NodeMaterialConnectionPoint;
  141970. /**
  141971. * Gets the r output component
  141972. */
  141973. get r(): NodeMaterialConnectionPoint;
  141974. /**
  141975. * Gets the g output component
  141976. */
  141977. get g(): NodeMaterialConnectionPoint;
  141978. /**
  141979. * Gets the b output component
  141980. */
  141981. get b(): NodeMaterialConnectionPoint;
  141982. /**
  141983. * Gets the a output component
  141984. */
  141985. get a(): NodeMaterialConnectionPoint;
  141986. autoConfigure(material: NodeMaterial): void;
  141987. protected _buildBlock(state: NodeMaterialBuildState): this;
  141988. }
  141989. }
  141990. declare module BABYLON {
  141991. /**
  141992. * Block used to add 2 vectors
  141993. */
  141994. export class AddBlock extends NodeMaterialBlock {
  141995. /**
  141996. * Creates a new AddBlock
  141997. * @param name defines the block name
  141998. */
  141999. constructor(name: string);
  142000. /**
  142001. * Gets the current class name
  142002. * @returns the class name
  142003. */
  142004. getClassName(): string;
  142005. /**
  142006. * Gets the left operand input component
  142007. */
  142008. get left(): NodeMaterialConnectionPoint;
  142009. /**
  142010. * Gets the right operand input component
  142011. */
  142012. get right(): NodeMaterialConnectionPoint;
  142013. /**
  142014. * Gets the output component
  142015. */
  142016. get output(): NodeMaterialConnectionPoint;
  142017. protected _buildBlock(state: NodeMaterialBuildState): this;
  142018. }
  142019. }
  142020. declare module BABYLON {
  142021. /**
  142022. * Block used to scale a vector by a float
  142023. */
  142024. export class ScaleBlock extends NodeMaterialBlock {
  142025. /**
  142026. * Creates a new ScaleBlock
  142027. * @param name defines the block name
  142028. */
  142029. constructor(name: string);
  142030. /**
  142031. * Gets the current class name
  142032. * @returns the class name
  142033. */
  142034. getClassName(): string;
  142035. /**
  142036. * Gets the input component
  142037. */
  142038. get input(): NodeMaterialConnectionPoint;
  142039. /**
  142040. * Gets the factor input component
  142041. */
  142042. get factor(): NodeMaterialConnectionPoint;
  142043. /**
  142044. * Gets the output component
  142045. */
  142046. get output(): NodeMaterialConnectionPoint;
  142047. protected _buildBlock(state: NodeMaterialBuildState): this;
  142048. }
  142049. }
  142050. declare module BABYLON {
  142051. /**
  142052. * Block used to clamp a float
  142053. */
  142054. export class ClampBlock extends NodeMaterialBlock {
  142055. /** Gets or sets the minimum range */
  142056. minimum: number;
  142057. /** Gets or sets the maximum range */
  142058. maximum: number;
  142059. /**
  142060. * Creates a new ClampBlock
  142061. * @param name defines the block name
  142062. */
  142063. constructor(name: string);
  142064. /**
  142065. * Gets the current class name
  142066. * @returns the class name
  142067. */
  142068. getClassName(): string;
  142069. /**
  142070. * Gets the value input component
  142071. */
  142072. get value(): NodeMaterialConnectionPoint;
  142073. /**
  142074. * Gets the output component
  142075. */
  142076. get output(): NodeMaterialConnectionPoint;
  142077. protected _buildBlock(state: NodeMaterialBuildState): this;
  142078. protected _dumpPropertiesCode(): string;
  142079. serialize(): any;
  142080. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142081. }
  142082. }
  142083. declare module BABYLON {
  142084. /**
  142085. * Block used to apply a cross product between 2 vectors
  142086. */
  142087. export class CrossBlock extends NodeMaterialBlock {
  142088. /**
  142089. * Creates a new CrossBlock
  142090. * @param name defines the block name
  142091. */
  142092. constructor(name: string);
  142093. /**
  142094. * Gets the current class name
  142095. * @returns the class name
  142096. */
  142097. getClassName(): string;
  142098. /**
  142099. * Gets the left operand input component
  142100. */
  142101. get left(): NodeMaterialConnectionPoint;
  142102. /**
  142103. * Gets the right operand input component
  142104. */
  142105. get right(): NodeMaterialConnectionPoint;
  142106. /**
  142107. * Gets the output component
  142108. */
  142109. get output(): NodeMaterialConnectionPoint;
  142110. protected _buildBlock(state: NodeMaterialBuildState): this;
  142111. }
  142112. }
  142113. declare module BABYLON {
  142114. /**
  142115. * Block used to apply a dot product between 2 vectors
  142116. */
  142117. export class DotBlock extends NodeMaterialBlock {
  142118. /**
  142119. * Creates a new DotBlock
  142120. * @param name defines the block name
  142121. */
  142122. constructor(name: string);
  142123. /**
  142124. * Gets the current class name
  142125. * @returns the class name
  142126. */
  142127. getClassName(): string;
  142128. /**
  142129. * Gets the left operand input component
  142130. */
  142131. get left(): NodeMaterialConnectionPoint;
  142132. /**
  142133. * Gets the right operand input component
  142134. */
  142135. get right(): NodeMaterialConnectionPoint;
  142136. /**
  142137. * Gets the output component
  142138. */
  142139. get output(): NodeMaterialConnectionPoint;
  142140. protected _buildBlock(state: NodeMaterialBuildState): this;
  142141. }
  142142. }
  142143. declare module BABYLON {
  142144. /**
  142145. * Block used to normalize a vector
  142146. */
  142147. export class NormalizeBlock extends NodeMaterialBlock {
  142148. /**
  142149. * Creates a new NormalizeBlock
  142150. * @param name defines the block name
  142151. */
  142152. constructor(name: string);
  142153. /**
  142154. * Gets the current class name
  142155. * @returns the class name
  142156. */
  142157. getClassName(): string;
  142158. /**
  142159. * Gets the input component
  142160. */
  142161. get input(): NodeMaterialConnectionPoint;
  142162. /**
  142163. * Gets the output component
  142164. */
  142165. get output(): NodeMaterialConnectionPoint;
  142166. protected _buildBlock(state: NodeMaterialBuildState): this;
  142167. }
  142168. }
  142169. declare module BABYLON {
  142170. /**
  142171. * Operations supported by the Trigonometry block
  142172. */
  142173. export enum TrigonometryBlockOperations {
  142174. /** Cos */
  142175. Cos = 0,
  142176. /** Sin */
  142177. Sin = 1,
  142178. /** Abs */
  142179. Abs = 2,
  142180. /** Exp */
  142181. Exp = 3,
  142182. /** Exp2 */
  142183. Exp2 = 4,
  142184. /** Round */
  142185. Round = 5,
  142186. /** Floor */
  142187. Floor = 6,
  142188. /** Ceiling */
  142189. Ceiling = 7,
  142190. /** Square root */
  142191. Sqrt = 8,
  142192. /** Log */
  142193. Log = 9,
  142194. /** Tangent */
  142195. Tan = 10,
  142196. /** Arc tangent */
  142197. ArcTan = 11,
  142198. /** Arc cosinus */
  142199. ArcCos = 12,
  142200. /** Arc sinus */
  142201. ArcSin = 13,
  142202. /** Fraction */
  142203. Fract = 14,
  142204. /** Sign */
  142205. Sign = 15,
  142206. /** To radians (from degrees) */
  142207. Radians = 16,
  142208. /** To degrees (from radians) */
  142209. Degrees = 17
  142210. }
  142211. /**
  142212. * Block used to apply trigonometry operation to floats
  142213. */
  142214. export class TrigonometryBlock extends NodeMaterialBlock {
  142215. /**
  142216. * Gets or sets the operation applied by the block
  142217. */
  142218. operation: TrigonometryBlockOperations;
  142219. /**
  142220. * Creates a new TrigonometryBlock
  142221. * @param name defines the block name
  142222. */
  142223. constructor(name: string);
  142224. /**
  142225. * Gets the current class name
  142226. * @returns the class name
  142227. */
  142228. getClassName(): string;
  142229. /**
  142230. * Gets the input component
  142231. */
  142232. get input(): NodeMaterialConnectionPoint;
  142233. /**
  142234. * Gets the output component
  142235. */
  142236. get output(): NodeMaterialConnectionPoint;
  142237. protected _buildBlock(state: NodeMaterialBuildState): this;
  142238. serialize(): any;
  142239. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142240. protected _dumpPropertiesCode(): string;
  142241. }
  142242. }
  142243. declare module BABYLON {
  142244. /**
  142245. * Block used to create a Color3/4 out of individual inputs (one for each component)
  142246. */
  142247. export class ColorMergerBlock extends NodeMaterialBlock {
  142248. /**
  142249. * Create a new ColorMergerBlock
  142250. * @param name defines the block name
  142251. */
  142252. constructor(name: string);
  142253. /**
  142254. * Gets the current class name
  142255. * @returns the class name
  142256. */
  142257. getClassName(): string;
  142258. /**
  142259. * Gets the rgb component (input)
  142260. */
  142261. get rgbIn(): NodeMaterialConnectionPoint;
  142262. /**
  142263. * Gets the r component (input)
  142264. */
  142265. get r(): NodeMaterialConnectionPoint;
  142266. /**
  142267. * Gets the g component (input)
  142268. */
  142269. get g(): NodeMaterialConnectionPoint;
  142270. /**
  142271. * Gets the b component (input)
  142272. */
  142273. get b(): NodeMaterialConnectionPoint;
  142274. /**
  142275. * Gets the a component (input)
  142276. */
  142277. get a(): NodeMaterialConnectionPoint;
  142278. /**
  142279. * Gets the rgba component (output)
  142280. */
  142281. get rgba(): NodeMaterialConnectionPoint;
  142282. /**
  142283. * Gets the rgb component (output)
  142284. */
  142285. get rgbOut(): NodeMaterialConnectionPoint;
  142286. /**
  142287. * Gets the rgb component (output)
  142288. * @deprecated Please use rgbOut instead.
  142289. */
  142290. get rgb(): NodeMaterialConnectionPoint;
  142291. protected _buildBlock(state: NodeMaterialBuildState): this;
  142292. }
  142293. }
  142294. declare module BABYLON {
  142295. /**
  142296. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  142297. */
  142298. export class VectorSplitterBlock extends NodeMaterialBlock {
  142299. /**
  142300. * Create a new VectorSplitterBlock
  142301. * @param name defines the block name
  142302. */
  142303. constructor(name: string);
  142304. /**
  142305. * Gets the current class name
  142306. * @returns the class name
  142307. */
  142308. getClassName(): string;
  142309. /**
  142310. * Gets the xyzw component (input)
  142311. */
  142312. get xyzw(): NodeMaterialConnectionPoint;
  142313. /**
  142314. * Gets the xyz component (input)
  142315. */
  142316. get xyzIn(): NodeMaterialConnectionPoint;
  142317. /**
  142318. * Gets the xy component (input)
  142319. */
  142320. get xyIn(): NodeMaterialConnectionPoint;
  142321. /**
  142322. * Gets the xyz component (output)
  142323. */
  142324. get xyzOut(): NodeMaterialConnectionPoint;
  142325. /**
  142326. * Gets the xy component (output)
  142327. */
  142328. get xyOut(): NodeMaterialConnectionPoint;
  142329. /**
  142330. * Gets the x component (output)
  142331. */
  142332. get x(): NodeMaterialConnectionPoint;
  142333. /**
  142334. * Gets the y component (output)
  142335. */
  142336. get y(): NodeMaterialConnectionPoint;
  142337. /**
  142338. * Gets the z component (output)
  142339. */
  142340. get z(): NodeMaterialConnectionPoint;
  142341. /**
  142342. * Gets the w component (output)
  142343. */
  142344. get w(): NodeMaterialConnectionPoint;
  142345. protected _inputRename(name: string): string;
  142346. protected _outputRename(name: string): string;
  142347. protected _buildBlock(state: NodeMaterialBuildState): this;
  142348. }
  142349. }
  142350. declare module BABYLON {
  142351. /**
  142352. * Block used to lerp between 2 values
  142353. */
  142354. export class LerpBlock extends NodeMaterialBlock {
  142355. /**
  142356. * Creates a new LerpBlock
  142357. * @param name defines the block name
  142358. */
  142359. constructor(name: string);
  142360. /**
  142361. * Gets the current class name
  142362. * @returns the class name
  142363. */
  142364. getClassName(): string;
  142365. /**
  142366. * Gets the left operand input component
  142367. */
  142368. get left(): NodeMaterialConnectionPoint;
  142369. /**
  142370. * Gets the right operand input component
  142371. */
  142372. get right(): NodeMaterialConnectionPoint;
  142373. /**
  142374. * Gets the gradient operand input component
  142375. */
  142376. get gradient(): NodeMaterialConnectionPoint;
  142377. /**
  142378. * Gets the output component
  142379. */
  142380. get output(): NodeMaterialConnectionPoint;
  142381. protected _buildBlock(state: NodeMaterialBuildState): this;
  142382. }
  142383. }
  142384. declare module BABYLON {
  142385. /**
  142386. * Block used to divide 2 vectors
  142387. */
  142388. export class DivideBlock extends NodeMaterialBlock {
  142389. /**
  142390. * Creates a new DivideBlock
  142391. * @param name defines the block name
  142392. */
  142393. constructor(name: string);
  142394. /**
  142395. * Gets the current class name
  142396. * @returns the class name
  142397. */
  142398. getClassName(): string;
  142399. /**
  142400. * Gets the left operand input component
  142401. */
  142402. get left(): NodeMaterialConnectionPoint;
  142403. /**
  142404. * Gets the right operand input component
  142405. */
  142406. get right(): NodeMaterialConnectionPoint;
  142407. /**
  142408. * Gets the output component
  142409. */
  142410. get output(): NodeMaterialConnectionPoint;
  142411. protected _buildBlock(state: NodeMaterialBuildState): this;
  142412. }
  142413. }
  142414. declare module BABYLON {
  142415. /**
  142416. * Block used to subtract 2 vectors
  142417. */
  142418. export class SubtractBlock extends NodeMaterialBlock {
  142419. /**
  142420. * Creates a new SubtractBlock
  142421. * @param name defines the block name
  142422. */
  142423. constructor(name: string);
  142424. /**
  142425. * Gets the current class name
  142426. * @returns the class name
  142427. */
  142428. getClassName(): string;
  142429. /**
  142430. * Gets the left operand input component
  142431. */
  142432. get left(): NodeMaterialConnectionPoint;
  142433. /**
  142434. * Gets the right operand input component
  142435. */
  142436. get right(): NodeMaterialConnectionPoint;
  142437. /**
  142438. * Gets the output component
  142439. */
  142440. get output(): NodeMaterialConnectionPoint;
  142441. protected _buildBlock(state: NodeMaterialBuildState): this;
  142442. }
  142443. }
  142444. declare module BABYLON {
  142445. /**
  142446. * Block used to step a value
  142447. */
  142448. export class StepBlock extends NodeMaterialBlock {
  142449. /**
  142450. * Creates a new StepBlock
  142451. * @param name defines the block name
  142452. */
  142453. constructor(name: string);
  142454. /**
  142455. * Gets the current class name
  142456. * @returns the class name
  142457. */
  142458. getClassName(): string;
  142459. /**
  142460. * Gets the value operand input component
  142461. */
  142462. get value(): NodeMaterialConnectionPoint;
  142463. /**
  142464. * Gets the edge operand input component
  142465. */
  142466. get edge(): NodeMaterialConnectionPoint;
  142467. /**
  142468. * Gets the output component
  142469. */
  142470. get output(): NodeMaterialConnectionPoint;
  142471. protected _buildBlock(state: NodeMaterialBuildState): this;
  142472. }
  142473. }
  142474. declare module BABYLON {
  142475. /**
  142476. * Block used to get the opposite (1 - x) of a value
  142477. */
  142478. export class OneMinusBlock extends NodeMaterialBlock {
  142479. /**
  142480. * Creates a new OneMinusBlock
  142481. * @param name defines the block name
  142482. */
  142483. constructor(name: string);
  142484. /**
  142485. * Gets the current class name
  142486. * @returns the class name
  142487. */
  142488. getClassName(): string;
  142489. /**
  142490. * Gets the input component
  142491. */
  142492. get input(): NodeMaterialConnectionPoint;
  142493. /**
  142494. * Gets the output component
  142495. */
  142496. get output(): NodeMaterialConnectionPoint;
  142497. protected _buildBlock(state: NodeMaterialBuildState): this;
  142498. }
  142499. }
  142500. declare module BABYLON {
  142501. /**
  142502. * Block used to get the view direction
  142503. */
  142504. export class ViewDirectionBlock extends NodeMaterialBlock {
  142505. /**
  142506. * Creates a new ViewDirectionBlock
  142507. * @param name defines the block name
  142508. */
  142509. constructor(name: string);
  142510. /**
  142511. * Gets the current class name
  142512. * @returns the class name
  142513. */
  142514. getClassName(): string;
  142515. /**
  142516. * Gets the world position component
  142517. */
  142518. get worldPosition(): NodeMaterialConnectionPoint;
  142519. /**
  142520. * Gets the camera position component
  142521. */
  142522. get cameraPosition(): NodeMaterialConnectionPoint;
  142523. /**
  142524. * Gets the output component
  142525. */
  142526. get output(): NodeMaterialConnectionPoint;
  142527. autoConfigure(material: NodeMaterial): void;
  142528. protected _buildBlock(state: NodeMaterialBuildState): this;
  142529. }
  142530. }
  142531. declare module BABYLON {
  142532. /**
  142533. * Block used to compute fresnel value
  142534. */
  142535. export class FresnelBlock extends NodeMaterialBlock {
  142536. /**
  142537. * Create a new FresnelBlock
  142538. * @param name defines the block name
  142539. */
  142540. constructor(name: string);
  142541. /**
  142542. * Gets the current class name
  142543. * @returns the class name
  142544. */
  142545. getClassName(): string;
  142546. /**
  142547. * Gets the world normal input component
  142548. */
  142549. get worldNormal(): NodeMaterialConnectionPoint;
  142550. /**
  142551. * Gets the view direction input component
  142552. */
  142553. get viewDirection(): NodeMaterialConnectionPoint;
  142554. /**
  142555. * Gets the bias input component
  142556. */
  142557. get bias(): NodeMaterialConnectionPoint;
  142558. /**
  142559. * Gets the camera (or eye) position component
  142560. */
  142561. get power(): NodeMaterialConnectionPoint;
  142562. /**
  142563. * Gets the fresnel output component
  142564. */
  142565. get fresnel(): NodeMaterialConnectionPoint;
  142566. autoConfigure(material: NodeMaterial): void;
  142567. protected _buildBlock(state: NodeMaterialBuildState): this;
  142568. }
  142569. }
  142570. declare module BABYLON {
  142571. /**
  142572. * Block used to get the max of 2 values
  142573. */
  142574. export class MaxBlock extends NodeMaterialBlock {
  142575. /**
  142576. * Creates a new MaxBlock
  142577. * @param name defines the block name
  142578. */
  142579. constructor(name: string);
  142580. /**
  142581. * Gets the current class name
  142582. * @returns the class name
  142583. */
  142584. getClassName(): string;
  142585. /**
  142586. * Gets the left operand input component
  142587. */
  142588. get left(): NodeMaterialConnectionPoint;
  142589. /**
  142590. * Gets the right operand input component
  142591. */
  142592. get right(): NodeMaterialConnectionPoint;
  142593. /**
  142594. * Gets the output component
  142595. */
  142596. get output(): NodeMaterialConnectionPoint;
  142597. protected _buildBlock(state: NodeMaterialBuildState): this;
  142598. }
  142599. }
  142600. declare module BABYLON {
  142601. /**
  142602. * Block used to get the min of 2 values
  142603. */
  142604. export class MinBlock extends NodeMaterialBlock {
  142605. /**
  142606. * Creates a new MinBlock
  142607. * @param name defines the block name
  142608. */
  142609. constructor(name: string);
  142610. /**
  142611. * Gets the current class name
  142612. * @returns the class name
  142613. */
  142614. getClassName(): string;
  142615. /**
  142616. * Gets the left operand input component
  142617. */
  142618. get left(): NodeMaterialConnectionPoint;
  142619. /**
  142620. * Gets the right operand input component
  142621. */
  142622. get right(): NodeMaterialConnectionPoint;
  142623. /**
  142624. * Gets the output component
  142625. */
  142626. get output(): NodeMaterialConnectionPoint;
  142627. protected _buildBlock(state: NodeMaterialBuildState): this;
  142628. }
  142629. }
  142630. declare module BABYLON {
  142631. /**
  142632. * Block used to get the distance between 2 values
  142633. */
  142634. export class DistanceBlock extends NodeMaterialBlock {
  142635. /**
  142636. * Creates a new DistanceBlock
  142637. * @param name defines the block name
  142638. */
  142639. constructor(name: string);
  142640. /**
  142641. * Gets the current class name
  142642. * @returns the class name
  142643. */
  142644. getClassName(): string;
  142645. /**
  142646. * Gets the left operand input component
  142647. */
  142648. get left(): NodeMaterialConnectionPoint;
  142649. /**
  142650. * Gets the right operand input component
  142651. */
  142652. get right(): NodeMaterialConnectionPoint;
  142653. /**
  142654. * Gets the output component
  142655. */
  142656. get output(): NodeMaterialConnectionPoint;
  142657. protected _buildBlock(state: NodeMaterialBuildState): this;
  142658. }
  142659. }
  142660. declare module BABYLON {
  142661. /**
  142662. * Block used to get the length of a vector
  142663. */
  142664. export class LengthBlock extends NodeMaterialBlock {
  142665. /**
  142666. * Creates a new LengthBlock
  142667. * @param name defines the block name
  142668. */
  142669. constructor(name: string);
  142670. /**
  142671. * Gets the current class name
  142672. * @returns the class name
  142673. */
  142674. getClassName(): string;
  142675. /**
  142676. * Gets the value input component
  142677. */
  142678. get value(): NodeMaterialConnectionPoint;
  142679. /**
  142680. * Gets the output component
  142681. */
  142682. get output(): NodeMaterialConnectionPoint;
  142683. protected _buildBlock(state: NodeMaterialBuildState): this;
  142684. }
  142685. }
  142686. declare module BABYLON {
  142687. /**
  142688. * Block used to get negative version of a value (i.e. x * -1)
  142689. */
  142690. export class NegateBlock extends NodeMaterialBlock {
  142691. /**
  142692. * Creates a new NegateBlock
  142693. * @param name defines the block name
  142694. */
  142695. constructor(name: string);
  142696. /**
  142697. * Gets the current class name
  142698. * @returns the class name
  142699. */
  142700. getClassName(): string;
  142701. /**
  142702. * Gets the value input component
  142703. */
  142704. get value(): NodeMaterialConnectionPoint;
  142705. /**
  142706. * Gets the output component
  142707. */
  142708. get output(): NodeMaterialConnectionPoint;
  142709. protected _buildBlock(state: NodeMaterialBuildState): this;
  142710. }
  142711. }
  142712. declare module BABYLON {
  142713. /**
  142714. * Block used to get the value of the first parameter raised to the power of the second
  142715. */
  142716. export class PowBlock extends NodeMaterialBlock {
  142717. /**
  142718. * Creates a new PowBlock
  142719. * @param name defines the block name
  142720. */
  142721. constructor(name: string);
  142722. /**
  142723. * Gets the current class name
  142724. * @returns the class name
  142725. */
  142726. getClassName(): string;
  142727. /**
  142728. * Gets the value operand input component
  142729. */
  142730. get value(): NodeMaterialConnectionPoint;
  142731. /**
  142732. * Gets the power operand input component
  142733. */
  142734. get power(): NodeMaterialConnectionPoint;
  142735. /**
  142736. * Gets the output component
  142737. */
  142738. get output(): NodeMaterialConnectionPoint;
  142739. protected _buildBlock(state: NodeMaterialBuildState): this;
  142740. }
  142741. }
  142742. declare module BABYLON {
  142743. /**
  142744. * Block used to get a random number
  142745. */
  142746. export class RandomNumberBlock extends NodeMaterialBlock {
  142747. /**
  142748. * Creates a new RandomNumberBlock
  142749. * @param name defines the block name
  142750. */
  142751. constructor(name: string);
  142752. /**
  142753. * Gets the current class name
  142754. * @returns the class name
  142755. */
  142756. getClassName(): string;
  142757. /**
  142758. * Gets the seed input component
  142759. */
  142760. get seed(): NodeMaterialConnectionPoint;
  142761. /**
  142762. * Gets the output component
  142763. */
  142764. get output(): NodeMaterialConnectionPoint;
  142765. protected _buildBlock(state: NodeMaterialBuildState): this;
  142766. }
  142767. }
  142768. declare module BABYLON {
  142769. /**
  142770. * Block used to compute arc tangent of 2 values
  142771. */
  142772. export class ArcTan2Block extends NodeMaterialBlock {
  142773. /**
  142774. * Creates a new ArcTan2Block
  142775. * @param name defines the block name
  142776. */
  142777. constructor(name: string);
  142778. /**
  142779. * Gets the current class name
  142780. * @returns the class name
  142781. */
  142782. getClassName(): string;
  142783. /**
  142784. * Gets the x operand input component
  142785. */
  142786. get x(): NodeMaterialConnectionPoint;
  142787. /**
  142788. * Gets the y operand input component
  142789. */
  142790. get y(): NodeMaterialConnectionPoint;
  142791. /**
  142792. * Gets the output component
  142793. */
  142794. get output(): NodeMaterialConnectionPoint;
  142795. protected _buildBlock(state: NodeMaterialBuildState): this;
  142796. }
  142797. }
  142798. declare module BABYLON {
  142799. /**
  142800. * Block used to smooth step a value
  142801. */
  142802. export class SmoothStepBlock extends NodeMaterialBlock {
  142803. /**
  142804. * Creates a new SmoothStepBlock
  142805. * @param name defines the block name
  142806. */
  142807. constructor(name: string);
  142808. /**
  142809. * Gets the current class name
  142810. * @returns the class name
  142811. */
  142812. getClassName(): string;
  142813. /**
  142814. * Gets the value operand input component
  142815. */
  142816. get value(): NodeMaterialConnectionPoint;
  142817. /**
  142818. * Gets the first edge operand input component
  142819. */
  142820. get edge0(): NodeMaterialConnectionPoint;
  142821. /**
  142822. * Gets the second edge operand input component
  142823. */
  142824. get edge1(): NodeMaterialConnectionPoint;
  142825. /**
  142826. * Gets the output component
  142827. */
  142828. get output(): NodeMaterialConnectionPoint;
  142829. protected _buildBlock(state: NodeMaterialBuildState): this;
  142830. }
  142831. }
  142832. declare module BABYLON {
  142833. /**
  142834. * Block used to get the reciprocal (1 / x) of a value
  142835. */
  142836. export class ReciprocalBlock extends NodeMaterialBlock {
  142837. /**
  142838. * Creates a new ReciprocalBlock
  142839. * @param name defines the block name
  142840. */
  142841. constructor(name: string);
  142842. /**
  142843. * Gets the current class name
  142844. * @returns the class name
  142845. */
  142846. getClassName(): string;
  142847. /**
  142848. * Gets the input component
  142849. */
  142850. get input(): NodeMaterialConnectionPoint;
  142851. /**
  142852. * Gets the output component
  142853. */
  142854. get output(): NodeMaterialConnectionPoint;
  142855. protected _buildBlock(state: NodeMaterialBuildState): this;
  142856. }
  142857. }
  142858. declare module BABYLON {
  142859. /**
  142860. * Block used to replace a color by another one
  142861. */
  142862. export class ReplaceColorBlock extends NodeMaterialBlock {
  142863. /**
  142864. * Creates a new ReplaceColorBlock
  142865. * @param name defines the block name
  142866. */
  142867. constructor(name: string);
  142868. /**
  142869. * Gets the current class name
  142870. * @returns the class name
  142871. */
  142872. getClassName(): string;
  142873. /**
  142874. * Gets the value input component
  142875. */
  142876. get value(): NodeMaterialConnectionPoint;
  142877. /**
  142878. * Gets the reference input component
  142879. */
  142880. get reference(): NodeMaterialConnectionPoint;
  142881. /**
  142882. * Gets the distance input component
  142883. */
  142884. get distance(): NodeMaterialConnectionPoint;
  142885. /**
  142886. * Gets the replacement input component
  142887. */
  142888. get replacement(): NodeMaterialConnectionPoint;
  142889. /**
  142890. * Gets the output component
  142891. */
  142892. get output(): NodeMaterialConnectionPoint;
  142893. protected _buildBlock(state: NodeMaterialBuildState): this;
  142894. }
  142895. }
  142896. declare module BABYLON {
  142897. /**
  142898. * Block used to posterize a value
  142899. * @see https://en.wikipedia.org/wiki/Posterization
  142900. */
  142901. export class PosterizeBlock extends NodeMaterialBlock {
  142902. /**
  142903. * Creates a new PosterizeBlock
  142904. * @param name defines the block name
  142905. */
  142906. constructor(name: string);
  142907. /**
  142908. * Gets the current class name
  142909. * @returns the class name
  142910. */
  142911. getClassName(): string;
  142912. /**
  142913. * Gets the value input component
  142914. */
  142915. get value(): NodeMaterialConnectionPoint;
  142916. /**
  142917. * Gets the steps input component
  142918. */
  142919. get steps(): NodeMaterialConnectionPoint;
  142920. /**
  142921. * Gets the output component
  142922. */
  142923. get output(): NodeMaterialConnectionPoint;
  142924. protected _buildBlock(state: NodeMaterialBuildState): this;
  142925. }
  142926. }
  142927. declare module BABYLON {
  142928. /**
  142929. * Operations supported by the Wave block
  142930. */
  142931. export enum WaveBlockKind {
  142932. /** SawTooth */
  142933. SawTooth = 0,
  142934. /** Square */
  142935. Square = 1,
  142936. /** Triangle */
  142937. Triangle = 2
  142938. }
  142939. /**
  142940. * Block used to apply wave operation to floats
  142941. */
  142942. export class WaveBlock extends NodeMaterialBlock {
  142943. /**
  142944. * Gets or sets the kibnd of wave to be applied by the block
  142945. */
  142946. kind: WaveBlockKind;
  142947. /**
  142948. * Creates a new WaveBlock
  142949. * @param name defines the block name
  142950. */
  142951. constructor(name: string);
  142952. /**
  142953. * Gets the current class name
  142954. * @returns the class name
  142955. */
  142956. getClassName(): string;
  142957. /**
  142958. * Gets the input component
  142959. */
  142960. get input(): NodeMaterialConnectionPoint;
  142961. /**
  142962. * Gets the output component
  142963. */
  142964. get output(): NodeMaterialConnectionPoint;
  142965. protected _buildBlock(state: NodeMaterialBuildState): this;
  142966. serialize(): any;
  142967. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142968. }
  142969. }
  142970. declare module BABYLON {
  142971. /**
  142972. * Class used to store a color step for the GradientBlock
  142973. */
  142974. export class GradientBlockColorStep {
  142975. /**
  142976. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  142977. */
  142978. step: number;
  142979. /**
  142980. * Gets or sets the color associated with this step
  142981. */
  142982. color: Color3;
  142983. /**
  142984. * Creates a new GradientBlockColorStep
  142985. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  142986. * @param color defines the color associated with this step
  142987. */
  142988. constructor(
  142989. /**
  142990. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  142991. */
  142992. step: number,
  142993. /**
  142994. * Gets or sets the color associated with this step
  142995. */
  142996. color: Color3);
  142997. }
  142998. /**
  142999. * Block used to return a color from a gradient based on an input value between 0 and 1
  143000. */
  143001. export class GradientBlock extends NodeMaterialBlock {
  143002. /**
  143003. * Gets or sets the list of color steps
  143004. */
  143005. colorSteps: GradientBlockColorStep[];
  143006. /**
  143007. * Creates a new GradientBlock
  143008. * @param name defines the block name
  143009. */
  143010. constructor(name: string);
  143011. /**
  143012. * Gets the current class name
  143013. * @returns the class name
  143014. */
  143015. getClassName(): string;
  143016. /**
  143017. * Gets the gradient input component
  143018. */
  143019. get gradient(): NodeMaterialConnectionPoint;
  143020. /**
  143021. * Gets the output component
  143022. */
  143023. get output(): NodeMaterialConnectionPoint;
  143024. private _writeColorConstant;
  143025. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  143026. serialize(): any;
  143027. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143028. protected _dumpPropertiesCode(): string;
  143029. }
  143030. }
  143031. declare module BABYLON {
  143032. /**
  143033. * Block used to normalize lerp between 2 values
  143034. */
  143035. export class NLerpBlock extends NodeMaterialBlock {
  143036. /**
  143037. * Creates a new NLerpBlock
  143038. * @param name defines the block name
  143039. */
  143040. constructor(name: string);
  143041. /**
  143042. * Gets the current class name
  143043. * @returns the class name
  143044. */
  143045. getClassName(): string;
  143046. /**
  143047. * Gets the left operand input component
  143048. */
  143049. get left(): NodeMaterialConnectionPoint;
  143050. /**
  143051. * Gets the right operand input component
  143052. */
  143053. get right(): NodeMaterialConnectionPoint;
  143054. /**
  143055. * Gets the gradient operand input component
  143056. */
  143057. get gradient(): NodeMaterialConnectionPoint;
  143058. /**
  143059. * Gets the output component
  143060. */
  143061. get output(): NodeMaterialConnectionPoint;
  143062. protected _buildBlock(state: NodeMaterialBuildState): this;
  143063. }
  143064. }
  143065. declare module BABYLON {
  143066. /**
  143067. * block used to Generate a Worley Noise 3D Noise Pattern
  143068. */
  143069. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  143070. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  143071. manhattanDistance: boolean;
  143072. /**
  143073. * Creates a new WorleyNoise3DBlock
  143074. * @param name defines the block name
  143075. */
  143076. constructor(name: string);
  143077. /**
  143078. * Gets the current class name
  143079. * @returns the class name
  143080. */
  143081. getClassName(): string;
  143082. /**
  143083. * Gets the seed input component
  143084. */
  143085. get seed(): NodeMaterialConnectionPoint;
  143086. /**
  143087. * Gets the jitter input component
  143088. */
  143089. get jitter(): NodeMaterialConnectionPoint;
  143090. /**
  143091. * Gets the output component
  143092. */
  143093. get output(): NodeMaterialConnectionPoint;
  143094. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  143095. /**
  143096. * Exposes the properties to the UI?
  143097. */
  143098. protected _dumpPropertiesCode(): string;
  143099. /**
  143100. * Exposes the properties to the Seralize?
  143101. */
  143102. serialize(): any;
  143103. /**
  143104. * Exposes the properties to the deseralize?
  143105. */
  143106. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143107. }
  143108. }
  143109. declare module BABYLON {
  143110. /**
  143111. * block used to Generate a Simplex Perlin 3d Noise Pattern
  143112. */
  143113. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  143114. /**
  143115. * Creates a new SimplexPerlin3DBlock
  143116. * @param name defines the block name
  143117. */
  143118. constructor(name: string);
  143119. /**
  143120. * Gets the current class name
  143121. * @returns the class name
  143122. */
  143123. getClassName(): string;
  143124. /**
  143125. * Gets the seed operand input component
  143126. */
  143127. get seed(): NodeMaterialConnectionPoint;
  143128. /**
  143129. * Gets the output component
  143130. */
  143131. get output(): NodeMaterialConnectionPoint;
  143132. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  143133. }
  143134. }
  143135. declare module BABYLON {
  143136. /**
  143137. * Block used to blend normals
  143138. */
  143139. export class NormalBlendBlock extends NodeMaterialBlock {
  143140. /**
  143141. * Creates a new NormalBlendBlock
  143142. * @param name defines the block name
  143143. */
  143144. constructor(name: string);
  143145. /**
  143146. * Gets the current class name
  143147. * @returns the class name
  143148. */
  143149. getClassName(): string;
  143150. /**
  143151. * Gets the first input component
  143152. */
  143153. get normalMap0(): NodeMaterialConnectionPoint;
  143154. /**
  143155. * Gets the second input component
  143156. */
  143157. get normalMap1(): NodeMaterialConnectionPoint;
  143158. /**
  143159. * Gets the output component
  143160. */
  143161. get output(): NodeMaterialConnectionPoint;
  143162. protected _buildBlock(state: NodeMaterialBuildState): this;
  143163. }
  143164. }
  143165. declare module BABYLON {
  143166. /**
  143167. * Block used to rotate a 2d vector by a given angle
  143168. */
  143169. export class Rotate2dBlock extends NodeMaterialBlock {
  143170. /**
  143171. * Creates a new Rotate2dBlock
  143172. * @param name defines the block name
  143173. */
  143174. constructor(name: string);
  143175. /**
  143176. * Gets the current class name
  143177. * @returns the class name
  143178. */
  143179. getClassName(): string;
  143180. /**
  143181. * Gets the input vector
  143182. */
  143183. get input(): NodeMaterialConnectionPoint;
  143184. /**
  143185. * Gets the input angle
  143186. */
  143187. get angle(): NodeMaterialConnectionPoint;
  143188. /**
  143189. * Gets the output component
  143190. */
  143191. get output(): NodeMaterialConnectionPoint;
  143192. autoConfigure(material: NodeMaterial): void;
  143193. protected _buildBlock(state: NodeMaterialBuildState): this;
  143194. }
  143195. }
  143196. declare module BABYLON {
  143197. /**
  143198. * Block used to get the reflected vector from a direction and a normal
  143199. */
  143200. export class ReflectBlock extends NodeMaterialBlock {
  143201. /**
  143202. * Creates a new ReflectBlock
  143203. * @param name defines the block name
  143204. */
  143205. constructor(name: string);
  143206. /**
  143207. * Gets the current class name
  143208. * @returns the class name
  143209. */
  143210. getClassName(): string;
  143211. /**
  143212. * Gets the incident component
  143213. */
  143214. get incident(): NodeMaterialConnectionPoint;
  143215. /**
  143216. * Gets the normal component
  143217. */
  143218. get normal(): NodeMaterialConnectionPoint;
  143219. /**
  143220. * Gets the output component
  143221. */
  143222. get output(): NodeMaterialConnectionPoint;
  143223. protected _buildBlock(state: NodeMaterialBuildState): this;
  143224. }
  143225. }
  143226. declare module BABYLON {
  143227. /**
  143228. * Block used to get the refracted vector from a direction and a normal
  143229. */
  143230. export class RefractBlock extends NodeMaterialBlock {
  143231. /**
  143232. * Creates a new RefractBlock
  143233. * @param name defines the block name
  143234. */
  143235. constructor(name: string);
  143236. /**
  143237. * Gets the current class name
  143238. * @returns the class name
  143239. */
  143240. getClassName(): string;
  143241. /**
  143242. * Gets the incident component
  143243. */
  143244. get incident(): NodeMaterialConnectionPoint;
  143245. /**
  143246. * Gets the normal component
  143247. */
  143248. get normal(): NodeMaterialConnectionPoint;
  143249. /**
  143250. * Gets the index of refraction component
  143251. */
  143252. get ior(): NodeMaterialConnectionPoint;
  143253. /**
  143254. * Gets the output component
  143255. */
  143256. get output(): NodeMaterialConnectionPoint;
  143257. protected _buildBlock(state: NodeMaterialBuildState): this;
  143258. }
  143259. }
  143260. declare module BABYLON {
  143261. /**
  143262. * Block used to desaturate a color
  143263. */
  143264. export class DesaturateBlock extends NodeMaterialBlock {
  143265. /**
  143266. * Creates a new DesaturateBlock
  143267. * @param name defines the block name
  143268. */
  143269. constructor(name: string);
  143270. /**
  143271. * Gets the current class name
  143272. * @returns the class name
  143273. */
  143274. getClassName(): string;
  143275. /**
  143276. * Gets the color operand input component
  143277. */
  143278. get color(): NodeMaterialConnectionPoint;
  143279. /**
  143280. * Gets the level operand input component
  143281. */
  143282. get level(): NodeMaterialConnectionPoint;
  143283. /**
  143284. * Gets the output component
  143285. */
  143286. get output(): NodeMaterialConnectionPoint;
  143287. protected _buildBlock(state: NodeMaterialBuildState): this;
  143288. }
  143289. }
  143290. declare module BABYLON {
  143291. /**
  143292. * Block used to implement the ambient occlusion module of the PBR material
  143293. */
  143294. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  143295. /**
  143296. * Create a new AmbientOcclusionBlock
  143297. * @param name defines the block name
  143298. */
  143299. constructor(name: string);
  143300. /**
  143301. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  143302. */
  143303. useAmbientInGrayScale: boolean;
  143304. /**
  143305. * Initialize the block and prepare the context for build
  143306. * @param state defines the state that will be used for the build
  143307. */
  143308. initialize(state: NodeMaterialBuildState): void;
  143309. /**
  143310. * Gets the current class name
  143311. * @returns the class name
  143312. */
  143313. getClassName(): string;
  143314. /**
  143315. * Gets the texture input component
  143316. */
  143317. get texture(): NodeMaterialConnectionPoint;
  143318. /**
  143319. * Gets the texture intensity component
  143320. */
  143321. get intensity(): NodeMaterialConnectionPoint;
  143322. /**
  143323. * Gets the direct light intensity input component
  143324. */
  143325. get directLightIntensity(): NodeMaterialConnectionPoint;
  143326. /**
  143327. * Gets the ambient occlusion object output component
  143328. */
  143329. get ambientOcclusion(): NodeMaterialConnectionPoint;
  143330. /**
  143331. * Gets the main code of the block (fragment side)
  143332. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  143333. * @returns the shader code
  143334. */
  143335. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  143336. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143337. protected _buildBlock(state: NodeMaterialBuildState): this;
  143338. protected _dumpPropertiesCode(): string;
  143339. serialize(): any;
  143340. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143341. }
  143342. }
  143343. declare module BABYLON {
  143344. /**
  143345. * Block used to implement the reflection module of the PBR material
  143346. */
  143347. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  143348. /** @hidden */
  143349. _defineLODReflectionAlpha: string;
  143350. /** @hidden */
  143351. _defineLinearSpecularReflection: string;
  143352. private _vEnvironmentIrradianceName;
  143353. /** @hidden */
  143354. _vReflectionMicrosurfaceInfosName: string;
  143355. /** @hidden */
  143356. _vReflectionInfosName: string;
  143357. /** @hidden */
  143358. _vReflectionFilteringInfoName: string;
  143359. private _scene;
  143360. /**
  143361. * The three properties below are set by the main PBR block prior to calling methods of this class.
  143362. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  143363. * It's less burden on the user side in the editor part.
  143364. */
  143365. /** @hidden */
  143366. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  143367. /** @hidden */
  143368. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  143369. /** @hidden */
  143370. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  143371. /**
  143372. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  143373. * diffuse part of the IBL.
  143374. */
  143375. useSphericalHarmonics: boolean;
  143376. /**
  143377. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  143378. */
  143379. forceIrradianceInFragment: boolean;
  143380. /**
  143381. * Create a new ReflectionBlock
  143382. * @param name defines the block name
  143383. */
  143384. constructor(name: string);
  143385. /**
  143386. * Gets the current class name
  143387. * @returns the class name
  143388. */
  143389. getClassName(): string;
  143390. /**
  143391. * Gets the position input component
  143392. */
  143393. get position(): NodeMaterialConnectionPoint;
  143394. /**
  143395. * Gets the world position input component
  143396. */
  143397. get worldPosition(): NodeMaterialConnectionPoint;
  143398. /**
  143399. * Gets the world normal input component
  143400. */
  143401. get worldNormal(): NodeMaterialConnectionPoint;
  143402. /**
  143403. * Gets the world input component
  143404. */
  143405. get world(): NodeMaterialConnectionPoint;
  143406. /**
  143407. * Gets the camera (or eye) position component
  143408. */
  143409. get cameraPosition(): NodeMaterialConnectionPoint;
  143410. /**
  143411. * Gets the view input component
  143412. */
  143413. get view(): NodeMaterialConnectionPoint;
  143414. /**
  143415. * Gets the color input component
  143416. */
  143417. get color(): NodeMaterialConnectionPoint;
  143418. /**
  143419. * Gets the reflection object output component
  143420. */
  143421. get reflection(): NodeMaterialConnectionPoint;
  143422. /**
  143423. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  143424. */
  143425. get hasTexture(): boolean;
  143426. /**
  143427. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  143428. */
  143429. get reflectionColor(): string;
  143430. protected _getTexture(): Nullable<BaseTexture>;
  143431. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143432. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  143433. /**
  143434. * Gets the code to inject in the vertex shader
  143435. * @param state current state of the node material building
  143436. * @returns the shader code
  143437. */
  143438. handleVertexSide(state: NodeMaterialBuildState): string;
  143439. /**
  143440. * Gets the main code of the block (fragment side)
  143441. * @param state current state of the node material building
  143442. * @param normalVarName name of the existing variable corresponding to the normal
  143443. * @returns the shader code
  143444. */
  143445. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  143446. protected _buildBlock(state: NodeMaterialBuildState): this;
  143447. protected _dumpPropertiesCode(): string;
  143448. serialize(): any;
  143449. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143450. }
  143451. }
  143452. declare module BABYLON {
  143453. /**
  143454. * Block used to implement the sheen module of the PBR material
  143455. */
  143456. export class SheenBlock extends NodeMaterialBlock {
  143457. /**
  143458. * Create a new SheenBlock
  143459. * @param name defines the block name
  143460. */
  143461. constructor(name: string);
  143462. /**
  143463. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  143464. * It allows the strength of the sheen effect to not depend on the base color of the material,
  143465. * making it easier to setup and tweak the effect
  143466. */
  143467. albedoScaling: boolean;
  143468. /**
  143469. * Defines if the sheen is linked to the sheen color.
  143470. */
  143471. linkSheenWithAlbedo: boolean;
  143472. /**
  143473. * Initialize the block and prepare the context for build
  143474. * @param state defines the state that will be used for the build
  143475. */
  143476. initialize(state: NodeMaterialBuildState): void;
  143477. /**
  143478. * Gets the current class name
  143479. * @returns the class name
  143480. */
  143481. getClassName(): string;
  143482. /**
  143483. * Gets the intensity input component
  143484. */
  143485. get intensity(): NodeMaterialConnectionPoint;
  143486. /**
  143487. * Gets the color input component
  143488. */
  143489. get color(): NodeMaterialConnectionPoint;
  143490. /**
  143491. * Gets the roughness input component
  143492. */
  143493. get roughness(): NodeMaterialConnectionPoint;
  143494. /**
  143495. * Gets the sheen object output component
  143496. */
  143497. get sheen(): NodeMaterialConnectionPoint;
  143498. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143499. /**
  143500. * Gets the main code of the block (fragment side)
  143501. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  143502. * @returns the shader code
  143503. */
  143504. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  143505. protected _buildBlock(state: NodeMaterialBuildState): this;
  143506. protected _dumpPropertiesCode(): string;
  143507. serialize(): any;
  143508. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143509. }
  143510. }
  143511. declare module BABYLON {
  143512. /**
  143513. * Block used to implement the reflectivity module of the PBR material
  143514. */
  143515. export class ReflectivityBlock extends NodeMaterialBlock {
  143516. private _metallicReflectanceColor;
  143517. private _metallicF0Factor;
  143518. /** @hidden */
  143519. _vMetallicReflectanceFactorsName: string;
  143520. /**
  143521. * The property below is set by the main PBR block prior to calling methods of this class.
  143522. */
  143523. /** @hidden */
  143524. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  143525. /**
  143526. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  143527. */
  143528. useAmbientOcclusionFromMetallicTextureRed: boolean;
  143529. /**
  143530. * Specifies if the metallic texture contains the metallness information in its blue channel.
  143531. */
  143532. useMetallnessFromMetallicTextureBlue: boolean;
  143533. /**
  143534. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  143535. */
  143536. useRoughnessFromMetallicTextureAlpha: boolean;
  143537. /**
  143538. * Specifies if the metallic texture contains the roughness information in its green channel.
  143539. */
  143540. useRoughnessFromMetallicTextureGreen: boolean;
  143541. /**
  143542. * Create a new ReflectivityBlock
  143543. * @param name defines the block name
  143544. */
  143545. constructor(name: string);
  143546. /**
  143547. * Initialize the block and prepare the context for build
  143548. * @param state defines the state that will be used for the build
  143549. */
  143550. initialize(state: NodeMaterialBuildState): void;
  143551. /**
  143552. * Gets the current class name
  143553. * @returns the class name
  143554. */
  143555. getClassName(): string;
  143556. /**
  143557. * Gets the metallic input component
  143558. */
  143559. get metallic(): NodeMaterialConnectionPoint;
  143560. /**
  143561. * Gets the roughness input component
  143562. */
  143563. get roughness(): NodeMaterialConnectionPoint;
  143564. /**
  143565. * Gets the texture input component
  143566. */
  143567. get texture(): NodeMaterialConnectionPoint;
  143568. /**
  143569. * Gets the reflectivity object output component
  143570. */
  143571. get reflectivity(): NodeMaterialConnectionPoint;
  143572. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  143573. /**
  143574. * Gets the main code of the block (fragment side)
  143575. * @param state current state of the node material building
  143576. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  143577. * @returns the shader code
  143578. */
  143579. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  143580. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143581. protected _buildBlock(state: NodeMaterialBuildState): this;
  143582. protected _dumpPropertiesCode(): string;
  143583. serialize(): any;
  143584. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143585. }
  143586. }
  143587. declare module BABYLON {
  143588. /**
  143589. * Block used to implement the anisotropy module of the PBR material
  143590. */
  143591. export class AnisotropyBlock extends NodeMaterialBlock {
  143592. /**
  143593. * The two properties below are set by the main PBR block prior to calling methods of this class.
  143594. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  143595. * It's less burden on the user side in the editor part.
  143596. */
  143597. /** @hidden */
  143598. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  143599. /** @hidden */
  143600. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  143601. /**
  143602. * Create a new AnisotropyBlock
  143603. * @param name defines the block name
  143604. */
  143605. constructor(name: string);
  143606. /**
  143607. * Initialize the block and prepare the context for build
  143608. * @param state defines the state that will be used for the build
  143609. */
  143610. initialize(state: NodeMaterialBuildState): void;
  143611. /**
  143612. * Gets the current class name
  143613. * @returns the class name
  143614. */
  143615. getClassName(): string;
  143616. /**
  143617. * Gets the intensity input component
  143618. */
  143619. get intensity(): NodeMaterialConnectionPoint;
  143620. /**
  143621. * Gets the direction input component
  143622. */
  143623. get direction(): NodeMaterialConnectionPoint;
  143624. /**
  143625. * Gets the texture input component
  143626. */
  143627. get texture(): NodeMaterialConnectionPoint;
  143628. /**
  143629. * Gets the uv input component
  143630. */
  143631. get uv(): NodeMaterialConnectionPoint;
  143632. /**
  143633. * Gets the worldTangent input component
  143634. */
  143635. get worldTangent(): NodeMaterialConnectionPoint;
  143636. /**
  143637. * Gets the anisotropy object output component
  143638. */
  143639. get anisotropy(): NodeMaterialConnectionPoint;
  143640. private _generateTBNSpace;
  143641. /**
  143642. * Gets the main code of the block (fragment side)
  143643. * @param state current state of the node material building
  143644. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  143645. * @returns the shader code
  143646. */
  143647. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  143648. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143649. protected _buildBlock(state: NodeMaterialBuildState): this;
  143650. }
  143651. }
  143652. declare module BABYLON {
  143653. /**
  143654. * Block used to implement the clear coat module of the PBR material
  143655. */
  143656. export class ClearCoatBlock extends NodeMaterialBlock {
  143657. private _scene;
  143658. /**
  143659. * Create a new ClearCoatBlock
  143660. * @param name defines the block name
  143661. */
  143662. constructor(name: string);
  143663. /**
  143664. * Initialize the block and prepare the context for build
  143665. * @param state defines the state that will be used for the build
  143666. */
  143667. initialize(state: NodeMaterialBuildState): void;
  143668. /**
  143669. * Gets the current class name
  143670. * @returns the class name
  143671. */
  143672. getClassName(): string;
  143673. /**
  143674. * Gets the intensity input component
  143675. */
  143676. get intensity(): NodeMaterialConnectionPoint;
  143677. /**
  143678. * Gets the roughness input component
  143679. */
  143680. get roughness(): NodeMaterialConnectionPoint;
  143681. /**
  143682. * Gets the ior input component
  143683. */
  143684. get ior(): NodeMaterialConnectionPoint;
  143685. /**
  143686. * Gets the texture input component
  143687. */
  143688. get texture(): NodeMaterialConnectionPoint;
  143689. /**
  143690. * Gets the bump texture input component
  143691. */
  143692. get bumpTexture(): NodeMaterialConnectionPoint;
  143693. /**
  143694. * Gets the uv input component
  143695. */
  143696. get uv(): NodeMaterialConnectionPoint;
  143697. /**
  143698. * Gets the tint color input component
  143699. */
  143700. get tintColor(): NodeMaterialConnectionPoint;
  143701. /**
  143702. * Gets the tint "at distance" input component
  143703. */
  143704. get tintAtDistance(): NodeMaterialConnectionPoint;
  143705. /**
  143706. * Gets the tint thickness input component
  143707. */
  143708. get tintThickness(): NodeMaterialConnectionPoint;
  143709. /**
  143710. * Gets the world tangent input component
  143711. */
  143712. get worldTangent(): NodeMaterialConnectionPoint;
  143713. /**
  143714. * Gets the clear coat object output component
  143715. */
  143716. get clearcoat(): NodeMaterialConnectionPoint;
  143717. autoConfigure(material: NodeMaterial): void;
  143718. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143719. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  143720. private _generateTBNSpace;
  143721. /**
  143722. * Gets the main code of the block (fragment side)
  143723. * @param state current state of the node material building
  143724. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  143725. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  143726. * @param worldPosVarName name of the variable holding the world position
  143727. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  143728. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  143729. * @param worldNormalVarName name of the variable holding the world normal
  143730. * @returns the shader code
  143731. */
  143732. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  143733. protected _buildBlock(state: NodeMaterialBuildState): this;
  143734. }
  143735. }
  143736. declare module BABYLON {
  143737. /**
  143738. * Block used to implement the sub surface module of the PBR material
  143739. */
  143740. export class SubSurfaceBlock extends NodeMaterialBlock {
  143741. /**
  143742. * Create a new SubSurfaceBlock
  143743. * @param name defines the block name
  143744. */
  143745. constructor(name: string);
  143746. /**
  143747. * Stores the intensity of the different subsurface effects in the thickness texture.
  143748. * * the green channel is the translucency intensity.
  143749. * * the blue channel is the scattering intensity.
  143750. * * the alpha channel is the refraction intensity.
  143751. */
  143752. useMaskFromThicknessTexture: boolean;
  143753. /**
  143754. * Initialize the block and prepare the context for build
  143755. * @param state defines the state that will be used for the build
  143756. */
  143757. initialize(state: NodeMaterialBuildState): void;
  143758. /**
  143759. * Gets the current class name
  143760. * @returns the class name
  143761. */
  143762. getClassName(): string;
  143763. /**
  143764. * Gets the min thickness input component
  143765. */
  143766. get minThickness(): NodeMaterialConnectionPoint;
  143767. /**
  143768. * Gets the max thickness input component
  143769. */
  143770. get maxThickness(): NodeMaterialConnectionPoint;
  143771. /**
  143772. * Gets the thickness texture component
  143773. */
  143774. get thicknessTexture(): NodeMaterialConnectionPoint;
  143775. /**
  143776. * Gets the tint color input component
  143777. */
  143778. get tintColor(): NodeMaterialConnectionPoint;
  143779. /**
  143780. * Gets the translucency intensity input component
  143781. */
  143782. get translucencyIntensity(): NodeMaterialConnectionPoint;
  143783. /**
  143784. * Gets the translucency diffusion distance input component
  143785. */
  143786. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  143787. /**
  143788. * Gets the refraction object parameters
  143789. */
  143790. get refraction(): NodeMaterialConnectionPoint;
  143791. /**
  143792. * Gets the sub surface object output component
  143793. */
  143794. get subsurface(): NodeMaterialConnectionPoint;
  143795. autoConfigure(material: NodeMaterial): void;
  143796. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143797. /**
  143798. * Gets the main code of the block (fragment side)
  143799. * @param state current state of the node material building
  143800. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  143801. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  143802. * @param worldPosVarName name of the variable holding the world position
  143803. * @returns the shader code
  143804. */
  143805. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  143806. protected _buildBlock(state: NodeMaterialBuildState): this;
  143807. }
  143808. }
  143809. declare module BABYLON {
  143810. /**
  143811. * Block used to implement the PBR metallic/roughness model
  143812. */
  143813. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  143814. /**
  143815. * Gets or sets the light associated with this block
  143816. */
  143817. light: Nullable<Light>;
  143818. private _lightId;
  143819. private _scene;
  143820. private _environmentBRDFTexture;
  143821. private _environmentBrdfSamplerName;
  143822. private _vNormalWName;
  143823. private _invertNormalName;
  143824. /**
  143825. * Create a new ReflectionBlock
  143826. * @param name defines the block name
  143827. */
  143828. constructor(name: string);
  143829. /**
  143830. * Intensity of the direct lights e.g. the four lights available in your scene.
  143831. * This impacts both the direct diffuse and specular highlights.
  143832. */
  143833. directIntensity: number;
  143834. /**
  143835. * Intensity of the environment e.g. how much the environment will light the object
  143836. * either through harmonics for rough material or through the refelction for shiny ones.
  143837. */
  143838. environmentIntensity: number;
  143839. /**
  143840. * This is a special control allowing the reduction of the specular highlights coming from the
  143841. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  143842. */
  143843. specularIntensity: number;
  143844. /**
  143845. * Defines the falloff type used in this material.
  143846. * It by default is Physical.
  143847. */
  143848. lightFalloff: number;
  143849. /**
  143850. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  143851. */
  143852. useAlphaFromAlbedoTexture: boolean;
  143853. /**
  143854. * Specifies that alpha test should be used
  143855. */
  143856. useAlphaTest: boolean;
  143857. /**
  143858. * Defines the alpha limits in alpha test mode.
  143859. */
  143860. alphaTestCutoff: number;
  143861. /**
  143862. * Specifies that alpha blending should be used
  143863. */
  143864. useAlphaBlending: boolean;
  143865. /**
  143866. * Defines if the alpha value should be determined via the rgb values.
  143867. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  143868. */
  143869. opacityRGB: boolean;
  143870. /**
  143871. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  143872. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  143873. */
  143874. useRadianceOverAlpha: boolean;
  143875. /**
  143876. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  143877. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  143878. */
  143879. useSpecularOverAlpha: boolean;
  143880. /**
  143881. * Enables specular anti aliasing in the PBR shader.
  143882. * It will both interacts on the Geometry for analytical and IBL lighting.
  143883. * It also prefilter the roughness map based on the bump values.
  143884. */
  143885. enableSpecularAntiAliasing: boolean;
  143886. /**
  143887. * Enables realtime filtering on the texture.
  143888. */
  143889. realTimeFiltering: boolean;
  143890. /**
  143891. * Quality switch for realtime filtering
  143892. */
  143893. realTimeFilteringQuality: number;
  143894. /**
  143895. * Defines if the material uses energy conservation.
  143896. */
  143897. useEnergyConservation: boolean;
  143898. /**
  143899. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  143900. * too much the area relying on ambient texture to define their ambient occlusion.
  143901. */
  143902. useRadianceOcclusion: boolean;
  143903. /**
  143904. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  143905. * makes the reflect vector face the model (under horizon).
  143906. */
  143907. useHorizonOcclusion: boolean;
  143908. /**
  143909. * If set to true, no lighting calculations will be applied.
  143910. */
  143911. unlit: boolean;
  143912. /**
  143913. * Force normal to face away from face.
  143914. */
  143915. forceNormalForward: boolean;
  143916. /**
  143917. * Defines the material debug mode.
  143918. * It helps seeing only some components of the material while troubleshooting.
  143919. */
  143920. debugMode: number;
  143921. /**
  143922. * Specify from where on screen the debug mode should start.
  143923. * The value goes from -1 (full screen) to 1 (not visible)
  143924. * It helps with side by side comparison against the final render
  143925. * This defaults to 0
  143926. */
  143927. debugLimit: number;
  143928. /**
  143929. * As the default viewing range might not be enough (if the ambient is really small for instance)
  143930. * You can use the factor to better multiply the final value.
  143931. */
  143932. debugFactor: number;
  143933. /**
  143934. * Initialize the block and prepare the context for build
  143935. * @param state defines the state that will be used for the build
  143936. */
  143937. initialize(state: NodeMaterialBuildState): void;
  143938. /**
  143939. * Gets the current class name
  143940. * @returns the class name
  143941. */
  143942. getClassName(): string;
  143943. /**
  143944. * Gets the world position input component
  143945. */
  143946. get worldPosition(): NodeMaterialConnectionPoint;
  143947. /**
  143948. * Gets the world normal input component
  143949. */
  143950. get worldNormal(): NodeMaterialConnectionPoint;
  143951. /**
  143952. * Gets the perturbed normal input component
  143953. */
  143954. get perturbedNormal(): NodeMaterialConnectionPoint;
  143955. /**
  143956. * Gets the camera position input component
  143957. */
  143958. get cameraPosition(): NodeMaterialConnectionPoint;
  143959. /**
  143960. * Gets the base color input component
  143961. */
  143962. get baseColor(): NodeMaterialConnectionPoint;
  143963. /**
  143964. * Gets the opacity texture input component
  143965. */
  143966. get opacityTexture(): NodeMaterialConnectionPoint;
  143967. /**
  143968. * Gets the ambient color input component
  143969. */
  143970. get ambientColor(): NodeMaterialConnectionPoint;
  143971. /**
  143972. * Gets the reflectivity object parameters
  143973. */
  143974. get reflectivity(): NodeMaterialConnectionPoint;
  143975. /**
  143976. * Gets the ambient occlusion object parameters
  143977. */
  143978. get ambientOcclusion(): NodeMaterialConnectionPoint;
  143979. /**
  143980. * Gets the reflection object parameters
  143981. */
  143982. get reflection(): NodeMaterialConnectionPoint;
  143983. /**
  143984. * Gets the sheen object parameters
  143985. */
  143986. get sheen(): NodeMaterialConnectionPoint;
  143987. /**
  143988. * Gets the clear coat object parameters
  143989. */
  143990. get clearcoat(): NodeMaterialConnectionPoint;
  143991. /**
  143992. * Gets the sub surface object parameters
  143993. */
  143994. get subsurface(): NodeMaterialConnectionPoint;
  143995. /**
  143996. * Gets the anisotropy object parameters
  143997. */
  143998. get anisotropy(): NodeMaterialConnectionPoint;
  143999. /**
  144000. * Gets the ambient output component
  144001. */
  144002. get ambient(): NodeMaterialConnectionPoint;
  144003. /**
  144004. * Gets the diffuse output component
  144005. */
  144006. get diffuse(): NodeMaterialConnectionPoint;
  144007. /**
  144008. * Gets the specular output component
  144009. */
  144010. get specular(): NodeMaterialConnectionPoint;
  144011. /**
  144012. * Gets the sheen output component
  144013. */
  144014. get sheenDir(): NodeMaterialConnectionPoint;
  144015. /**
  144016. * Gets the clear coat output component
  144017. */
  144018. get clearcoatDir(): NodeMaterialConnectionPoint;
  144019. /**
  144020. * Gets the indirect diffuse output component
  144021. */
  144022. get diffuseIndirect(): NodeMaterialConnectionPoint;
  144023. /**
  144024. * Gets the indirect specular output component
  144025. */
  144026. get specularIndirect(): NodeMaterialConnectionPoint;
  144027. /**
  144028. * Gets the indirect sheen output component
  144029. */
  144030. get sheenIndirect(): NodeMaterialConnectionPoint;
  144031. /**
  144032. * Gets the indirect clear coat output component
  144033. */
  144034. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  144035. /**
  144036. * Gets the refraction output component
  144037. */
  144038. get refraction(): NodeMaterialConnectionPoint;
  144039. /**
  144040. * Gets the global lighting output component
  144041. */
  144042. get lighting(): NodeMaterialConnectionPoint;
  144043. /**
  144044. * Gets the shadow output component
  144045. */
  144046. get shadow(): NodeMaterialConnectionPoint;
  144047. /**
  144048. * Gets the alpha output component
  144049. */
  144050. get alpha(): NodeMaterialConnectionPoint;
  144051. autoConfigure(material: NodeMaterial): void;
  144052. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144053. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  144054. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144055. private _injectVertexCode;
  144056. /**
  144057. * Gets the code corresponding to the albedo/opacity module
  144058. * @returns the shader code
  144059. */
  144060. getAlbedoOpacityCode(): string;
  144061. protected _buildBlock(state: NodeMaterialBuildState): this;
  144062. protected _dumpPropertiesCode(): string;
  144063. serialize(): any;
  144064. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144065. }
  144066. }
  144067. declare module BABYLON {
  144068. /**
  144069. * Block used to compute value of one parameter modulo another
  144070. */
  144071. export class ModBlock extends NodeMaterialBlock {
  144072. /**
  144073. * Creates a new ModBlock
  144074. * @param name defines the block name
  144075. */
  144076. constructor(name: string);
  144077. /**
  144078. * Gets the current class name
  144079. * @returns the class name
  144080. */
  144081. getClassName(): string;
  144082. /**
  144083. * Gets the left operand input component
  144084. */
  144085. get left(): NodeMaterialConnectionPoint;
  144086. /**
  144087. * Gets the right operand input component
  144088. */
  144089. get right(): NodeMaterialConnectionPoint;
  144090. /**
  144091. * Gets the output component
  144092. */
  144093. get output(): NodeMaterialConnectionPoint;
  144094. protected _buildBlock(state: NodeMaterialBuildState): this;
  144095. }
  144096. }
  144097. declare module BABYLON {
  144098. /**
  144099. * Helper class to push actions to a pool of workers.
  144100. */
  144101. export class WorkerPool implements IDisposable {
  144102. private _workerInfos;
  144103. private _pendingActions;
  144104. /**
  144105. * Constructor
  144106. * @param workers Array of workers to use for actions
  144107. */
  144108. constructor(workers: Array<Worker>);
  144109. /**
  144110. * Terminates all workers and clears any pending actions.
  144111. */
  144112. dispose(): void;
  144113. /**
  144114. * Pushes an action to the worker pool. If all the workers are active, the action will be
  144115. * pended until a worker has completed its action.
  144116. * @param action The action to perform. Call onComplete when the action is complete.
  144117. */
  144118. push(action: (worker: Worker, onComplete: () => void) => void): void;
  144119. private _execute;
  144120. }
  144121. }
  144122. declare module BABYLON {
  144123. /**
  144124. * Configuration for Draco compression
  144125. */
  144126. export interface IDracoCompressionConfiguration {
  144127. /**
  144128. * Configuration for the decoder.
  144129. */
  144130. decoder: {
  144131. /**
  144132. * The url to the WebAssembly module.
  144133. */
  144134. wasmUrl?: string;
  144135. /**
  144136. * The url to the WebAssembly binary.
  144137. */
  144138. wasmBinaryUrl?: string;
  144139. /**
  144140. * The url to the fallback JavaScript module.
  144141. */
  144142. fallbackUrl?: string;
  144143. };
  144144. }
  144145. /**
  144146. * Draco compression (https://google.github.io/draco/)
  144147. *
  144148. * This class wraps the Draco module.
  144149. *
  144150. * **Encoder**
  144151. *
  144152. * The encoder is not currently implemented.
  144153. *
  144154. * **Decoder**
  144155. *
  144156. * 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.
  144157. *
  144158. * To update the configuration, use the following code:
  144159. * ```javascript
  144160. * DracoCompression.Configuration = {
  144161. * decoder: {
  144162. * wasmUrl: "<url to the WebAssembly library>",
  144163. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  144164. * fallbackUrl: "<url to the fallback JavaScript library>",
  144165. * }
  144166. * };
  144167. * ```
  144168. *
  144169. * 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.
  144170. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  144171. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  144172. *
  144173. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  144174. * ```javascript
  144175. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  144176. * ```
  144177. *
  144178. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  144179. */
  144180. export class DracoCompression implements IDisposable {
  144181. private _workerPoolPromise?;
  144182. private _decoderModulePromise?;
  144183. /**
  144184. * The configuration. Defaults to the following urls:
  144185. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  144186. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  144187. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  144188. */
  144189. static Configuration: IDracoCompressionConfiguration;
  144190. /**
  144191. * Returns true if the decoder configuration is available.
  144192. */
  144193. static get DecoderAvailable(): boolean;
  144194. /**
  144195. * Default number of workers to create when creating the draco compression object.
  144196. */
  144197. static DefaultNumWorkers: number;
  144198. private static GetDefaultNumWorkers;
  144199. private static _Default;
  144200. /**
  144201. * Default instance for the draco compression object.
  144202. */
  144203. static get Default(): DracoCompression;
  144204. /**
  144205. * Constructor
  144206. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  144207. */
  144208. constructor(numWorkers?: number);
  144209. /**
  144210. * Stop all async operations and release resources.
  144211. */
  144212. dispose(): void;
  144213. /**
  144214. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  144215. * @returns a promise that resolves when ready
  144216. */
  144217. whenReadyAsync(): Promise<void>;
  144218. /**
  144219. * Decode Draco compressed mesh data to vertex data.
  144220. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  144221. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  144222. * @returns A promise that resolves with the decoded vertex data
  144223. */
  144224. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  144225. [kind: string]: number;
  144226. }): Promise<VertexData>;
  144227. }
  144228. }
  144229. declare module BABYLON {
  144230. /**
  144231. * Class for building Constructive Solid Geometry
  144232. */
  144233. export class CSG {
  144234. private polygons;
  144235. /**
  144236. * The world matrix
  144237. */
  144238. matrix: Matrix;
  144239. /**
  144240. * Stores the position
  144241. */
  144242. position: Vector3;
  144243. /**
  144244. * Stores the rotation
  144245. */
  144246. rotation: Vector3;
  144247. /**
  144248. * Stores the rotation quaternion
  144249. */
  144250. rotationQuaternion: Nullable<Quaternion>;
  144251. /**
  144252. * Stores the scaling vector
  144253. */
  144254. scaling: Vector3;
  144255. /**
  144256. * Convert the Mesh to CSG
  144257. * @param mesh The Mesh to convert to CSG
  144258. * @returns A new CSG from the Mesh
  144259. */
  144260. static FromMesh(mesh: Mesh): CSG;
  144261. /**
  144262. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  144263. * @param polygons Polygons used to construct a CSG solid
  144264. */
  144265. private static FromPolygons;
  144266. /**
  144267. * Clones, or makes a deep copy, of the CSG
  144268. * @returns A new CSG
  144269. */
  144270. clone(): CSG;
  144271. /**
  144272. * Unions this CSG with another CSG
  144273. * @param csg The CSG to union against this CSG
  144274. * @returns The unioned CSG
  144275. */
  144276. union(csg: CSG): CSG;
  144277. /**
  144278. * Unions this CSG with another CSG in place
  144279. * @param csg The CSG to union against this CSG
  144280. */
  144281. unionInPlace(csg: CSG): void;
  144282. /**
  144283. * Subtracts this CSG with another CSG
  144284. * @param csg The CSG to subtract against this CSG
  144285. * @returns A new CSG
  144286. */
  144287. subtract(csg: CSG): CSG;
  144288. /**
  144289. * Subtracts this CSG with another CSG in place
  144290. * @param csg The CSG to subtact against this CSG
  144291. */
  144292. subtractInPlace(csg: CSG): void;
  144293. /**
  144294. * Intersect this CSG with another CSG
  144295. * @param csg The CSG to intersect against this CSG
  144296. * @returns A new CSG
  144297. */
  144298. intersect(csg: CSG): CSG;
  144299. /**
  144300. * Intersects this CSG with another CSG in place
  144301. * @param csg The CSG to intersect against this CSG
  144302. */
  144303. intersectInPlace(csg: CSG): void;
  144304. /**
  144305. * Return a new CSG solid with solid and empty space switched. This solid is
  144306. * not modified.
  144307. * @returns A new CSG solid with solid and empty space switched
  144308. */
  144309. inverse(): CSG;
  144310. /**
  144311. * Inverses the CSG in place
  144312. */
  144313. inverseInPlace(): void;
  144314. /**
  144315. * This is used to keep meshes transformations so they can be restored
  144316. * when we build back a Babylon Mesh
  144317. * NB : All CSG operations are performed in world coordinates
  144318. * @param csg The CSG to copy the transform attributes from
  144319. * @returns This CSG
  144320. */
  144321. copyTransformAttributes(csg: CSG): CSG;
  144322. /**
  144323. * Build Raw mesh from CSG
  144324. * Coordinates here are in world space
  144325. * @param name The name of the mesh geometry
  144326. * @param scene The Scene
  144327. * @param keepSubMeshes Specifies if the submeshes should be kept
  144328. * @returns A new Mesh
  144329. */
  144330. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  144331. /**
  144332. * Build Mesh from CSG taking material and transforms into account
  144333. * @param name The name of the Mesh
  144334. * @param material The material of the Mesh
  144335. * @param scene The Scene
  144336. * @param keepSubMeshes Specifies if submeshes should be kept
  144337. * @returns The new Mesh
  144338. */
  144339. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  144340. }
  144341. }
  144342. declare module BABYLON {
  144343. /**
  144344. * Class used to create a trail following a mesh
  144345. */
  144346. export class TrailMesh extends Mesh {
  144347. private _generator;
  144348. private _autoStart;
  144349. private _running;
  144350. private _diameter;
  144351. private _length;
  144352. private _sectionPolygonPointsCount;
  144353. private _sectionVectors;
  144354. private _sectionNormalVectors;
  144355. private _beforeRenderObserver;
  144356. /**
  144357. * @constructor
  144358. * @param name The value used by scene.getMeshByName() to do a lookup.
  144359. * @param generator The mesh or transform node to generate a trail.
  144360. * @param scene The scene to add this mesh to.
  144361. * @param diameter Diameter of trailing mesh. Default is 1.
  144362. * @param length Length of trailing mesh. Default is 60.
  144363. * @param autoStart Automatically start trailing mesh. Default true.
  144364. */
  144365. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  144366. /**
  144367. * "TrailMesh"
  144368. * @returns "TrailMesh"
  144369. */
  144370. getClassName(): string;
  144371. private _createMesh;
  144372. /**
  144373. * Start trailing mesh.
  144374. */
  144375. start(): void;
  144376. /**
  144377. * Stop trailing mesh.
  144378. */
  144379. stop(): void;
  144380. /**
  144381. * Update trailing mesh geometry.
  144382. */
  144383. update(): void;
  144384. /**
  144385. * Returns a new TrailMesh object.
  144386. * @param name is a string, the name given to the new mesh
  144387. * @param newGenerator use new generator object for cloned trail mesh
  144388. * @returns a new mesh
  144389. */
  144390. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  144391. /**
  144392. * Serializes this trail mesh
  144393. * @param serializationObject object to write serialization to
  144394. */
  144395. serialize(serializationObject: any): void;
  144396. /**
  144397. * Parses a serialized trail mesh
  144398. * @param parsedMesh the serialized mesh
  144399. * @param scene the scene to create the trail mesh in
  144400. * @returns the created trail mesh
  144401. */
  144402. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  144403. }
  144404. }
  144405. declare module BABYLON {
  144406. /**
  144407. * Class containing static functions to help procedurally build meshes
  144408. */
  144409. export class TiledBoxBuilder {
  144410. /**
  144411. * Creates a box mesh
  144412. * 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)
  144413. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  144414. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144415. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144416. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144417. * @param name defines the name of the mesh
  144418. * @param options defines the options used to create the mesh
  144419. * @param scene defines the hosting scene
  144420. * @returns the box mesh
  144421. */
  144422. static CreateTiledBox(name: string, options: {
  144423. pattern?: number;
  144424. width?: number;
  144425. height?: number;
  144426. depth?: number;
  144427. tileSize?: number;
  144428. tileWidth?: number;
  144429. tileHeight?: number;
  144430. alignHorizontal?: number;
  144431. alignVertical?: number;
  144432. faceUV?: Vector4[];
  144433. faceColors?: Color4[];
  144434. sideOrientation?: number;
  144435. updatable?: boolean;
  144436. }, scene?: Nullable<Scene>): Mesh;
  144437. }
  144438. }
  144439. declare module BABYLON {
  144440. /**
  144441. * Class containing static functions to help procedurally build meshes
  144442. */
  144443. export class TorusKnotBuilder {
  144444. /**
  144445. * Creates a torus knot mesh
  144446. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  144447. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  144448. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  144449. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  144450. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144451. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144452. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  144453. * @param name defines the name of the mesh
  144454. * @param options defines the options used to create the mesh
  144455. * @param scene defines the hosting scene
  144456. * @returns the torus knot mesh
  144457. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  144458. */
  144459. static CreateTorusKnot(name: string, options: {
  144460. radius?: number;
  144461. tube?: number;
  144462. radialSegments?: number;
  144463. tubularSegments?: number;
  144464. p?: number;
  144465. q?: number;
  144466. updatable?: boolean;
  144467. sideOrientation?: number;
  144468. frontUVs?: Vector4;
  144469. backUVs?: Vector4;
  144470. }, scene: any): Mesh;
  144471. }
  144472. }
  144473. declare module BABYLON {
  144474. /**
  144475. * Polygon
  144476. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  144477. */
  144478. export class Polygon {
  144479. /**
  144480. * Creates a rectangle
  144481. * @param xmin bottom X coord
  144482. * @param ymin bottom Y coord
  144483. * @param xmax top X coord
  144484. * @param ymax top Y coord
  144485. * @returns points that make the resulting rectation
  144486. */
  144487. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  144488. /**
  144489. * Creates a circle
  144490. * @param radius radius of circle
  144491. * @param cx scale in x
  144492. * @param cy scale in y
  144493. * @param numberOfSides number of sides that make up the circle
  144494. * @returns points that make the resulting circle
  144495. */
  144496. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  144497. /**
  144498. * Creates a polygon from input string
  144499. * @param input Input polygon data
  144500. * @returns the parsed points
  144501. */
  144502. static Parse(input: string): Vector2[];
  144503. /**
  144504. * Starts building a polygon from x and y coordinates
  144505. * @param x x coordinate
  144506. * @param y y coordinate
  144507. * @returns the started path2
  144508. */
  144509. static StartingAt(x: number, y: number): Path2;
  144510. }
  144511. /**
  144512. * Builds a polygon
  144513. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  144514. */
  144515. export class PolygonMeshBuilder {
  144516. private _points;
  144517. private _outlinepoints;
  144518. private _holes;
  144519. private _name;
  144520. private _scene;
  144521. private _epoints;
  144522. private _eholes;
  144523. private _addToepoint;
  144524. /**
  144525. * Babylon reference to the earcut plugin.
  144526. */
  144527. bjsEarcut: any;
  144528. /**
  144529. * Creates a PolygonMeshBuilder
  144530. * @param name name of the builder
  144531. * @param contours Path of the polygon
  144532. * @param scene scene to add to when creating the mesh
  144533. * @param earcutInjection can be used to inject your own earcut reference
  144534. */
  144535. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  144536. /**
  144537. * Adds a whole within the polygon
  144538. * @param hole Array of points defining the hole
  144539. * @returns this
  144540. */
  144541. addHole(hole: Vector2[]): PolygonMeshBuilder;
  144542. /**
  144543. * Creates the polygon
  144544. * @param updatable If the mesh should be updatable
  144545. * @param depth The depth of the mesh created
  144546. * @returns the created mesh
  144547. */
  144548. build(updatable?: boolean, depth?: number): Mesh;
  144549. /**
  144550. * Creates the polygon
  144551. * @param depth The depth of the mesh created
  144552. * @returns the created VertexData
  144553. */
  144554. buildVertexData(depth?: number): VertexData;
  144555. /**
  144556. * Adds a side to the polygon
  144557. * @param positions points that make the polygon
  144558. * @param normals normals of the polygon
  144559. * @param uvs uvs of the polygon
  144560. * @param indices indices of the polygon
  144561. * @param bounds bounds of the polygon
  144562. * @param points points of the polygon
  144563. * @param depth depth of the polygon
  144564. * @param flip flip of the polygon
  144565. */
  144566. private addSide;
  144567. }
  144568. }
  144569. declare module BABYLON {
  144570. /**
  144571. * Class containing static functions to help procedurally build meshes
  144572. */
  144573. export class PolygonBuilder {
  144574. /**
  144575. * Creates a polygon mesh
  144576. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  144577. * * 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
  144578. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  144579. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144580. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  144581. * * Remember you can only change the shape positions, not their number when updating a polygon
  144582. * @param name defines the name of the mesh
  144583. * @param options defines the options used to create the mesh
  144584. * @param scene defines the hosting scene
  144585. * @param earcutInjection can be used to inject your own earcut reference
  144586. * @returns the polygon mesh
  144587. */
  144588. static CreatePolygon(name: string, options: {
  144589. shape: Vector3[];
  144590. holes?: Vector3[][];
  144591. depth?: number;
  144592. faceUV?: Vector4[];
  144593. faceColors?: Color4[];
  144594. updatable?: boolean;
  144595. sideOrientation?: number;
  144596. frontUVs?: Vector4;
  144597. backUVs?: Vector4;
  144598. wrap?: boolean;
  144599. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  144600. /**
  144601. * Creates an extruded polygon mesh, with depth in the Y direction.
  144602. * * 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)
  144603. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  144604. * @param name defines the name of the mesh
  144605. * @param options defines the options used to create the mesh
  144606. * @param scene defines the hosting scene
  144607. * @param earcutInjection can be used to inject your own earcut reference
  144608. * @returns the polygon mesh
  144609. */
  144610. static ExtrudePolygon(name: string, options: {
  144611. shape: Vector3[];
  144612. holes?: Vector3[][];
  144613. depth?: number;
  144614. faceUV?: Vector4[];
  144615. faceColors?: Color4[];
  144616. updatable?: boolean;
  144617. sideOrientation?: number;
  144618. frontUVs?: Vector4;
  144619. backUVs?: Vector4;
  144620. wrap?: boolean;
  144621. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  144622. }
  144623. }
  144624. declare module BABYLON {
  144625. /**
  144626. * Class containing static functions to help procedurally build meshes
  144627. */
  144628. export class LatheBuilder {
  144629. /**
  144630. * Creates lathe mesh.
  144631. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  144632. * * 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
  144633. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  144634. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  144635. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  144636. * * 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
  144637. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  144638. * * 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
  144639. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144640. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144641. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  144642. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144643. * @param name defines the name of the mesh
  144644. * @param options defines the options used to create the mesh
  144645. * @param scene defines the hosting scene
  144646. * @returns the lathe mesh
  144647. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  144648. */
  144649. static CreateLathe(name: string, options: {
  144650. shape: Vector3[];
  144651. radius?: number;
  144652. tessellation?: number;
  144653. clip?: number;
  144654. arc?: number;
  144655. closed?: boolean;
  144656. updatable?: boolean;
  144657. sideOrientation?: number;
  144658. frontUVs?: Vector4;
  144659. backUVs?: Vector4;
  144660. cap?: number;
  144661. invertUV?: boolean;
  144662. }, scene?: Nullable<Scene>): Mesh;
  144663. }
  144664. }
  144665. declare module BABYLON {
  144666. /**
  144667. * Class containing static functions to help procedurally build meshes
  144668. */
  144669. export class TiledPlaneBuilder {
  144670. /**
  144671. * Creates a tiled plane mesh
  144672. * * The parameter `pattern` will, depending on value, do nothing or
  144673. * * * flip (reflect about central vertical) alternate tiles across and up
  144674. * * * flip every tile on alternate rows
  144675. * * * rotate (180 degs) alternate tiles across and up
  144676. * * * rotate every tile on alternate rows
  144677. * * * flip and rotate alternate tiles across and up
  144678. * * * flip and rotate every tile on alternate rows
  144679. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  144680. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  144681. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144682. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  144683. * * 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)
  144684. * * 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)
  144685. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  144686. * @param name defines the name of the mesh
  144687. * @param options defines the options used to create the mesh
  144688. * @param scene defines the hosting scene
  144689. * @returns the box mesh
  144690. */
  144691. static CreateTiledPlane(name: string, options: {
  144692. pattern?: number;
  144693. tileSize?: number;
  144694. tileWidth?: number;
  144695. tileHeight?: number;
  144696. size?: number;
  144697. width?: number;
  144698. height?: number;
  144699. alignHorizontal?: number;
  144700. alignVertical?: number;
  144701. sideOrientation?: number;
  144702. frontUVs?: Vector4;
  144703. backUVs?: Vector4;
  144704. updatable?: boolean;
  144705. }, scene?: Nullable<Scene>): Mesh;
  144706. }
  144707. }
  144708. declare module BABYLON {
  144709. /**
  144710. * Class containing static functions to help procedurally build meshes
  144711. */
  144712. export class TubeBuilder {
  144713. /**
  144714. * Creates a tube mesh.
  144715. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  144716. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  144717. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  144718. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  144719. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  144720. * * 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)
  144721. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  144722. * * 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
  144723. * * 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
  144724. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144725. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144726. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  144727. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144728. * @param name defines the name of the mesh
  144729. * @param options defines the options used to create the mesh
  144730. * @param scene defines the hosting scene
  144731. * @returns the tube mesh
  144732. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  144733. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  144734. */
  144735. static CreateTube(name: string, options: {
  144736. path: Vector3[];
  144737. radius?: number;
  144738. tessellation?: number;
  144739. radiusFunction?: {
  144740. (i: number, distance: number): number;
  144741. };
  144742. cap?: number;
  144743. arc?: number;
  144744. updatable?: boolean;
  144745. sideOrientation?: number;
  144746. frontUVs?: Vector4;
  144747. backUVs?: Vector4;
  144748. instance?: Mesh;
  144749. invertUV?: boolean;
  144750. }, scene?: Nullable<Scene>): Mesh;
  144751. }
  144752. }
  144753. declare module BABYLON {
  144754. /**
  144755. * Class containing static functions to help procedurally build meshes
  144756. */
  144757. export class IcoSphereBuilder {
  144758. /**
  144759. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  144760. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  144761. * * 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`)
  144762. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  144763. * * 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
  144764. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144765. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144766. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144767. * @param name defines the name of the mesh
  144768. * @param options defines the options used to create the mesh
  144769. * @param scene defines the hosting scene
  144770. * @returns the icosahedron mesh
  144771. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  144772. */
  144773. static CreateIcoSphere(name: string, options: {
  144774. radius?: number;
  144775. radiusX?: number;
  144776. radiusY?: number;
  144777. radiusZ?: number;
  144778. flat?: boolean;
  144779. subdivisions?: number;
  144780. sideOrientation?: number;
  144781. frontUVs?: Vector4;
  144782. backUVs?: Vector4;
  144783. updatable?: boolean;
  144784. }, scene?: Nullable<Scene>): Mesh;
  144785. }
  144786. }
  144787. declare module BABYLON {
  144788. /**
  144789. * Class containing static functions to help procedurally build meshes
  144790. */
  144791. export class DecalBuilder {
  144792. /**
  144793. * Creates a decal mesh.
  144794. * 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
  144795. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  144796. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  144797. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  144798. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  144799. * @param name defines the name of the mesh
  144800. * @param sourceMesh defines the mesh where the decal must be applied
  144801. * @param options defines the options used to create the mesh
  144802. * @param scene defines the hosting scene
  144803. * @returns the decal mesh
  144804. * @see https://doc.babylonjs.com/how_to/decals
  144805. */
  144806. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  144807. position?: Vector3;
  144808. normal?: Vector3;
  144809. size?: Vector3;
  144810. angle?: number;
  144811. }): Mesh;
  144812. }
  144813. }
  144814. declare module BABYLON {
  144815. /**
  144816. * Class containing static functions to help procedurally build meshes
  144817. */
  144818. export class MeshBuilder {
  144819. /**
  144820. * Creates a box mesh
  144821. * * The parameter `size` sets the size (float) of each box side (default 1)
  144822. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  144823. * * 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)
  144824. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  144825. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144826. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144827. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144828. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  144829. * @param name defines the name of the mesh
  144830. * @param options defines the options used to create the mesh
  144831. * @param scene defines the hosting scene
  144832. * @returns the box mesh
  144833. */
  144834. static CreateBox(name: string, options: {
  144835. size?: number;
  144836. width?: number;
  144837. height?: number;
  144838. depth?: number;
  144839. faceUV?: Vector4[];
  144840. faceColors?: Color4[];
  144841. sideOrientation?: number;
  144842. frontUVs?: Vector4;
  144843. backUVs?: Vector4;
  144844. wrap?: boolean;
  144845. topBaseAt?: number;
  144846. bottomBaseAt?: number;
  144847. updatable?: boolean;
  144848. }, scene?: Nullable<Scene>): Mesh;
  144849. /**
  144850. * Creates a tiled box mesh
  144851. * * faceTiles sets the pattern, tile size and number of tiles for a face
  144852. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144853. * @param name defines the name of the mesh
  144854. * @param options defines the options used to create the mesh
  144855. * @param scene defines the hosting scene
  144856. * @returns the tiled box mesh
  144857. */
  144858. static CreateTiledBox(name: string, options: {
  144859. pattern?: number;
  144860. size?: number;
  144861. width?: number;
  144862. height?: number;
  144863. depth: number;
  144864. tileSize?: number;
  144865. tileWidth?: number;
  144866. tileHeight?: number;
  144867. faceUV?: Vector4[];
  144868. faceColors?: Color4[];
  144869. alignHorizontal?: number;
  144870. alignVertical?: number;
  144871. sideOrientation?: number;
  144872. updatable?: boolean;
  144873. }, scene?: Nullable<Scene>): Mesh;
  144874. /**
  144875. * Creates a sphere mesh
  144876. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  144877. * * 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`)
  144878. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  144879. * * 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
  144880. * * 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)
  144881. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144882. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144883. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144884. * @param name defines the name of the mesh
  144885. * @param options defines the options used to create the mesh
  144886. * @param scene defines the hosting scene
  144887. * @returns the sphere mesh
  144888. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  144889. */
  144890. static CreateSphere(name: string, options: {
  144891. segments?: number;
  144892. diameter?: number;
  144893. diameterX?: number;
  144894. diameterY?: number;
  144895. diameterZ?: number;
  144896. arc?: number;
  144897. slice?: number;
  144898. sideOrientation?: number;
  144899. frontUVs?: Vector4;
  144900. backUVs?: Vector4;
  144901. updatable?: boolean;
  144902. }, scene?: Nullable<Scene>): Mesh;
  144903. /**
  144904. * Creates a plane polygonal mesh. By default, this is a disc
  144905. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  144906. * * 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
  144907. * * 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
  144908. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144909. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144910. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144911. * @param name defines the name of the mesh
  144912. * @param options defines the options used to create the mesh
  144913. * @param scene defines the hosting scene
  144914. * @returns the plane polygonal mesh
  144915. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  144916. */
  144917. static CreateDisc(name: string, options: {
  144918. radius?: number;
  144919. tessellation?: number;
  144920. arc?: number;
  144921. updatable?: boolean;
  144922. sideOrientation?: number;
  144923. frontUVs?: Vector4;
  144924. backUVs?: Vector4;
  144925. }, scene?: Nullable<Scene>): Mesh;
  144926. /**
  144927. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  144928. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  144929. * * 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`)
  144930. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  144931. * * 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
  144932. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144933. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144934. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144935. * @param name defines the name of the mesh
  144936. * @param options defines the options used to create the mesh
  144937. * @param scene defines the hosting scene
  144938. * @returns the icosahedron mesh
  144939. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  144940. */
  144941. static CreateIcoSphere(name: string, options: {
  144942. radius?: number;
  144943. radiusX?: number;
  144944. radiusY?: number;
  144945. radiusZ?: number;
  144946. flat?: boolean;
  144947. subdivisions?: number;
  144948. sideOrientation?: number;
  144949. frontUVs?: Vector4;
  144950. backUVs?: Vector4;
  144951. updatable?: boolean;
  144952. }, scene?: Nullable<Scene>): Mesh;
  144953. /**
  144954. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  144955. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  144956. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  144957. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  144958. * * 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
  144959. * * 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
  144960. * * 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
  144961. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144962. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144963. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  144964. * * 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
  144965. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  144966. * * 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
  144967. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  144968. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144969. * @param name defines the name of the mesh
  144970. * @param options defines the options used to create the mesh
  144971. * @param scene defines the hosting scene
  144972. * @returns the ribbon mesh
  144973. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  144974. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  144975. */
  144976. static CreateRibbon(name: string, options: {
  144977. pathArray: Vector3[][];
  144978. closeArray?: boolean;
  144979. closePath?: boolean;
  144980. offset?: number;
  144981. updatable?: boolean;
  144982. sideOrientation?: number;
  144983. frontUVs?: Vector4;
  144984. backUVs?: Vector4;
  144985. instance?: Mesh;
  144986. invertUV?: boolean;
  144987. uvs?: Vector2[];
  144988. colors?: Color4[];
  144989. }, scene?: Nullable<Scene>): Mesh;
  144990. /**
  144991. * Creates a cylinder or a cone mesh
  144992. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  144993. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  144994. * * 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.
  144995. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  144996. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  144997. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  144998. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  144999. * * 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).
  145000. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  145001. * * 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).
  145002. * * 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
  145003. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  145004. * * 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
  145005. * * 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.
  145006. * * If `enclose` is false, a ring surface is one element.
  145007. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  145008. * * 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
  145009. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145010. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145011. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  145012. * @param name defines the name of the mesh
  145013. * @param options defines the options used to create the mesh
  145014. * @param scene defines the hosting scene
  145015. * @returns the cylinder mesh
  145016. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  145017. */
  145018. static CreateCylinder(name: string, options: {
  145019. height?: number;
  145020. diameterTop?: number;
  145021. diameterBottom?: number;
  145022. diameter?: number;
  145023. tessellation?: number;
  145024. subdivisions?: number;
  145025. arc?: number;
  145026. faceColors?: Color4[];
  145027. faceUV?: Vector4[];
  145028. updatable?: boolean;
  145029. hasRings?: boolean;
  145030. enclose?: boolean;
  145031. cap?: number;
  145032. sideOrientation?: number;
  145033. frontUVs?: Vector4;
  145034. backUVs?: Vector4;
  145035. }, scene?: Nullable<Scene>): Mesh;
  145036. /**
  145037. * Creates a torus mesh
  145038. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  145039. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  145040. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  145041. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145042. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145043. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  145044. * @param name defines the name of the mesh
  145045. * @param options defines the options used to create the mesh
  145046. * @param scene defines the hosting scene
  145047. * @returns the torus mesh
  145048. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  145049. */
  145050. static CreateTorus(name: string, options: {
  145051. diameter?: number;
  145052. thickness?: number;
  145053. tessellation?: number;
  145054. updatable?: boolean;
  145055. sideOrientation?: number;
  145056. frontUVs?: Vector4;
  145057. backUVs?: Vector4;
  145058. }, scene?: Nullable<Scene>): Mesh;
  145059. /**
  145060. * Creates a torus knot mesh
  145061. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  145062. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  145063. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  145064. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  145065. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145066. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145067. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  145068. * @param name defines the name of the mesh
  145069. * @param options defines the options used to create the mesh
  145070. * @param scene defines the hosting scene
  145071. * @returns the torus knot mesh
  145072. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  145073. */
  145074. static CreateTorusKnot(name: string, options: {
  145075. radius?: number;
  145076. tube?: number;
  145077. radialSegments?: number;
  145078. tubularSegments?: number;
  145079. p?: number;
  145080. q?: number;
  145081. updatable?: boolean;
  145082. sideOrientation?: number;
  145083. frontUVs?: Vector4;
  145084. backUVs?: Vector4;
  145085. }, scene?: Nullable<Scene>): Mesh;
  145086. /**
  145087. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  145088. * * 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
  145089. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  145090. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  145091. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  145092. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  145093. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  145094. * * 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
  145095. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  145096. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145097. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  145098. * @param name defines the name of the new line system
  145099. * @param options defines the options used to create the line system
  145100. * @param scene defines the hosting scene
  145101. * @returns a new line system mesh
  145102. */
  145103. static CreateLineSystem(name: string, options: {
  145104. lines: Vector3[][];
  145105. updatable?: boolean;
  145106. instance?: Nullable<LinesMesh>;
  145107. colors?: Nullable<Color4[][]>;
  145108. useVertexAlpha?: boolean;
  145109. }, scene: Nullable<Scene>): LinesMesh;
  145110. /**
  145111. * Creates a line mesh
  145112. * 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
  145113. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  145114. * * The parameter `points` is an array successive Vector3
  145115. * * 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
  145116. * * The optional parameter `colors` is an array of successive Color4, one per line point
  145117. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  145118. * * When updating an instance, remember that only point positions can change, not the number of points
  145119. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145120. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  145121. * @param name defines the name of the new line system
  145122. * @param options defines the options used to create the line system
  145123. * @param scene defines the hosting scene
  145124. * @returns a new line mesh
  145125. */
  145126. static CreateLines(name: string, options: {
  145127. points: Vector3[];
  145128. updatable?: boolean;
  145129. instance?: Nullable<LinesMesh>;
  145130. colors?: Color4[];
  145131. useVertexAlpha?: boolean;
  145132. }, scene?: Nullable<Scene>): LinesMesh;
  145133. /**
  145134. * Creates a dashed line mesh
  145135. * * 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
  145136. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  145137. * * The parameter `points` is an array successive Vector3
  145138. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  145139. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  145140. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  145141. * * 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
  145142. * * When updating an instance, remember that only point positions can change, not the number of points
  145143. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145144. * @param name defines the name of the mesh
  145145. * @param options defines the options used to create the mesh
  145146. * @param scene defines the hosting scene
  145147. * @returns the dashed line mesh
  145148. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  145149. */
  145150. static CreateDashedLines(name: string, options: {
  145151. points: Vector3[];
  145152. dashSize?: number;
  145153. gapSize?: number;
  145154. dashNb?: number;
  145155. updatable?: boolean;
  145156. instance?: LinesMesh;
  145157. }, scene?: Nullable<Scene>): LinesMesh;
  145158. /**
  145159. * 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.
  145160. * * 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.
  145161. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  145162. * * 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.
  145163. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  145164. * * 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
  145165. * * 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
  145166. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  145167. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145168. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145169. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  145170. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  145171. * @param name defines the name of the mesh
  145172. * @param options defines the options used to create the mesh
  145173. * @param scene defines the hosting scene
  145174. * @returns the extruded shape mesh
  145175. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  145176. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  145177. */
  145178. static ExtrudeShape(name: string, options: {
  145179. shape: Vector3[];
  145180. path: Vector3[];
  145181. scale?: number;
  145182. rotation?: number;
  145183. cap?: number;
  145184. updatable?: boolean;
  145185. sideOrientation?: number;
  145186. frontUVs?: Vector4;
  145187. backUVs?: Vector4;
  145188. instance?: Mesh;
  145189. invertUV?: boolean;
  145190. }, scene?: Nullable<Scene>): Mesh;
  145191. /**
  145192. * Creates an custom extruded shape mesh.
  145193. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  145194. * * 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.
  145195. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  145196. * * 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
  145197. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  145198. * * 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
  145199. * * It must returns a float value that will be the scale value applied to the shape on each path point
  145200. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  145201. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  145202. * * 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
  145203. * * 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
  145204. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  145205. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145206. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145207. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  145208. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145209. * @param name defines the name of the mesh
  145210. * @param options defines the options used to create the mesh
  145211. * @param scene defines the hosting scene
  145212. * @returns the custom extruded shape mesh
  145213. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  145214. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  145215. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  145216. */
  145217. static ExtrudeShapeCustom(name: string, options: {
  145218. shape: Vector3[];
  145219. path: Vector3[];
  145220. scaleFunction?: any;
  145221. rotationFunction?: any;
  145222. ribbonCloseArray?: boolean;
  145223. ribbonClosePath?: boolean;
  145224. cap?: number;
  145225. updatable?: boolean;
  145226. sideOrientation?: number;
  145227. frontUVs?: Vector4;
  145228. backUVs?: Vector4;
  145229. instance?: Mesh;
  145230. invertUV?: boolean;
  145231. }, scene?: Nullable<Scene>): Mesh;
  145232. /**
  145233. * Creates lathe mesh.
  145234. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  145235. * * 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
  145236. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  145237. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  145238. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  145239. * * 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
  145240. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  145241. * * 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
  145242. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145243. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145244. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  145245. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145246. * @param name defines the name of the mesh
  145247. * @param options defines the options used to create the mesh
  145248. * @param scene defines the hosting scene
  145249. * @returns the lathe mesh
  145250. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  145251. */
  145252. static CreateLathe(name: string, options: {
  145253. shape: Vector3[];
  145254. radius?: number;
  145255. tessellation?: number;
  145256. clip?: number;
  145257. arc?: number;
  145258. closed?: boolean;
  145259. updatable?: boolean;
  145260. sideOrientation?: number;
  145261. frontUVs?: Vector4;
  145262. backUVs?: Vector4;
  145263. cap?: number;
  145264. invertUV?: boolean;
  145265. }, scene?: Nullable<Scene>): Mesh;
  145266. /**
  145267. * Creates a tiled plane mesh
  145268. * * You can set a limited pattern arrangement with the tiles
  145269. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145270. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145271. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145272. * @param name defines the name of the mesh
  145273. * @param options defines the options used to create the mesh
  145274. * @param scene defines the hosting scene
  145275. * @returns the plane mesh
  145276. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  145277. */
  145278. static CreateTiledPlane(name: string, options: {
  145279. pattern?: number;
  145280. tileSize?: number;
  145281. tileWidth?: number;
  145282. tileHeight?: number;
  145283. size?: number;
  145284. width?: number;
  145285. height?: number;
  145286. alignHorizontal?: number;
  145287. alignVertical?: number;
  145288. sideOrientation?: number;
  145289. frontUVs?: Vector4;
  145290. backUVs?: Vector4;
  145291. updatable?: boolean;
  145292. }, scene?: Nullable<Scene>): Mesh;
  145293. /**
  145294. * Creates a plane mesh
  145295. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  145296. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  145297. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  145298. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145299. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145300. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145301. * @param name defines the name of the mesh
  145302. * @param options defines the options used to create the mesh
  145303. * @param scene defines the hosting scene
  145304. * @returns the plane mesh
  145305. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  145306. */
  145307. static CreatePlane(name: string, options: {
  145308. size?: number;
  145309. width?: number;
  145310. height?: number;
  145311. sideOrientation?: number;
  145312. frontUVs?: Vector4;
  145313. backUVs?: Vector4;
  145314. updatable?: boolean;
  145315. sourcePlane?: Plane;
  145316. }, scene?: Nullable<Scene>): Mesh;
  145317. /**
  145318. * Creates a ground mesh
  145319. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  145320. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  145321. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145322. * @param name defines the name of the mesh
  145323. * @param options defines the options used to create the mesh
  145324. * @param scene defines the hosting scene
  145325. * @returns the ground mesh
  145326. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  145327. */
  145328. static CreateGround(name: string, options: {
  145329. width?: number;
  145330. height?: number;
  145331. subdivisions?: number;
  145332. subdivisionsX?: number;
  145333. subdivisionsY?: number;
  145334. updatable?: boolean;
  145335. }, scene?: Nullable<Scene>): Mesh;
  145336. /**
  145337. * Creates a tiled ground mesh
  145338. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  145339. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  145340. * * 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
  145341. * * 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
  145342. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  145343. * @param name defines the name of the mesh
  145344. * @param options defines the options used to create the mesh
  145345. * @param scene defines the hosting scene
  145346. * @returns the tiled ground mesh
  145347. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  145348. */
  145349. static CreateTiledGround(name: string, options: {
  145350. xmin: number;
  145351. zmin: number;
  145352. xmax: number;
  145353. zmax: number;
  145354. subdivisions?: {
  145355. w: number;
  145356. h: number;
  145357. };
  145358. precision?: {
  145359. w: number;
  145360. h: number;
  145361. };
  145362. updatable?: boolean;
  145363. }, scene?: Nullable<Scene>): Mesh;
  145364. /**
  145365. * Creates a ground mesh from a height map
  145366. * * The parameter `url` sets the URL of the height map image resource.
  145367. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  145368. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  145369. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  145370. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  145371. * * 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.
  145372. * * 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).
  145373. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  145374. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  145375. * @param name defines the name of the mesh
  145376. * @param url defines the url to the height map
  145377. * @param options defines the options used to create the mesh
  145378. * @param scene defines the hosting scene
  145379. * @returns the ground mesh
  145380. * @see https://doc.babylonjs.com/babylon101/height_map
  145381. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  145382. */
  145383. static CreateGroundFromHeightMap(name: string, url: string, options: {
  145384. width?: number;
  145385. height?: number;
  145386. subdivisions?: number;
  145387. minHeight?: number;
  145388. maxHeight?: number;
  145389. colorFilter?: Color3;
  145390. alphaFilter?: number;
  145391. updatable?: boolean;
  145392. onReady?: (mesh: GroundMesh) => void;
  145393. }, scene?: Nullable<Scene>): GroundMesh;
  145394. /**
  145395. * Creates a polygon mesh
  145396. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  145397. * * 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
  145398. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  145399. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145400. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  145401. * * Remember you can only change the shape positions, not their number when updating a polygon
  145402. * @param name defines the name of the mesh
  145403. * @param options defines the options used to create the mesh
  145404. * @param scene defines the hosting scene
  145405. * @param earcutInjection can be used to inject your own earcut reference
  145406. * @returns the polygon mesh
  145407. */
  145408. static CreatePolygon(name: string, options: {
  145409. shape: Vector3[];
  145410. holes?: Vector3[][];
  145411. depth?: number;
  145412. faceUV?: Vector4[];
  145413. faceColors?: Color4[];
  145414. updatable?: boolean;
  145415. sideOrientation?: number;
  145416. frontUVs?: Vector4;
  145417. backUVs?: Vector4;
  145418. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  145419. /**
  145420. * Creates an extruded polygon mesh, with depth in the Y direction.
  145421. * * 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)
  145422. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  145423. * @param name defines the name of the mesh
  145424. * @param options defines the options used to create the mesh
  145425. * @param scene defines the hosting scene
  145426. * @param earcutInjection can be used to inject your own earcut reference
  145427. * @returns the polygon mesh
  145428. */
  145429. static ExtrudePolygon(name: string, options: {
  145430. shape: Vector3[];
  145431. holes?: Vector3[][];
  145432. depth?: number;
  145433. faceUV?: Vector4[];
  145434. faceColors?: Color4[];
  145435. updatable?: boolean;
  145436. sideOrientation?: number;
  145437. frontUVs?: Vector4;
  145438. backUVs?: Vector4;
  145439. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  145440. /**
  145441. * Creates a tube mesh.
  145442. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  145443. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  145444. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  145445. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  145446. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  145447. * * 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)
  145448. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  145449. * * 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
  145450. * * 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
  145451. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145452. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145453. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  145454. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145455. * @param name defines the name of the mesh
  145456. * @param options defines the options used to create the mesh
  145457. * @param scene defines the hosting scene
  145458. * @returns the tube mesh
  145459. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  145460. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  145461. */
  145462. static CreateTube(name: string, options: {
  145463. path: Vector3[];
  145464. radius?: number;
  145465. tessellation?: number;
  145466. radiusFunction?: {
  145467. (i: number, distance: number): number;
  145468. };
  145469. cap?: number;
  145470. arc?: number;
  145471. updatable?: boolean;
  145472. sideOrientation?: number;
  145473. frontUVs?: Vector4;
  145474. backUVs?: Vector4;
  145475. instance?: Mesh;
  145476. invertUV?: boolean;
  145477. }, scene?: Nullable<Scene>): Mesh;
  145478. /**
  145479. * Creates a polyhedron mesh
  145480. * * 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
  145481. * * The parameter `size` (positive float, default 1) sets the polygon size
  145482. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  145483. * * 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`
  145484. * * 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
  145485. * * 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)`)
  145486. * * 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
  145487. * * 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
  145488. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145489. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145490. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145491. * @param name defines the name of the mesh
  145492. * @param options defines the options used to create the mesh
  145493. * @param scene defines the hosting scene
  145494. * @returns the polyhedron mesh
  145495. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  145496. */
  145497. static CreatePolyhedron(name: string, options: {
  145498. type?: number;
  145499. size?: number;
  145500. sizeX?: number;
  145501. sizeY?: number;
  145502. sizeZ?: number;
  145503. custom?: any;
  145504. faceUV?: Vector4[];
  145505. faceColors?: Color4[];
  145506. flat?: boolean;
  145507. updatable?: boolean;
  145508. sideOrientation?: number;
  145509. frontUVs?: Vector4;
  145510. backUVs?: Vector4;
  145511. }, scene?: Nullable<Scene>): Mesh;
  145512. /**
  145513. * Creates a decal mesh.
  145514. * 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
  145515. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  145516. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  145517. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  145518. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  145519. * @param name defines the name of the mesh
  145520. * @param sourceMesh defines the mesh where the decal must be applied
  145521. * @param options defines the options used to create the mesh
  145522. * @param scene defines the hosting scene
  145523. * @returns the decal mesh
  145524. * @see https://doc.babylonjs.com/how_to/decals
  145525. */
  145526. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  145527. position?: Vector3;
  145528. normal?: Vector3;
  145529. size?: Vector3;
  145530. angle?: number;
  145531. }): Mesh;
  145532. }
  145533. }
  145534. declare module BABYLON {
  145535. /**
  145536. * A simplifier interface for future simplification implementations
  145537. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  145538. */
  145539. export interface ISimplifier {
  145540. /**
  145541. * Simplification of a given mesh according to the given settings.
  145542. * Since this requires computation, it is assumed that the function runs async.
  145543. * @param settings The settings of the simplification, including quality and distance
  145544. * @param successCallback A callback that will be called after the mesh was simplified.
  145545. * @param errorCallback in case of an error, this callback will be called. optional.
  145546. */
  145547. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  145548. }
  145549. /**
  145550. * Expected simplification settings.
  145551. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  145552. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  145553. */
  145554. export interface ISimplificationSettings {
  145555. /**
  145556. * Gets or sets the expected quality
  145557. */
  145558. quality: number;
  145559. /**
  145560. * Gets or sets the distance when this optimized version should be used
  145561. */
  145562. distance: number;
  145563. /**
  145564. * Gets an already optimized mesh
  145565. */
  145566. optimizeMesh?: boolean;
  145567. }
  145568. /**
  145569. * Class used to specify simplification options
  145570. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  145571. */
  145572. export class SimplificationSettings implements ISimplificationSettings {
  145573. /** expected quality */
  145574. quality: number;
  145575. /** distance when this optimized version should be used */
  145576. distance: number;
  145577. /** already optimized mesh */
  145578. optimizeMesh?: boolean | undefined;
  145579. /**
  145580. * Creates a SimplificationSettings
  145581. * @param quality expected quality
  145582. * @param distance distance when this optimized version should be used
  145583. * @param optimizeMesh already optimized mesh
  145584. */
  145585. constructor(
  145586. /** expected quality */
  145587. quality: number,
  145588. /** distance when this optimized version should be used */
  145589. distance: number,
  145590. /** already optimized mesh */
  145591. optimizeMesh?: boolean | undefined);
  145592. }
  145593. /**
  145594. * Interface used to define a simplification task
  145595. */
  145596. export interface ISimplificationTask {
  145597. /**
  145598. * Array of settings
  145599. */
  145600. settings: Array<ISimplificationSettings>;
  145601. /**
  145602. * Simplification type
  145603. */
  145604. simplificationType: SimplificationType;
  145605. /**
  145606. * Mesh to simplify
  145607. */
  145608. mesh: Mesh;
  145609. /**
  145610. * Callback called on success
  145611. */
  145612. successCallback?: () => void;
  145613. /**
  145614. * Defines if parallel processing can be used
  145615. */
  145616. parallelProcessing: boolean;
  145617. }
  145618. /**
  145619. * Queue used to order the simplification tasks
  145620. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  145621. */
  145622. export class SimplificationQueue {
  145623. private _simplificationArray;
  145624. /**
  145625. * Gets a boolean indicating that the process is still running
  145626. */
  145627. running: boolean;
  145628. /**
  145629. * Creates a new queue
  145630. */
  145631. constructor();
  145632. /**
  145633. * Adds a new simplification task
  145634. * @param task defines a task to add
  145635. */
  145636. addTask(task: ISimplificationTask): void;
  145637. /**
  145638. * Execute next task
  145639. */
  145640. executeNext(): void;
  145641. /**
  145642. * Execute a simplification task
  145643. * @param task defines the task to run
  145644. */
  145645. runSimplification(task: ISimplificationTask): void;
  145646. private getSimplifier;
  145647. }
  145648. /**
  145649. * The implemented types of simplification
  145650. * At the moment only Quadratic Error Decimation is implemented
  145651. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  145652. */
  145653. export enum SimplificationType {
  145654. /** Quadratic error decimation */
  145655. QUADRATIC = 0
  145656. }
  145657. /**
  145658. * An implementation of the Quadratic Error simplification algorithm.
  145659. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  145660. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  145661. * @author RaananW
  145662. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  145663. */
  145664. export class QuadraticErrorSimplification implements ISimplifier {
  145665. private _mesh;
  145666. private triangles;
  145667. private vertices;
  145668. private references;
  145669. private _reconstructedMesh;
  145670. /** Gets or sets the number pf sync interations */
  145671. syncIterations: number;
  145672. /** Gets or sets the aggressiveness of the simplifier */
  145673. aggressiveness: number;
  145674. /** Gets or sets the number of allowed iterations for decimation */
  145675. decimationIterations: number;
  145676. /** Gets or sets the espilon to use for bounding box computation */
  145677. boundingBoxEpsilon: number;
  145678. /**
  145679. * Creates a new QuadraticErrorSimplification
  145680. * @param _mesh defines the target mesh
  145681. */
  145682. constructor(_mesh: Mesh);
  145683. /**
  145684. * Simplification of a given mesh according to the given settings.
  145685. * Since this requires computation, it is assumed that the function runs async.
  145686. * @param settings The settings of the simplification, including quality and distance
  145687. * @param successCallback A callback that will be called after the mesh was simplified.
  145688. */
  145689. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  145690. private runDecimation;
  145691. private initWithMesh;
  145692. private init;
  145693. private reconstructMesh;
  145694. private initDecimatedMesh;
  145695. private isFlipped;
  145696. private updateTriangles;
  145697. private identifyBorder;
  145698. private updateMesh;
  145699. private vertexError;
  145700. private calculateError;
  145701. }
  145702. }
  145703. declare module BABYLON {
  145704. interface Scene {
  145705. /** @hidden (Backing field) */
  145706. _simplificationQueue: SimplificationQueue;
  145707. /**
  145708. * Gets or sets the simplification queue attached to the scene
  145709. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  145710. */
  145711. simplificationQueue: SimplificationQueue;
  145712. }
  145713. interface Mesh {
  145714. /**
  145715. * Simplify the mesh according to the given array of settings.
  145716. * Function will return immediately and will simplify async
  145717. * @param settings a collection of simplification settings
  145718. * @param parallelProcessing should all levels calculate parallel or one after the other
  145719. * @param simplificationType the type of simplification to run
  145720. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  145721. * @returns the current mesh
  145722. */
  145723. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  145724. }
  145725. /**
  145726. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  145727. * created in a scene
  145728. */
  145729. export class SimplicationQueueSceneComponent implements ISceneComponent {
  145730. /**
  145731. * The component name helpfull to identify the component in the list of scene components.
  145732. */
  145733. readonly name: string;
  145734. /**
  145735. * The scene the component belongs to.
  145736. */
  145737. scene: Scene;
  145738. /**
  145739. * Creates a new instance of the component for the given scene
  145740. * @param scene Defines the scene to register the component in
  145741. */
  145742. constructor(scene: Scene);
  145743. /**
  145744. * Registers the component in a given scene
  145745. */
  145746. register(): void;
  145747. /**
  145748. * Rebuilds the elements related to this component in case of
  145749. * context lost for instance.
  145750. */
  145751. rebuild(): void;
  145752. /**
  145753. * Disposes the component and the associated ressources
  145754. */
  145755. dispose(): void;
  145756. private _beforeCameraUpdate;
  145757. }
  145758. }
  145759. declare module BABYLON {
  145760. interface Mesh {
  145761. /**
  145762. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  145763. */
  145764. thinInstanceEnablePicking: boolean;
  145765. /**
  145766. * Creates a new thin instance
  145767. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  145768. * @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
  145769. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  145770. */
  145771. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  145772. /**
  145773. * Adds the transformation (matrix) of the current mesh as a thin instance
  145774. * @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
  145775. * @returns the thin instance index number
  145776. */
  145777. thinInstanceAddSelf(refresh: boolean): number;
  145778. /**
  145779. * Registers a custom attribute to be used with thin instances
  145780. * @param kind name of the attribute
  145781. * @param stride size in floats of the attribute
  145782. */
  145783. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  145784. /**
  145785. * Sets the matrix of a thin instance
  145786. * @param index index of the thin instance
  145787. * @param matrix matrix to set
  145788. * @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
  145789. */
  145790. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  145791. /**
  145792. * Sets the value of a custom attribute for a thin instance
  145793. * @param kind name of the attribute
  145794. * @param index index of the thin instance
  145795. * @param value value to set
  145796. * @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
  145797. */
  145798. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  145799. /**
  145800. * 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.
  145801. */
  145802. thinInstanceCount: number;
  145803. /**
  145804. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  145805. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  145806. * @param buffer buffer to set
  145807. * @param stride size in floats of each value of the buffer
  145808. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  145809. */
  145810. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  145811. /**
  145812. * Gets the list of world matrices
  145813. * @return an array containing all the world matrices from the thin instances
  145814. */
  145815. thinInstanceGetWorldMatrices(): Matrix[];
  145816. /**
  145817. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  145818. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  145819. */
  145820. thinInstanceBufferUpdated(kind: string): void;
  145821. /**
  145822. * Refreshes the bounding info, taking into account all the thin instances defined
  145823. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  145824. */
  145825. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  145826. /** @hidden */
  145827. _thinInstanceInitializeUserStorage(): void;
  145828. /** @hidden */
  145829. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  145830. /** @hidden */
  145831. _userThinInstanceBuffersStorage: {
  145832. data: {
  145833. [key: string]: Float32Array;
  145834. };
  145835. sizes: {
  145836. [key: string]: number;
  145837. };
  145838. vertexBuffers: {
  145839. [key: string]: Nullable<VertexBuffer>;
  145840. };
  145841. strides: {
  145842. [key: string]: number;
  145843. };
  145844. };
  145845. }
  145846. }
  145847. declare module BABYLON {
  145848. /**
  145849. * Navigation plugin interface to add navigation constrained by a navigation mesh
  145850. */
  145851. export interface INavigationEnginePlugin {
  145852. /**
  145853. * plugin name
  145854. */
  145855. name: string;
  145856. /**
  145857. * Creates a navigation mesh
  145858. * @param meshes array of all the geometry used to compute the navigatio mesh
  145859. * @param parameters bunch of parameters used to filter geometry
  145860. */
  145861. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  145862. /**
  145863. * Create a navigation mesh debug mesh
  145864. * @param scene is where the mesh will be added
  145865. * @returns debug display mesh
  145866. */
  145867. createDebugNavMesh(scene: Scene): Mesh;
  145868. /**
  145869. * Get a navigation mesh constrained position, closest to the parameter position
  145870. * @param position world position
  145871. * @returns the closest point to position constrained by the navigation mesh
  145872. */
  145873. getClosestPoint(position: Vector3): Vector3;
  145874. /**
  145875. * Get a navigation mesh constrained position, closest to the parameter position
  145876. * @param position world position
  145877. * @param result output the closest point to position constrained by the navigation mesh
  145878. */
  145879. getClosestPointToRef(position: Vector3, result: Vector3): void;
  145880. /**
  145881. * Get a navigation mesh constrained position, within a particular radius
  145882. * @param position world position
  145883. * @param maxRadius the maximum distance to the constrained world position
  145884. * @returns the closest point to position constrained by the navigation mesh
  145885. */
  145886. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  145887. /**
  145888. * Get a navigation mesh constrained position, within a particular radius
  145889. * @param position world position
  145890. * @param maxRadius the maximum distance to the constrained world position
  145891. * @param result output the closest point to position constrained by the navigation mesh
  145892. */
  145893. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  145894. /**
  145895. * Compute the final position from a segment made of destination-position
  145896. * @param position world position
  145897. * @param destination world position
  145898. * @returns the resulting point along the navmesh
  145899. */
  145900. moveAlong(position: Vector3, destination: Vector3): Vector3;
  145901. /**
  145902. * Compute the final position from a segment made of destination-position
  145903. * @param position world position
  145904. * @param destination world position
  145905. * @param result output the resulting point along the navmesh
  145906. */
  145907. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  145908. /**
  145909. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  145910. * @param start world position
  145911. * @param end world position
  145912. * @returns array containing world position composing the path
  145913. */
  145914. computePath(start: Vector3, end: Vector3): Vector3[];
  145915. /**
  145916. * If this plugin is supported
  145917. * @returns true if plugin is supported
  145918. */
  145919. isSupported(): boolean;
  145920. /**
  145921. * Create a new Crowd so you can add agents
  145922. * @param maxAgents the maximum agent count in the crowd
  145923. * @param maxAgentRadius the maximum radius an agent can have
  145924. * @param scene to attach the crowd to
  145925. * @returns the crowd you can add agents to
  145926. */
  145927. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  145928. /**
  145929. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  145930. * The queries will try to find a solution within those bounds
  145931. * default is (1,1,1)
  145932. * @param extent x,y,z value that define the extent around the queries point of reference
  145933. */
  145934. setDefaultQueryExtent(extent: Vector3): void;
  145935. /**
  145936. * Get the Bounding box extent specified by setDefaultQueryExtent
  145937. * @returns the box extent values
  145938. */
  145939. getDefaultQueryExtent(): Vector3;
  145940. /**
  145941. * build the navmesh from a previously saved state using getNavmeshData
  145942. * @param data the Uint8Array returned by getNavmeshData
  145943. */
  145944. buildFromNavmeshData(data: Uint8Array): void;
  145945. /**
  145946. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  145947. * @returns data the Uint8Array that can be saved and reused
  145948. */
  145949. getNavmeshData(): Uint8Array;
  145950. /**
  145951. * Get the Bounding box extent result specified by setDefaultQueryExtent
  145952. * @param result output the box extent values
  145953. */
  145954. getDefaultQueryExtentToRef(result: Vector3): void;
  145955. /**
  145956. * Release all resources
  145957. */
  145958. dispose(): void;
  145959. }
  145960. /**
  145961. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  145962. */
  145963. export interface ICrowd {
  145964. /**
  145965. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  145966. * You can attach anything to that node. The node position is updated in the scene update tick.
  145967. * @param pos world position that will be constrained by the navigation mesh
  145968. * @param parameters agent parameters
  145969. * @param transform hooked to the agent that will be update by the scene
  145970. * @returns agent index
  145971. */
  145972. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  145973. /**
  145974. * Returns the agent position in world space
  145975. * @param index agent index returned by addAgent
  145976. * @returns world space position
  145977. */
  145978. getAgentPosition(index: number): Vector3;
  145979. /**
  145980. * Gets the agent position result in world space
  145981. * @param index agent index returned by addAgent
  145982. * @param result output world space position
  145983. */
  145984. getAgentPositionToRef(index: number, result: Vector3): void;
  145985. /**
  145986. * Gets the agent velocity in world space
  145987. * @param index agent index returned by addAgent
  145988. * @returns world space velocity
  145989. */
  145990. getAgentVelocity(index: number): Vector3;
  145991. /**
  145992. * Gets the agent velocity result in world space
  145993. * @param index agent index returned by addAgent
  145994. * @param result output world space velocity
  145995. */
  145996. getAgentVelocityToRef(index: number, result: Vector3): void;
  145997. /**
  145998. * remove a particular agent previously created
  145999. * @param index agent index returned by addAgent
  146000. */
  146001. removeAgent(index: number): void;
  146002. /**
  146003. * get the list of all agents attached to this crowd
  146004. * @returns list of agent indices
  146005. */
  146006. getAgents(): number[];
  146007. /**
  146008. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  146009. * @param deltaTime in seconds
  146010. */
  146011. update(deltaTime: number): void;
  146012. /**
  146013. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  146014. * @param index agent index returned by addAgent
  146015. * @param destination targeted world position
  146016. */
  146017. agentGoto(index: number, destination: Vector3): void;
  146018. /**
  146019. * Teleport the agent to a new position
  146020. * @param index agent index returned by addAgent
  146021. * @param destination targeted world position
  146022. */
  146023. agentTeleport(index: number, destination: Vector3): void;
  146024. /**
  146025. * Update agent parameters
  146026. * @param index agent index returned by addAgent
  146027. * @param parameters agent parameters
  146028. */
  146029. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  146030. /**
  146031. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  146032. * The queries will try to find a solution within those bounds
  146033. * default is (1,1,1)
  146034. * @param extent x,y,z value that define the extent around the queries point of reference
  146035. */
  146036. setDefaultQueryExtent(extent: Vector3): void;
  146037. /**
  146038. * Get the Bounding box extent specified by setDefaultQueryExtent
  146039. * @returns the box extent values
  146040. */
  146041. getDefaultQueryExtent(): Vector3;
  146042. /**
  146043. * Get the Bounding box extent result specified by setDefaultQueryExtent
  146044. * @param result output the box extent values
  146045. */
  146046. getDefaultQueryExtentToRef(result: Vector3): void;
  146047. /**
  146048. * Release all resources
  146049. */
  146050. dispose(): void;
  146051. }
  146052. /**
  146053. * Configures an agent
  146054. */
  146055. export interface IAgentParameters {
  146056. /**
  146057. * Agent radius. [Limit: >= 0]
  146058. */
  146059. radius: number;
  146060. /**
  146061. * Agent height. [Limit: > 0]
  146062. */
  146063. height: number;
  146064. /**
  146065. * Maximum allowed acceleration. [Limit: >= 0]
  146066. */
  146067. maxAcceleration: number;
  146068. /**
  146069. * Maximum allowed speed. [Limit: >= 0]
  146070. */
  146071. maxSpeed: number;
  146072. /**
  146073. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  146074. */
  146075. collisionQueryRange: number;
  146076. /**
  146077. * The path visibility optimization range. [Limit: > 0]
  146078. */
  146079. pathOptimizationRange: number;
  146080. /**
  146081. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  146082. */
  146083. separationWeight: number;
  146084. }
  146085. /**
  146086. * Configures the navigation mesh creation
  146087. */
  146088. export interface INavMeshParameters {
  146089. /**
  146090. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  146091. */
  146092. cs: number;
  146093. /**
  146094. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  146095. */
  146096. ch: number;
  146097. /**
  146098. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  146099. */
  146100. walkableSlopeAngle: number;
  146101. /**
  146102. * Minimum floor to 'ceiling' height that will still allow the floor area to
  146103. * be considered walkable. [Limit: >= 3] [Units: vx]
  146104. */
  146105. walkableHeight: number;
  146106. /**
  146107. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  146108. */
  146109. walkableClimb: number;
  146110. /**
  146111. * The distance to erode/shrink the walkable area of the heightfield away from
  146112. * obstructions. [Limit: >=0] [Units: vx]
  146113. */
  146114. walkableRadius: number;
  146115. /**
  146116. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  146117. */
  146118. maxEdgeLen: number;
  146119. /**
  146120. * The maximum distance a simplfied contour's border edges should deviate
  146121. * the original raw contour. [Limit: >=0] [Units: vx]
  146122. */
  146123. maxSimplificationError: number;
  146124. /**
  146125. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  146126. */
  146127. minRegionArea: number;
  146128. /**
  146129. * Any regions with a span count smaller than this value will, if possible,
  146130. * be merged with larger regions. [Limit: >=0] [Units: vx]
  146131. */
  146132. mergeRegionArea: number;
  146133. /**
  146134. * The maximum number of vertices allowed for polygons generated during the
  146135. * contour to polygon conversion process. [Limit: >= 3]
  146136. */
  146137. maxVertsPerPoly: number;
  146138. /**
  146139. * Sets the sampling distance to use when generating the detail mesh.
  146140. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  146141. */
  146142. detailSampleDist: number;
  146143. /**
  146144. * The maximum distance the detail mesh surface should deviate from heightfield
  146145. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  146146. */
  146147. detailSampleMaxError: number;
  146148. }
  146149. }
  146150. declare module BABYLON {
  146151. /**
  146152. * RecastJS navigation plugin
  146153. */
  146154. export class RecastJSPlugin implements INavigationEnginePlugin {
  146155. /**
  146156. * Reference to the Recast library
  146157. */
  146158. bjsRECAST: any;
  146159. /**
  146160. * plugin name
  146161. */
  146162. name: string;
  146163. /**
  146164. * the first navmesh created. We might extend this to support multiple navmeshes
  146165. */
  146166. navMesh: any;
  146167. /**
  146168. * Initializes the recastJS plugin
  146169. * @param recastInjection can be used to inject your own recast reference
  146170. */
  146171. constructor(recastInjection?: any);
  146172. /**
  146173. * Creates a navigation mesh
  146174. * @param meshes array of all the geometry used to compute the navigatio mesh
  146175. * @param parameters bunch of parameters used to filter geometry
  146176. */
  146177. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  146178. /**
  146179. * Create a navigation mesh debug mesh
  146180. * @param scene is where the mesh will be added
  146181. * @returns debug display mesh
  146182. */
  146183. createDebugNavMesh(scene: Scene): Mesh;
  146184. /**
  146185. * Get a navigation mesh constrained position, closest to the parameter position
  146186. * @param position world position
  146187. * @returns the closest point to position constrained by the navigation mesh
  146188. */
  146189. getClosestPoint(position: Vector3): Vector3;
  146190. /**
  146191. * Get a navigation mesh constrained position, closest to the parameter position
  146192. * @param position world position
  146193. * @param result output the closest point to position constrained by the navigation mesh
  146194. */
  146195. getClosestPointToRef(position: Vector3, result: Vector3): void;
  146196. /**
  146197. * Get a navigation mesh constrained position, within a particular radius
  146198. * @param position world position
  146199. * @param maxRadius the maximum distance to the constrained world position
  146200. * @returns the closest point to position constrained by the navigation mesh
  146201. */
  146202. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  146203. /**
  146204. * Get a navigation mesh constrained position, within a particular radius
  146205. * @param position world position
  146206. * @param maxRadius the maximum distance to the constrained world position
  146207. * @param result output the closest point to position constrained by the navigation mesh
  146208. */
  146209. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  146210. /**
  146211. * Compute the final position from a segment made of destination-position
  146212. * @param position world position
  146213. * @param destination world position
  146214. * @returns the resulting point along the navmesh
  146215. */
  146216. moveAlong(position: Vector3, destination: Vector3): Vector3;
  146217. /**
  146218. * Compute the final position from a segment made of destination-position
  146219. * @param position world position
  146220. * @param destination world position
  146221. * @param result output the resulting point along the navmesh
  146222. */
  146223. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  146224. /**
  146225. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  146226. * @param start world position
  146227. * @param end world position
  146228. * @returns array containing world position composing the path
  146229. */
  146230. computePath(start: Vector3, end: Vector3): Vector3[];
  146231. /**
  146232. * Create a new Crowd so you can add agents
  146233. * @param maxAgents the maximum agent count in the crowd
  146234. * @param maxAgentRadius the maximum radius an agent can have
  146235. * @param scene to attach the crowd to
  146236. * @returns the crowd you can add agents to
  146237. */
  146238. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  146239. /**
  146240. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  146241. * The queries will try to find a solution within those bounds
  146242. * default is (1,1,1)
  146243. * @param extent x,y,z value that define the extent around the queries point of reference
  146244. */
  146245. setDefaultQueryExtent(extent: Vector3): void;
  146246. /**
  146247. * Get the Bounding box extent specified by setDefaultQueryExtent
  146248. * @returns the box extent values
  146249. */
  146250. getDefaultQueryExtent(): Vector3;
  146251. /**
  146252. * build the navmesh from a previously saved state using getNavmeshData
  146253. * @param data the Uint8Array returned by getNavmeshData
  146254. */
  146255. buildFromNavmeshData(data: Uint8Array): void;
  146256. /**
  146257. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  146258. * @returns data the Uint8Array that can be saved and reused
  146259. */
  146260. getNavmeshData(): Uint8Array;
  146261. /**
  146262. * Get the Bounding box extent result specified by setDefaultQueryExtent
  146263. * @param result output the box extent values
  146264. */
  146265. getDefaultQueryExtentToRef(result: Vector3): void;
  146266. /**
  146267. * Disposes
  146268. */
  146269. dispose(): void;
  146270. /**
  146271. * If this plugin is supported
  146272. * @returns true if plugin is supported
  146273. */
  146274. isSupported(): boolean;
  146275. }
  146276. /**
  146277. * Recast detour crowd implementation
  146278. */
  146279. export class RecastJSCrowd implements ICrowd {
  146280. /**
  146281. * Recast/detour plugin
  146282. */
  146283. bjsRECASTPlugin: RecastJSPlugin;
  146284. /**
  146285. * Link to the detour crowd
  146286. */
  146287. recastCrowd: any;
  146288. /**
  146289. * One transform per agent
  146290. */
  146291. transforms: TransformNode[];
  146292. /**
  146293. * All agents created
  146294. */
  146295. agents: number[];
  146296. /**
  146297. * Link to the scene is kept to unregister the crowd from the scene
  146298. */
  146299. private _scene;
  146300. /**
  146301. * Observer for crowd updates
  146302. */
  146303. private _onBeforeAnimationsObserver;
  146304. /**
  146305. * Constructor
  146306. * @param plugin recastJS plugin
  146307. * @param maxAgents the maximum agent count in the crowd
  146308. * @param maxAgentRadius the maximum radius an agent can have
  146309. * @param scene to attach the crowd to
  146310. * @returns the crowd you can add agents to
  146311. */
  146312. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  146313. /**
  146314. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  146315. * You can attach anything to that node. The node position is updated in the scene update tick.
  146316. * @param pos world position that will be constrained by the navigation mesh
  146317. * @param parameters agent parameters
  146318. * @param transform hooked to the agent that will be update by the scene
  146319. * @returns agent index
  146320. */
  146321. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  146322. /**
  146323. * Returns the agent position in world space
  146324. * @param index agent index returned by addAgent
  146325. * @returns world space position
  146326. */
  146327. getAgentPosition(index: number): Vector3;
  146328. /**
  146329. * Returns the agent position result in world space
  146330. * @param index agent index returned by addAgent
  146331. * @param result output world space position
  146332. */
  146333. getAgentPositionToRef(index: number, result: Vector3): void;
  146334. /**
  146335. * Returns the agent velocity in world space
  146336. * @param index agent index returned by addAgent
  146337. * @returns world space velocity
  146338. */
  146339. getAgentVelocity(index: number): Vector3;
  146340. /**
  146341. * Returns the agent velocity result in world space
  146342. * @param index agent index returned by addAgent
  146343. * @param result output world space velocity
  146344. */
  146345. getAgentVelocityToRef(index: number, result: Vector3): void;
  146346. /**
  146347. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  146348. * @param index agent index returned by addAgent
  146349. * @param destination targeted world position
  146350. */
  146351. agentGoto(index: number, destination: Vector3): void;
  146352. /**
  146353. * Teleport the agent to a new position
  146354. * @param index agent index returned by addAgent
  146355. * @param destination targeted world position
  146356. */
  146357. agentTeleport(index: number, destination: Vector3): void;
  146358. /**
  146359. * Update agent parameters
  146360. * @param index agent index returned by addAgent
  146361. * @param parameters agent parameters
  146362. */
  146363. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  146364. /**
  146365. * remove a particular agent previously created
  146366. * @param index agent index returned by addAgent
  146367. */
  146368. removeAgent(index: number): void;
  146369. /**
  146370. * get the list of all agents attached to this crowd
  146371. * @returns list of agent indices
  146372. */
  146373. getAgents(): number[];
  146374. /**
  146375. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  146376. * @param deltaTime in seconds
  146377. */
  146378. update(deltaTime: number): void;
  146379. /**
  146380. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  146381. * The queries will try to find a solution within those bounds
  146382. * default is (1,1,1)
  146383. * @param extent x,y,z value that define the extent around the queries point of reference
  146384. */
  146385. setDefaultQueryExtent(extent: Vector3): void;
  146386. /**
  146387. * Get the Bounding box extent specified by setDefaultQueryExtent
  146388. * @returns the box extent values
  146389. */
  146390. getDefaultQueryExtent(): Vector3;
  146391. /**
  146392. * Get the Bounding box extent result specified by setDefaultQueryExtent
  146393. * @param result output the box extent values
  146394. */
  146395. getDefaultQueryExtentToRef(result: Vector3): void;
  146396. /**
  146397. * Release all resources
  146398. */
  146399. dispose(): void;
  146400. }
  146401. }
  146402. declare module BABYLON {
  146403. /**
  146404. * Class used to enable access to IndexedDB
  146405. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  146406. */
  146407. export class Database implements IOfflineProvider {
  146408. private _callbackManifestChecked;
  146409. private _currentSceneUrl;
  146410. private _db;
  146411. private _enableSceneOffline;
  146412. private _enableTexturesOffline;
  146413. private _manifestVersionFound;
  146414. private _mustUpdateRessources;
  146415. private _hasReachedQuota;
  146416. private _isSupported;
  146417. private _idbFactory;
  146418. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  146419. private static IsUASupportingBlobStorage;
  146420. /**
  146421. * Gets a boolean indicating if Database storate is enabled (off by default)
  146422. */
  146423. static IDBStorageEnabled: boolean;
  146424. /**
  146425. * Gets a boolean indicating if scene must be saved in the database
  146426. */
  146427. get enableSceneOffline(): boolean;
  146428. /**
  146429. * Gets a boolean indicating if textures must be saved in the database
  146430. */
  146431. get enableTexturesOffline(): boolean;
  146432. /**
  146433. * Creates a new Database
  146434. * @param urlToScene defines the url to load the scene
  146435. * @param callbackManifestChecked defines the callback to use when manifest is checked
  146436. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  146437. */
  146438. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  146439. private static _ParseURL;
  146440. private static _ReturnFullUrlLocation;
  146441. private _checkManifestFile;
  146442. /**
  146443. * Open the database and make it available
  146444. * @param successCallback defines the callback to call on success
  146445. * @param errorCallback defines the callback to call on error
  146446. */
  146447. open(successCallback: () => void, errorCallback: () => void): void;
  146448. /**
  146449. * Loads an image from the database
  146450. * @param url defines the url to load from
  146451. * @param image defines the target DOM image
  146452. */
  146453. loadImage(url: string, image: HTMLImageElement): void;
  146454. private _loadImageFromDBAsync;
  146455. private _saveImageIntoDBAsync;
  146456. private _checkVersionFromDB;
  146457. private _loadVersionFromDBAsync;
  146458. private _saveVersionIntoDBAsync;
  146459. /**
  146460. * Loads a file from database
  146461. * @param url defines the URL to load from
  146462. * @param sceneLoaded defines a callback to call on success
  146463. * @param progressCallBack defines a callback to call when progress changed
  146464. * @param errorCallback defines a callback to call on error
  146465. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  146466. */
  146467. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  146468. private _loadFileAsync;
  146469. private _saveFileAsync;
  146470. /**
  146471. * Validates if xhr data is correct
  146472. * @param xhr defines the request to validate
  146473. * @param dataType defines the expected data type
  146474. * @returns true if data is correct
  146475. */
  146476. private static _ValidateXHRData;
  146477. }
  146478. }
  146479. declare module BABYLON {
  146480. /** @hidden */
  146481. export var gpuUpdateParticlesPixelShader: {
  146482. name: string;
  146483. shader: string;
  146484. };
  146485. }
  146486. declare module BABYLON {
  146487. /** @hidden */
  146488. export var gpuUpdateParticlesVertexShader: {
  146489. name: string;
  146490. shader: string;
  146491. };
  146492. }
  146493. declare module BABYLON {
  146494. /** @hidden */
  146495. export var clipPlaneFragmentDeclaration2: {
  146496. name: string;
  146497. shader: string;
  146498. };
  146499. }
  146500. declare module BABYLON {
  146501. /** @hidden */
  146502. export var gpuRenderParticlesPixelShader: {
  146503. name: string;
  146504. shader: string;
  146505. };
  146506. }
  146507. declare module BABYLON {
  146508. /** @hidden */
  146509. export var clipPlaneVertexDeclaration2: {
  146510. name: string;
  146511. shader: string;
  146512. };
  146513. }
  146514. declare module BABYLON {
  146515. /** @hidden */
  146516. export var gpuRenderParticlesVertexShader: {
  146517. name: string;
  146518. shader: string;
  146519. };
  146520. }
  146521. declare module BABYLON {
  146522. /**
  146523. * This represents a GPU particle system in Babylon
  146524. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  146525. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  146526. */
  146527. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  146528. /**
  146529. * The layer mask we are rendering the particles through.
  146530. */
  146531. layerMask: number;
  146532. private _capacity;
  146533. private _activeCount;
  146534. private _currentActiveCount;
  146535. private _accumulatedCount;
  146536. private _renderEffect;
  146537. private _updateEffect;
  146538. private _buffer0;
  146539. private _buffer1;
  146540. private _spriteBuffer;
  146541. private _updateVAO;
  146542. private _renderVAO;
  146543. private _targetIndex;
  146544. private _sourceBuffer;
  146545. private _targetBuffer;
  146546. private _currentRenderId;
  146547. private _started;
  146548. private _stopped;
  146549. private _timeDelta;
  146550. private _randomTexture;
  146551. private _randomTexture2;
  146552. private _attributesStrideSize;
  146553. private _updateEffectOptions;
  146554. private _randomTextureSize;
  146555. private _actualFrame;
  146556. private _customEffect;
  146557. private readonly _rawTextureWidth;
  146558. /**
  146559. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  146560. */
  146561. static get IsSupported(): boolean;
  146562. /**
  146563. * An event triggered when the system is disposed.
  146564. */
  146565. onDisposeObservable: Observable<IParticleSystem>;
  146566. /**
  146567. * Gets the maximum number of particles active at the same time.
  146568. * @returns The max number of active particles.
  146569. */
  146570. getCapacity(): number;
  146571. /**
  146572. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  146573. * to override the particles.
  146574. */
  146575. forceDepthWrite: boolean;
  146576. /**
  146577. * Gets or set the number of active particles
  146578. */
  146579. get activeParticleCount(): number;
  146580. set activeParticleCount(value: number);
  146581. private _preWarmDone;
  146582. /**
  146583. * Specifies if the particles are updated in emitter local space or world space.
  146584. */
  146585. isLocal: boolean;
  146586. /** Gets or sets a matrix to use to compute projection */
  146587. defaultProjectionMatrix: Matrix;
  146588. /**
  146589. * Is this system ready to be used/rendered
  146590. * @return true if the system is ready
  146591. */
  146592. isReady(): boolean;
  146593. /**
  146594. * Gets if the system has been started. (Note: this will still be true after stop is called)
  146595. * @returns True if it has been started, otherwise false.
  146596. */
  146597. isStarted(): boolean;
  146598. /**
  146599. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  146600. * @returns True if it has been stopped, otherwise false.
  146601. */
  146602. isStopped(): boolean;
  146603. /**
  146604. * Gets a boolean indicating that the system is stopping
  146605. * @returns true if the system is currently stopping
  146606. */
  146607. isStopping(): boolean;
  146608. /**
  146609. * Gets the number of particles active at the same time.
  146610. * @returns The number of active particles.
  146611. */
  146612. getActiveCount(): number;
  146613. /**
  146614. * Starts the particle system and begins to emit
  146615. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  146616. */
  146617. start(delay?: number): void;
  146618. /**
  146619. * Stops the particle system.
  146620. */
  146621. stop(): void;
  146622. /**
  146623. * Remove all active particles
  146624. */
  146625. reset(): void;
  146626. /**
  146627. * Returns the string "GPUParticleSystem"
  146628. * @returns a string containing the class name
  146629. */
  146630. getClassName(): string;
  146631. /**
  146632. * Gets the custom effect used to render the particles
  146633. * @param blendMode Blend mode for which the effect should be retrieved
  146634. * @returns The effect
  146635. */
  146636. getCustomEffect(blendMode?: number): Nullable<Effect>;
  146637. /**
  146638. * Sets the custom effect used to render the particles
  146639. * @param effect The effect to set
  146640. * @param blendMode Blend mode for which the effect should be set
  146641. */
  146642. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  146643. /** @hidden */
  146644. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  146645. /**
  146646. * Observable that will be called just before the particles are drawn
  146647. */
  146648. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  146649. /**
  146650. * Gets the name of the particle vertex shader
  146651. */
  146652. get vertexShaderName(): string;
  146653. private _colorGradientsTexture;
  146654. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  146655. /**
  146656. * Adds a new color gradient
  146657. * @param gradient defines the gradient to use (between 0 and 1)
  146658. * @param color1 defines the color to affect to the specified gradient
  146659. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  146660. * @returns the current particle system
  146661. */
  146662. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  146663. private _refreshColorGradient;
  146664. /** Force the system to rebuild all gradients that need to be resync */
  146665. forceRefreshGradients(): void;
  146666. /**
  146667. * Remove a specific color gradient
  146668. * @param gradient defines the gradient to remove
  146669. * @returns the current particle system
  146670. */
  146671. removeColorGradient(gradient: number): GPUParticleSystem;
  146672. private _angularSpeedGradientsTexture;
  146673. private _sizeGradientsTexture;
  146674. private _velocityGradientsTexture;
  146675. private _limitVelocityGradientsTexture;
  146676. private _dragGradientsTexture;
  146677. private _addFactorGradient;
  146678. /**
  146679. * Adds a new size gradient
  146680. * @param gradient defines the gradient to use (between 0 and 1)
  146681. * @param factor defines the size factor to affect to the specified gradient
  146682. * @returns the current particle system
  146683. */
  146684. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  146685. /**
  146686. * Remove a specific size gradient
  146687. * @param gradient defines the gradient to remove
  146688. * @returns the current particle system
  146689. */
  146690. removeSizeGradient(gradient: number): GPUParticleSystem;
  146691. private _refreshFactorGradient;
  146692. /**
  146693. * Adds a new angular speed gradient
  146694. * @param gradient defines the gradient to use (between 0 and 1)
  146695. * @param factor defines the angular speed to affect to the specified gradient
  146696. * @returns the current particle system
  146697. */
  146698. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  146699. /**
  146700. * Remove a specific angular speed gradient
  146701. * @param gradient defines the gradient to remove
  146702. * @returns the current particle system
  146703. */
  146704. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  146705. /**
  146706. * Adds a new velocity gradient
  146707. * @param gradient defines the gradient to use (between 0 and 1)
  146708. * @param factor defines the velocity to affect to the specified gradient
  146709. * @returns the current particle system
  146710. */
  146711. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  146712. /**
  146713. * Remove a specific velocity gradient
  146714. * @param gradient defines the gradient to remove
  146715. * @returns the current particle system
  146716. */
  146717. removeVelocityGradient(gradient: number): GPUParticleSystem;
  146718. /**
  146719. * Adds a new limit velocity gradient
  146720. * @param gradient defines the gradient to use (between 0 and 1)
  146721. * @param factor defines the limit velocity value to affect to the specified gradient
  146722. * @returns the current particle system
  146723. */
  146724. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  146725. /**
  146726. * Remove a specific limit velocity gradient
  146727. * @param gradient defines the gradient to remove
  146728. * @returns the current particle system
  146729. */
  146730. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  146731. /**
  146732. * Adds a new drag gradient
  146733. * @param gradient defines the gradient to use (between 0 and 1)
  146734. * @param factor defines the drag value to affect to the specified gradient
  146735. * @returns the current particle system
  146736. */
  146737. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  146738. /**
  146739. * Remove a specific drag gradient
  146740. * @param gradient defines the gradient to remove
  146741. * @returns the current particle system
  146742. */
  146743. removeDragGradient(gradient: number): GPUParticleSystem;
  146744. /**
  146745. * Not supported by GPUParticleSystem
  146746. * @param gradient defines the gradient to use (between 0 and 1)
  146747. * @param factor defines the emit rate value to affect to the specified gradient
  146748. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  146749. * @returns the current particle system
  146750. */
  146751. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  146752. /**
  146753. * Not supported by GPUParticleSystem
  146754. * @param gradient defines the gradient to remove
  146755. * @returns the current particle system
  146756. */
  146757. removeEmitRateGradient(gradient: number): IParticleSystem;
  146758. /**
  146759. * Not supported by GPUParticleSystem
  146760. * @param gradient defines the gradient to use (between 0 and 1)
  146761. * @param factor defines the start size value to affect to the specified gradient
  146762. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  146763. * @returns the current particle system
  146764. */
  146765. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  146766. /**
  146767. * Not supported by GPUParticleSystem
  146768. * @param gradient defines the gradient to remove
  146769. * @returns the current particle system
  146770. */
  146771. removeStartSizeGradient(gradient: number): IParticleSystem;
  146772. /**
  146773. * Not supported by GPUParticleSystem
  146774. * @param gradient defines the gradient to use (between 0 and 1)
  146775. * @param min defines the color remap minimal range
  146776. * @param max defines the color remap maximal range
  146777. * @returns the current particle system
  146778. */
  146779. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  146780. /**
  146781. * Not supported by GPUParticleSystem
  146782. * @param gradient defines the gradient to remove
  146783. * @returns the current particle system
  146784. */
  146785. removeColorRemapGradient(): IParticleSystem;
  146786. /**
  146787. * Not supported by GPUParticleSystem
  146788. * @param gradient defines the gradient to use (between 0 and 1)
  146789. * @param min defines the alpha remap minimal range
  146790. * @param max defines the alpha remap maximal range
  146791. * @returns the current particle system
  146792. */
  146793. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  146794. /**
  146795. * Not supported by GPUParticleSystem
  146796. * @param gradient defines the gradient to remove
  146797. * @returns the current particle system
  146798. */
  146799. removeAlphaRemapGradient(): IParticleSystem;
  146800. /**
  146801. * Not supported by GPUParticleSystem
  146802. * @param gradient defines the gradient to use (between 0 and 1)
  146803. * @param color defines the color to affect to the specified gradient
  146804. * @returns the current particle system
  146805. */
  146806. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  146807. /**
  146808. * Not supported by GPUParticleSystem
  146809. * @param gradient defines the gradient to remove
  146810. * @returns the current particle system
  146811. */
  146812. removeRampGradient(): IParticleSystem;
  146813. /**
  146814. * Not supported by GPUParticleSystem
  146815. * @returns the list of ramp gradients
  146816. */
  146817. getRampGradients(): Nullable<Array<Color3Gradient>>;
  146818. /**
  146819. * Not supported by GPUParticleSystem
  146820. * Gets or sets a boolean indicating that ramp gradients must be used
  146821. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  146822. */
  146823. get useRampGradients(): boolean;
  146824. set useRampGradients(value: boolean);
  146825. /**
  146826. * Not supported by GPUParticleSystem
  146827. * @param gradient defines the gradient to use (between 0 and 1)
  146828. * @param factor defines the life time factor to affect to the specified gradient
  146829. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  146830. * @returns the current particle system
  146831. */
  146832. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  146833. /**
  146834. * Not supported by GPUParticleSystem
  146835. * @param gradient defines the gradient to remove
  146836. * @returns the current particle system
  146837. */
  146838. removeLifeTimeGradient(gradient: number): IParticleSystem;
  146839. /**
  146840. * Instantiates a GPU particle system.
  146841. * 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.
  146842. * @param name The name of the particle system
  146843. * @param options The options used to create the system
  146844. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  146845. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  146846. * @param customEffect a custom effect used to change the way particles are rendered by default
  146847. */
  146848. constructor(name: string, options: Partial<{
  146849. capacity: number;
  146850. randomTextureSize: number;
  146851. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  146852. protected _reset(): void;
  146853. private _createUpdateVAO;
  146854. private _createRenderVAO;
  146855. private _initialize;
  146856. /** @hidden */
  146857. _recreateUpdateEffect(): void;
  146858. private _getEffect;
  146859. /**
  146860. * Fill the defines array according to the current settings of the particle system
  146861. * @param defines Array to be updated
  146862. * @param blendMode blend mode to take into account when updating the array
  146863. */
  146864. fillDefines(defines: Array<string>, blendMode?: number): void;
  146865. /**
  146866. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  146867. * @param uniforms Uniforms array to fill
  146868. * @param attributes Attributes array to fill
  146869. * @param samplers Samplers array to fill
  146870. */
  146871. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  146872. /** @hidden */
  146873. _recreateRenderEffect(): Effect;
  146874. /**
  146875. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  146876. * @param preWarm defines if we are in the pre-warmimg phase
  146877. */
  146878. animate(preWarm?: boolean): void;
  146879. private _createFactorGradientTexture;
  146880. private _createSizeGradientTexture;
  146881. private _createAngularSpeedGradientTexture;
  146882. private _createVelocityGradientTexture;
  146883. private _createLimitVelocityGradientTexture;
  146884. private _createDragGradientTexture;
  146885. private _createColorGradientTexture;
  146886. /**
  146887. * Renders the particle system in its current state
  146888. * @param preWarm defines if the system should only update the particles but not render them
  146889. * @returns the current number of particles
  146890. */
  146891. render(preWarm?: boolean): number;
  146892. /**
  146893. * Rebuilds the particle system
  146894. */
  146895. rebuild(): void;
  146896. private _releaseBuffers;
  146897. private _releaseVAOs;
  146898. /**
  146899. * Disposes the particle system and free the associated resources
  146900. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  146901. */
  146902. dispose(disposeTexture?: boolean): void;
  146903. /**
  146904. * Clones the particle system.
  146905. * @param name The name of the cloned object
  146906. * @param newEmitter The new emitter to use
  146907. * @returns the cloned particle system
  146908. */
  146909. clone(name: string, newEmitter: any): GPUParticleSystem;
  146910. /**
  146911. * Serializes the particle system to a JSON object
  146912. * @param serializeTexture defines if the texture must be serialized as well
  146913. * @returns the JSON object
  146914. */
  146915. serialize(serializeTexture?: boolean): any;
  146916. /**
  146917. * Parses a JSON object to create a GPU particle system.
  146918. * @param parsedParticleSystem The JSON object to parse
  146919. * @param sceneOrEngine The scene or the engine to create the particle system in
  146920. * @param rootUrl The root url to use to load external dependencies like texture
  146921. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  146922. * @returns the parsed GPU particle system
  146923. */
  146924. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  146925. }
  146926. }
  146927. declare module BABYLON {
  146928. /**
  146929. * Represents a set of particle systems working together to create a specific effect
  146930. */
  146931. export class ParticleSystemSet implements IDisposable {
  146932. /**
  146933. * Gets or sets base Assets URL
  146934. */
  146935. static BaseAssetsUrl: string;
  146936. private _emitterCreationOptions;
  146937. private _emitterNode;
  146938. /**
  146939. * Gets the particle system list
  146940. */
  146941. systems: IParticleSystem[];
  146942. /**
  146943. * Gets the emitter node used with this set
  146944. */
  146945. get emitterNode(): Nullable<TransformNode>;
  146946. /**
  146947. * Creates a new emitter mesh as a sphere
  146948. * @param options defines the options used to create the sphere
  146949. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  146950. * @param scene defines the hosting scene
  146951. */
  146952. setEmitterAsSphere(options: {
  146953. diameter: number;
  146954. segments: number;
  146955. color: Color3;
  146956. }, renderingGroupId: number, scene: Scene): void;
  146957. /**
  146958. * Starts all particle systems of the set
  146959. * @param emitter defines an optional mesh to use as emitter for the particle systems
  146960. */
  146961. start(emitter?: AbstractMesh): void;
  146962. /**
  146963. * Release all associated resources
  146964. */
  146965. dispose(): void;
  146966. /**
  146967. * Serialize the set into a JSON compatible object
  146968. * @param serializeTexture defines if the texture must be serialized as well
  146969. * @returns a JSON compatible representation of the set
  146970. */
  146971. serialize(serializeTexture?: boolean): any;
  146972. /**
  146973. * Parse a new ParticleSystemSet from a serialized source
  146974. * @param data defines a JSON compatible representation of the set
  146975. * @param scene defines the hosting scene
  146976. * @param gpu defines if we want GPU particles or CPU particles
  146977. * @returns a new ParticleSystemSet
  146978. */
  146979. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  146980. }
  146981. }
  146982. declare module BABYLON {
  146983. /**
  146984. * This class is made for on one-liner static method to help creating particle system set.
  146985. */
  146986. export class ParticleHelper {
  146987. /**
  146988. * Gets or sets base Assets URL
  146989. */
  146990. static BaseAssetsUrl: string;
  146991. /** Define the Url to load snippets */
  146992. static SnippetUrl: string;
  146993. /**
  146994. * Create a default particle system that you can tweak
  146995. * @param emitter defines the emitter to use
  146996. * @param capacity defines the system capacity (default is 500 particles)
  146997. * @param scene defines the hosting scene
  146998. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  146999. * @returns the new Particle system
  147000. */
  147001. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  147002. /**
  147003. * This is the main static method (one-liner) of this helper to create different particle systems
  147004. * @param type This string represents the type to the particle system to create
  147005. * @param scene The scene where the particle system should live
  147006. * @param gpu If the system will use gpu
  147007. * @returns the ParticleSystemSet created
  147008. */
  147009. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  147010. /**
  147011. * Static function used to export a particle system to a ParticleSystemSet variable.
  147012. * Please note that the emitter shape is not exported
  147013. * @param systems defines the particle systems to export
  147014. * @returns the created particle system set
  147015. */
  147016. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  147017. /**
  147018. * Creates a particle system from a snippet saved in a remote file
  147019. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  147020. * @param url defines the url to load from
  147021. * @param scene defines the hosting scene
  147022. * @param gpu If the system will use gpu
  147023. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  147024. * @returns a promise that will resolve to the new particle system
  147025. */
  147026. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  147027. /**
  147028. * Creates a particle system from a snippet saved by the particle system editor
  147029. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  147030. * @param scene defines the hosting scene
  147031. * @param gpu If the system will use gpu
  147032. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  147033. * @returns a promise that will resolve to the new particle system
  147034. */
  147035. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  147036. }
  147037. }
  147038. declare module BABYLON {
  147039. interface Engine {
  147040. /**
  147041. * Create an effect to use with particle systems.
  147042. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  147043. * the particle system for which you want to create a custom effect in the last parameter
  147044. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  147045. * @param uniformsNames defines a list of attribute names
  147046. * @param samplers defines an array of string used to represent textures
  147047. * @param defines defines the string containing the defines to use to compile the shaders
  147048. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  147049. * @param onCompiled defines a function to call when the effect creation is successful
  147050. * @param onError defines a function to call when the effect creation has failed
  147051. * @param particleSystem the particle system you want to create the effect for
  147052. * @returns the new Effect
  147053. */
  147054. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  147055. }
  147056. interface Mesh {
  147057. /**
  147058. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  147059. * @returns an array of IParticleSystem
  147060. */
  147061. getEmittedParticleSystems(): IParticleSystem[];
  147062. /**
  147063. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  147064. * @returns an array of IParticleSystem
  147065. */
  147066. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  147067. }
  147068. }
  147069. declare module BABYLON {
  147070. /** Defines the 4 color options */
  147071. export enum PointColor {
  147072. /** color value */
  147073. Color = 2,
  147074. /** uv value */
  147075. UV = 1,
  147076. /** random value */
  147077. Random = 0,
  147078. /** stated value */
  147079. Stated = 3
  147080. }
  147081. /**
  147082. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  147083. * 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.
  147084. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  147085. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  147086. *
  147087. * Full documentation here : TO BE ENTERED
  147088. */
  147089. export class PointsCloudSystem implements IDisposable {
  147090. /**
  147091. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  147092. * Example : var p = SPS.particles[i];
  147093. */
  147094. particles: CloudPoint[];
  147095. /**
  147096. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  147097. */
  147098. nbParticles: number;
  147099. /**
  147100. * This a counter for your own usage. It's not set by any SPS functions.
  147101. */
  147102. counter: number;
  147103. /**
  147104. * The PCS name. This name is also given to the underlying mesh.
  147105. */
  147106. name: string;
  147107. /**
  147108. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  147109. */
  147110. mesh: Mesh;
  147111. /**
  147112. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  147113. * Please read :
  147114. */
  147115. vars: any;
  147116. /**
  147117. * @hidden
  147118. */
  147119. _size: number;
  147120. private _scene;
  147121. private _promises;
  147122. private _positions;
  147123. private _indices;
  147124. private _normals;
  147125. private _colors;
  147126. private _uvs;
  147127. private _indices32;
  147128. private _positions32;
  147129. private _colors32;
  147130. private _uvs32;
  147131. private _updatable;
  147132. private _isVisibilityBoxLocked;
  147133. private _alwaysVisible;
  147134. private _groups;
  147135. private _groupCounter;
  147136. private _computeParticleColor;
  147137. private _computeParticleTexture;
  147138. private _computeParticleRotation;
  147139. private _computeBoundingBox;
  147140. private _isReady;
  147141. /**
  147142. * Creates a PCS (Points Cloud System) object
  147143. * @param name (String) is the PCS name, this will be the underlying mesh name
  147144. * @param pointSize (number) is the size for each point
  147145. * @param scene (Scene) is the scene in which the PCS is added
  147146. * @param options defines the options of the PCS e.g.
  147147. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  147148. */
  147149. constructor(name: string, pointSize: number, scene: Scene, options?: {
  147150. updatable?: boolean;
  147151. });
  147152. /**
  147153. * Builds the PCS underlying mesh. Returns a standard Mesh.
  147154. * If no points were added to the PCS, the returned mesh is just a single point.
  147155. * @returns a promise for the created mesh
  147156. */
  147157. buildMeshAsync(): Promise<Mesh>;
  147158. /**
  147159. * @hidden
  147160. */
  147161. private _buildMesh;
  147162. private _addParticle;
  147163. private _randomUnitVector;
  147164. private _getColorIndicesForCoord;
  147165. private _setPointsColorOrUV;
  147166. private _colorFromTexture;
  147167. private _calculateDensity;
  147168. /**
  147169. * Adds points to the PCS in random positions within a unit sphere
  147170. * @param nb (positive integer) the number of particles to be created from this model
  147171. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  147172. * @returns the number of groups in the system
  147173. */
  147174. addPoints(nb: number, pointFunction?: any): number;
  147175. /**
  147176. * Adds points to the PCS from the surface of the model shape
  147177. * @param mesh is any Mesh object that will be used as a surface model for the points
  147178. * @param nb (positive integer) the number of particles to be created from this model
  147179. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  147180. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  147181. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  147182. * @returns the number of groups in the system
  147183. */
  147184. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  147185. /**
  147186. * Adds points to the PCS inside the model shape
  147187. * @param mesh is any Mesh object that will be used as a surface model for the points
  147188. * @param nb (positive integer) the number of particles to be created from this model
  147189. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  147190. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  147191. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  147192. * @returns the number of groups in the system
  147193. */
  147194. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  147195. /**
  147196. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  147197. * This method calls `updateParticle()` for each particle of the SPS.
  147198. * For an animated SPS, it is usually called within the render loop.
  147199. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  147200. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  147201. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  147202. * @returns the PCS.
  147203. */
  147204. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  147205. /**
  147206. * Disposes the PCS.
  147207. */
  147208. dispose(): void;
  147209. /**
  147210. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  147211. * doc :
  147212. * @returns the PCS.
  147213. */
  147214. refreshVisibleSize(): PointsCloudSystem;
  147215. /**
  147216. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  147217. * @param size the size (float) of the visibility box
  147218. * note : this doesn't lock the PCS mesh bounding box.
  147219. * doc :
  147220. */
  147221. setVisibilityBox(size: number): void;
  147222. /**
  147223. * Gets whether the PCS is always visible or not
  147224. * doc :
  147225. */
  147226. get isAlwaysVisible(): boolean;
  147227. /**
  147228. * Sets the PCS as always visible or not
  147229. * doc :
  147230. */
  147231. set isAlwaysVisible(val: boolean);
  147232. /**
  147233. * Tells to `setParticles()` to compute the particle rotations or not
  147234. * Default value : false. The PCS is faster when it's set to false
  147235. * Note : particle rotations are only applied to parent particles
  147236. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  147237. */
  147238. set computeParticleRotation(val: boolean);
  147239. /**
  147240. * Tells to `setParticles()` to compute the particle colors or not.
  147241. * Default value : true. The PCS is faster when it's set to false.
  147242. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  147243. */
  147244. set computeParticleColor(val: boolean);
  147245. set computeParticleTexture(val: boolean);
  147246. /**
  147247. * Gets if `setParticles()` computes the particle colors or not.
  147248. * Default value : false. The PCS is faster when it's set to false.
  147249. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  147250. */
  147251. get computeParticleColor(): boolean;
  147252. /**
  147253. * Gets if `setParticles()` computes the particle textures or not.
  147254. * Default value : false. The PCS is faster when it's set to false.
  147255. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  147256. */
  147257. get computeParticleTexture(): boolean;
  147258. /**
  147259. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  147260. */
  147261. set computeBoundingBox(val: boolean);
  147262. /**
  147263. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  147264. */
  147265. get computeBoundingBox(): boolean;
  147266. /**
  147267. * This function does nothing. It may be overwritten to set all the particle first values.
  147268. * The PCS doesn't call this function, you may have to call it by your own.
  147269. * doc :
  147270. */
  147271. initParticles(): void;
  147272. /**
  147273. * This function does nothing. It may be overwritten to recycle a particle
  147274. * The PCS doesn't call this function, you can to call it
  147275. * doc :
  147276. * @param particle The particle to recycle
  147277. * @returns the recycled particle
  147278. */
  147279. recycleParticle(particle: CloudPoint): CloudPoint;
  147280. /**
  147281. * Updates a particle : this function should be overwritten by the user.
  147282. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  147283. * doc :
  147284. * @example : just set a particle position or velocity and recycle conditions
  147285. * @param particle The particle to update
  147286. * @returns the updated particle
  147287. */
  147288. updateParticle(particle: CloudPoint): CloudPoint;
  147289. /**
  147290. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  147291. * This does nothing and may be overwritten by the user.
  147292. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  147293. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  147294. * @param update the boolean update value actually passed to setParticles()
  147295. */
  147296. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  147297. /**
  147298. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  147299. * This will be passed three parameters.
  147300. * This does nothing and may be overwritten by the user.
  147301. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  147302. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  147303. * @param update the boolean update value actually passed to setParticles()
  147304. */
  147305. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  147306. }
  147307. }
  147308. declare module BABYLON {
  147309. /**
  147310. * Represents one particle of a points cloud system.
  147311. */
  147312. export class CloudPoint {
  147313. /**
  147314. * particle global index
  147315. */
  147316. idx: number;
  147317. /**
  147318. * The color of the particle
  147319. */
  147320. color: Nullable<Color4>;
  147321. /**
  147322. * The world space position of the particle.
  147323. */
  147324. position: Vector3;
  147325. /**
  147326. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  147327. */
  147328. rotation: Vector3;
  147329. /**
  147330. * The world space rotation quaternion of the particle.
  147331. */
  147332. rotationQuaternion: Nullable<Quaternion>;
  147333. /**
  147334. * The uv of the particle.
  147335. */
  147336. uv: Nullable<Vector2>;
  147337. /**
  147338. * The current speed of the particle.
  147339. */
  147340. velocity: Vector3;
  147341. /**
  147342. * The pivot point in the particle local space.
  147343. */
  147344. pivot: Vector3;
  147345. /**
  147346. * Must the particle be translated from its pivot point in its local space ?
  147347. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  147348. * Default : false
  147349. */
  147350. translateFromPivot: boolean;
  147351. /**
  147352. * Index of this particle in the global "positions" array (Internal use)
  147353. * @hidden
  147354. */
  147355. _pos: number;
  147356. /**
  147357. * @hidden Index of this particle in the global "indices" array (Internal use)
  147358. */
  147359. _ind: number;
  147360. /**
  147361. * Group this particle belongs to
  147362. */
  147363. _group: PointsGroup;
  147364. /**
  147365. * Group id of this particle
  147366. */
  147367. groupId: number;
  147368. /**
  147369. * Index of the particle in its group id (Internal use)
  147370. */
  147371. idxInGroup: number;
  147372. /**
  147373. * @hidden Particle BoundingInfo object (Internal use)
  147374. */
  147375. _boundingInfo: BoundingInfo;
  147376. /**
  147377. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  147378. */
  147379. _pcs: PointsCloudSystem;
  147380. /**
  147381. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  147382. */
  147383. _stillInvisible: boolean;
  147384. /**
  147385. * @hidden Last computed particle rotation matrix
  147386. */
  147387. _rotationMatrix: number[];
  147388. /**
  147389. * Parent particle Id, if any.
  147390. * Default null.
  147391. */
  147392. parentId: Nullable<number>;
  147393. /**
  147394. * @hidden Internal global position in the PCS.
  147395. */
  147396. _globalPosition: Vector3;
  147397. /**
  147398. * Creates a Point Cloud object.
  147399. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  147400. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  147401. * @param group (PointsGroup) is the group the particle belongs to
  147402. * @param groupId (integer) is the group identifier in the PCS.
  147403. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  147404. * @param pcs defines the PCS it is associated to
  147405. */
  147406. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  147407. /**
  147408. * get point size
  147409. */
  147410. get size(): Vector3;
  147411. /**
  147412. * Set point size
  147413. */
  147414. set size(scale: Vector3);
  147415. /**
  147416. * Legacy support, changed quaternion to rotationQuaternion
  147417. */
  147418. get quaternion(): Nullable<Quaternion>;
  147419. /**
  147420. * Legacy support, changed quaternion to rotationQuaternion
  147421. */
  147422. set quaternion(q: Nullable<Quaternion>);
  147423. /**
  147424. * Returns a boolean. True if the particle intersects a mesh, else false
  147425. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  147426. * @param target is the object (point or mesh) what the intersection is computed against
  147427. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  147428. * @returns true if it intersects
  147429. */
  147430. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  147431. /**
  147432. * get the rotation matrix of the particle
  147433. * @hidden
  147434. */
  147435. getRotationMatrix(m: Matrix): void;
  147436. }
  147437. /**
  147438. * Represents a group of points in a points cloud system
  147439. * * PCS internal tool, don't use it manually.
  147440. */
  147441. export class PointsGroup {
  147442. /**
  147443. * The group id
  147444. * @hidden
  147445. */
  147446. groupID: number;
  147447. /**
  147448. * image data for group (internal use)
  147449. * @hidden
  147450. */
  147451. _groupImageData: Nullable<ArrayBufferView>;
  147452. /**
  147453. * Image Width (internal use)
  147454. * @hidden
  147455. */
  147456. _groupImgWidth: number;
  147457. /**
  147458. * Image Height (internal use)
  147459. * @hidden
  147460. */
  147461. _groupImgHeight: number;
  147462. /**
  147463. * Custom position function (internal use)
  147464. * @hidden
  147465. */
  147466. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  147467. /**
  147468. * density per facet for surface points
  147469. * @hidden
  147470. */
  147471. _groupDensity: number[];
  147472. /**
  147473. * Only when points are colored by texture carries pointer to texture list array
  147474. * @hidden
  147475. */
  147476. _textureNb: number;
  147477. /**
  147478. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  147479. * PCS internal tool, don't use it manually.
  147480. * @hidden
  147481. */
  147482. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  147483. }
  147484. }
  147485. declare module BABYLON {
  147486. interface Scene {
  147487. /** @hidden (Backing field) */
  147488. _physicsEngine: Nullable<IPhysicsEngine>;
  147489. /** @hidden */
  147490. _physicsTimeAccumulator: number;
  147491. /**
  147492. * Gets the current physics engine
  147493. * @returns a IPhysicsEngine or null if none attached
  147494. */
  147495. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  147496. /**
  147497. * Enables physics to the current scene
  147498. * @param gravity defines the scene's gravity for the physics engine
  147499. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  147500. * @return a boolean indicating if the physics engine was initialized
  147501. */
  147502. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  147503. /**
  147504. * Disables and disposes the physics engine associated with the scene
  147505. */
  147506. disablePhysicsEngine(): void;
  147507. /**
  147508. * Gets a boolean indicating if there is an active physics engine
  147509. * @returns a boolean indicating if there is an active physics engine
  147510. */
  147511. isPhysicsEnabled(): boolean;
  147512. /**
  147513. * Deletes a physics compound impostor
  147514. * @param compound defines the compound to delete
  147515. */
  147516. deleteCompoundImpostor(compound: any): void;
  147517. /**
  147518. * An event triggered when physic simulation is about to be run
  147519. */
  147520. onBeforePhysicsObservable: Observable<Scene>;
  147521. /**
  147522. * An event triggered when physic simulation has been done
  147523. */
  147524. onAfterPhysicsObservable: Observable<Scene>;
  147525. }
  147526. interface AbstractMesh {
  147527. /** @hidden */
  147528. _physicsImpostor: Nullable<PhysicsImpostor>;
  147529. /**
  147530. * Gets or sets impostor used for physic simulation
  147531. * @see https://doc.babylonjs.com/features/physics_engine
  147532. */
  147533. physicsImpostor: Nullable<PhysicsImpostor>;
  147534. /**
  147535. * Gets the current physics impostor
  147536. * @see https://doc.babylonjs.com/features/physics_engine
  147537. * @returns a physics impostor or null
  147538. */
  147539. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  147540. /** Apply a physic impulse to the mesh
  147541. * @param force defines the force to apply
  147542. * @param contactPoint defines where to apply the force
  147543. * @returns the current mesh
  147544. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  147545. */
  147546. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  147547. /**
  147548. * Creates a physic joint between two meshes
  147549. * @param otherMesh defines the other mesh to use
  147550. * @param pivot1 defines the pivot to use on this mesh
  147551. * @param pivot2 defines the pivot to use on the other mesh
  147552. * @param options defines additional options (can be plugin dependent)
  147553. * @returns the current mesh
  147554. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  147555. */
  147556. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  147557. /** @hidden */
  147558. _disposePhysicsObserver: Nullable<Observer<Node>>;
  147559. }
  147560. /**
  147561. * Defines the physics engine scene component responsible to manage a physics engine
  147562. */
  147563. export class PhysicsEngineSceneComponent implements ISceneComponent {
  147564. /**
  147565. * The component name helpful to identify the component in the list of scene components.
  147566. */
  147567. readonly name: string;
  147568. /**
  147569. * The scene the component belongs to.
  147570. */
  147571. scene: Scene;
  147572. /**
  147573. * Creates a new instance of the component for the given scene
  147574. * @param scene Defines the scene to register the component in
  147575. */
  147576. constructor(scene: Scene);
  147577. /**
  147578. * Registers the component in a given scene
  147579. */
  147580. register(): void;
  147581. /**
  147582. * Rebuilds the elements related to this component in case of
  147583. * context lost for instance.
  147584. */
  147585. rebuild(): void;
  147586. /**
  147587. * Disposes the component and the associated ressources
  147588. */
  147589. dispose(): void;
  147590. }
  147591. }
  147592. declare module BABYLON {
  147593. /**
  147594. * A helper for physics simulations
  147595. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147596. */
  147597. export class PhysicsHelper {
  147598. private _scene;
  147599. private _physicsEngine;
  147600. /**
  147601. * Initializes the Physics helper
  147602. * @param scene Babylon.js scene
  147603. */
  147604. constructor(scene: Scene);
  147605. /**
  147606. * Applies a radial explosion impulse
  147607. * @param origin the origin of the explosion
  147608. * @param radiusOrEventOptions the radius or the options of radial explosion
  147609. * @param strength the explosion strength
  147610. * @param falloff possible options: Constant & Linear. Defaults to Constant
  147611. * @returns A physics radial explosion event, or null
  147612. */
  147613. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  147614. /**
  147615. * Applies a radial explosion force
  147616. * @param origin the origin of the explosion
  147617. * @param radiusOrEventOptions the radius or the options of radial explosion
  147618. * @param strength the explosion strength
  147619. * @param falloff possible options: Constant & Linear. Defaults to Constant
  147620. * @returns A physics radial explosion event, or null
  147621. */
  147622. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  147623. /**
  147624. * Creates a gravitational field
  147625. * @param origin the origin of the explosion
  147626. * @param radiusOrEventOptions the radius or the options of radial explosion
  147627. * @param strength the explosion strength
  147628. * @param falloff possible options: Constant & Linear. Defaults to Constant
  147629. * @returns A physics gravitational field event, or null
  147630. */
  147631. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  147632. /**
  147633. * Creates a physics updraft event
  147634. * @param origin the origin of the updraft
  147635. * @param radiusOrEventOptions the radius or the options of the updraft
  147636. * @param strength the strength of the updraft
  147637. * @param height the height of the updraft
  147638. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  147639. * @returns A physics updraft event, or null
  147640. */
  147641. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  147642. /**
  147643. * Creates a physics vortex event
  147644. * @param origin the of the vortex
  147645. * @param radiusOrEventOptions the radius or the options of the vortex
  147646. * @param strength the strength of the vortex
  147647. * @param height the height of the vortex
  147648. * @returns a Physics vortex event, or null
  147649. * A physics vortex event or null
  147650. */
  147651. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  147652. }
  147653. /**
  147654. * Represents a physics radial explosion event
  147655. */
  147656. class PhysicsRadialExplosionEvent {
  147657. private _scene;
  147658. private _options;
  147659. private _sphere;
  147660. private _dataFetched;
  147661. /**
  147662. * Initializes a radial explosioin event
  147663. * @param _scene BabylonJS scene
  147664. * @param _options The options for the vortex event
  147665. */
  147666. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  147667. /**
  147668. * Returns the data related to the radial explosion event (sphere).
  147669. * @returns The radial explosion event data
  147670. */
  147671. getData(): PhysicsRadialExplosionEventData;
  147672. /**
  147673. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  147674. * @param impostor A physics imposter
  147675. * @param origin the origin of the explosion
  147676. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  147677. */
  147678. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  147679. /**
  147680. * Triggers affecterd impostors callbacks
  147681. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  147682. */
  147683. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  147684. /**
  147685. * Disposes the sphere.
  147686. * @param force Specifies if the sphere should be disposed by force
  147687. */
  147688. dispose(force?: boolean): void;
  147689. /*** Helpers ***/
  147690. private _prepareSphere;
  147691. private _intersectsWithSphere;
  147692. }
  147693. /**
  147694. * Represents a gravitational field event
  147695. */
  147696. class PhysicsGravitationalFieldEvent {
  147697. private _physicsHelper;
  147698. private _scene;
  147699. private _origin;
  147700. private _options;
  147701. private _tickCallback;
  147702. private _sphere;
  147703. private _dataFetched;
  147704. /**
  147705. * Initializes the physics gravitational field event
  147706. * @param _physicsHelper A physics helper
  147707. * @param _scene BabylonJS scene
  147708. * @param _origin The origin position of the gravitational field event
  147709. * @param _options The options for the vortex event
  147710. */
  147711. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  147712. /**
  147713. * Returns the data related to the gravitational field event (sphere).
  147714. * @returns A gravitational field event
  147715. */
  147716. getData(): PhysicsGravitationalFieldEventData;
  147717. /**
  147718. * Enables the gravitational field.
  147719. */
  147720. enable(): void;
  147721. /**
  147722. * Disables the gravitational field.
  147723. */
  147724. disable(): void;
  147725. /**
  147726. * Disposes the sphere.
  147727. * @param force The force to dispose from the gravitational field event
  147728. */
  147729. dispose(force?: boolean): void;
  147730. private _tick;
  147731. }
  147732. /**
  147733. * Represents a physics updraft event
  147734. */
  147735. class PhysicsUpdraftEvent {
  147736. private _scene;
  147737. private _origin;
  147738. private _options;
  147739. private _physicsEngine;
  147740. private _originTop;
  147741. private _originDirection;
  147742. private _tickCallback;
  147743. private _cylinder;
  147744. private _cylinderPosition;
  147745. private _dataFetched;
  147746. /**
  147747. * Initializes the physics updraft event
  147748. * @param _scene BabylonJS scene
  147749. * @param _origin The origin position of the updraft
  147750. * @param _options The options for the updraft event
  147751. */
  147752. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  147753. /**
  147754. * Returns the data related to the updraft event (cylinder).
  147755. * @returns A physics updraft event
  147756. */
  147757. getData(): PhysicsUpdraftEventData;
  147758. /**
  147759. * Enables the updraft.
  147760. */
  147761. enable(): void;
  147762. /**
  147763. * Disables the updraft.
  147764. */
  147765. disable(): void;
  147766. /**
  147767. * Disposes the cylinder.
  147768. * @param force Specifies if the updraft should be disposed by force
  147769. */
  147770. dispose(force?: boolean): void;
  147771. private getImpostorHitData;
  147772. private _tick;
  147773. /*** Helpers ***/
  147774. private _prepareCylinder;
  147775. private _intersectsWithCylinder;
  147776. }
  147777. /**
  147778. * Represents a physics vortex event
  147779. */
  147780. class PhysicsVortexEvent {
  147781. private _scene;
  147782. private _origin;
  147783. private _options;
  147784. private _physicsEngine;
  147785. private _originTop;
  147786. private _tickCallback;
  147787. private _cylinder;
  147788. private _cylinderPosition;
  147789. private _dataFetched;
  147790. /**
  147791. * Initializes the physics vortex event
  147792. * @param _scene The BabylonJS scene
  147793. * @param _origin The origin position of the vortex
  147794. * @param _options The options for the vortex event
  147795. */
  147796. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  147797. /**
  147798. * Returns the data related to the vortex event (cylinder).
  147799. * @returns The physics vortex event data
  147800. */
  147801. getData(): PhysicsVortexEventData;
  147802. /**
  147803. * Enables the vortex.
  147804. */
  147805. enable(): void;
  147806. /**
  147807. * Disables the cortex.
  147808. */
  147809. disable(): void;
  147810. /**
  147811. * Disposes the sphere.
  147812. * @param force
  147813. */
  147814. dispose(force?: boolean): void;
  147815. private getImpostorHitData;
  147816. private _tick;
  147817. /*** Helpers ***/
  147818. private _prepareCylinder;
  147819. private _intersectsWithCylinder;
  147820. }
  147821. /**
  147822. * Options fot the radial explosion event
  147823. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147824. */
  147825. export class PhysicsRadialExplosionEventOptions {
  147826. /**
  147827. * The radius of the sphere for the radial explosion.
  147828. */
  147829. radius: number;
  147830. /**
  147831. * The strenth of the explosion.
  147832. */
  147833. strength: number;
  147834. /**
  147835. * The strenght of the force in correspondence to the distance of the affected object
  147836. */
  147837. falloff: PhysicsRadialImpulseFalloff;
  147838. /**
  147839. * Sphere options for the radial explosion.
  147840. */
  147841. sphere: {
  147842. segments: number;
  147843. diameter: number;
  147844. };
  147845. /**
  147846. * Sphere options for the radial explosion.
  147847. */
  147848. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  147849. }
  147850. /**
  147851. * Options fot the updraft event
  147852. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147853. */
  147854. export class PhysicsUpdraftEventOptions {
  147855. /**
  147856. * The radius of the cylinder for the vortex
  147857. */
  147858. radius: number;
  147859. /**
  147860. * The strenth of the updraft.
  147861. */
  147862. strength: number;
  147863. /**
  147864. * The height of the cylinder for the updraft.
  147865. */
  147866. height: number;
  147867. /**
  147868. * The mode for the the updraft.
  147869. */
  147870. updraftMode: PhysicsUpdraftMode;
  147871. }
  147872. /**
  147873. * Options fot the vortex event
  147874. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147875. */
  147876. export class PhysicsVortexEventOptions {
  147877. /**
  147878. * The radius of the cylinder for the vortex
  147879. */
  147880. radius: number;
  147881. /**
  147882. * The strenth of the vortex.
  147883. */
  147884. strength: number;
  147885. /**
  147886. * The height of the cylinder for the vortex.
  147887. */
  147888. height: number;
  147889. /**
  147890. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  147891. */
  147892. centripetalForceThreshold: number;
  147893. /**
  147894. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  147895. */
  147896. centripetalForceMultiplier: number;
  147897. /**
  147898. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  147899. */
  147900. centrifugalForceMultiplier: number;
  147901. /**
  147902. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  147903. */
  147904. updraftForceMultiplier: number;
  147905. }
  147906. /**
  147907. * The strenght of the force in correspondence to the distance of the affected object
  147908. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147909. */
  147910. export enum PhysicsRadialImpulseFalloff {
  147911. /** Defines that impulse is constant in strength across it's whole radius */
  147912. Constant = 0,
  147913. /** Defines that impulse gets weaker if it's further from the origin */
  147914. Linear = 1
  147915. }
  147916. /**
  147917. * The strength of the force in correspondence to the distance of the affected object
  147918. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147919. */
  147920. export enum PhysicsUpdraftMode {
  147921. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  147922. Center = 0,
  147923. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  147924. Perpendicular = 1
  147925. }
  147926. /**
  147927. * Interface for a physics hit data
  147928. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147929. */
  147930. export interface PhysicsHitData {
  147931. /**
  147932. * The force applied at the contact point
  147933. */
  147934. force: Vector3;
  147935. /**
  147936. * The contact point
  147937. */
  147938. contactPoint: Vector3;
  147939. /**
  147940. * The distance from the origin to the contact point
  147941. */
  147942. distanceFromOrigin: number;
  147943. }
  147944. /**
  147945. * Interface for radial explosion event data
  147946. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147947. */
  147948. export interface PhysicsRadialExplosionEventData {
  147949. /**
  147950. * A sphere used for the radial explosion event
  147951. */
  147952. sphere: Mesh;
  147953. }
  147954. /**
  147955. * Interface for gravitational field event data
  147956. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147957. */
  147958. export interface PhysicsGravitationalFieldEventData {
  147959. /**
  147960. * A sphere mesh used for the gravitational field event
  147961. */
  147962. sphere: Mesh;
  147963. }
  147964. /**
  147965. * Interface for updraft event data
  147966. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147967. */
  147968. export interface PhysicsUpdraftEventData {
  147969. /**
  147970. * A cylinder used for the updraft event
  147971. */
  147972. cylinder: Mesh;
  147973. }
  147974. /**
  147975. * Interface for vortex event data
  147976. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147977. */
  147978. export interface PhysicsVortexEventData {
  147979. /**
  147980. * A cylinder used for the vortex event
  147981. */
  147982. cylinder: Mesh;
  147983. }
  147984. /**
  147985. * Interface for an affected physics impostor
  147986. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147987. */
  147988. export interface PhysicsAffectedImpostorWithData {
  147989. /**
  147990. * The impostor affected by the effect
  147991. */
  147992. impostor: PhysicsImpostor;
  147993. /**
  147994. * The data about the hit/horce from the explosion
  147995. */
  147996. hitData: PhysicsHitData;
  147997. }
  147998. }
  147999. declare module BABYLON {
  148000. /** @hidden */
  148001. export var blackAndWhitePixelShader: {
  148002. name: string;
  148003. shader: string;
  148004. };
  148005. }
  148006. declare module BABYLON {
  148007. /**
  148008. * Post process used to render in black and white
  148009. */
  148010. export class BlackAndWhitePostProcess extends PostProcess {
  148011. /**
  148012. * Linear about to convert he result to black and white (default: 1)
  148013. */
  148014. degree: number;
  148015. /**
  148016. * Gets a string identifying the name of the class
  148017. * @returns "BlackAndWhitePostProcess" string
  148018. */
  148019. getClassName(): string;
  148020. /**
  148021. * Creates a black and white post process
  148022. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  148023. * @param name The name of the effect.
  148024. * @param options The required width/height ratio to downsize to before computing the render pass.
  148025. * @param camera The camera to apply the render pass to.
  148026. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148027. * @param engine The engine which the post process will be applied. (default: current engine)
  148028. * @param reusable If the post process can be reused on the same frame. (default: false)
  148029. */
  148030. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  148031. /** @hidden */
  148032. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  148033. }
  148034. }
  148035. declare module BABYLON {
  148036. /**
  148037. * This represents a set of one or more post processes in Babylon.
  148038. * A post process can be used to apply a shader to a texture after it is rendered.
  148039. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  148040. */
  148041. export class PostProcessRenderEffect {
  148042. private _postProcesses;
  148043. private _getPostProcesses;
  148044. private _singleInstance;
  148045. private _cameras;
  148046. private _indicesForCamera;
  148047. /**
  148048. * Name of the effect
  148049. * @hidden
  148050. */
  148051. _name: string;
  148052. /**
  148053. * Instantiates a post process render effect.
  148054. * A post process can be used to apply a shader to a texture after it is rendered.
  148055. * @param engine The engine the effect is tied to
  148056. * @param name The name of the effect
  148057. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  148058. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  148059. */
  148060. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  148061. /**
  148062. * Checks if all the post processes in the effect are supported.
  148063. */
  148064. get isSupported(): boolean;
  148065. /**
  148066. * Updates the current state of the effect
  148067. * @hidden
  148068. */
  148069. _update(): void;
  148070. /**
  148071. * Attaches the effect on cameras
  148072. * @param cameras The camera to attach to.
  148073. * @hidden
  148074. */
  148075. _attachCameras(cameras: Camera): void;
  148076. /**
  148077. * Attaches the effect on cameras
  148078. * @param cameras The camera to attach to.
  148079. * @hidden
  148080. */
  148081. _attachCameras(cameras: Camera[]): void;
  148082. /**
  148083. * Detaches the effect on cameras
  148084. * @param cameras The camera to detatch from.
  148085. * @hidden
  148086. */
  148087. _detachCameras(cameras: Camera): void;
  148088. /**
  148089. * Detatches the effect on cameras
  148090. * @param cameras The camera to detatch from.
  148091. * @hidden
  148092. */
  148093. _detachCameras(cameras: Camera[]): void;
  148094. /**
  148095. * Enables the effect on given cameras
  148096. * @param cameras The camera to enable.
  148097. * @hidden
  148098. */
  148099. _enable(cameras: Camera): void;
  148100. /**
  148101. * Enables the effect on given cameras
  148102. * @param cameras The camera to enable.
  148103. * @hidden
  148104. */
  148105. _enable(cameras: Nullable<Camera[]>): void;
  148106. /**
  148107. * Disables the effect on the given cameras
  148108. * @param cameras The camera to disable.
  148109. * @hidden
  148110. */
  148111. _disable(cameras: Camera): void;
  148112. /**
  148113. * Disables the effect on the given cameras
  148114. * @param cameras The camera to disable.
  148115. * @hidden
  148116. */
  148117. _disable(cameras: Nullable<Camera[]>): void;
  148118. /**
  148119. * Gets a list of the post processes contained in the effect.
  148120. * @param camera The camera to get the post processes on.
  148121. * @returns The list of the post processes in the effect.
  148122. */
  148123. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  148124. }
  148125. }
  148126. declare module BABYLON {
  148127. /** @hidden */
  148128. export var extractHighlightsPixelShader: {
  148129. name: string;
  148130. shader: string;
  148131. };
  148132. }
  148133. declare module BABYLON {
  148134. /**
  148135. * 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.
  148136. */
  148137. export class ExtractHighlightsPostProcess extends PostProcess {
  148138. /**
  148139. * The luminance threshold, pixels below this value will be set to black.
  148140. */
  148141. threshold: number;
  148142. /** @hidden */
  148143. _exposure: number;
  148144. /**
  148145. * Post process which has the input texture to be used when performing highlight extraction
  148146. * @hidden
  148147. */
  148148. _inputPostProcess: Nullable<PostProcess>;
  148149. /**
  148150. * Gets a string identifying the name of the class
  148151. * @returns "ExtractHighlightsPostProcess" string
  148152. */
  148153. getClassName(): string;
  148154. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  148155. }
  148156. }
  148157. declare module BABYLON {
  148158. /** @hidden */
  148159. export var bloomMergePixelShader: {
  148160. name: string;
  148161. shader: string;
  148162. };
  148163. }
  148164. declare module BABYLON {
  148165. /**
  148166. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  148167. */
  148168. export class BloomMergePostProcess extends PostProcess {
  148169. /** Weight of the bloom to be added to the original input. */
  148170. weight: number;
  148171. /**
  148172. * Gets a string identifying the name of the class
  148173. * @returns "BloomMergePostProcess" string
  148174. */
  148175. getClassName(): string;
  148176. /**
  148177. * Creates a new instance of @see BloomMergePostProcess
  148178. * @param name The name of the effect.
  148179. * @param originalFromInput Post process which's input will be used for the merge.
  148180. * @param blurred Blurred highlights post process which's output will be used.
  148181. * @param weight Weight of the bloom to be added to the original input.
  148182. * @param options The required width/height ratio to downsize to before computing the render pass.
  148183. * @param camera The camera to apply the render pass to.
  148184. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148185. * @param engine The engine which the post process will be applied. (default: current engine)
  148186. * @param reusable If the post process can be reused on the same frame. (default: false)
  148187. * @param textureType Type of textures used when performing the post process. (default: 0)
  148188. * @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)
  148189. */
  148190. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  148191. /** Weight of the bloom to be added to the original input. */
  148192. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  148193. }
  148194. }
  148195. declare module BABYLON {
  148196. /**
  148197. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  148198. */
  148199. export class BloomEffect extends PostProcessRenderEffect {
  148200. private bloomScale;
  148201. /**
  148202. * @hidden Internal
  148203. */
  148204. _effects: Array<PostProcess>;
  148205. /**
  148206. * @hidden Internal
  148207. */
  148208. _downscale: ExtractHighlightsPostProcess;
  148209. private _blurX;
  148210. private _blurY;
  148211. private _merge;
  148212. /**
  148213. * The luminance threshold to find bright areas of the image to bloom.
  148214. */
  148215. get threshold(): number;
  148216. set threshold(value: number);
  148217. /**
  148218. * The strength of the bloom.
  148219. */
  148220. get weight(): number;
  148221. set weight(value: number);
  148222. /**
  148223. * Specifies the size of the bloom blur kernel, relative to the final output size
  148224. */
  148225. get kernel(): number;
  148226. set kernel(value: number);
  148227. /**
  148228. * Creates a new instance of @see BloomEffect
  148229. * @param scene The scene the effect belongs to.
  148230. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  148231. * @param bloomKernel The size of the kernel to be used when applying the blur.
  148232. * @param bloomWeight The the strength of bloom.
  148233. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  148234. * @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)
  148235. */
  148236. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  148237. /**
  148238. * Disposes each of the internal effects for a given camera.
  148239. * @param camera The camera to dispose the effect on.
  148240. */
  148241. disposeEffects(camera: Camera): void;
  148242. /**
  148243. * @hidden Internal
  148244. */
  148245. _updateEffects(): void;
  148246. /**
  148247. * Internal
  148248. * @returns if all the contained post processes are ready.
  148249. * @hidden
  148250. */
  148251. _isReady(): boolean;
  148252. }
  148253. }
  148254. declare module BABYLON {
  148255. /** @hidden */
  148256. export var chromaticAberrationPixelShader: {
  148257. name: string;
  148258. shader: string;
  148259. };
  148260. }
  148261. declare module BABYLON {
  148262. /**
  148263. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  148264. */
  148265. export class ChromaticAberrationPostProcess extends PostProcess {
  148266. /**
  148267. * The amount of seperation of rgb channels (default: 30)
  148268. */
  148269. aberrationAmount: number;
  148270. /**
  148271. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  148272. */
  148273. radialIntensity: number;
  148274. /**
  148275. * 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))
  148276. */
  148277. direction: Vector2;
  148278. /**
  148279. * 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))
  148280. */
  148281. centerPosition: Vector2;
  148282. /** The width of the screen to apply the effect on */
  148283. screenWidth: number;
  148284. /** The height of the screen to apply the effect on */
  148285. screenHeight: number;
  148286. /**
  148287. * Gets a string identifying the name of the class
  148288. * @returns "ChromaticAberrationPostProcess" string
  148289. */
  148290. getClassName(): string;
  148291. /**
  148292. * Creates a new instance ChromaticAberrationPostProcess
  148293. * @param name The name of the effect.
  148294. * @param screenWidth The width of the screen to apply the effect on.
  148295. * @param screenHeight The height of the screen to apply the effect on.
  148296. * @param options The required width/height ratio to downsize to before computing the render pass.
  148297. * @param camera The camera to apply the render pass to.
  148298. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148299. * @param engine The engine which the post process will be applied. (default: current engine)
  148300. * @param reusable If the post process can be reused on the same frame. (default: false)
  148301. * @param textureType Type of textures used when performing the post process. (default: 0)
  148302. * @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)
  148303. */
  148304. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  148305. /** @hidden */
  148306. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  148307. }
  148308. }
  148309. declare module BABYLON {
  148310. /** @hidden */
  148311. export var circleOfConfusionPixelShader: {
  148312. name: string;
  148313. shader: string;
  148314. };
  148315. }
  148316. declare module BABYLON {
  148317. /**
  148318. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  148319. */
  148320. export class CircleOfConfusionPostProcess extends PostProcess {
  148321. /**
  148322. * 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.
  148323. */
  148324. lensSize: number;
  148325. /**
  148326. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  148327. */
  148328. fStop: number;
  148329. /**
  148330. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  148331. */
  148332. focusDistance: number;
  148333. /**
  148334. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  148335. */
  148336. focalLength: number;
  148337. /**
  148338. * Gets a string identifying the name of the class
  148339. * @returns "CircleOfConfusionPostProcess" string
  148340. */
  148341. getClassName(): string;
  148342. private _depthTexture;
  148343. /**
  148344. * Creates a new instance CircleOfConfusionPostProcess
  148345. * @param name The name of the effect.
  148346. * @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.
  148347. * @param options The required width/height ratio to downsize to before computing the render pass.
  148348. * @param camera The camera to apply the render pass to.
  148349. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148350. * @param engine The engine which the post process will be applied. (default: current engine)
  148351. * @param reusable If the post process can be reused on the same frame. (default: false)
  148352. * @param textureType Type of textures used when performing the post process. (default: 0)
  148353. * @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)
  148354. */
  148355. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  148356. /**
  148357. * 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.
  148358. */
  148359. set depthTexture(value: RenderTargetTexture);
  148360. }
  148361. }
  148362. declare module BABYLON {
  148363. /** @hidden */
  148364. export var colorCorrectionPixelShader: {
  148365. name: string;
  148366. shader: string;
  148367. };
  148368. }
  148369. declare module BABYLON {
  148370. /**
  148371. *
  148372. * This post-process allows the modification of rendered colors by using
  148373. * a 'look-up table' (LUT). This effect is also called Color Grading.
  148374. *
  148375. * The object needs to be provided an url to a texture containing the color
  148376. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  148377. * Use an image editing software to tweak the LUT to match your needs.
  148378. *
  148379. * For an example of a color LUT, see here:
  148380. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  148381. * For explanations on color grading, see here:
  148382. * @see http://udn.epicgames.com/Three/ColorGrading.html
  148383. *
  148384. */
  148385. export class ColorCorrectionPostProcess extends PostProcess {
  148386. private _colorTableTexture;
  148387. /**
  148388. * Gets the color table url used to create the LUT texture
  148389. */
  148390. colorTableUrl: string;
  148391. /**
  148392. * Gets a string identifying the name of the class
  148393. * @returns "ColorCorrectionPostProcess" string
  148394. */
  148395. getClassName(): string;
  148396. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  148397. /** @hidden */
  148398. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  148399. }
  148400. }
  148401. declare module BABYLON {
  148402. /** @hidden */
  148403. export var convolutionPixelShader: {
  148404. name: string;
  148405. shader: string;
  148406. };
  148407. }
  148408. declare module BABYLON {
  148409. /**
  148410. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  148411. * input texture to perform effects such as edge detection or sharpening
  148412. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  148413. */
  148414. export class ConvolutionPostProcess extends PostProcess {
  148415. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  148416. kernel: number[];
  148417. /**
  148418. * Gets a string identifying the name of the class
  148419. * @returns "ConvolutionPostProcess" string
  148420. */
  148421. getClassName(): string;
  148422. /**
  148423. * Creates a new instance ConvolutionPostProcess
  148424. * @param name The name of the effect.
  148425. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  148426. * @param options The required width/height ratio to downsize to before computing the render pass.
  148427. * @param camera The camera to apply the render pass to.
  148428. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148429. * @param engine The engine which the post process will be applied. (default: current engine)
  148430. * @param reusable If the post process can be reused on the same frame. (default: false)
  148431. * @param textureType Type of textures used when performing the post process. (default: 0)
  148432. */
  148433. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  148434. /** @hidden */
  148435. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  148436. /**
  148437. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  148438. */
  148439. static EdgeDetect0Kernel: number[];
  148440. /**
  148441. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  148442. */
  148443. static EdgeDetect1Kernel: number[];
  148444. /**
  148445. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  148446. */
  148447. static EdgeDetect2Kernel: number[];
  148448. /**
  148449. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  148450. */
  148451. static SharpenKernel: number[];
  148452. /**
  148453. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  148454. */
  148455. static EmbossKernel: number[];
  148456. /**
  148457. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  148458. */
  148459. static GaussianKernel: number[];
  148460. }
  148461. }
  148462. declare module BABYLON {
  148463. /**
  148464. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  148465. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  148466. * based on samples that have a large difference in distance than the center pixel.
  148467. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  148468. */
  148469. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  148470. /**
  148471. * The direction the blur should be applied
  148472. */
  148473. direction: Vector2;
  148474. /**
  148475. * Gets a string identifying the name of the class
  148476. * @returns "DepthOfFieldBlurPostProcess" string
  148477. */
  148478. getClassName(): string;
  148479. /**
  148480. * Creates a new instance CircleOfConfusionPostProcess
  148481. * @param name The name of the effect.
  148482. * @param scene The scene the effect belongs to.
  148483. * @param direction The direction the blur should be applied.
  148484. * @param kernel The size of the kernel used to blur.
  148485. * @param options The required width/height ratio to downsize to before computing the render pass.
  148486. * @param camera The camera to apply the render pass to.
  148487. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  148488. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  148489. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148490. * @param engine The engine which the post process will be applied. (default: current engine)
  148491. * @param reusable If the post process can be reused on the same frame. (default: false)
  148492. * @param textureType Type of textures used when performing the post process. (default: 0)
  148493. * @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)
  148494. */
  148495. 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);
  148496. }
  148497. }
  148498. declare module BABYLON {
  148499. /** @hidden */
  148500. export var depthOfFieldMergePixelShader: {
  148501. name: string;
  148502. shader: string;
  148503. };
  148504. }
  148505. declare module BABYLON {
  148506. /**
  148507. * Options to be set when merging outputs from the default pipeline.
  148508. */
  148509. export class DepthOfFieldMergePostProcessOptions {
  148510. /**
  148511. * The original image to merge on top of
  148512. */
  148513. originalFromInput: PostProcess;
  148514. /**
  148515. * Parameters to perform the merge of the depth of field effect
  148516. */
  148517. depthOfField?: {
  148518. circleOfConfusion: PostProcess;
  148519. blurSteps: Array<PostProcess>;
  148520. };
  148521. /**
  148522. * Parameters to perform the merge of bloom effect
  148523. */
  148524. bloom?: {
  148525. blurred: PostProcess;
  148526. weight: number;
  148527. };
  148528. }
  148529. /**
  148530. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  148531. */
  148532. export class DepthOfFieldMergePostProcess extends PostProcess {
  148533. private blurSteps;
  148534. /**
  148535. * Gets a string identifying the name of the class
  148536. * @returns "DepthOfFieldMergePostProcess" string
  148537. */
  148538. getClassName(): string;
  148539. /**
  148540. * Creates a new instance of DepthOfFieldMergePostProcess
  148541. * @param name The name of the effect.
  148542. * @param originalFromInput Post process which's input will be used for the merge.
  148543. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  148544. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  148545. * @param options The required width/height ratio to downsize to before computing the render pass.
  148546. * @param camera The camera to apply the render pass to.
  148547. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148548. * @param engine The engine which the post process will be applied. (default: current engine)
  148549. * @param reusable If the post process can be reused on the same frame. (default: false)
  148550. * @param textureType Type of textures used when performing the post process. (default: 0)
  148551. * @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)
  148552. */
  148553. 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);
  148554. /**
  148555. * Updates the effect with the current post process compile time values and recompiles the shader.
  148556. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  148557. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  148558. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  148559. * @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
  148560. * @param onCompiled Called when the shader has been compiled.
  148561. * @param onError Called if there is an error when compiling a shader.
  148562. */
  148563. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  148564. }
  148565. }
  148566. declare module BABYLON {
  148567. /**
  148568. * Specifies the level of max blur that should be applied when using the depth of field effect
  148569. */
  148570. export enum DepthOfFieldEffectBlurLevel {
  148571. /**
  148572. * Subtle blur
  148573. */
  148574. Low = 0,
  148575. /**
  148576. * Medium blur
  148577. */
  148578. Medium = 1,
  148579. /**
  148580. * Large blur
  148581. */
  148582. High = 2
  148583. }
  148584. /**
  148585. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  148586. */
  148587. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  148588. private _circleOfConfusion;
  148589. /**
  148590. * @hidden Internal, blurs from high to low
  148591. */
  148592. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  148593. private _depthOfFieldBlurY;
  148594. private _dofMerge;
  148595. /**
  148596. * @hidden Internal post processes in depth of field effect
  148597. */
  148598. _effects: Array<PostProcess>;
  148599. /**
  148600. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  148601. */
  148602. set focalLength(value: number);
  148603. get focalLength(): number;
  148604. /**
  148605. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  148606. */
  148607. set fStop(value: number);
  148608. get fStop(): number;
  148609. /**
  148610. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  148611. */
  148612. set focusDistance(value: number);
  148613. get focusDistance(): number;
  148614. /**
  148615. * 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.
  148616. */
  148617. set lensSize(value: number);
  148618. get lensSize(): number;
  148619. /**
  148620. * Creates a new instance DepthOfFieldEffect
  148621. * @param scene The scene the effect belongs to.
  148622. * @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.
  148623. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  148624. * @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)
  148625. */
  148626. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  148627. /**
  148628. * Get the current class name of the current effet
  148629. * @returns "DepthOfFieldEffect"
  148630. */
  148631. getClassName(): string;
  148632. /**
  148633. * 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.
  148634. */
  148635. set depthTexture(value: RenderTargetTexture);
  148636. /**
  148637. * Disposes each of the internal effects for a given camera.
  148638. * @param camera The camera to dispose the effect on.
  148639. */
  148640. disposeEffects(camera: Camera): void;
  148641. /**
  148642. * @hidden Internal
  148643. */
  148644. _updateEffects(): void;
  148645. /**
  148646. * Internal
  148647. * @returns if all the contained post processes are ready.
  148648. * @hidden
  148649. */
  148650. _isReady(): boolean;
  148651. }
  148652. }
  148653. declare module BABYLON {
  148654. /** @hidden */
  148655. export var displayPassPixelShader: {
  148656. name: string;
  148657. shader: string;
  148658. };
  148659. }
  148660. declare module BABYLON {
  148661. /**
  148662. * DisplayPassPostProcess which produces an output the same as it's input
  148663. */
  148664. export class DisplayPassPostProcess extends PostProcess {
  148665. /**
  148666. * Gets a string identifying the name of the class
  148667. * @returns "DisplayPassPostProcess" string
  148668. */
  148669. getClassName(): string;
  148670. /**
  148671. * Creates the DisplayPassPostProcess
  148672. * @param name The name of the effect.
  148673. * @param options The required width/height ratio to downsize to before computing the render pass.
  148674. * @param camera The camera to apply the render pass to.
  148675. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148676. * @param engine The engine which the post process will be applied. (default: current engine)
  148677. * @param reusable If the post process can be reused on the same frame. (default: false)
  148678. */
  148679. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  148680. /** @hidden */
  148681. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  148682. }
  148683. }
  148684. declare module BABYLON {
  148685. /** @hidden */
  148686. export var filterPixelShader: {
  148687. name: string;
  148688. shader: string;
  148689. };
  148690. }
  148691. declare module BABYLON {
  148692. /**
  148693. * Applies a kernel filter to the image
  148694. */
  148695. export class FilterPostProcess extends PostProcess {
  148696. /** The matrix to be applied to the image */
  148697. kernelMatrix: Matrix;
  148698. /**
  148699. * Gets a string identifying the name of the class
  148700. * @returns "FilterPostProcess" string
  148701. */
  148702. getClassName(): string;
  148703. /**
  148704. *
  148705. * @param name The name of the effect.
  148706. * @param kernelMatrix The matrix to be applied to the image
  148707. * @param options The required width/height ratio to downsize to before computing the render pass.
  148708. * @param camera The camera to apply the render pass to.
  148709. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148710. * @param engine The engine which the post process will be applied. (default: current engine)
  148711. * @param reusable If the post process can be reused on the same frame. (default: false)
  148712. */
  148713. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  148714. /** @hidden */
  148715. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  148716. }
  148717. }
  148718. declare module BABYLON {
  148719. /** @hidden */
  148720. export var fxaaPixelShader: {
  148721. name: string;
  148722. shader: string;
  148723. };
  148724. }
  148725. declare module BABYLON {
  148726. /** @hidden */
  148727. export var fxaaVertexShader: {
  148728. name: string;
  148729. shader: string;
  148730. };
  148731. }
  148732. declare module BABYLON {
  148733. /**
  148734. * Fxaa post process
  148735. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  148736. */
  148737. export class FxaaPostProcess extends PostProcess {
  148738. /**
  148739. * Gets a string identifying the name of the class
  148740. * @returns "FxaaPostProcess" string
  148741. */
  148742. getClassName(): string;
  148743. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  148744. private _getDefines;
  148745. /** @hidden */
  148746. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  148747. }
  148748. }
  148749. declare module BABYLON {
  148750. /** @hidden */
  148751. export var grainPixelShader: {
  148752. name: string;
  148753. shader: string;
  148754. };
  148755. }
  148756. declare module BABYLON {
  148757. /**
  148758. * The GrainPostProcess adds noise to the image at mid luminance levels
  148759. */
  148760. export class GrainPostProcess extends PostProcess {
  148761. /**
  148762. * The intensity of the grain added (default: 30)
  148763. */
  148764. intensity: number;
  148765. /**
  148766. * If the grain should be randomized on every frame
  148767. */
  148768. animated: boolean;
  148769. /**
  148770. * Gets a string identifying the name of the class
  148771. * @returns "GrainPostProcess" string
  148772. */
  148773. getClassName(): string;
  148774. /**
  148775. * Creates a new instance of @see GrainPostProcess
  148776. * @param name The name of the effect.
  148777. * @param options The required width/height ratio to downsize to before computing the render pass.
  148778. * @param camera The camera to apply the render pass to.
  148779. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148780. * @param engine The engine which the post process will be applied. (default: current engine)
  148781. * @param reusable If the post process can be reused on the same frame. (default: false)
  148782. * @param textureType Type of textures used when performing the post process. (default: 0)
  148783. * @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)
  148784. */
  148785. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  148786. /** @hidden */
  148787. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  148788. }
  148789. }
  148790. declare module BABYLON {
  148791. /** @hidden */
  148792. export var highlightsPixelShader: {
  148793. name: string;
  148794. shader: string;
  148795. };
  148796. }
  148797. declare module BABYLON {
  148798. /**
  148799. * Extracts highlights from the image
  148800. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  148801. */
  148802. export class HighlightsPostProcess extends PostProcess {
  148803. /**
  148804. * Gets a string identifying the name of the class
  148805. * @returns "HighlightsPostProcess" string
  148806. */
  148807. getClassName(): string;
  148808. /**
  148809. * Extracts highlights from the image
  148810. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  148811. * @param name The name of the effect.
  148812. * @param options The required width/height ratio to downsize to before computing the render pass.
  148813. * @param camera The camera to apply the render pass to.
  148814. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148815. * @param engine The engine which the post process will be applied. (default: current engine)
  148816. * @param reusable If the post process can be reused on the same frame. (default: false)
  148817. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  148818. */
  148819. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  148820. }
  148821. }
  148822. declare module BABYLON {
  148823. /** @hidden */
  148824. export var mrtFragmentDeclaration: {
  148825. name: string;
  148826. shader: string;
  148827. };
  148828. }
  148829. declare module BABYLON {
  148830. /** @hidden */
  148831. export var geometryPixelShader: {
  148832. name: string;
  148833. shader: string;
  148834. };
  148835. }
  148836. declare module BABYLON {
  148837. /** @hidden */
  148838. export var geometryVertexShader: {
  148839. name: string;
  148840. shader: string;
  148841. };
  148842. }
  148843. declare module BABYLON {
  148844. /** @hidden */
  148845. interface ISavedTransformationMatrix {
  148846. world: Matrix;
  148847. viewProjection: Matrix;
  148848. }
  148849. /**
  148850. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  148851. */
  148852. export class GeometryBufferRenderer {
  148853. /**
  148854. * Constant used to retrieve the position texture index in the G-Buffer textures array
  148855. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  148856. */
  148857. static readonly POSITION_TEXTURE_TYPE: number;
  148858. /**
  148859. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  148860. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  148861. */
  148862. static readonly VELOCITY_TEXTURE_TYPE: number;
  148863. /**
  148864. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  148865. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  148866. */
  148867. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  148868. /**
  148869. * Dictionary used to store the previous transformation matrices of each rendered mesh
  148870. * in order to compute objects velocities when enableVelocity is set to "true"
  148871. * @hidden
  148872. */
  148873. _previousTransformationMatrices: {
  148874. [index: number]: ISavedTransformationMatrix;
  148875. };
  148876. /**
  148877. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  148878. * in order to compute objects velocities when enableVelocity is set to "true"
  148879. * @hidden
  148880. */
  148881. _previousBonesTransformationMatrices: {
  148882. [index: number]: Float32Array;
  148883. };
  148884. /**
  148885. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  148886. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  148887. */
  148888. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  148889. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  148890. renderTransparentMeshes: boolean;
  148891. private _scene;
  148892. private _resizeObserver;
  148893. private _multiRenderTarget;
  148894. private _ratio;
  148895. private _enablePosition;
  148896. private _enableVelocity;
  148897. private _enableReflectivity;
  148898. private _positionIndex;
  148899. private _velocityIndex;
  148900. private _reflectivityIndex;
  148901. protected _effect: Effect;
  148902. protected _cachedDefines: string;
  148903. /**
  148904. * Set the render list (meshes to be rendered) used in the G buffer.
  148905. */
  148906. set renderList(meshes: Mesh[]);
  148907. /**
  148908. * Gets wether or not G buffer are supported by the running hardware.
  148909. * This requires draw buffer supports
  148910. */
  148911. get isSupported(): boolean;
  148912. /**
  148913. * Returns the index of the given texture type in the G-Buffer textures array
  148914. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  148915. * @returns the index of the given texture type in the G-Buffer textures array
  148916. */
  148917. getTextureIndex(textureType: number): number;
  148918. /**
  148919. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  148920. */
  148921. get enablePosition(): boolean;
  148922. /**
  148923. * Sets whether or not objects positions are enabled for the G buffer.
  148924. */
  148925. set enablePosition(enable: boolean);
  148926. /**
  148927. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  148928. */
  148929. get enableVelocity(): boolean;
  148930. /**
  148931. * Sets wether or not objects velocities are enabled for the G buffer.
  148932. */
  148933. set enableVelocity(enable: boolean);
  148934. /**
  148935. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  148936. */
  148937. get enableReflectivity(): boolean;
  148938. /**
  148939. * Sets wether or not objects roughness are enabled for the G buffer.
  148940. */
  148941. set enableReflectivity(enable: boolean);
  148942. /**
  148943. * Gets the scene associated with the buffer.
  148944. */
  148945. get scene(): Scene;
  148946. /**
  148947. * Gets the ratio used by the buffer during its creation.
  148948. * How big is the buffer related to the main canvas.
  148949. */
  148950. get ratio(): number;
  148951. /** @hidden */
  148952. static _SceneComponentInitialization: (scene: Scene) => void;
  148953. /**
  148954. * Creates a new G Buffer for the scene
  148955. * @param scene The scene the buffer belongs to
  148956. * @param ratio How big is the buffer related to the main canvas.
  148957. */
  148958. constructor(scene: Scene, ratio?: number);
  148959. /**
  148960. * Checks wether everything is ready to render a submesh to the G buffer.
  148961. * @param subMesh the submesh to check readiness for
  148962. * @param useInstances is the mesh drawn using instance or not
  148963. * @returns true if ready otherwise false
  148964. */
  148965. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  148966. /**
  148967. * Gets the current underlying G Buffer.
  148968. * @returns the buffer
  148969. */
  148970. getGBuffer(): MultiRenderTarget;
  148971. /**
  148972. * Gets the number of samples used to render the buffer (anti aliasing).
  148973. */
  148974. get samples(): number;
  148975. /**
  148976. * Sets the number of samples used to render the buffer (anti aliasing).
  148977. */
  148978. set samples(value: number);
  148979. /**
  148980. * Disposes the renderer and frees up associated resources.
  148981. */
  148982. dispose(): void;
  148983. protected _createRenderTargets(): void;
  148984. private _copyBonesTransformationMatrices;
  148985. }
  148986. }
  148987. declare module BABYLON {
  148988. interface Scene {
  148989. /** @hidden (Backing field) */
  148990. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  148991. /**
  148992. * Gets or Sets the current geometry buffer associated to the scene.
  148993. */
  148994. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  148995. /**
  148996. * Enables a GeometryBufferRender and associates it with the scene
  148997. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  148998. * @returns the GeometryBufferRenderer
  148999. */
  149000. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  149001. /**
  149002. * Disables the GeometryBufferRender associated with the scene
  149003. */
  149004. disableGeometryBufferRenderer(): void;
  149005. }
  149006. /**
  149007. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  149008. * in several rendering techniques.
  149009. */
  149010. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  149011. /**
  149012. * The component name helpful to identify the component in the list of scene components.
  149013. */
  149014. readonly name: string;
  149015. /**
  149016. * The scene the component belongs to.
  149017. */
  149018. scene: Scene;
  149019. /**
  149020. * Creates a new instance of the component for the given scene
  149021. * @param scene Defines the scene to register the component in
  149022. */
  149023. constructor(scene: Scene);
  149024. /**
  149025. * Registers the component in a given scene
  149026. */
  149027. register(): void;
  149028. /**
  149029. * Rebuilds the elements related to this component in case of
  149030. * context lost for instance.
  149031. */
  149032. rebuild(): void;
  149033. /**
  149034. * Disposes the component and the associated ressources
  149035. */
  149036. dispose(): void;
  149037. private _gatherRenderTargets;
  149038. }
  149039. }
  149040. declare module BABYLON {
  149041. /** @hidden */
  149042. export var motionBlurPixelShader: {
  149043. name: string;
  149044. shader: string;
  149045. };
  149046. }
  149047. declare module BABYLON {
  149048. /**
  149049. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  149050. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  149051. * As an example, all you have to do is to create the post-process:
  149052. * var mb = new BABYLON.MotionBlurPostProcess(
  149053. * 'mb', // The name of the effect.
  149054. * scene, // The scene containing the objects to blur according to their velocity.
  149055. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  149056. * camera // The camera to apply the render pass to.
  149057. * );
  149058. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  149059. */
  149060. export class MotionBlurPostProcess extends PostProcess {
  149061. /**
  149062. * Defines how much the image is blurred by the movement. Default value is equal to 1
  149063. */
  149064. motionStrength: number;
  149065. /**
  149066. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  149067. */
  149068. get motionBlurSamples(): number;
  149069. /**
  149070. * Sets the number of iterations to be used for motion blur quality
  149071. */
  149072. set motionBlurSamples(samples: number);
  149073. private _motionBlurSamples;
  149074. private _geometryBufferRenderer;
  149075. /**
  149076. * Gets a string identifying the name of the class
  149077. * @returns "MotionBlurPostProcess" string
  149078. */
  149079. getClassName(): string;
  149080. /**
  149081. * Creates a new instance MotionBlurPostProcess
  149082. * @param name The name of the effect.
  149083. * @param scene The scene containing the objects to blur according to their velocity.
  149084. * @param options The required width/height ratio to downsize to before computing the render pass.
  149085. * @param camera The camera to apply the render pass to.
  149086. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149087. * @param engine The engine which the post process will be applied. (default: current engine)
  149088. * @param reusable If the post process can be reused on the same frame. (default: false)
  149089. * @param textureType Type of textures used when performing the post process. (default: 0)
  149090. * @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)
  149091. */
  149092. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149093. /**
  149094. * Excludes the given skinned mesh from computing bones velocities.
  149095. * 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.
  149096. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  149097. */
  149098. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  149099. /**
  149100. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  149101. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  149102. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  149103. */
  149104. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  149105. /**
  149106. * Disposes the post process.
  149107. * @param camera The camera to dispose the post process on.
  149108. */
  149109. dispose(camera?: Camera): void;
  149110. /** @hidden */
  149111. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  149112. }
  149113. }
  149114. declare module BABYLON {
  149115. /** @hidden */
  149116. export var refractionPixelShader: {
  149117. name: string;
  149118. shader: string;
  149119. };
  149120. }
  149121. declare module BABYLON {
  149122. /**
  149123. * Post process which applies a refractin texture
  149124. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  149125. */
  149126. export class RefractionPostProcess extends PostProcess {
  149127. private _refTexture;
  149128. private _ownRefractionTexture;
  149129. /** the base color of the refraction (used to taint the rendering) */
  149130. color: Color3;
  149131. /** simulated refraction depth */
  149132. depth: number;
  149133. /** the coefficient of the base color (0 to remove base color tainting) */
  149134. colorLevel: number;
  149135. /** Gets the url used to load the refraction texture */
  149136. refractionTextureUrl: string;
  149137. /**
  149138. * Gets or sets the refraction texture
  149139. * Please note that you are responsible for disposing the texture if you set it manually
  149140. */
  149141. get refractionTexture(): Texture;
  149142. set refractionTexture(value: Texture);
  149143. /**
  149144. * Gets a string identifying the name of the class
  149145. * @returns "RefractionPostProcess" string
  149146. */
  149147. getClassName(): string;
  149148. /**
  149149. * Initializes the RefractionPostProcess
  149150. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  149151. * @param name The name of the effect.
  149152. * @param refractionTextureUrl Url of the refraction texture to use
  149153. * @param color the base color of the refraction (used to taint the rendering)
  149154. * @param depth simulated refraction depth
  149155. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  149156. * @param camera The camera to apply the render pass to.
  149157. * @param options The required width/height ratio to downsize to before computing the render pass.
  149158. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149159. * @param engine The engine which the post process will be applied. (default: current engine)
  149160. * @param reusable If the post process can be reused on the same frame. (default: false)
  149161. */
  149162. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  149163. /**
  149164. * Disposes of the post process
  149165. * @param camera Camera to dispose post process on
  149166. */
  149167. dispose(camera: Camera): void;
  149168. /** @hidden */
  149169. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  149170. }
  149171. }
  149172. declare module BABYLON {
  149173. /** @hidden */
  149174. export var sharpenPixelShader: {
  149175. name: string;
  149176. shader: string;
  149177. };
  149178. }
  149179. declare module BABYLON {
  149180. /**
  149181. * The SharpenPostProcess applies a sharpen kernel to every pixel
  149182. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  149183. */
  149184. export class SharpenPostProcess extends PostProcess {
  149185. /**
  149186. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  149187. */
  149188. colorAmount: number;
  149189. /**
  149190. * How much sharpness should be applied (default: 0.3)
  149191. */
  149192. edgeAmount: number;
  149193. /**
  149194. * Gets a string identifying the name of the class
  149195. * @returns "SharpenPostProcess" string
  149196. */
  149197. getClassName(): string;
  149198. /**
  149199. * Creates a new instance ConvolutionPostProcess
  149200. * @param name The name of the effect.
  149201. * @param options The required width/height ratio to downsize to before computing the render pass.
  149202. * @param camera The camera to apply the render pass to.
  149203. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149204. * @param engine The engine which the post process will be applied. (default: current engine)
  149205. * @param reusable If the post process can be reused on the same frame. (default: false)
  149206. * @param textureType Type of textures used when performing the post process. (default: 0)
  149207. * @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)
  149208. */
  149209. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149210. /** @hidden */
  149211. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  149212. }
  149213. }
  149214. declare module BABYLON {
  149215. /**
  149216. * PostProcessRenderPipeline
  149217. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  149218. */
  149219. export class PostProcessRenderPipeline {
  149220. private engine;
  149221. private _renderEffects;
  149222. private _renderEffectsForIsolatedPass;
  149223. /**
  149224. * List of inspectable custom properties (used by the Inspector)
  149225. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  149226. */
  149227. inspectableCustomProperties: IInspectable[];
  149228. /**
  149229. * @hidden
  149230. */
  149231. protected _cameras: Camera[];
  149232. /** @hidden */
  149233. _name: string;
  149234. /**
  149235. * Gets pipeline name
  149236. */
  149237. get name(): string;
  149238. /** Gets the list of attached cameras */
  149239. get cameras(): Camera[];
  149240. /**
  149241. * Initializes a PostProcessRenderPipeline
  149242. * @param engine engine to add the pipeline to
  149243. * @param name name of the pipeline
  149244. */
  149245. constructor(engine: Engine, name: string);
  149246. /**
  149247. * Gets the class name
  149248. * @returns "PostProcessRenderPipeline"
  149249. */
  149250. getClassName(): string;
  149251. /**
  149252. * If all the render effects in the pipeline are supported
  149253. */
  149254. get isSupported(): boolean;
  149255. /**
  149256. * Adds an effect to the pipeline
  149257. * @param renderEffect the effect to add
  149258. */
  149259. addEffect(renderEffect: PostProcessRenderEffect): void;
  149260. /** @hidden */
  149261. _rebuild(): void;
  149262. /** @hidden */
  149263. _enableEffect(renderEffectName: string, cameras: Camera): void;
  149264. /** @hidden */
  149265. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  149266. /** @hidden */
  149267. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  149268. /** @hidden */
  149269. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  149270. /** @hidden */
  149271. _attachCameras(cameras: Camera, unique: boolean): void;
  149272. /** @hidden */
  149273. _attachCameras(cameras: Camera[], unique: boolean): void;
  149274. /** @hidden */
  149275. _detachCameras(cameras: Camera): void;
  149276. /** @hidden */
  149277. _detachCameras(cameras: Nullable<Camera[]>): void;
  149278. /** @hidden */
  149279. _update(): void;
  149280. /** @hidden */
  149281. _reset(): void;
  149282. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  149283. /**
  149284. * Sets the required values to the prepass renderer.
  149285. * @param prePassRenderer defines the prepass renderer to setup.
  149286. * @returns true if the pre pass is needed.
  149287. */
  149288. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  149289. /**
  149290. * Disposes of the pipeline
  149291. */
  149292. dispose(): void;
  149293. }
  149294. }
  149295. declare module BABYLON {
  149296. /**
  149297. * PostProcessRenderPipelineManager class
  149298. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  149299. */
  149300. export class PostProcessRenderPipelineManager {
  149301. private _renderPipelines;
  149302. /**
  149303. * Initializes a PostProcessRenderPipelineManager
  149304. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  149305. */
  149306. constructor();
  149307. /**
  149308. * Gets the list of supported render pipelines
  149309. */
  149310. get supportedPipelines(): PostProcessRenderPipeline[];
  149311. /**
  149312. * Adds a pipeline to the manager
  149313. * @param renderPipeline The pipeline to add
  149314. */
  149315. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  149316. /**
  149317. * Attaches a camera to the pipeline
  149318. * @param renderPipelineName The name of the pipeline to attach to
  149319. * @param cameras the camera to attach
  149320. * @param unique if the camera can be attached multiple times to the pipeline
  149321. */
  149322. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  149323. /**
  149324. * Detaches a camera from the pipeline
  149325. * @param renderPipelineName The name of the pipeline to detach from
  149326. * @param cameras the camera to detach
  149327. */
  149328. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  149329. /**
  149330. * Enables an effect by name on a pipeline
  149331. * @param renderPipelineName the name of the pipeline to enable the effect in
  149332. * @param renderEffectName the name of the effect to enable
  149333. * @param cameras the cameras that the effect should be enabled on
  149334. */
  149335. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  149336. /**
  149337. * Disables an effect by name on a pipeline
  149338. * @param renderPipelineName the name of the pipeline to disable the effect in
  149339. * @param renderEffectName the name of the effect to disable
  149340. * @param cameras the cameras that the effect should be disabled on
  149341. */
  149342. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  149343. /**
  149344. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  149345. */
  149346. update(): void;
  149347. /** @hidden */
  149348. _rebuild(): void;
  149349. /**
  149350. * Disposes of the manager and pipelines
  149351. */
  149352. dispose(): void;
  149353. }
  149354. }
  149355. declare module BABYLON {
  149356. interface Scene {
  149357. /** @hidden (Backing field) */
  149358. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  149359. /**
  149360. * Gets the postprocess render pipeline manager
  149361. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  149362. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  149363. */
  149364. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  149365. }
  149366. /**
  149367. * Defines the Render Pipeline scene component responsible to rendering pipelines
  149368. */
  149369. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  149370. /**
  149371. * The component name helpfull to identify the component in the list of scene components.
  149372. */
  149373. readonly name: string;
  149374. /**
  149375. * The scene the component belongs to.
  149376. */
  149377. scene: Scene;
  149378. /**
  149379. * Creates a new instance of the component for the given scene
  149380. * @param scene Defines the scene to register the component in
  149381. */
  149382. constructor(scene: Scene);
  149383. /**
  149384. * Registers the component in a given scene
  149385. */
  149386. register(): void;
  149387. /**
  149388. * Rebuilds the elements related to this component in case of
  149389. * context lost for instance.
  149390. */
  149391. rebuild(): void;
  149392. /**
  149393. * Disposes the component and the associated ressources
  149394. */
  149395. dispose(): void;
  149396. private _gatherRenderTargets;
  149397. }
  149398. }
  149399. declare module BABYLON {
  149400. /**
  149401. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  149402. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  149403. */
  149404. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  149405. private _scene;
  149406. private _camerasToBeAttached;
  149407. /**
  149408. * ID of the sharpen post process,
  149409. */
  149410. private readonly SharpenPostProcessId;
  149411. /**
  149412. * @ignore
  149413. * ID of the image processing post process;
  149414. */
  149415. readonly ImageProcessingPostProcessId: string;
  149416. /**
  149417. * @ignore
  149418. * ID of the Fast Approximate Anti-Aliasing post process;
  149419. */
  149420. readonly FxaaPostProcessId: string;
  149421. /**
  149422. * ID of the chromatic aberration post process,
  149423. */
  149424. private readonly ChromaticAberrationPostProcessId;
  149425. /**
  149426. * ID of the grain post process
  149427. */
  149428. private readonly GrainPostProcessId;
  149429. /**
  149430. * Sharpen post process which will apply a sharpen convolution to enhance edges
  149431. */
  149432. sharpen: SharpenPostProcess;
  149433. private _sharpenEffect;
  149434. private bloom;
  149435. /**
  149436. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  149437. */
  149438. depthOfField: DepthOfFieldEffect;
  149439. /**
  149440. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  149441. */
  149442. fxaa: FxaaPostProcess;
  149443. /**
  149444. * Image post processing pass used to perform operations such as tone mapping or color grading.
  149445. */
  149446. imageProcessing: ImageProcessingPostProcess;
  149447. /**
  149448. * Chromatic aberration post process which will shift rgb colors in the image
  149449. */
  149450. chromaticAberration: ChromaticAberrationPostProcess;
  149451. private _chromaticAberrationEffect;
  149452. /**
  149453. * Grain post process which add noise to the image
  149454. */
  149455. grain: GrainPostProcess;
  149456. private _grainEffect;
  149457. /**
  149458. * Glow post process which adds a glow to emissive areas of the image
  149459. */
  149460. private _glowLayer;
  149461. /**
  149462. * Animations which can be used to tweak settings over a period of time
  149463. */
  149464. animations: Animation[];
  149465. private _imageProcessingConfigurationObserver;
  149466. private _sharpenEnabled;
  149467. private _bloomEnabled;
  149468. private _depthOfFieldEnabled;
  149469. private _depthOfFieldBlurLevel;
  149470. private _fxaaEnabled;
  149471. private _imageProcessingEnabled;
  149472. private _defaultPipelineTextureType;
  149473. private _bloomScale;
  149474. private _chromaticAberrationEnabled;
  149475. private _grainEnabled;
  149476. private _buildAllowed;
  149477. /**
  149478. * Gets active scene
  149479. */
  149480. get scene(): Scene;
  149481. /**
  149482. * Enable or disable the sharpen process from the pipeline
  149483. */
  149484. set sharpenEnabled(enabled: boolean);
  149485. get sharpenEnabled(): boolean;
  149486. private _resizeObserver;
  149487. private _hardwareScaleLevel;
  149488. private _bloomKernel;
  149489. /**
  149490. * Specifies the size of the bloom blur kernel, relative to the final output size
  149491. */
  149492. get bloomKernel(): number;
  149493. set bloomKernel(value: number);
  149494. /**
  149495. * Specifies the weight of the bloom in the final rendering
  149496. */
  149497. private _bloomWeight;
  149498. /**
  149499. * Specifies the luma threshold for the area that will be blurred by the bloom
  149500. */
  149501. private _bloomThreshold;
  149502. private _hdr;
  149503. /**
  149504. * The strength of the bloom.
  149505. */
  149506. set bloomWeight(value: number);
  149507. get bloomWeight(): number;
  149508. /**
  149509. * The strength of the bloom.
  149510. */
  149511. set bloomThreshold(value: number);
  149512. get bloomThreshold(): number;
  149513. /**
  149514. * The scale of the bloom, lower value will provide better performance.
  149515. */
  149516. set bloomScale(value: number);
  149517. get bloomScale(): number;
  149518. /**
  149519. * Enable or disable the bloom from the pipeline
  149520. */
  149521. set bloomEnabled(enabled: boolean);
  149522. get bloomEnabled(): boolean;
  149523. private _rebuildBloom;
  149524. /**
  149525. * If the depth of field is enabled.
  149526. */
  149527. get depthOfFieldEnabled(): boolean;
  149528. set depthOfFieldEnabled(enabled: boolean);
  149529. /**
  149530. * Blur level of the depth of field effect. (Higher blur will effect performance)
  149531. */
  149532. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  149533. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  149534. /**
  149535. * If the anti aliasing is enabled.
  149536. */
  149537. set fxaaEnabled(enabled: boolean);
  149538. get fxaaEnabled(): boolean;
  149539. private _samples;
  149540. /**
  149541. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  149542. */
  149543. set samples(sampleCount: number);
  149544. get samples(): number;
  149545. /**
  149546. * If image processing is enabled.
  149547. */
  149548. set imageProcessingEnabled(enabled: boolean);
  149549. get imageProcessingEnabled(): boolean;
  149550. /**
  149551. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  149552. */
  149553. set glowLayerEnabled(enabled: boolean);
  149554. get glowLayerEnabled(): boolean;
  149555. /**
  149556. * Gets the glow layer (or null if not defined)
  149557. */
  149558. get glowLayer(): Nullable<GlowLayer>;
  149559. /**
  149560. * Enable or disable the chromaticAberration process from the pipeline
  149561. */
  149562. set chromaticAberrationEnabled(enabled: boolean);
  149563. get chromaticAberrationEnabled(): boolean;
  149564. /**
  149565. * Enable or disable the grain process from the pipeline
  149566. */
  149567. set grainEnabled(enabled: boolean);
  149568. get grainEnabled(): boolean;
  149569. /**
  149570. * @constructor
  149571. * @param name - The rendering pipeline name (default: "")
  149572. * @param hdr - If high dynamic range textures should be used (default: true)
  149573. * @param scene - The scene linked to this pipeline (default: the last created scene)
  149574. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  149575. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  149576. */
  149577. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  149578. /**
  149579. * Get the class name
  149580. * @returns "DefaultRenderingPipeline"
  149581. */
  149582. getClassName(): string;
  149583. /**
  149584. * Force the compilation of the entire pipeline.
  149585. */
  149586. prepare(): void;
  149587. private _hasCleared;
  149588. private _prevPostProcess;
  149589. private _prevPrevPostProcess;
  149590. private _setAutoClearAndTextureSharing;
  149591. private _depthOfFieldSceneObserver;
  149592. private _buildPipeline;
  149593. private _disposePostProcesses;
  149594. /**
  149595. * Adds a camera to the pipeline
  149596. * @param camera the camera to be added
  149597. */
  149598. addCamera(camera: Camera): void;
  149599. /**
  149600. * Removes a camera from the pipeline
  149601. * @param camera the camera to remove
  149602. */
  149603. removeCamera(camera: Camera): void;
  149604. /**
  149605. * Dispose of the pipeline and stop all post processes
  149606. */
  149607. dispose(): void;
  149608. /**
  149609. * Serialize the rendering pipeline (Used when exporting)
  149610. * @returns the serialized object
  149611. */
  149612. serialize(): any;
  149613. /**
  149614. * Parse the serialized pipeline
  149615. * @param source Source pipeline.
  149616. * @param scene The scene to load the pipeline to.
  149617. * @param rootUrl The URL of the serialized pipeline.
  149618. * @returns An instantiated pipeline from the serialized object.
  149619. */
  149620. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  149621. }
  149622. }
  149623. declare module BABYLON {
  149624. /** @hidden */
  149625. export var lensHighlightsPixelShader: {
  149626. name: string;
  149627. shader: string;
  149628. };
  149629. }
  149630. declare module BABYLON {
  149631. /** @hidden */
  149632. export var depthOfFieldPixelShader: {
  149633. name: string;
  149634. shader: string;
  149635. };
  149636. }
  149637. declare module BABYLON {
  149638. /**
  149639. * BABYLON.JS Chromatic Aberration GLSL Shader
  149640. * Author: Olivier Guyot
  149641. * Separates very slightly R, G and B colors on the edges of the screen
  149642. * Inspired by Francois Tarlier & Martins Upitis
  149643. */
  149644. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  149645. /**
  149646. * @ignore
  149647. * The chromatic aberration PostProcess id in the pipeline
  149648. */
  149649. LensChromaticAberrationEffect: string;
  149650. /**
  149651. * @ignore
  149652. * The highlights enhancing PostProcess id in the pipeline
  149653. */
  149654. HighlightsEnhancingEffect: string;
  149655. /**
  149656. * @ignore
  149657. * The depth-of-field PostProcess id in the pipeline
  149658. */
  149659. LensDepthOfFieldEffect: string;
  149660. private _scene;
  149661. private _depthTexture;
  149662. private _grainTexture;
  149663. private _chromaticAberrationPostProcess;
  149664. private _highlightsPostProcess;
  149665. private _depthOfFieldPostProcess;
  149666. private _edgeBlur;
  149667. private _grainAmount;
  149668. private _chromaticAberration;
  149669. private _distortion;
  149670. private _highlightsGain;
  149671. private _highlightsThreshold;
  149672. private _dofDistance;
  149673. private _dofAperture;
  149674. private _dofDarken;
  149675. private _dofPentagon;
  149676. private _blurNoise;
  149677. /**
  149678. * @constructor
  149679. *
  149680. * Effect parameters are as follow:
  149681. * {
  149682. * chromatic_aberration: number; // from 0 to x (1 for realism)
  149683. * edge_blur: number; // from 0 to x (1 for realism)
  149684. * distortion: number; // from 0 to x (1 for realism)
  149685. * grain_amount: number; // from 0 to 1
  149686. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  149687. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  149688. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  149689. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  149690. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  149691. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  149692. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  149693. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  149694. * }
  149695. * Note: if an effect parameter is unset, effect is disabled
  149696. *
  149697. * @param name The rendering pipeline name
  149698. * @param parameters - An object containing all parameters (see above)
  149699. * @param scene The scene linked to this pipeline
  149700. * @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)
  149701. * @param cameras The array of cameras that the rendering pipeline will be attached to
  149702. */
  149703. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  149704. /**
  149705. * Get the class name
  149706. * @returns "LensRenderingPipeline"
  149707. */
  149708. getClassName(): string;
  149709. /**
  149710. * Gets associated scene
  149711. */
  149712. get scene(): Scene;
  149713. /**
  149714. * Gets or sets the edge blur
  149715. */
  149716. get edgeBlur(): number;
  149717. set edgeBlur(value: number);
  149718. /**
  149719. * Gets or sets the grain amount
  149720. */
  149721. get grainAmount(): number;
  149722. set grainAmount(value: number);
  149723. /**
  149724. * Gets or sets the chromatic aberration amount
  149725. */
  149726. get chromaticAberration(): number;
  149727. set chromaticAberration(value: number);
  149728. /**
  149729. * Gets or sets the depth of field aperture
  149730. */
  149731. get dofAperture(): number;
  149732. set dofAperture(value: number);
  149733. /**
  149734. * Gets or sets the edge distortion
  149735. */
  149736. get edgeDistortion(): number;
  149737. set edgeDistortion(value: number);
  149738. /**
  149739. * Gets or sets the depth of field distortion
  149740. */
  149741. get dofDistortion(): number;
  149742. set dofDistortion(value: number);
  149743. /**
  149744. * Gets or sets the darken out of focus amount
  149745. */
  149746. get darkenOutOfFocus(): number;
  149747. set darkenOutOfFocus(value: number);
  149748. /**
  149749. * Gets or sets a boolean indicating if blur noise is enabled
  149750. */
  149751. get blurNoise(): boolean;
  149752. set blurNoise(value: boolean);
  149753. /**
  149754. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  149755. */
  149756. get pentagonBokeh(): boolean;
  149757. set pentagonBokeh(value: boolean);
  149758. /**
  149759. * Gets or sets the highlight grain amount
  149760. */
  149761. get highlightsGain(): number;
  149762. set highlightsGain(value: number);
  149763. /**
  149764. * Gets or sets the highlight threshold
  149765. */
  149766. get highlightsThreshold(): number;
  149767. set highlightsThreshold(value: number);
  149768. /**
  149769. * Sets the amount of blur at the edges
  149770. * @param amount blur amount
  149771. */
  149772. setEdgeBlur(amount: number): void;
  149773. /**
  149774. * Sets edge blur to 0
  149775. */
  149776. disableEdgeBlur(): void;
  149777. /**
  149778. * Sets the amout of grain
  149779. * @param amount Amount of grain
  149780. */
  149781. setGrainAmount(amount: number): void;
  149782. /**
  149783. * Set grain amount to 0
  149784. */
  149785. disableGrain(): void;
  149786. /**
  149787. * Sets the chromatic aberration amount
  149788. * @param amount amount of chromatic aberration
  149789. */
  149790. setChromaticAberration(amount: number): void;
  149791. /**
  149792. * Sets chromatic aberration amount to 0
  149793. */
  149794. disableChromaticAberration(): void;
  149795. /**
  149796. * Sets the EdgeDistortion amount
  149797. * @param amount amount of EdgeDistortion
  149798. */
  149799. setEdgeDistortion(amount: number): void;
  149800. /**
  149801. * Sets edge distortion to 0
  149802. */
  149803. disableEdgeDistortion(): void;
  149804. /**
  149805. * Sets the FocusDistance amount
  149806. * @param amount amount of FocusDistance
  149807. */
  149808. setFocusDistance(amount: number): void;
  149809. /**
  149810. * Disables depth of field
  149811. */
  149812. disableDepthOfField(): void;
  149813. /**
  149814. * Sets the Aperture amount
  149815. * @param amount amount of Aperture
  149816. */
  149817. setAperture(amount: number): void;
  149818. /**
  149819. * Sets the DarkenOutOfFocus amount
  149820. * @param amount amount of DarkenOutOfFocus
  149821. */
  149822. setDarkenOutOfFocus(amount: number): void;
  149823. private _pentagonBokehIsEnabled;
  149824. /**
  149825. * Creates a pentagon bokeh effect
  149826. */
  149827. enablePentagonBokeh(): void;
  149828. /**
  149829. * Disables the pentagon bokeh effect
  149830. */
  149831. disablePentagonBokeh(): void;
  149832. /**
  149833. * Enables noise blur
  149834. */
  149835. enableNoiseBlur(): void;
  149836. /**
  149837. * Disables noise blur
  149838. */
  149839. disableNoiseBlur(): void;
  149840. /**
  149841. * Sets the HighlightsGain amount
  149842. * @param amount amount of HighlightsGain
  149843. */
  149844. setHighlightsGain(amount: number): void;
  149845. /**
  149846. * Sets the HighlightsThreshold amount
  149847. * @param amount amount of HighlightsThreshold
  149848. */
  149849. setHighlightsThreshold(amount: number): void;
  149850. /**
  149851. * Disables highlights
  149852. */
  149853. disableHighlights(): void;
  149854. /**
  149855. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  149856. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  149857. */
  149858. dispose(disableDepthRender?: boolean): void;
  149859. private _createChromaticAberrationPostProcess;
  149860. private _createHighlightsPostProcess;
  149861. private _createDepthOfFieldPostProcess;
  149862. private _createGrainTexture;
  149863. }
  149864. }
  149865. declare module BABYLON {
  149866. /** @hidden */
  149867. export var ssao2PixelShader: {
  149868. name: string;
  149869. shader: string;
  149870. };
  149871. }
  149872. declare module BABYLON {
  149873. /** @hidden */
  149874. export var ssaoCombinePixelShader: {
  149875. name: string;
  149876. shader: string;
  149877. };
  149878. }
  149879. declare module BABYLON {
  149880. /**
  149881. * Render pipeline to produce ssao effect
  149882. */
  149883. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  149884. /**
  149885. * @ignore
  149886. * The PassPostProcess id in the pipeline that contains the original scene color
  149887. */
  149888. SSAOOriginalSceneColorEffect: string;
  149889. /**
  149890. * @ignore
  149891. * The SSAO PostProcess id in the pipeline
  149892. */
  149893. SSAORenderEffect: string;
  149894. /**
  149895. * @ignore
  149896. * The horizontal blur PostProcess id in the pipeline
  149897. */
  149898. SSAOBlurHRenderEffect: string;
  149899. /**
  149900. * @ignore
  149901. * The vertical blur PostProcess id in the pipeline
  149902. */
  149903. SSAOBlurVRenderEffect: string;
  149904. /**
  149905. * @ignore
  149906. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  149907. */
  149908. SSAOCombineRenderEffect: string;
  149909. /**
  149910. * The output strength of the SSAO post-process. Default value is 1.0.
  149911. */
  149912. totalStrength: number;
  149913. /**
  149914. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  149915. */
  149916. maxZ: number;
  149917. /**
  149918. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  149919. */
  149920. minZAspect: number;
  149921. private _samples;
  149922. /**
  149923. * Number of samples used for the SSAO calculations. Default value is 8
  149924. */
  149925. set samples(n: number);
  149926. get samples(): number;
  149927. private _textureSamples;
  149928. /**
  149929. * Number of samples to use for antialiasing
  149930. */
  149931. set textureSamples(n: number);
  149932. get textureSamples(): number;
  149933. /**
  149934. * Force rendering the geometry through geometry buffer
  149935. */
  149936. private _forceGeometryBuffer;
  149937. /**
  149938. * Ratio object used for SSAO ratio and blur ratio
  149939. */
  149940. private _ratio;
  149941. /**
  149942. * Dynamically generated sphere sampler.
  149943. */
  149944. private _sampleSphere;
  149945. /**
  149946. * Blur filter offsets
  149947. */
  149948. private _samplerOffsets;
  149949. private _expensiveBlur;
  149950. /**
  149951. * If bilateral blur should be used
  149952. */
  149953. set expensiveBlur(b: boolean);
  149954. get expensiveBlur(): boolean;
  149955. /**
  149956. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  149957. */
  149958. radius: number;
  149959. /**
  149960. * The base color of the SSAO post-process
  149961. * The final result is "base + ssao" between [0, 1]
  149962. */
  149963. base: number;
  149964. /**
  149965. * Support test.
  149966. */
  149967. static get IsSupported(): boolean;
  149968. private _scene;
  149969. private _randomTexture;
  149970. private _originalColorPostProcess;
  149971. private _ssaoPostProcess;
  149972. private _blurHPostProcess;
  149973. private _blurVPostProcess;
  149974. private _ssaoCombinePostProcess;
  149975. private _prePassRenderer;
  149976. /**
  149977. * Gets active scene
  149978. */
  149979. get scene(): Scene;
  149980. /**
  149981. * @constructor
  149982. * @param name The rendering pipeline name
  149983. * @param scene The scene linked to this pipeline
  149984. * @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 }
  149985. * @param cameras The array of cameras that the rendering pipeline will be attached to
  149986. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  149987. */
  149988. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  149989. /**
  149990. * Get the class name
  149991. * @returns "SSAO2RenderingPipeline"
  149992. */
  149993. getClassName(): string;
  149994. /**
  149995. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  149996. */
  149997. dispose(disableGeometryBufferRenderer?: boolean): void;
  149998. private _createBlurPostProcess;
  149999. /** @hidden */
  150000. _rebuild(): void;
  150001. private _bits;
  150002. private _radicalInverse_VdC;
  150003. private _hammersley;
  150004. private _hemisphereSample_uniform;
  150005. private _generateHemisphere;
  150006. private _getDefinesForSSAO;
  150007. private _createSSAOPostProcess;
  150008. private _createSSAOCombinePostProcess;
  150009. private _createRandomTexture;
  150010. /**
  150011. * Serialize the rendering pipeline (Used when exporting)
  150012. * @returns the serialized object
  150013. */
  150014. serialize(): any;
  150015. /**
  150016. * Parse the serialized pipeline
  150017. * @param source Source pipeline.
  150018. * @param scene The scene to load the pipeline to.
  150019. * @param rootUrl The URL of the serialized pipeline.
  150020. * @returns An instantiated pipeline from the serialized object.
  150021. */
  150022. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  150023. /**
  150024. * Sets the required values to the prepass renderer.
  150025. * @param prePassRenderer defines the prepass renderer to setup
  150026. * @returns true if the pre pass is needed.
  150027. */
  150028. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  150029. }
  150030. }
  150031. declare module BABYLON {
  150032. /** @hidden */
  150033. export var ssaoPixelShader: {
  150034. name: string;
  150035. shader: string;
  150036. };
  150037. }
  150038. declare module BABYLON {
  150039. /**
  150040. * Render pipeline to produce ssao effect
  150041. */
  150042. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  150043. /**
  150044. * @ignore
  150045. * The PassPostProcess id in the pipeline that contains the original scene color
  150046. */
  150047. SSAOOriginalSceneColorEffect: string;
  150048. /**
  150049. * @ignore
  150050. * The SSAO PostProcess id in the pipeline
  150051. */
  150052. SSAORenderEffect: string;
  150053. /**
  150054. * @ignore
  150055. * The horizontal blur PostProcess id in the pipeline
  150056. */
  150057. SSAOBlurHRenderEffect: string;
  150058. /**
  150059. * @ignore
  150060. * The vertical blur PostProcess id in the pipeline
  150061. */
  150062. SSAOBlurVRenderEffect: string;
  150063. /**
  150064. * @ignore
  150065. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  150066. */
  150067. SSAOCombineRenderEffect: string;
  150068. /**
  150069. * The output strength of the SSAO post-process. Default value is 1.0.
  150070. */
  150071. totalStrength: number;
  150072. /**
  150073. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  150074. */
  150075. radius: number;
  150076. /**
  150077. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  150078. * Must not be equal to fallOff and superior to fallOff.
  150079. * Default value is 0.0075
  150080. */
  150081. area: number;
  150082. /**
  150083. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  150084. * Must not be equal to area and inferior to area.
  150085. * Default value is 0.000001
  150086. */
  150087. fallOff: number;
  150088. /**
  150089. * The base color of the SSAO post-process
  150090. * The final result is "base + ssao" between [0, 1]
  150091. */
  150092. base: number;
  150093. private _scene;
  150094. private _depthTexture;
  150095. private _randomTexture;
  150096. private _originalColorPostProcess;
  150097. private _ssaoPostProcess;
  150098. private _blurHPostProcess;
  150099. private _blurVPostProcess;
  150100. private _ssaoCombinePostProcess;
  150101. private _firstUpdate;
  150102. /**
  150103. * Gets active scene
  150104. */
  150105. get scene(): Scene;
  150106. /**
  150107. * @constructor
  150108. * @param name - The rendering pipeline name
  150109. * @param scene - The scene linked to this pipeline
  150110. * @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 }
  150111. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  150112. */
  150113. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  150114. /**
  150115. * Get the class name
  150116. * @returns "SSAORenderingPipeline"
  150117. */
  150118. getClassName(): string;
  150119. /**
  150120. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  150121. */
  150122. dispose(disableDepthRender?: boolean): void;
  150123. private _createBlurPostProcess;
  150124. /** @hidden */
  150125. _rebuild(): void;
  150126. private _createSSAOPostProcess;
  150127. private _createSSAOCombinePostProcess;
  150128. private _createRandomTexture;
  150129. }
  150130. }
  150131. declare module BABYLON {
  150132. /** @hidden */
  150133. export var screenSpaceReflectionPixelShader: {
  150134. name: string;
  150135. shader: string;
  150136. };
  150137. }
  150138. declare module BABYLON {
  150139. /**
  150140. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  150141. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  150142. */
  150143. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  150144. /**
  150145. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  150146. */
  150147. threshold: number;
  150148. /**
  150149. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  150150. */
  150151. strength: number;
  150152. /**
  150153. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  150154. */
  150155. reflectionSpecularFalloffExponent: number;
  150156. /**
  150157. * 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]
  150158. */
  150159. step: number;
  150160. /**
  150161. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  150162. */
  150163. roughnessFactor: number;
  150164. private _geometryBufferRenderer;
  150165. private _enableSmoothReflections;
  150166. private _reflectionSamples;
  150167. private _smoothSteps;
  150168. /**
  150169. * Gets a string identifying the name of the class
  150170. * @returns "ScreenSpaceReflectionPostProcess" string
  150171. */
  150172. getClassName(): string;
  150173. /**
  150174. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  150175. * @param name The name of the effect.
  150176. * @param scene The scene containing the objects to calculate reflections.
  150177. * @param options The required width/height ratio to downsize to before computing the render pass.
  150178. * @param camera The camera to apply the render pass to.
  150179. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150180. * @param engine The engine which the post process will be applied. (default: current engine)
  150181. * @param reusable If the post process can be reused on the same frame. (default: false)
  150182. * @param textureType Type of textures used when performing the post process. (default: 0)
  150183. * @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)
  150184. */
  150185. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150186. /**
  150187. * Gets wether or not smoothing reflections is enabled.
  150188. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  150189. */
  150190. get enableSmoothReflections(): boolean;
  150191. /**
  150192. * Sets wether or not smoothing reflections is enabled.
  150193. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  150194. */
  150195. set enableSmoothReflections(enabled: boolean);
  150196. /**
  150197. * Gets the number of samples taken while computing reflections. More samples count is high,
  150198. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  150199. */
  150200. get reflectionSamples(): number;
  150201. /**
  150202. * Sets the number of samples taken while computing reflections. More samples count is high,
  150203. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  150204. */
  150205. set reflectionSamples(samples: number);
  150206. /**
  150207. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  150208. * more the post-process will require GPU power and can generate a drop in FPS.
  150209. * Default value (5.0) work pretty well in all cases but can be adjusted.
  150210. */
  150211. get smoothSteps(): number;
  150212. set smoothSteps(steps: number);
  150213. private _updateEffectDefines;
  150214. /** @hidden */
  150215. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  150216. }
  150217. }
  150218. declare module BABYLON {
  150219. /** @hidden */
  150220. export var standardPixelShader: {
  150221. name: string;
  150222. shader: string;
  150223. };
  150224. }
  150225. declare module BABYLON {
  150226. /**
  150227. * Standard rendering pipeline
  150228. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  150229. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  150230. */
  150231. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  150232. /**
  150233. * Public members
  150234. */
  150235. /**
  150236. * Post-process which contains the original scene color before the pipeline applies all the effects
  150237. */
  150238. originalPostProcess: Nullable<PostProcess>;
  150239. /**
  150240. * Post-process used to down scale an image x4
  150241. */
  150242. downSampleX4PostProcess: Nullable<PostProcess>;
  150243. /**
  150244. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  150245. */
  150246. brightPassPostProcess: Nullable<PostProcess>;
  150247. /**
  150248. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  150249. */
  150250. blurHPostProcesses: PostProcess[];
  150251. /**
  150252. * Post-process array storing all the vertical blur post-processes used by the pipeline
  150253. */
  150254. blurVPostProcesses: PostProcess[];
  150255. /**
  150256. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  150257. */
  150258. textureAdderPostProcess: Nullable<PostProcess>;
  150259. /**
  150260. * Post-process used to create volumetric lighting effect
  150261. */
  150262. volumetricLightPostProcess: Nullable<PostProcess>;
  150263. /**
  150264. * Post-process used to smooth the previous volumetric light post-process on the X axis
  150265. */
  150266. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  150267. /**
  150268. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  150269. */
  150270. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  150271. /**
  150272. * Post-process used to merge the volumetric light effect and the real scene color
  150273. */
  150274. volumetricLightMergePostProces: Nullable<PostProcess>;
  150275. /**
  150276. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  150277. */
  150278. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  150279. /**
  150280. * Base post-process used to calculate the average luminance of the final image for HDR
  150281. */
  150282. luminancePostProcess: Nullable<PostProcess>;
  150283. /**
  150284. * Post-processes used to create down sample post-processes in order to get
  150285. * the average luminance of the final image for HDR
  150286. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  150287. */
  150288. luminanceDownSamplePostProcesses: PostProcess[];
  150289. /**
  150290. * Post-process used to create a HDR effect (light adaptation)
  150291. */
  150292. hdrPostProcess: Nullable<PostProcess>;
  150293. /**
  150294. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  150295. */
  150296. textureAdderFinalPostProcess: Nullable<PostProcess>;
  150297. /**
  150298. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  150299. */
  150300. lensFlareFinalPostProcess: Nullable<PostProcess>;
  150301. /**
  150302. * Post-process used to merge the final HDR post-process and the real scene color
  150303. */
  150304. hdrFinalPostProcess: Nullable<PostProcess>;
  150305. /**
  150306. * Post-process used to create a lens flare effect
  150307. */
  150308. lensFlarePostProcess: Nullable<PostProcess>;
  150309. /**
  150310. * Post-process that merges the result of the lens flare post-process and the real scene color
  150311. */
  150312. lensFlareComposePostProcess: Nullable<PostProcess>;
  150313. /**
  150314. * Post-process used to create a motion blur effect
  150315. */
  150316. motionBlurPostProcess: Nullable<PostProcess>;
  150317. /**
  150318. * Post-process used to create a depth of field effect
  150319. */
  150320. depthOfFieldPostProcess: Nullable<PostProcess>;
  150321. /**
  150322. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  150323. */
  150324. fxaaPostProcess: Nullable<FxaaPostProcess>;
  150325. /**
  150326. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  150327. */
  150328. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  150329. /**
  150330. * Represents the brightness threshold in order to configure the illuminated surfaces
  150331. */
  150332. brightThreshold: number;
  150333. /**
  150334. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  150335. */
  150336. blurWidth: number;
  150337. /**
  150338. * Sets if the blur for highlighted surfaces must be only horizontal
  150339. */
  150340. horizontalBlur: boolean;
  150341. /**
  150342. * Gets the overall exposure used by the pipeline
  150343. */
  150344. get exposure(): number;
  150345. /**
  150346. * Sets the overall exposure used by the pipeline
  150347. */
  150348. set exposure(value: number);
  150349. /**
  150350. * Texture used typically to simulate "dirty" on camera lens
  150351. */
  150352. lensTexture: Nullable<Texture>;
  150353. /**
  150354. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  150355. */
  150356. volumetricLightCoefficient: number;
  150357. /**
  150358. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  150359. */
  150360. volumetricLightPower: number;
  150361. /**
  150362. * Used the set the blur intensity to smooth the volumetric lights
  150363. */
  150364. volumetricLightBlurScale: number;
  150365. /**
  150366. * Light (spot or directional) used to generate the volumetric lights rays
  150367. * The source light must have a shadow generate so the pipeline can get its
  150368. * depth map
  150369. */
  150370. sourceLight: Nullable<SpotLight | DirectionalLight>;
  150371. /**
  150372. * For eye adaptation, represents the minimum luminance the eye can see
  150373. */
  150374. hdrMinimumLuminance: number;
  150375. /**
  150376. * For eye adaptation, represents the decrease luminance speed
  150377. */
  150378. hdrDecreaseRate: number;
  150379. /**
  150380. * For eye adaptation, represents the increase luminance speed
  150381. */
  150382. hdrIncreaseRate: number;
  150383. /**
  150384. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  150385. */
  150386. get hdrAutoExposure(): boolean;
  150387. /**
  150388. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  150389. */
  150390. set hdrAutoExposure(value: boolean);
  150391. /**
  150392. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  150393. */
  150394. lensColorTexture: Nullable<Texture>;
  150395. /**
  150396. * The overall strengh for the lens flare effect
  150397. */
  150398. lensFlareStrength: number;
  150399. /**
  150400. * Dispersion coefficient for lens flare ghosts
  150401. */
  150402. lensFlareGhostDispersal: number;
  150403. /**
  150404. * Main lens flare halo width
  150405. */
  150406. lensFlareHaloWidth: number;
  150407. /**
  150408. * Based on the lens distortion effect, defines how much the lens flare result
  150409. * is distorted
  150410. */
  150411. lensFlareDistortionStrength: number;
  150412. /**
  150413. * Configures the blur intensity used for for lens flare (halo)
  150414. */
  150415. lensFlareBlurWidth: number;
  150416. /**
  150417. * Lens star texture must be used to simulate rays on the flares and is available
  150418. * in the documentation
  150419. */
  150420. lensStarTexture: Nullable<Texture>;
  150421. /**
  150422. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  150423. * flare effect by taking account of the dirt texture
  150424. */
  150425. lensFlareDirtTexture: Nullable<Texture>;
  150426. /**
  150427. * Represents the focal length for the depth of field effect
  150428. */
  150429. depthOfFieldDistance: number;
  150430. /**
  150431. * Represents the blur intensity for the blurred part of the depth of field effect
  150432. */
  150433. depthOfFieldBlurWidth: number;
  150434. /**
  150435. * Gets how much the image is blurred by the movement while using the motion blur post-process
  150436. */
  150437. get motionStrength(): number;
  150438. /**
  150439. * Sets how much the image is blurred by the movement while using the motion blur post-process
  150440. */
  150441. set motionStrength(strength: number);
  150442. /**
  150443. * Gets wether or not the motion blur post-process is object based or screen based.
  150444. */
  150445. get objectBasedMotionBlur(): boolean;
  150446. /**
  150447. * Sets wether or not the motion blur post-process should be object based or screen based
  150448. */
  150449. set objectBasedMotionBlur(value: boolean);
  150450. /**
  150451. * List of animations for the pipeline (IAnimatable implementation)
  150452. */
  150453. animations: Animation[];
  150454. /**
  150455. * Private members
  150456. */
  150457. private _scene;
  150458. private _currentDepthOfFieldSource;
  150459. private _basePostProcess;
  150460. private _fixedExposure;
  150461. private _currentExposure;
  150462. private _hdrAutoExposure;
  150463. private _hdrCurrentLuminance;
  150464. private _motionStrength;
  150465. private _isObjectBasedMotionBlur;
  150466. private _floatTextureType;
  150467. private _camerasToBeAttached;
  150468. private _ratio;
  150469. private _bloomEnabled;
  150470. private _depthOfFieldEnabled;
  150471. private _vlsEnabled;
  150472. private _lensFlareEnabled;
  150473. private _hdrEnabled;
  150474. private _motionBlurEnabled;
  150475. private _fxaaEnabled;
  150476. private _screenSpaceReflectionsEnabled;
  150477. private _motionBlurSamples;
  150478. private _volumetricLightStepsCount;
  150479. private _samples;
  150480. /**
  150481. * @ignore
  150482. * Specifies if the bloom pipeline is enabled
  150483. */
  150484. get BloomEnabled(): boolean;
  150485. set BloomEnabled(enabled: boolean);
  150486. /**
  150487. * @ignore
  150488. * Specifies if the depth of field pipeline is enabed
  150489. */
  150490. get DepthOfFieldEnabled(): boolean;
  150491. set DepthOfFieldEnabled(enabled: boolean);
  150492. /**
  150493. * @ignore
  150494. * Specifies if the lens flare pipeline is enabed
  150495. */
  150496. get LensFlareEnabled(): boolean;
  150497. set LensFlareEnabled(enabled: boolean);
  150498. /**
  150499. * @ignore
  150500. * Specifies if the HDR pipeline is enabled
  150501. */
  150502. get HDREnabled(): boolean;
  150503. set HDREnabled(enabled: boolean);
  150504. /**
  150505. * @ignore
  150506. * Specifies if the volumetric lights scattering effect is enabled
  150507. */
  150508. get VLSEnabled(): boolean;
  150509. set VLSEnabled(enabled: boolean);
  150510. /**
  150511. * @ignore
  150512. * Specifies if the motion blur effect is enabled
  150513. */
  150514. get MotionBlurEnabled(): boolean;
  150515. set MotionBlurEnabled(enabled: boolean);
  150516. /**
  150517. * Specifies if anti-aliasing is enabled
  150518. */
  150519. get fxaaEnabled(): boolean;
  150520. set fxaaEnabled(enabled: boolean);
  150521. /**
  150522. * Specifies if screen space reflections are enabled.
  150523. */
  150524. get screenSpaceReflectionsEnabled(): boolean;
  150525. set screenSpaceReflectionsEnabled(enabled: boolean);
  150526. /**
  150527. * Specifies the number of steps used to calculate the volumetric lights
  150528. * Typically in interval [50, 200]
  150529. */
  150530. get volumetricLightStepsCount(): number;
  150531. set volumetricLightStepsCount(count: number);
  150532. /**
  150533. * Specifies the number of samples used for the motion blur effect
  150534. * Typically in interval [16, 64]
  150535. */
  150536. get motionBlurSamples(): number;
  150537. set motionBlurSamples(samples: number);
  150538. /**
  150539. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  150540. */
  150541. get samples(): number;
  150542. set samples(sampleCount: number);
  150543. /**
  150544. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  150545. * @constructor
  150546. * @param name The rendering pipeline name
  150547. * @param scene The scene linked to this pipeline
  150548. * @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)
  150549. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  150550. * @param cameras The array of cameras that the rendering pipeline will be attached to
  150551. */
  150552. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  150553. private _buildPipeline;
  150554. private _createDownSampleX4PostProcess;
  150555. private _createBrightPassPostProcess;
  150556. private _createBlurPostProcesses;
  150557. private _createTextureAdderPostProcess;
  150558. private _createVolumetricLightPostProcess;
  150559. private _createLuminancePostProcesses;
  150560. private _createHdrPostProcess;
  150561. private _createLensFlarePostProcess;
  150562. private _createDepthOfFieldPostProcess;
  150563. private _createMotionBlurPostProcess;
  150564. private _getDepthTexture;
  150565. private _disposePostProcesses;
  150566. /**
  150567. * Dispose of the pipeline and stop all post processes
  150568. */
  150569. dispose(): void;
  150570. /**
  150571. * Serialize the rendering pipeline (Used when exporting)
  150572. * @returns the serialized object
  150573. */
  150574. serialize(): any;
  150575. /**
  150576. * Parse the serialized pipeline
  150577. * @param source Source pipeline.
  150578. * @param scene The scene to load the pipeline to.
  150579. * @param rootUrl The URL of the serialized pipeline.
  150580. * @returns An instantiated pipeline from the serialized object.
  150581. */
  150582. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  150583. /**
  150584. * Luminance steps
  150585. */
  150586. static LuminanceSteps: number;
  150587. }
  150588. }
  150589. declare module BABYLON {
  150590. /** @hidden */
  150591. export var stereoscopicInterlacePixelShader: {
  150592. name: string;
  150593. shader: string;
  150594. };
  150595. }
  150596. declare module BABYLON {
  150597. /**
  150598. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  150599. */
  150600. export class StereoscopicInterlacePostProcessI extends PostProcess {
  150601. private _stepSize;
  150602. private _passedProcess;
  150603. /**
  150604. * Gets a string identifying the name of the class
  150605. * @returns "StereoscopicInterlacePostProcessI" string
  150606. */
  150607. getClassName(): string;
  150608. /**
  150609. * Initializes a StereoscopicInterlacePostProcessI
  150610. * @param name The name of the effect.
  150611. * @param rigCameras The rig cameras to be appled to the post process
  150612. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  150613. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  150614. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150615. * @param engine The engine which the post process will be applied. (default: current engine)
  150616. * @param reusable If the post process can be reused on the same frame. (default: false)
  150617. */
  150618. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  150619. }
  150620. /**
  150621. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  150622. */
  150623. export class StereoscopicInterlacePostProcess extends PostProcess {
  150624. private _stepSize;
  150625. private _passedProcess;
  150626. /**
  150627. * Gets a string identifying the name of the class
  150628. * @returns "StereoscopicInterlacePostProcess" string
  150629. */
  150630. getClassName(): string;
  150631. /**
  150632. * Initializes a StereoscopicInterlacePostProcess
  150633. * @param name The name of the effect.
  150634. * @param rigCameras The rig cameras to be appled to the post process
  150635. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  150636. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150637. * @param engine The engine which the post process will be applied. (default: current engine)
  150638. * @param reusable If the post process can be reused on the same frame. (default: false)
  150639. */
  150640. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  150641. }
  150642. }
  150643. declare module BABYLON {
  150644. /** @hidden */
  150645. export var tonemapPixelShader: {
  150646. name: string;
  150647. shader: string;
  150648. };
  150649. }
  150650. declare module BABYLON {
  150651. /** Defines operator used for tonemapping */
  150652. export enum TonemappingOperator {
  150653. /** Hable */
  150654. Hable = 0,
  150655. /** Reinhard */
  150656. Reinhard = 1,
  150657. /** HejiDawson */
  150658. HejiDawson = 2,
  150659. /** Photographic */
  150660. Photographic = 3
  150661. }
  150662. /**
  150663. * Defines a post process to apply tone mapping
  150664. */
  150665. export class TonemapPostProcess extends PostProcess {
  150666. private _operator;
  150667. /** Defines the required exposure adjustement */
  150668. exposureAdjustment: number;
  150669. /**
  150670. * Gets a string identifying the name of the class
  150671. * @returns "TonemapPostProcess" string
  150672. */
  150673. getClassName(): string;
  150674. /**
  150675. * Creates a new TonemapPostProcess
  150676. * @param name defines the name of the postprocess
  150677. * @param _operator defines the operator to use
  150678. * @param exposureAdjustment defines the required exposure adjustement
  150679. * @param camera defines the camera to use (can be null)
  150680. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  150681. * @param engine defines the hosting engine (can be ignore if camera is set)
  150682. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  150683. */
  150684. constructor(name: string, _operator: TonemappingOperator,
  150685. /** Defines the required exposure adjustement */
  150686. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  150687. }
  150688. }
  150689. declare module BABYLON {
  150690. /** @hidden */
  150691. export var volumetricLightScatteringPixelShader: {
  150692. name: string;
  150693. shader: string;
  150694. };
  150695. }
  150696. declare module BABYLON {
  150697. /** @hidden */
  150698. export var volumetricLightScatteringPassVertexShader: {
  150699. name: string;
  150700. shader: string;
  150701. };
  150702. }
  150703. declare module BABYLON {
  150704. /** @hidden */
  150705. export var volumetricLightScatteringPassPixelShader: {
  150706. name: string;
  150707. shader: string;
  150708. };
  150709. }
  150710. declare module BABYLON {
  150711. /**
  150712. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  150713. */
  150714. export class VolumetricLightScatteringPostProcess extends PostProcess {
  150715. private _volumetricLightScatteringPass;
  150716. private _volumetricLightScatteringRTT;
  150717. private _viewPort;
  150718. private _screenCoordinates;
  150719. private _cachedDefines;
  150720. /**
  150721. * If not undefined, the mesh position is computed from the attached node position
  150722. */
  150723. attachedNode: {
  150724. position: Vector3;
  150725. };
  150726. /**
  150727. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  150728. */
  150729. customMeshPosition: Vector3;
  150730. /**
  150731. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  150732. */
  150733. useCustomMeshPosition: boolean;
  150734. /**
  150735. * If the post-process should inverse the light scattering direction
  150736. */
  150737. invert: boolean;
  150738. /**
  150739. * The internal mesh used by the post-process
  150740. */
  150741. mesh: Mesh;
  150742. /**
  150743. * @hidden
  150744. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  150745. */
  150746. get useDiffuseColor(): boolean;
  150747. set useDiffuseColor(useDiffuseColor: boolean);
  150748. /**
  150749. * Array containing the excluded meshes not rendered in the internal pass
  150750. */
  150751. excludedMeshes: AbstractMesh[];
  150752. /**
  150753. * Controls the overall intensity of the post-process
  150754. */
  150755. exposure: number;
  150756. /**
  150757. * Dissipates each sample's contribution in range [0, 1]
  150758. */
  150759. decay: number;
  150760. /**
  150761. * Controls the overall intensity of each sample
  150762. */
  150763. weight: number;
  150764. /**
  150765. * Controls the density of each sample
  150766. */
  150767. density: number;
  150768. /**
  150769. * @constructor
  150770. * @param name The post-process name
  150771. * @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)
  150772. * @param camera The camera that the post-process will be attached to
  150773. * @param mesh The mesh used to create the light scattering
  150774. * @param samples The post-process quality, default 100
  150775. * @param samplingModeThe post-process filtering mode
  150776. * @param engine The babylon engine
  150777. * @param reusable If the post-process is reusable
  150778. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  150779. */
  150780. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  150781. /**
  150782. * Returns the string "VolumetricLightScatteringPostProcess"
  150783. * @returns "VolumetricLightScatteringPostProcess"
  150784. */
  150785. getClassName(): string;
  150786. private _isReady;
  150787. /**
  150788. * Sets the new light position for light scattering effect
  150789. * @param position The new custom light position
  150790. */
  150791. setCustomMeshPosition(position: Vector3): void;
  150792. /**
  150793. * Returns the light position for light scattering effect
  150794. * @return Vector3 The custom light position
  150795. */
  150796. getCustomMeshPosition(): Vector3;
  150797. /**
  150798. * Disposes the internal assets and detaches the post-process from the camera
  150799. */
  150800. dispose(camera: Camera): void;
  150801. /**
  150802. * Returns the render target texture used by the post-process
  150803. * @return the render target texture used by the post-process
  150804. */
  150805. getPass(): RenderTargetTexture;
  150806. private _meshExcluded;
  150807. private _createPass;
  150808. private _updateMeshScreenCoordinates;
  150809. /**
  150810. * Creates a default mesh for the Volumeric Light Scattering post-process
  150811. * @param name The mesh name
  150812. * @param scene The scene where to create the mesh
  150813. * @return the default mesh
  150814. */
  150815. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  150816. }
  150817. }
  150818. declare module BABYLON {
  150819. /** @hidden */
  150820. export var screenSpaceCurvaturePixelShader: {
  150821. name: string;
  150822. shader: string;
  150823. };
  150824. }
  150825. declare module BABYLON {
  150826. /**
  150827. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  150828. */
  150829. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  150830. /**
  150831. * Defines how much ridge the curvature effect displays.
  150832. */
  150833. ridge: number;
  150834. /**
  150835. * Defines how much valley the curvature effect displays.
  150836. */
  150837. valley: number;
  150838. private _geometryBufferRenderer;
  150839. /**
  150840. * Gets a string identifying the name of the class
  150841. * @returns "ScreenSpaceCurvaturePostProcess" string
  150842. */
  150843. getClassName(): string;
  150844. /**
  150845. * Creates a new instance ScreenSpaceCurvaturePostProcess
  150846. * @param name The name of the effect.
  150847. * @param scene The scene containing the objects to blur according to their velocity.
  150848. * @param options The required width/height ratio to downsize to before computing the render pass.
  150849. * @param camera The camera to apply the render pass to.
  150850. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150851. * @param engine The engine which the post process will be applied. (default: current engine)
  150852. * @param reusable If the post process can be reused on the same frame. (default: false)
  150853. * @param textureType Type of textures used when performing the post process. (default: 0)
  150854. * @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)
  150855. */
  150856. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150857. /**
  150858. * Support test.
  150859. */
  150860. static get IsSupported(): boolean;
  150861. /** @hidden */
  150862. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  150863. }
  150864. }
  150865. declare module BABYLON {
  150866. interface Scene {
  150867. /** @hidden (Backing field) */
  150868. _boundingBoxRenderer: BoundingBoxRenderer;
  150869. /** @hidden (Backing field) */
  150870. _forceShowBoundingBoxes: boolean;
  150871. /**
  150872. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  150873. */
  150874. forceShowBoundingBoxes: boolean;
  150875. /**
  150876. * Gets the bounding box renderer associated with the scene
  150877. * @returns a BoundingBoxRenderer
  150878. */
  150879. getBoundingBoxRenderer(): BoundingBoxRenderer;
  150880. }
  150881. interface AbstractMesh {
  150882. /** @hidden (Backing field) */
  150883. _showBoundingBox: boolean;
  150884. /**
  150885. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  150886. */
  150887. showBoundingBox: boolean;
  150888. }
  150889. /**
  150890. * Component responsible of rendering the bounding box of the meshes in a scene.
  150891. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  150892. */
  150893. export class BoundingBoxRenderer implements ISceneComponent {
  150894. /**
  150895. * The component name helpfull to identify the component in the list of scene components.
  150896. */
  150897. readonly name: string;
  150898. /**
  150899. * The scene the component belongs to.
  150900. */
  150901. scene: Scene;
  150902. /**
  150903. * Color of the bounding box lines placed in front of an object
  150904. */
  150905. frontColor: Color3;
  150906. /**
  150907. * Color of the bounding box lines placed behind an object
  150908. */
  150909. backColor: Color3;
  150910. /**
  150911. * Defines if the renderer should show the back lines or not
  150912. */
  150913. showBackLines: boolean;
  150914. /**
  150915. * Observable raised before rendering a bounding box
  150916. */
  150917. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  150918. /**
  150919. * Observable raised after rendering a bounding box
  150920. */
  150921. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  150922. /**
  150923. * @hidden
  150924. */
  150925. renderList: SmartArray<BoundingBox>;
  150926. private _colorShader;
  150927. private _vertexBuffers;
  150928. private _indexBuffer;
  150929. private _fillIndexBuffer;
  150930. private _fillIndexData;
  150931. /**
  150932. * Instantiates a new bounding box renderer in a scene.
  150933. * @param scene the scene the renderer renders in
  150934. */
  150935. constructor(scene: Scene);
  150936. /**
  150937. * Registers the component in a given scene
  150938. */
  150939. register(): void;
  150940. private _evaluateSubMesh;
  150941. private _activeMesh;
  150942. private _prepareRessources;
  150943. private _createIndexBuffer;
  150944. /**
  150945. * Rebuilds the elements related to this component in case of
  150946. * context lost for instance.
  150947. */
  150948. rebuild(): void;
  150949. /**
  150950. * @hidden
  150951. */
  150952. reset(): void;
  150953. /**
  150954. * Render the bounding boxes of a specific rendering group
  150955. * @param renderingGroupId defines the rendering group to render
  150956. */
  150957. render(renderingGroupId: number): void;
  150958. /**
  150959. * In case of occlusion queries, we can render the occlusion bounding box through this method
  150960. * @param mesh Define the mesh to render the occlusion bounding box for
  150961. */
  150962. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  150963. /**
  150964. * Dispose and release the resources attached to this renderer.
  150965. */
  150966. dispose(): void;
  150967. }
  150968. }
  150969. declare module BABYLON {
  150970. interface Scene {
  150971. /** @hidden (Backing field) */
  150972. _depthRenderer: {
  150973. [id: string]: DepthRenderer;
  150974. };
  150975. /**
  150976. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  150977. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  150978. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  150979. * @returns the created depth renderer
  150980. */
  150981. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  150982. /**
  150983. * Disables a depth renderer for a given camera
  150984. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  150985. */
  150986. disableDepthRenderer(camera?: Nullable<Camera>): void;
  150987. }
  150988. /**
  150989. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  150990. * in several rendering techniques.
  150991. */
  150992. export class DepthRendererSceneComponent implements ISceneComponent {
  150993. /**
  150994. * The component name helpfull to identify the component in the list of scene components.
  150995. */
  150996. readonly name: string;
  150997. /**
  150998. * The scene the component belongs to.
  150999. */
  151000. scene: Scene;
  151001. /**
  151002. * Creates a new instance of the component for the given scene
  151003. * @param scene Defines the scene to register the component in
  151004. */
  151005. constructor(scene: Scene);
  151006. /**
  151007. * Registers the component in a given scene
  151008. */
  151009. register(): void;
  151010. /**
  151011. * Rebuilds the elements related to this component in case of
  151012. * context lost for instance.
  151013. */
  151014. rebuild(): void;
  151015. /**
  151016. * Disposes the component and the associated ressources
  151017. */
  151018. dispose(): void;
  151019. private _gatherRenderTargets;
  151020. private _gatherActiveCameraRenderTargets;
  151021. }
  151022. }
  151023. declare module BABYLON {
  151024. interface AbstractScene {
  151025. /** @hidden (Backing field) */
  151026. _prePassRenderer: Nullable<PrePassRenderer>;
  151027. /**
  151028. * Gets or Sets the current prepass renderer associated to the scene.
  151029. */
  151030. prePassRenderer: Nullable<PrePassRenderer>;
  151031. /**
  151032. * Enables the prepass and associates it with the scene
  151033. * @returns the PrePassRenderer
  151034. */
  151035. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  151036. /**
  151037. * Disables the prepass associated with the scene
  151038. */
  151039. disablePrePassRenderer(): void;
  151040. }
  151041. /**
  151042. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  151043. * in several rendering techniques.
  151044. */
  151045. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  151046. /**
  151047. * The component name helpful to identify the component in the list of scene components.
  151048. */
  151049. readonly name: string;
  151050. /**
  151051. * The scene the component belongs to.
  151052. */
  151053. scene: Scene;
  151054. /**
  151055. * Creates a new instance of the component for the given scene
  151056. * @param scene Defines the scene to register the component in
  151057. */
  151058. constructor(scene: Scene);
  151059. /**
  151060. * Registers the component in a given scene
  151061. */
  151062. register(): void;
  151063. private _beforeCameraDraw;
  151064. private _afterCameraDraw;
  151065. private _beforeClearStage;
  151066. /**
  151067. * Serializes the component data to the specified json object
  151068. * @param serializationObject The object to serialize to
  151069. */
  151070. serialize(serializationObject: any): void;
  151071. /**
  151072. * Adds all the elements from the container to the scene
  151073. * @param container the container holding the elements
  151074. */
  151075. addFromContainer(container: AbstractScene): void;
  151076. /**
  151077. * Removes all the elements in the container from the scene
  151078. * @param container contains the elements to remove
  151079. * @param dispose if the removed element should be disposed (default: false)
  151080. */
  151081. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  151082. /**
  151083. * Rebuilds the elements related to this component in case of
  151084. * context lost for instance.
  151085. */
  151086. rebuild(): void;
  151087. /**
  151088. * Disposes the component and the associated ressources
  151089. */
  151090. dispose(): void;
  151091. }
  151092. }
  151093. declare module BABYLON {
  151094. /** @hidden */
  151095. export var outlinePixelShader: {
  151096. name: string;
  151097. shader: string;
  151098. };
  151099. }
  151100. declare module BABYLON {
  151101. /** @hidden */
  151102. export var outlineVertexShader: {
  151103. name: string;
  151104. shader: string;
  151105. };
  151106. }
  151107. declare module BABYLON {
  151108. interface Scene {
  151109. /** @hidden */
  151110. _outlineRenderer: OutlineRenderer;
  151111. /**
  151112. * Gets the outline renderer associated with the scene
  151113. * @returns a OutlineRenderer
  151114. */
  151115. getOutlineRenderer(): OutlineRenderer;
  151116. }
  151117. interface AbstractMesh {
  151118. /** @hidden (Backing field) */
  151119. _renderOutline: boolean;
  151120. /**
  151121. * Gets or sets a boolean indicating if the outline must be rendered as well
  151122. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  151123. */
  151124. renderOutline: boolean;
  151125. /** @hidden (Backing field) */
  151126. _renderOverlay: boolean;
  151127. /**
  151128. * Gets or sets a boolean indicating if the overlay must be rendered as well
  151129. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  151130. */
  151131. renderOverlay: boolean;
  151132. }
  151133. /**
  151134. * This class is responsible to draw bothe outline/overlay of meshes.
  151135. * It should not be used directly but through the available method on mesh.
  151136. */
  151137. export class OutlineRenderer implements ISceneComponent {
  151138. /**
  151139. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  151140. */
  151141. private static _StencilReference;
  151142. /**
  151143. * The name of the component. Each component must have a unique name.
  151144. */
  151145. name: string;
  151146. /**
  151147. * The scene the component belongs to.
  151148. */
  151149. scene: Scene;
  151150. /**
  151151. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  151152. */
  151153. zOffset: number;
  151154. private _engine;
  151155. private _effect;
  151156. private _cachedDefines;
  151157. private _savedDepthWrite;
  151158. /**
  151159. * Instantiates a new outline renderer. (There could be only one per scene).
  151160. * @param scene Defines the scene it belongs to
  151161. */
  151162. constructor(scene: Scene);
  151163. /**
  151164. * Register the component to one instance of a scene.
  151165. */
  151166. register(): void;
  151167. /**
  151168. * Rebuilds the elements related to this component in case of
  151169. * context lost for instance.
  151170. */
  151171. rebuild(): void;
  151172. /**
  151173. * Disposes the component and the associated ressources.
  151174. */
  151175. dispose(): void;
  151176. /**
  151177. * Renders the outline in the canvas.
  151178. * @param subMesh Defines the sumesh to render
  151179. * @param batch Defines the batch of meshes in case of instances
  151180. * @param useOverlay Defines if the rendering is for the overlay or the outline
  151181. */
  151182. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  151183. /**
  151184. * Returns whether or not the outline renderer is ready for a given submesh.
  151185. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  151186. * @param subMesh Defines the submesh to check readyness for
  151187. * @param useInstances Defines wheter wee are trying to render instances or not
  151188. * @returns true if ready otherwise false
  151189. */
  151190. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  151191. private _beforeRenderingMesh;
  151192. private _afterRenderingMesh;
  151193. }
  151194. }
  151195. declare module BABYLON {
  151196. /**
  151197. * Defines the basic options interface of a Sprite Frame Source Size.
  151198. */
  151199. export interface ISpriteJSONSpriteSourceSize {
  151200. /**
  151201. * number of the original width of the Frame
  151202. */
  151203. w: number;
  151204. /**
  151205. * number of the original height of the Frame
  151206. */
  151207. h: number;
  151208. }
  151209. /**
  151210. * Defines the basic options interface of a Sprite Frame Data.
  151211. */
  151212. export interface ISpriteJSONSpriteFrameData {
  151213. /**
  151214. * number of the x offset of the Frame
  151215. */
  151216. x: number;
  151217. /**
  151218. * number of the y offset of the Frame
  151219. */
  151220. y: number;
  151221. /**
  151222. * number of the width of the Frame
  151223. */
  151224. w: number;
  151225. /**
  151226. * number of the height of the Frame
  151227. */
  151228. h: number;
  151229. }
  151230. /**
  151231. * Defines the basic options interface of a JSON Sprite.
  151232. */
  151233. export interface ISpriteJSONSprite {
  151234. /**
  151235. * string name of the Frame
  151236. */
  151237. filename: string;
  151238. /**
  151239. * ISpriteJSONSpriteFrame basic object of the frame data
  151240. */
  151241. frame: ISpriteJSONSpriteFrameData;
  151242. /**
  151243. * boolean to flag is the frame was rotated.
  151244. */
  151245. rotated: boolean;
  151246. /**
  151247. * boolean to flag is the frame was trimmed.
  151248. */
  151249. trimmed: boolean;
  151250. /**
  151251. * ISpriteJSONSpriteFrame basic object of the source data
  151252. */
  151253. spriteSourceSize: ISpriteJSONSpriteFrameData;
  151254. /**
  151255. * ISpriteJSONSpriteFrame basic object of the source data
  151256. */
  151257. sourceSize: ISpriteJSONSpriteSourceSize;
  151258. }
  151259. /**
  151260. * Defines the basic options interface of a JSON atlas.
  151261. */
  151262. export interface ISpriteJSONAtlas {
  151263. /**
  151264. * Array of objects that contain the frame data.
  151265. */
  151266. frames: Array<ISpriteJSONSprite>;
  151267. /**
  151268. * object basic object containing the sprite meta data.
  151269. */
  151270. meta?: object;
  151271. }
  151272. }
  151273. declare module BABYLON {
  151274. /** @hidden */
  151275. export var spriteMapPixelShader: {
  151276. name: string;
  151277. shader: string;
  151278. };
  151279. }
  151280. declare module BABYLON {
  151281. /** @hidden */
  151282. export var spriteMapVertexShader: {
  151283. name: string;
  151284. shader: string;
  151285. };
  151286. }
  151287. declare module BABYLON {
  151288. /**
  151289. * Defines the basic options interface of a SpriteMap
  151290. */
  151291. export interface ISpriteMapOptions {
  151292. /**
  151293. * Vector2 of the number of cells in the grid.
  151294. */
  151295. stageSize?: Vector2;
  151296. /**
  151297. * Vector2 of the size of the output plane in World Units.
  151298. */
  151299. outputSize?: Vector2;
  151300. /**
  151301. * Vector3 of the position of the output plane in World Units.
  151302. */
  151303. outputPosition?: Vector3;
  151304. /**
  151305. * Vector3 of the rotation of the output plane.
  151306. */
  151307. outputRotation?: Vector3;
  151308. /**
  151309. * number of layers that the system will reserve in resources.
  151310. */
  151311. layerCount?: number;
  151312. /**
  151313. * number of max animation frames a single cell will reserve in resources.
  151314. */
  151315. maxAnimationFrames?: number;
  151316. /**
  151317. * number cell index of the base tile when the system compiles.
  151318. */
  151319. baseTile?: number;
  151320. /**
  151321. * boolean flip the sprite after its been repositioned by the framing data.
  151322. */
  151323. flipU?: boolean;
  151324. /**
  151325. * Vector3 scalar of the global RGB values of the SpriteMap.
  151326. */
  151327. colorMultiply?: Vector3;
  151328. }
  151329. /**
  151330. * Defines the IDisposable interface in order to be cleanable from resources.
  151331. */
  151332. export interface ISpriteMap extends IDisposable {
  151333. /**
  151334. * String name of the SpriteMap.
  151335. */
  151336. name: string;
  151337. /**
  151338. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  151339. */
  151340. atlasJSON: ISpriteJSONAtlas;
  151341. /**
  151342. * Texture of the SpriteMap.
  151343. */
  151344. spriteSheet: Texture;
  151345. /**
  151346. * The parameters to initialize the SpriteMap with.
  151347. */
  151348. options: ISpriteMapOptions;
  151349. }
  151350. /**
  151351. * Class used to manage a grid restricted sprite deployment on an Output plane.
  151352. */
  151353. export class SpriteMap implements ISpriteMap {
  151354. /** The Name of the spriteMap */
  151355. name: string;
  151356. /** The JSON file with the frame and meta data */
  151357. atlasJSON: ISpriteJSONAtlas;
  151358. /** The systems Sprite Sheet Texture */
  151359. spriteSheet: Texture;
  151360. /** Arguments passed with the Constructor */
  151361. options: ISpriteMapOptions;
  151362. /** Public Sprite Storage array, parsed from atlasJSON */
  151363. sprites: Array<ISpriteJSONSprite>;
  151364. /** Returns the Number of Sprites in the System */
  151365. get spriteCount(): number;
  151366. /** Returns the Position of Output Plane*/
  151367. get position(): Vector3;
  151368. /** Returns the Position of Output Plane*/
  151369. set position(v: Vector3);
  151370. /** Returns the Rotation of Output Plane*/
  151371. get rotation(): Vector3;
  151372. /** Returns the Rotation of Output Plane*/
  151373. set rotation(v: Vector3);
  151374. /** Sets the AnimationMap*/
  151375. get animationMap(): RawTexture;
  151376. /** Sets the AnimationMap*/
  151377. set animationMap(v: RawTexture);
  151378. /** Scene that the SpriteMap was created in */
  151379. private _scene;
  151380. /** Texture Buffer of Float32 that holds tile frame data*/
  151381. private _frameMap;
  151382. /** Texture Buffers of Float32 that holds tileMap data*/
  151383. private _tileMaps;
  151384. /** Texture Buffer of Float32 that holds Animation Data*/
  151385. private _animationMap;
  151386. /** Custom ShaderMaterial Central to the System*/
  151387. private _material;
  151388. /** Custom ShaderMaterial Central to the System*/
  151389. private _output;
  151390. /** Systems Time Ticker*/
  151391. private _time;
  151392. /**
  151393. * Creates a new SpriteMap
  151394. * @param name defines the SpriteMaps Name
  151395. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  151396. * @param spriteSheet is the Texture that the Sprites are on.
  151397. * @param options a basic deployment configuration
  151398. * @param scene The Scene that the map is deployed on
  151399. */
  151400. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  151401. /**
  151402. * Returns tileID location
  151403. * @returns Vector2 the cell position ID
  151404. */
  151405. getTileID(): Vector2;
  151406. /**
  151407. * Gets the UV location of the mouse over the SpriteMap.
  151408. * @returns Vector2 the UV position of the mouse interaction
  151409. */
  151410. getMousePosition(): Vector2;
  151411. /**
  151412. * Creates the "frame" texture Buffer
  151413. * -------------------------------------
  151414. * Structure of frames
  151415. * "filename": "Falling-Water-2.png",
  151416. * "frame": {"x":69,"y":103,"w":24,"h":32},
  151417. * "rotated": true,
  151418. * "trimmed": true,
  151419. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  151420. * "sourceSize": {"w":32,"h":32}
  151421. * @returns RawTexture of the frameMap
  151422. */
  151423. private _createFrameBuffer;
  151424. /**
  151425. * Creates the tileMap texture Buffer
  151426. * @param buffer normally and array of numbers, or a false to generate from scratch
  151427. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  151428. * @returns RawTexture of the tileMap
  151429. */
  151430. private _createTileBuffer;
  151431. /**
  151432. * Modifies the data of the tileMaps
  151433. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  151434. * @param pos is the iVector2 Coordinates of the Tile
  151435. * @param tile The SpriteIndex of the new Tile
  151436. */
  151437. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  151438. /**
  151439. * Creates the animationMap texture Buffer
  151440. * @param buffer normally and array of numbers, or a false to generate from scratch
  151441. * @returns RawTexture of the animationMap
  151442. */
  151443. private _createTileAnimationBuffer;
  151444. /**
  151445. * Modifies the data of the animationMap
  151446. * @param cellID is the Index of the Sprite
  151447. * @param _frame is the target Animation frame
  151448. * @param toCell is the Target Index of the next frame of the animation
  151449. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  151450. * @param speed is a global scalar of the time variable on the map.
  151451. */
  151452. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  151453. /**
  151454. * Exports the .tilemaps file
  151455. */
  151456. saveTileMaps(): void;
  151457. /**
  151458. * Imports the .tilemaps file
  151459. * @param url of the .tilemaps file
  151460. */
  151461. loadTileMaps(url: string): void;
  151462. /**
  151463. * Release associated resources
  151464. */
  151465. dispose(): void;
  151466. }
  151467. }
  151468. declare module BABYLON {
  151469. /**
  151470. * Class used to manage multiple sprites of different sizes on the same spritesheet
  151471. * @see https://doc.babylonjs.com/babylon101/sprites
  151472. */
  151473. export class SpritePackedManager extends SpriteManager {
  151474. /** defines the packed manager's name */
  151475. name: string;
  151476. /**
  151477. * Creates a new sprite manager from a packed sprite sheet
  151478. * @param name defines the manager's name
  151479. * @param imgUrl defines the sprite sheet url
  151480. * @param capacity defines the maximum allowed number of sprites
  151481. * @param scene defines the hosting scene
  151482. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  151483. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  151484. * @param samplingMode defines the smapling mode to use with spritesheet
  151485. * @param fromPacked set to true; do not alter
  151486. */
  151487. constructor(
  151488. /** defines the packed manager's name */
  151489. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  151490. }
  151491. }
  151492. declare module BABYLON {
  151493. /**
  151494. * Defines the list of states available for a task inside a AssetsManager
  151495. */
  151496. export enum AssetTaskState {
  151497. /**
  151498. * Initialization
  151499. */
  151500. INIT = 0,
  151501. /**
  151502. * Running
  151503. */
  151504. RUNNING = 1,
  151505. /**
  151506. * Done
  151507. */
  151508. DONE = 2,
  151509. /**
  151510. * Error
  151511. */
  151512. ERROR = 3
  151513. }
  151514. /**
  151515. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  151516. */
  151517. export abstract class AbstractAssetTask {
  151518. /**
  151519. * Task name
  151520. */ name: string;
  151521. /**
  151522. * Callback called when the task is successful
  151523. */
  151524. onSuccess: (task: any) => void;
  151525. /**
  151526. * Callback called when the task is not successful
  151527. */
  151528. onError: (task: any, message?: string, exception?: any) => void;
  151529. /**
  151530. * Creates a new AssetsManager
  151531. * @param name defines the name of the task
  151532. */
  151533. constructor(
  151534. /**
  151535. * Task name
  151536. */ name: string);
  151537. private _isCompleted;
  151538. private _taskState;
  151539. private _errorObject;
  151540. /**
  151541. * Get if the task is completed
  151542. */
  151543. get isCompleted(): boolean;
  151544. /**
  151545. * Gets the current state of the task
  151546. */
  151547. get taskState(): AssetTaskState;
  151548. /**
  151549. * Gets the current error object (if task is in error)
  151550. */
  151551. get errorObject(): {
  151552. message?: string;
  151553. exception?: any;
  151554. };
  151555. /**
  151556. * Internal only
  151557. * @hidden
  151558. */
  151559. _setErrorObject(message?: string, exception?: any): void;
  151560. /**
  151561. * Execute the current task
  151562. * @param scene defines the scene where you want your assets to be loaded
  151563. * @param onSuccess is a callback called when the task is successfully executed
  151564. * @param onError is a callback called if an error occurs
  151565. */
  151566. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151567. /**
  151568. * Execute the current task
  151569. * @param scene defines the scene where you want your assets to be loaded
  151570. * @param onSuccess is a callback called when the task is successfully executed
  151571. * @param onError is a callback called if an error occurs
  151572. */
  151573. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151574. /**
  151575. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  151576. * This can be used with failed tasks that have the reason for failure fixed.
  151577. */
  151578. reset(): void;
  151579. private onErrorCallback;
  151580. private onDoneCallback;
  151581. }
  151582. /**
  151583. * Define the interface used by progress events raised during assets loading
  151584. */
  151585. export interface IAssetsProgressEvent {
  151586. /**
  151587. * Defines the number of remaining tasks to process
  151588. */
  151589. remainingCount: number;
  151590. /**
  151591. * Defines the total number of tasks
  151592. */
  151593. totalCount: number;
  151594. /**
  151595. * Defines the task that was just processed
  151596. */
  151597. task: AbstractAssetTask;
  151598. }
  151599. /**
  151600. * Class used to share progress information about assets loading
  151601. */
  151602. export class AssetsProgressEvent implements IAssetsProgressEvent {
  151603. /**
  151604. * Defines the number of remaining tasks to process
  151605. */
  151606. remainingCount: number;
  151607. /**
  151608. * Defines the total number of tasks
  151609. */
  151610. totalCount: number;
  151611. /**
  151612. * Defines the task that was just processed
  151613. */
  151614. task: AbstractAssetTask;
  151615. /**
  151616. * Creates a AssetsProgressEvent
  151617. * @param remainingCount defines the number of remaining tasks to process
  151618. * @param totalCount defines the total number of tasks
  151619. * @param task defines the task that was just processed
  151620. */
  151621. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  151622. }
  151623. /**
  151624. * Define a task used by AssetsManager to load assets into a container
  151625. */
  151626. export class ContainerAssetTask extends AbstractAssetTask {
  151627. /**
  151628. * Defines the name of the task
  151629. */
  151630. name: string;
  151631. /**
  151632. * Defines the list of mesh's names you want to load
  151633. */
  151634. meshesNames: any;
  151635. /**
  151636. * Defines the root url to use as a base to load your meshes and associated resources
  151637. */
  151638. rootUrl: string;
  151639. /**
  151640. * Defines the filename or File of the scene to load from
  151641. */
  151642. sceneFilename: string | File;
  151643. /**
  151644. * Get the loaded asset container
  151645. */
  151646. loadedContainer: AssetContainer;
  151647. /**
  151648. * Gets the list of loaded meshes
  151649. */
  151650. loadedMeshes: Array<AbstractMesh>;
  151651. /**
  151652. * Gets the list of loaded particle systems
  151653. */
  151654. loadedParticleSystems: Array<IParticleSystem>;
  151655. /**
  151656. * Gets the list of loaded skeletons
  151657. */
  151658. loadedSkeletons: Array<Skeleton>;
  151659. /**
  151660. * Gets the list of loaded animation groups
  151661. */
  151662. loadedAnimationGroups: Array<AnimationGroup>;
  151663. /**
  151664. * Callback called when the task is successful
  151665. */
  151666. onSuccess: (task: ContainerAssetTask) => void;
  151667. /**
  151668. * Callback called when the task is successful
  151669. */
  151670. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  151671. /**
  151672. * Creates a new ContainerAssetTask
  151673. * @param name defines the name of the task
  151674. * @param meshesNames defines the list of mesh's names you want to load
  151675. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  151676. * @param sceneFilename defines the filename or File of the scene to load from
  151677. */
  151678. constructor(
  151679. /**
  151680. * Defines the name of the task
  151681. */
  151682. name: string,
  151683. /**
  151684. * Defines the list of mesh's names you want to load
  151685. */
  151686. meshesNames: any,
  151687. /**
  151688. * Defines the root url to use as a base to load your meshes and associated resources
  151689. */
  151690. rootUrl: string,
  151691. /**
  151692. * Defines the filename or File of the scene to load from
  151693. */
  151694. sceneFilename: string | File);
  151695. /**
  151696. * Execute the current task
  151697. * @param scene defines the scene where you want your assets to be loaded
  151698. * @param onSuccess is a callback called when the task is successfully executed
  151699. * @param onError is a callback called if an error occurs
  151700. */
  151701. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151702. }
  151703. /**
  151704. * Define a task used by AssetsManager to load meshes
  151705. */
  151706. export class MeshAssetTask extends AbstractAssetTask {
  151707. /**
  151708. * Defines the name of the task
  151709. */
  151710. name: string;
  151711. /**
  151712. * Defines the list of mesh's names you want to load
  151713. */
  151714. meshesNames: any;
  151715. /**
  151716. * Defines the root url to use as a base to load your meshes and associated resources
  151717. */
  151718. rootUrl: string;
  151719. /**
  151720. * Defines the filename or File of the scene to load from
  151721. */
  151722. sceneFilename: string | File;
  151723. /**
  151724. * Gets the list of loaded meshes
  151725. */
  151726. loadedMeshes: Array<AbstractMesh>;
  151727. /**
  151728. * Gets the list of loaded particle systems
  151729. */
  151730. loadedParticleSystems: Array<IParticleSystem>;
  151731. /**
  151732. * Gets the list of loaded skeletons
  151733. */
  151734. loadedSkeletons: Array<Skeleton>;
  151735. /**
  151736. * Gets the list of loaded animation groups
  151737. */
  151738. loadedAnimationGroups: Array<AnimationGroup>;
  151739. /**
  151740. * Callback called when the task is successful
  151741. */
  151742. onSuccess: (task: MeshAssetTask) => void;
  151743. /**
  151744. * Callback called when the task is successful
  151745. */
  151746. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  151747. /**
  151748. * Creates a new MeshAssetTask
  151749. * @param name defines the name of the task
  151750. * @param meshesNames defines the list of mesh's names you want to load
  151751. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  151752. * @param sceneFilename defines the filename or File of the scene to load from
  151753. */
  151754. constructor(
  151755. /**
  151756. * Defines the name of the task
  151757. */
  151758. name: string,
  151759. /**
  151760. * Defines the list of mesh's names you want to load
  151761. */
  151762. meshesNames: any,
  151763. /**
  151764. * Defines the root url to use as a base to load your meshes and associated resources
  151765. */
  151766. rootUrl: string,
  151767. /**
  151768. * Defines the filename or File of the scene to load from
  151769. */
  151770. sceneFilename: string | File);
  151771. /**
  151772. * Execute the current task
  151773. * @param scene defines the scene where you want your assets to be loaded
  151774. * @param onSuccess is a callback called when the task is successfully executed
  151775. * @param onError is a callback called if an error occurs
  151776. */
  151777. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151778. }
  151779. /**
  151780. * Define a task used by AssetsManager to load text content
  151781. */
  151782. export class TextFileAssetTask extends AbstractAssetTask {
  151783. /**
  151784. * Defines the name of the task
  151785. */
  151786. name: string;
  151787. /**
  151788. * Defines the location of the file to load
  151789. */
  151790. url: string;
  151791. /**
  151792. * Gets the loaded text string
  151793. */
  151794. text: string;
  151795. /**
  151796. * Callback called when the task is successful
  151797. */
  151798. onSuccess: (task: TextFileAssetTask) => void;
  151799. /**
  151800. * Callback called when the task is successful
  151801. */
  151802. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  151803. /**
  151804. * Creates a new TextFileAssetTask object
  151805. * @param name defines the name of the task
  151806. * @param url defines the location of the file to load
  151807. */
  151808. constructor(
  151809. /**
  151810. * Defines the name of the task
  151811. */
  151812. name: string,
  151813. /**
  151814. * Defines the location of the file to load
  151815. */
  151816. url: string);
  151817. /**
  151818. * Execute the current task
  151819. * @param scene defines the scene where you want your assets to be loaded
  151820. * @param onSuccess is a callback called when the task is successfully executed
  151821. * @param onError is a callback called if an error occurs
  151822. */
  151823. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151824. }
  151825. /**
  151826. * Define a task used by AssetsManager to load binary data
  151827. */
  151828. export class BinaryFileAssetTask extends AbstractAssetTask {
  151829. /**
  151830. * Defines the name of the task
  151831. */
  151832. name: string;
  151833. /**
  151834. * Defines the location of the file to load
  151835. */
  151836. url: string;
  151837. /**
  151838. * Gets the lodaded data (as an array buffer)
  151839. */
  151840. data: ArrayBuffer;
  151841. /**
  151842. * Callback called when the task is successful
  151843. */
  151844. onSuccess: (task: BinaryFileAssetTask) => void;
  151845. /**
  151846. * Callback called when the task is successful
  151847. */
  151848. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  151849. /**
  151850. * Creates a new BinaryFileAssetTask object
  151851. * @param name defines the name of the new task
  151852. * @param url defines the location of the file to load
  151853. */
  151854. constructor(
  151855. /**
  151856. * Defines the name of the task
  151857. */
  151858. name: string,
  151859. /**
  151860. * Defines the location of the file to load
  151861. */
  151862. url: string);
  151863. /**
  151864. * Execute the current task
  151865. * @param scene defines the scene where you want your assets to be loaded
  151866. * @param onSuccess is a callback called when the task is successfully executed
  151867. * @param onError is a callback called if an error occurs
  151868. */
  151869. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151870. }
  151871. /**
  151872. * Define a task used by AssetsManager to load images
  151873. */
  151874. export class ImageAssetTask extends AbstractAssetTask {
  151875. /**
  151876. * Defines the name of the task
  151877. */
  151878. name: string;
  151879. /**
  151880. * Defines the location of the image to load
  151881. */
  151882. url: string;
  151883. /**
  151884. * Gets the loaded images
  151885. */
  151886. image: HTMLImageElement;
  151887. /**
  151888. * Callback called when the task is successful
  151889. */
  151890. onSuccess: (task: ImageAssetTask) => void;
  151891. /**
  151892. * Callback called when the task is successful
  151893. */
  151894. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  151895. /**
  151896. * Creates a new ImageAssetTask
  151897. * @param name defines the name of the task
  151898. * @param url defines the location of the image to load
  151899. */
  151900. constructor(
  151901. /**
  151902. * Defines the name of the task
  151903. */
  151904. name: string,
  151905. /**
  151906. * Defines the location of the image to load
  151907. */
  151908. url: string);
  151909. /**
  151910. * Execute the current task
  151911. * @param scene defines the scene where you want your assets to be loaded
  151912. * @param onSuccess is a callback called when the task is successfully executed
  151913. * @param onError is a callback called if an error occurs
  151914. */
  151915. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151916. }
  151917. /**
  151918. * Defines the interface used by texture loading tasks
  151919. */
  151920. export interface ITextureAssetTask<TEX extends BaseTexture> {
  151921. /**
  151922. * Gets the loaded texture
  151923. */
  151924. texture: TEX;
  151925. }
  151926. /**
  151927. * Define a task used by AssetsManager to load 2D textures
  151928. */
  151929. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  151930. /**
  151931. * Defines the name of the task
  151932. */
  151933. name: string;
  151934. /**
  151935. * Defines the location of the file to load
  151936. */
  151937. url: string;
  151938. /**
  151939. * Defines if mipmap should not be generated (default is false)
  151940. */
  151941. noMipmap?: boolean | undefined;
  151942. /**
  151943. * Defines if texture must be inverted on Y axis (default is true)
  151944. */
  151945. invertY: boolean;
  151946. /**
  151947. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  151948. */
  151949. samplingMode: number;
  151950. /**
  151951. * Gets the loaded texture
  151952. */
  151953. texture: Texture;
  151954. /**
  151955. * Callback called when the task is successful
  151956. */
  151957. onSuccess: (task: TextureAssetTask) => void;
  151958. /**
  151959. * Callback called when the task is successful
  151960. */
  151961. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  151962. /**
  151963. * Creates a new TextureAssetTask object
  151964. * @param name defines the name of the task
  151965. * @param url defines the location of the file to load
  151966. * @param noMipmap defines if mipmap should not be generated (default is false)
  151967. * @param invertY defines if texture must be inverted on Y axis (default is true)
  151968. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  151969. */
  151970. constructor(
  151971. /**
  151972. * Defines the name of the task
  151973. */
  151974. name: string,
  151975. /**
  151976. * Defines the location of the file to load
  151977. */
  151978. url: string,
  151979. /**
  151980. * Defines if mipmap should not be generated (default is false)
  151981. */
  151982. noMipmap?: boolean | undefined,
  151983. /**
  151984. * Defines if texture must be inverted on Y axis (default is true)
  151985. */
  151986. invertY?: boolean,
  151987. /**
  151988. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  151989. */
  151990. samplingMode?: number);
  151991. /**
  151992. * Execute the current task
  151993. * @param scene defines the scene where you want your assets to be loaded
  151994. * @param onSuccess is a callback called when the task is successfully executed
  151995. * @param onError is a callback called if an error occurs
  151996. */
  151997. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151998. }
  151999. /**
  152000. * Define a task used by AssetsManager to load cube textures
  152001. */
  152002. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  152003. /**
  152004. * Defines the name of the task
  152005. */
  152006. name: string;
  152007. /**
  152008. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  152009. */
  152010. url: string;
  152011. /**
  152012. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  152013. */
  152014. extensions?: string[] | undefined;
  152015. /**
  152016. * Defines if mipmaps should not be generated (default is false)
  152017. */
  152018. noMipmap?: boolean | undefined;
  152019. /**
  152020. * Defines the explicit list of files (undefined by default)
  152021. */
  152022. files?: string[] | undefined;
  152023. /**
  152024. * Gets the loaded texture
  152025. */
  152026. texture: CubeTexture;
  152027. /**
  152028. * Callback called when the task is successful
  152029. */
  152030. onSuccess: (task: CubeTextureAssetTask) => void;
  152031. /**
  152032. * Callback called when the task is successful
  152033. */
  152034. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  152035. /**
  152036. * Creates a new CubeTextureAssetTask
  152037. * @param name defines the name of the task
  152038. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  152039. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  152040. * @param noMipmap defines if mipmaps should not be generated (default is false)
  152041. * @param files defines the explicit list of files (undefined by default)
  152042. */
  152043. constructor(
  152044. /**
  152045. * Defines the name of the task
  152046. */
  152047. name: string,
  152048. /**
  152049. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  152050. */
  152051. url: string,
  152052. /**
  152053. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  152054. */
  152055. extensions?: string[] | undefined,
  152056. /**
  152057. * Defines if mipmaps should not be generated (default is false)
  152058. */
  152059. noMipmap?: boolean | undefined,
  152060. /**
  152061. * Defines the explicit list of files (undefined by default)
  152062. */
  152063. files?: string[] | undefined);
  152064. /**
  152065. * Execute the current task
  152066. * @param scene defines the scene where you want your assets to be loaded
  152067. * @param onSuccess is a callback called when the task is successfully executed
  152068. * @param onError is a callback called if an error occurs
  152069. */
  152070. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152071. }
  152072. /**
  152073. * Define a task used by AssetsManager to load HDR cube textures
  152074. */
  152075. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  152076. /**
  152077. * Defines the name of the task
  152078. */
  152079. name: string;
  152080. /**
  152081. * Defines the location of the file to load
  152082. */
  152083. url: string;
  152084. /**
  152085. * Defines the desired size (the more it increases the longer the generation will be)
  152086. */
  152087. size: number;
  152088. /**
  152089. * Defines if mipmaps should not be generated (default is false)
  152090. */
  152091. noMipmap: boolean;
  152092. /**
  152093. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  152094. */
  152095. generateHarmonics: boolean;
  152096. /**
  152097. * 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)
  152098. */
  152099. gammaSpace: boolean;
  152100. /**
  152101. * Internal Use Only
  152102. */
  152103. reserved: boolean;
  152104. /**
  152105. * Gets the loaded texture
  152106. */
  152107. texture: HDRCubeTexture;
  152108. /**
  152109. * Callback called when the task is successful
  152110. */
  152111. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  152112. /**
  152113. * Callback called when the task is successful
  152114. */
  152115. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  152116. /**
  152117. * Creates a new HDRCubeTextureAssetTask object
  152118. * @param name defines the name of the task
  152119. * @param url defines the location of the file to load
  152120. * @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.
  152121. * @param noMipmap defines if mipmaps should not be generated (default is false)
  152122. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  152123. * @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)
  152124. * @param reserved Internal use only
  152125. */
  152126. constructor(
  152127. /**
  152128. * Defines the name of the task
  152129. */
  152130. name: string,
  152131. /**
  152132. * Defines the location of the file to load
  152133. */
  152134. url: string,
  152135. /**
  152136. * Defines the desired size (the more it increases the longer the generation will be)
  152137. */
  152138. size: number,
  152139. /**
  152140. * Defines if mipmaps should not be generated (default is false)
  152141. */
  152142. noMipmap?: boolean,
  152143. /**
  152144. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  152145. */
  152146. generateHarmonics?: boolean,
  152147. /**
  152148. * 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)
  152149. */
  152150. gammaSpace?: boolean,
  152151. /**
  152152. * Internal Use Only
  152153. */
  152154. reserved?: boolean);
  152155. /**
  152156. * Execute the current task
  152157. * @param scene defines the scene where you want your assets to be loaded
  152158. * @param onSuccess is a callback called when the task is successfully executed
  152159. * @param onError is a callback called if an error occurs
  152160. */
  152161. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152162. }
  152163. /**
  152164. * Define a task used by AssetsManager to load Equirectangular cube textures
  152165. */
  152166. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  152167. /**
  152168. * Defines the name of the task
  152169. */
  152170. name: string;
  152171. /**
  152172. * Defines the location of the file to load
  152173. */
  152174. url: string;
  152175. /**
  152176. * Defines the desired size (the more it increases the longer the generation will be)
  152177. */
  152178. size: number;
  152179. /**
  152180. * Defines if mipmaps should not be generated (default is false)
  152181. */
  152182. noMipmap: boolean;
  152183. /**
  152184. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  152185. * but the standard material would require them in Gamma space) (default is true)
  152186. */
  152187. gammaSpace: boolean;
  152188. /**
  152189. * Gets the loaded texture
  152190. */
  152191. texture: EquiRectangularCubeTexture;
  152192. /**
  152193. * Callback called when the task is successful
  152194. */
  152195. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  152196. /**
  152197. * Callback called when the task is successful
  152198. */
  152199. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  152200. /**
  152201. * Creates a new EquiRectangularCubeTextureAssetTask object
  152202. * @param name defines the name of the task
  152203. * @param url defines the location of the file to load
  152204. * @param size defines the desired size (the more it increases the longer the generation will be)
  152205. * If the size is omitted this implies you are using a preprocessed cubemap.
  152206. * @param noMipmap defines if mipmaps should not be generated (default is false)
  152207. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  152208. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  152209. * (default is true)
  152210. */
  152211. constructor(
  152212. /**
  152213. * Defines the name of the task
  152214. */
  152215. name: string,
  152216. /**
  152217. * Defines the location of the file to load
  152218. */
  152219. url: string,
  152220. /**
  152221. * Defines the desired size (the more it increases the longer the generation will be)
  152222. */
  152223. size: number,
  152224. /**
  152225. * Defines if mipmaps should not be generated (default is false)
  152226. */
  152227. noMipmap?: boolean,
  152228. /**
  152229. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  152230. * but the standard material would require them in Gamma space) (default is true)
  152231. */
  152232. gammaSpace?: boolean);
  152233. /**
  152234. * Execute the current task
  152235. * @param scene defines the scene where you want your assets to be loaded
  152236. * @param onSuccess is a callback called when the task is successfully executed
  152237. * @param onError is a callback called if an error occurs
  152238. */
  152239. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152240. }
  152241. /**
  152242. * This class can be used to easily import assets into a scene
  152243. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  152244. */
  152245. export class AssetsManager {
  152246. private _scene;
  152247. private _isLoading;
  152248. protected _tasks: AbstractAssetTask[];
  152249. protected _waitingTasksCount: number;
  152250. protected _totalTasksCount: number;
  152251. /**
  152252. * Callback called when all tasks are processed
  152253. */
  152254. onFinish: (tasks: AbstractAssetTask[]) => void;
  152255. /**
  152256. * Callback called when a task is successful
  152257. */
  152258. onTaskSuccess: (task: AbstractAssetTask) => void;
  152259. /**
  152260. * Callback called when a task had an error
  152261. */
  152262. onTaskError: (task: AbstractAssetTask) => void;
  152263. /**
  152264. * Callback called when a task is done (whatever the result is)
  152265. */
  152266. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  152267. /**
  152268. * Observable called when all tasks are processed
  152269. */
  152270. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  152271. /**
  152272. * Observable called when a task had an error
  152273. */
  152274. onTaskErrorObservable: Observable<AbstractAssetTask>;
  152275. /**
  152276. * Observable called when all tasks were executed
  152277. */
  152278. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  152279. /**
  152280. * Observable called when a task is done (whatever the result is)
  152281. */
  152282. onProgressObservable: Observable<IAssetsProgressEvent>;
  152283. /**
  152284. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  152285. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  152286. */
  152287. useDefaultLoadingScreen: boolean;
  152288. /**
  152289. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  152290. * when all assets have been downloaded.
  152291. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  152292. */
  152293. autoHideLoadingUI: boolean;
  152294. /**
  152295. * Creates a new AssetsManager
  152296. * @param scene defines the scene to work on
  152297. */
  152298. constructor(scene: Scene);
  152299. /**
  152300. * Add a ContainerAssetTask to the list of active tasks
  152301. * @param taskName defines the name of the new task
  152302. * @param meshesNames defines the name of meshes to load
  152303. * @param rootUrl defines the root url to use to locate files
  152304. * @param sceneFilename defines the filename of the scene file
  152305. * @returns a new ContainerAssetTask object
  152306. */
  152307. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  152308. /**
  152309. * Add a MeshAssetTask to the list of active tasks
  152310. * @param taskName defines the name of the new task
  152311. * @param meshesNames defines the name of meshes to load
  152312. * @param rootUrl defines the root url to use to locate files
  152313. * @param sceneFilename defines the filename of the scene file
  152314. * @returns a new MeshAssetTask object
  152315. */
  152316. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  152317. /**
  152318. * Add a TextFileAssetTask to the list of active tasks
  152319. * @param taskName defines the name of the new task
  152320. * @param url defines the url of the file to load
  152321. * @returns a new TextFileAssetTask object
  152322. */
  152323. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  152324. /**
  152325. * Add a BinaryFileAssetTask to the list of active tasks
  152326. * @param taskName defines the name of the new task
  152327. * @param url defines the url of the file to load
  152328. * @returns a new BinaryFileAssetTask object
  152329. */
  152330. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  152331. /**
  152332. * Add a ImageAssetTask to the list of active tasks
  152333. * @param taskName defines the name of the new task
  152334. * @param url defines the url of the file to load
  152335. * @returns a new ImageAssetTask object
  152336. */
  152337. addImageTask(taskName: string, url: string): ImageAssetTask;
  152338. /**
  152339. * Add a TextureAssetTask to the list of active tasks
  152340. * @param taskName defines the name of the new task
  152341. * @param url defines the url of the file to load
  152342. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  152343. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  152344. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  152345. * @returns a new TextureAssetTask object
  152346. */
  152347. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  152348. /**
  152349. * Add a CubeTextureAssetTask to the list of active tasks
  152350. * @param taskName defines the name of the new task
  152351. * @param url defines the url of the file to load
  152352. * @param extensions defines the extension to use to load the cube map (can be null)
  152353. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  152354. * @param files defines the list of files to load (can be null)
  152355. * @returns a new CubeTextureAssetTask object
  152356. */
  152357. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  152358. /**
  152359. *
  152360. * Add a HDRCubeTextureAssetTask to the list of active tasks
  152361. * @param taskName defines the name of the new task
  152362. * @param url defines the url of the file to load
  152363. * @param size defines the size you want for the cubemap (can be null)
  152364. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  152365. * @param generateHarmonics defines if you want to automatically generate (true by default)
  152366. * @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)
  152367. * @param reserved Internal use only
  152368. * @returns a new HDRCubeTextureAssetTask object
  152369. */
  152370. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  152371. /**
  152372. *
  152373. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  152374. * @param taskName defines the name of the new task
  152375. * @param url defines the url of the file to load
  152376. * @param size defines the size you want for the cubemap (can be null)
  152377. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  152378. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  152379. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  152380. * @returns a new EquiRectangularCubeTextureAssetTask object
  152381. */
  152382. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  152383. /**
  152384. * Remove a task from the assets manager.
  152385. * @param task the task to remove
  152386. */
  152387. removeTask(task: AbstractAssetTask): void;
  152388. private _decreaseWaitingTasksCount;
  152389. private _runTask;
  152390. /**
  152391. * Reset the AssetsManager and remove all tasks
  152392. * @return the current instance of the AssetsManager
  152393. */
  152394. reset(): AssetsManager;
  152395. /**
  152396. * Start the loading process
  152397. * @return the current instance of the AssetsManager
  152398. */
  152399. load(): AssetsManager;
  152400. /**
  152401. * Start the loading process as an async operation
  152402. * @return a promise returning the list of failed tasks
  152403. */
  152404. loadAsync(): Promise<void>;
  152405. }
  152406. }
  152407. declare module BABYLON {
  152408. /**
  152409. * Wrapper class for promise with external resolve and reject.
  152410. */
  152411. export class Deferred<T> {
  152412. /**
  152413. * The promise associated with this deferred object.
  152414. */
  152415. readonly promise: Promise<T>;
  152416. private _resolve;
  152417. private _reject;
  152418. /**
  152419. * The resolve method of the promise associated with this deferred object.
  152420. */
  152421. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  152422. /**
  152423. * The reject method of the promise associated with this deferred object.
  152424. */
  152425. get reject(): (reason?: any) => void;
  152426. /**
  152427. * Constructor for this deferred object.
  152428. */
  152429. constructor();
  152430. }
  152431. }
  152432. declare module BABYLON {
  152433. /**
  152434. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  152435. */
  152436. export class MeshExploder {
  152437. private _centerMesh;
  152438. private _meshes;
  152439. private _meshesOrigins;
  152440. private _toCenterVectors;
  152441. private _scaledDirection;
  152442. private _newPosition;
  152443. private _centerPosition;
  152444. /**
  152445. * Explodes meshes from a center mesh.
  152446. * @param meshes The meshes to explode.
  152447. * @param centerMesh The mesh to be center of explosion.
  152448. */
  152449. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  152450. private _setCenterMesh;
  152451. /**
  152452. * Get class name
  152453. * @returns "MeshExploder"
  152454. */
  152455. getClassName(): string;
  152456. /**
  152457. * "Exploded meshes"
  152458. * @returns Array of meshes with the centerMesh at index 0.
  152459. */
  152460. getMeshes(): Array<Mesh>;
  152461. /**
  152462. * Explodes meshes giving a specific direction
  152463. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  152464. */
  152465. explode(direction?: number): void;
  152466. }
  152467. }
  152468. declare module BABYLON {
  152469. /**
  152470. * Class used to help managing file picking and drag'n'drop
  152471. */
  152472. export class FilesInput {
  152473. /**
  152474. * List of files ready to be loaded
  152475. */
  152476. static get FilesToLoad(): {
  152477. [key: string]: File;
  152478. };
  152479. /**
  152480. * Callback called when a file is processed
  152481. */
  152482. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  152483. private _engine;
  152484. private _currentScene;
  152485. private _sceneLoadedCallback;
  152486. private _progressCallback;
  152487. private _additionalRenderLoopLogicCallback;
  152488. private _textureLoadingCallback;
  152489. private _startingProcessingFilesCallback;
  152490. private _onReloadCallback;
  152491. private _errorCallback;
  152492. private _elementToMonitor;
  152493. private _sceneFileToLoad;
  152494. private _filesToLoad;
  152495. /**
  152496. * Creates a new FilesInput
  152497. * @param engine defines the rendering engine
  152498. * @param scene defines the hosting scene
  152499. * @param sceneLoadedCallback callback called when scene is loaded
  152500. * @param progressCallback callback called to track progress
  152501. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  152502. * @param textureLoadingCallback callback called when a texture is loading
  152503. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  152504. * @param onReloadCallback callback called when a reload is requested
  152505. * @param errorCallback callback call if an error occurs
  152506. */
  152507. 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>);
  152508. private _dragEnterHandler;
  152509. private _dragOverHandler;
  152510. private _dropHandler;
  152511. /**
  152512. * Calls this function to listen to drag'n'drop events on a specific DOM element
  152513. * @param elementToMonitor defines the DOM element to track
  152514. */
  152515. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  152516. /** Gets the current list of files to load */
  152517. get filesToLoad(): File[];
  152518. /**
  152519. * Release all associated resources
  152520. */
  152521. dispose(): void;
  152522. private renderFunction;
  152523. private drag;
  152524. private drop;
  152525. private _traverseFolder;
  152526. private _processFiles;
  152527. /**
  152528. * Load files from a drop event
  152529. * @param event defines the drop event to use as source
  152530. */
  152531. loadFiles(event: any): void;
  152532. private _processReload;
  152533. /**
  152534. * Reload the current scene from the loaded files
  152535. */
  152536. reload(): void;
  152537. }
  152538. }
  152539. declare module BABYLON {
  152540. /**
  152541. * Defines the root class used to create scene optimization to use with SceneOptimizer
  152542. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  152543. */
  152544. export class SceneOptimization {
  152545. /**
  152546. * Defines the priority of this optimization (0 by default which means first in the list)
  152547. */
  152548. priority: number;
  152549. /**
  152550. * Gets a string describing the action executed by the current optimization
  152551. * @returns description string
  152552. */
  152553. getDescription(): string;
  152554. /**
  152555. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  152556. * @param scene defines the current scene where to apply this optimization
  152557. * @param optimizer defines the current optimizer
  152558. * @returns true if everything that can be done was applied
  152559. */
  152560. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  152561. /**
  152562. * Creates the SceneOptimization object
  152563. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  152564. * @param desc defines the description associated with the optimization
  152565. */
  152566. constructor(
  152567. /**
  152568. * Defines the priority of this optimization (0 by default which means first in the list)
  152569. */
  152570. priority?: number);
  152571. }
  152572. /**
  152573. * Defines an optimization used to reduce the size of render target textures
  152574. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  152575. */
  152576. export class TextureOptimization extends SceneOptimization {
  152577. /**
  152578. * Defines the priority of this optimization (0 by default which means first in the list)
  152579. */
  152580. priority: number;
  152581. /**
  152582. * 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
  152583. */
  152584. maximumSize: number;
  152585. /**
  152586. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  152587. */
  152588. step: number;
  152589. /**
  152590. * Gets a string describing the action executed by the current optimization
  152591. * @returns description string
  152592. */
  152593. getDescription(): string;
  152594. /**
  152595. * Creates the TextureOptimization object
  152596. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  152597. * @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
  152598. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  152599. */
  152600. constructor(
  152601. /**
  152602. * Defines the priority of this optimization (0 by default which means first in the list)
  152603. */
  152604. priority?: number,
  152605. /**
  152606. * 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
  152607. */
  152608. maximumSize?: number,
  152609. /**
  152610. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  152611. */
  152612. step?: number);
  152613. /**
  152614. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  152615. * @param scene defines the current scene where to apply this optimization
  152616. * @param optimizer defines the current optimizer
  152617. * @returns true if everything that can be done was applied
  152618. */
  152619. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  152620. }
  152621. /**
  152622. * Defines an optimization used to increase or decrease the rendering resolution
  152623. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  152624. */
  152625. export class HardwareScalingOptimization extends SceneOptimization {
  152626. /**
  152627. * Defines the priority of this optimization (0 by default which means first in the list)
  152628. */
  152629. priority: number;
  152630. /**
  152631. * Defines the maximum scale to use (2 by default)
  152632. */
  152633. maximumScale: number;
  152634. /**
  152635. * Defines the step to use between two passes (0.5 by default)
  152636. */
  152637. step: number;
  152638. private _currentScale;
  152639. private _directionOffset;
  152640. /**
  152641. * Gets a string describing the action executed by the current optimization
  152642. * @return description string
  152643. */
  152644. getDescription(): string;
  152645. /**
  152646. * Creates the HardwareScalingOptimization object
  152647. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  152648. * @param maximumScale defines the maximum scale to use (2 by default)
  152649. * @param step defines the step to use between two passes (0.5 by default)
  152650. */
  152651. constructor(
  152652. /**
  152653. * Defines the priority of this optimization (0 by default which means first in the list)
  152654. */
  152655. priority?: number,
  152656. /**
  152657. * Defines the maximum scale to use (2 by default)
  152658. */
  152659. maximumScale?: number,
  152660. /**
  152661. * Defines the step to use between two passes (0.5 by default)
  152662. */
  152663. step?: number);
  152664. /**
  152665. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  152666. * @param scene defines the current scene where to apply this optimization
  152667. * @param optimizer defines the current optimizer
  152668. * @returns true if everything that can be done was applied
  152669. */
  152670. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  152671. }
  152672. /**
  152673. * Defines an optimization used to remove shadows
  152674. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  152675. */
  152676. export class ShadowsOptimization extends SceneOptimization {
  152677. /**
  152678. * Gets a string describing the action executed by the current optimization
  152679. * @return description string
  152680. */
  152681. getDescription(): string;
  152682. /**
  152683. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  152684. * @param scene defines the current scene where to apply this optimization
  152685. * @param optimizer defines the current optimizer
  152686. * @returns true if everything that can be done was applied
  152687. */
  152688. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  152689. }
  152690. /**
  152691. * Defines an optimization used to turn post-processes off
  152692. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  152693. */
  152694. export class PostProcessesOptimization extends SceneOptimization {
  152695. /**
  152696. * Gets a string describing the action executed by the current optimization
  152697. * @return description string
  152698. */
  152699. getDescription(): string;
  152700. /**
  152701. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  152702. * @param scene defines the current scene where to apply this optimization
  152703. * @param optimizer defines the current optimizer
  152704. * @returns true if everything that can be done was applied
  152705. */
  152706. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  152707. }
  152708. /**
  152709. * Defines an optimization used to turn lens flares off
  152710. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  152711. */
  152712. export class LensFlaresOptimization extends SceneOptimization {
  152713. /**
  152714. * Gets a string describing the action executed by the current optimization
  152715. * @return description string
  152716. */
  152717. getDescription(): string;
  152718. /**
  152719. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  152720. * @param scene defines the current scene where to apply this optimization
  152721. * @param optimizer defines the current optimizer
  152722. * @returns true if everything that can be done was applied
  152723. */
  152724. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  152725. }
  152726. /**
  152727. * Defines an optimization based on user defined callback.
  152728. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  152729. */
  152730. export class CustomOptimization extends SceneOptimization {
  152731. /**
  152732. * Callback called to apply the custom optimization.
  152733. */
  152734. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  152735. /**
  152736. * Callback called to get custom description
  152737. */
  152738. onGetDescription: () => string;
  152739. /**
  152740. * Gets a string describing the action executed by the current optimization
  152741. * @returns description string
  152742. */
  152743. getDescription(): string;
  152744. /**
  152745. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  152746. * @param scene defines the current scene where to apply this optimization
  152747. * @param optimizer defines the current optimizer
  152748. * @returns true if everything that can be done was applied
  152749. */
  152750. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  152751. }
  152752. /**
  152753. * Defines an optimization used to turn particles off
  152754. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  152755. */
  152756. export class ParticlesOptimization extends SceneOptimization {
  152757. /**
  152758. * Gets a string describing the action executed by the current optimization
  152759. * @return description string
  152760. */
  152761. getDescription(): string;
  152762. /**
  152763. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  152764. * @param scene defines the current scene where to apply this optimization
  152765. * @param optimizer defines the current optimizer
  152766. * @returns true if everything that can be done was applied
  152767. */
  152768. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  152769. }
  152770. /**
  152771. * Defines an optimization used to turn render targets off
  152772. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  152773. */
  152774. export class RenderTargetsOptimization extends SceneOptimization {
  152775. /**
  152776. * Gets a string describing the action executed by the current optimization
  152777. * @return description string
  152778. */
  152779. getDescription(): string;
  152780. /**
  152781. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  152782. * @param scene defines the current scene where to apply this optimization
  152783. * @param optimizer defines the current optimizer
  152784. * @returns true if everything that can be done was applied
  152785. */
  152786. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  152787. }
  152788. /**
  152789. * Defines an optimization used to merge meshes with compatible materials
  152790. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  152791. */
  152792. export class MergeMeshesOptimization extends SceneOptimization {
  152793. private static _UpdateSelectionTree;
  152794. /**
  152795. * Gets or sets a boolean which defines if optimization octree has to be updated
  152796. */
  152797. static get UpdateSelectionTree(): boolean;
  152798. /**
  152799. * Gets or sets a boolean which defines if optimization octree has to be updated
  152800. */
  152801. static set UpdateSelectionTree(value: boolean);
  152802. /**
  152803. * Gets a string describing the action executed by the current optimization
  152804. * @return description string
  152805. */
  152806. getDescription(): string;
  152807. private _canBeMerged;
  152808. /**
  152809. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  152810. * @param scene defines the current scene where to apply this optimization
  152811. * @param optimizer defines the current optimizer
  152812. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  152813. * @returns true if everything that can be done was applied
  152814. */
  152815. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  152816. }
  152817. /**
  152818. * Defines a list of options used by SceneOptimizer
  152819. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  152820. */
  152821. export class SceneOptimizerOptions {
  152822. /**
  152823. * Defines the target frame rate to reach (60 by default)
  152824. */
  152825. targetFrameRate: number;
  152826. /**
  152827. * Defines the interval between two checkes (2000ms by default)
  152828. */
  152829. trackerDuration: number;
  152830. /**
  152831. * Gets the list of optimizations to apply
  152832. */
  152833. optimizations: SceneOptimization[];
  152834. /**
  152835. * Creates a new list of options used by SceneOptimizer
  152836. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  152837. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  152838. */
  152839. constructor(
  152840. /**
  152841. * Defines the target frame rate to reach (60 by default)
  152842. */
  152843. targetFrameRate?: number,
  152844. /**
  152845. * Defines the interval between two checkes (2000ms by default)
  152846. */
  152847. trackerDuration?: number);
  152848. /**
  152849. * Add a new optimization
  152850. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  152851. * @returns the current SceneOptimizerOptions
  152852. */
  152853. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  152854. /**
  152855. * Add a new custom optimization
  152856. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  152857. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  152858. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  152859. * @returns the current SceneOptimizerOptions
  152860. */
  152861. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  152862. /**
  152863. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  152864. * @param targetFrameRate defines the target frame rate (60 by default)
  152865. * @returns a SceneOptimizerOptions object
  152866. */
  152867. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  152868. /**
  152869. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  152870. * @param targetFrameRate defines the target frame rate (60 by default)
  152871. * @returns a SceneOptimizerOptions object
  152872. */
  152873. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  152874. /**
  152875. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  152876. * @param targetFrameRate defines the target frame rate (60 by default)
  152877. * @returns a SceneOptimizerOptions object
  152878. */
  152879. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  152880. }
  152881. /**
  152882. * Class used to run optimizations in order to reach a target frame rate
  152883. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  152884. */
  152885. export class SceneOptimizer implements IDisposable {
  152886. private _isRunning;
  152887. private _options;
  152888. private _scene;
  152889. private _currentPriorityLevel;
  152890. private _targetFrameRate;
  152891. private _trackerDuration;
  152892. private _currentFrameRate;
  152893. private _sceneDisposeObserver;
  152894. private _improvementMode;
  152895. /**
  152896. * Defines an observable called when the optimizer reaches the target frame rate
  152897. */
  152898. onSuccessObservable: Observable<SceneOptimizer>;
  152899. /**
  152900. * Defines an observable called when the optimizer enables an optimization
  152901. */
  152902. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  152903. /**
  152904. * Defines an observable called when the optimizer is not able to reach the target frame rate
  152905. */
  152906. onFailureObservable: Observable<SceneOptimizer>;
  152907. /**
  152908. * Gets a boolean indicating if the optimizer is in improvement mode
  152909. */
  152910. get isInImprovementMode(): boolean;
  152911. /**
  152912. * Gets the current priority level (0 at start)
  152913. */
  152914. get currentPriorityLevel(): number;
  152915. /**
  152916. * Gets the current frame rate checked by the SceneOptimizer
  152917. */
  152918. get currentFrameRate(): number;
  152919. /**
  152920. * Gets or sets the current target frame rate (60 by default)
  152921. */
  152922. get targetFrameRate(): number;
  152923. /**
  152924. * Gets or sets the current target frame rate (60 by default)
  152925. */
  152926. set targetFrameRate(value: number);
  152927. /**
  152928. * Gets or sets the current interval between two checks (every 2000ms by default)
  152929. */
  152930. get trackerDuration(): number;
  152931. /**
  152932. * Gets or sets the current interval between two checks (every 2000ms by default)
  152933. */
  152934. set trackerDuration(value: number);
  152935. /**
  152936. * Gets the list of active optimizations
  152937. */
  152938. get optimizations(): SceneOptimization[];
  152939. /**
  152940. * Creates a new SceneOptimizer
  152941. * @param scene defines the scene to work on
  152942. * @param options defines the options to use with the SceneOptimizer
  152943. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  152944. * @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)
  152945. */
  152946. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  152947. /**
  152948. * Stops the current optimizer
  152949. */
  152950. stop(): void;
  152951. /**
  152952. * Reset the optimizer to initial step (current priority level = 0)
  152953. */
  152954. reset(): void;
  152955. /**
  152956. * Start the optimizer. By default it will try to reach a specific framerate
  152957. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  152958. */
  152959. start(): void;
  152960. private _checkCurrentState;
  152961. /**
  152962. * Release all resources
  152963. */
  152964. dispose(): void;
  152965. /**
  152966. * Helper function to create a SceneOptimizer with one single line of code
  152967. * @param scene defines the scene to work on
  152968. * @param options defines the options to use with the SceneOptimizer
  152969. * @param onSuccess defines a callback to call on success
  152970. * @param onFailure defines a callback to call on failure
  152971. * @returns the new SceneOptimizer object
  152972. */
  152973. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  152974. }
  152975. }
  152976. declare module BABYLON {
  152977. /**
  152978. * Class used to serialize a scene into a string
  152979. */
  152980. export class SceneSerializer {
  152981. /**
  152982. * Clear cache used by a previous serialization
  152983. */
  152984. static ClearCache(): void;
  152985. /**
  152986. * Serialize a scene into a JSON compatible object
  152987. * @param scene defines the scene to serialize
  152988. * @returns a JSON compatible object
  152989. */
  152990. static Serialize(scene: Scene): any;
  152991. /**
  152992. * Serialize a mesh into a JSON compatible object
  152993. * @param toSerialize defines the mesh to serialize
  152994. * @param withParents defines if parents must be serialized as well
  152995. * @param withChildren defines if children must be serialized as well
  152996. * @returns a JSON compatible object
  152997. */
  152998. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  152999. }
  153000. }
  153001. declare module BABYLON {
  153002. /**
  153003. * Class used to host texture specific utilities
  153004. */
  153005. export class TextureTools {
  153006. /**
  153007. * Uses the GPU to create a copy texture rescaled at a given size
  153008. * @param texture Texture to copy from
  153009. * @param width defines the desired width
  153010. * @param height defines the desired height
  153011. * @param useBilinearMode defines if bilinear mode has to be used
  153012. * @return the generated texture
  153013. */
  153014. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  153015. }
  153016. }
  153017. declare module BABYLON {
  153018. /**
  153019. * This represents the different options available for the video capture.
  153020. */
  153021. export interface VideoRecorderOptions {
  153022. /** Defines the mime type of the video. */
  153023. mimeType: string;
  153024. /** Defines the FPS the video should be recorded at. */
  153025. fps: number;
  153026. /** Defines the chunk size for the recording data. */
  153027. recordChunckSize: number;
  153028. /** The audio tracks to attach to the recording. */
  153029. audioTracks?: MediaStreamTrack[];
  153030. }
  153031. /**
  153032. * This can help with recording videos from BabylonJS.
  153033. * This is based on the available WebRTC functionalities of the browser.
  153034. *
  153035. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  153036. */
  153037. export class VideoRecorder {
  153038. private static readonly _defaultOptions;
  153039. /**
  153040. * Returns whether or not the VideoRecorder is available in your browser.
  153041. * @param engine Defines the Babylon Engine.
  153042. * @returns true if supported otherwise false.
  153043. */
  153044. static IsSupported(engine: Engine): boolean;
  153045. private readonly _options;
  153046. private _canvas;
  153047. private _mediaRecorder;
  153048. private _recordedChunks;
  153049. private _fileName;
  153050. private _resolve;
  153051. private _reject;
  153052. /**
  153053. * True when a recording is already in progress.
  153054. */
  153055. get isRecording(): boolean;
  153056. /**
  153057. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  153058. * @param engine Defines the BabylonJS Engine you wish to record.
  153059. * @param options Defines options that can be used to customize the capture.
  153060. */
  153061. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  153062. /**
  153063. * Stops the current recording before the default capture timeout passed in the startRecording function.
  153064. */
  153065. stopRecording(): void;
  153066. /**
  153067. * Starts recording the canvas for a max duration specified in parameters.
  153068. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  153069. * If null no automatic download will start and you can rely on the promise to get the data back.
  153070. * @param maxDuration Defines the maximum recording time in seconds.
  153071. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  153072. * @return A promise callback at the end of the recording with the video data in Blob.
  153073. */
  153074. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  153075. /**
  153076. * Releases internal resources used during the recording.
  153077. */
  153078. dispose(): void;
  153079. private _handleDataAvailable;
  153080. private _handleError;
  153081. private _handleStop;
  153082. }
  153083. }
  153084. declare module BABYLON {
  153085. /**
  153086. * Class containing a set of static utilities functions for screenshots
  153087. */
  153088. export class ScreenshotTools {
  153089. /**
  153090. * Captures a screenshot of the current rendering
  153091. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  153092. * @param engine defines the rendering engine
  153093. * @param camera defines the source camera
  153094. * @param size This parameter can be set to a single number or to an object with the
  153095. * following (optional) properties: precision, width, height. If a single number is passed,
  153096. * it will be used for both width and height. If an object is passed, the screenshot size
  153097. * will be derived from the parameters. The precision property is a multiplier allowing
  153098. * rendering at a higher or lower resolution
  153099. * @param successCallback defines the callback receives a single parameter which contains the
  153100. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  153101. * src parameter of an <img> to display it
  153102. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  153103. * Check your browser for supported MIME types
  153104. */
  153105. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  153106. /**
  153107. * Captures a screenshot of the current rendering
  153108. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  153109. * @param engine defines the rendering engine
  153110. * @param camera defines the source camera
  153111. * @param size This parameter can be set to a single number or to an object with the
  153112. * following (optional) properties: precision, width, height. If a single number is passed,
  153113. * it will be used for both width and height. If an object is passed, the screenshot size
  153114. * will be derived from the parameters. The precision property is a multiplier allowing
  153115. * rendering at a higher or lower resolution
  153116. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  153117. * Check your browser for supported MIME types
  153118. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  153119. * to the src parameter of an <img> to display it
  153120. */
  153121. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  153122. /**
  153123. * Generates an image screenshot from the specified camera.
  153124. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  153125. * @param engine The engine to use for rendering
  153126. * @param camera The camera to use for rendering
  153127. * @param size This parameter can be set to a single number or to an object with the
  153128. * following (optional) properties: precision, width, height. If a single number is passed,
  153129. * it will be used for both width and height. If an object is passed, the screenshot size
  153130. * will be derived from the parameters. The precision property is a multiplier allowing
  153131. * rendering at a higher or lower resolution
  153132. * @param successCallback The callback receives a single parameter which contains the
  153133. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  153134. * src parameter of an <img> to display it
  153135. * @param mimeType The MIME type of the screenshot image (default: image/png).
  153136. * Check your browser for supported MIME types
  153137. * @param samples Texture samples (default: 1)
  153138. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  153139. * @param fileName A name for for the downloaded file.
  153140. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  153141. */
  153142. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  153143. /**
  153144. * Generates an image screenshot from the specified camera.
  153145. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  153146. * @param engine The engine to use for rendering
  153147. * @param camera The camera to use for rendering
  153148. * @param size This parameter can be set to a single number or to an object with the
  153149. * following (optional) properties: precision, width, height. If a single number is passed,
  153150. * it will be used for both width and height. If an object is passed, the screenshot size
  153151. * will be derived from the parameters. The precision property is a multiplier allowing
  153152. * rendering at a higher or lower resolution
  153153. * @param mimeType The MIME type of the screenshot image (default: image/png).
  153154. * Check your browser for supported MIME types
  153155. * @param samples Texture samples (default: 1)
  153156. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  153157. * @param fileName A name for for the downloaded file.
  153158. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  153159. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  153160. * to the src parameter of an <img> to display it
  153161. */
  153162. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  153163. /**
  153164. * Gets height and width for screenshot size
  153165. * @private
  153166. */
  153167. private static _getScreenshotSize;
  153168. }
  153169. }
  153170. declare module BABYLON {
  153171. /**
  153172. * Interface for a data buffer
  153173. */
  153174. export interface IDataBuffer {
  153175. /**
  153176. * Reads bytes from the data buffer.
  153177. * @param byteOffset The byte offset to read
  153178. * @param byteLength The byte length to read
  153179. * @returns A promise that resolves when the bytes are read
  153180. */
  153181. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  153182. /**
  153183. * The byte length of the buffer.
  153184. */
  153185. readonly byteLength: number;
  153186. }
  153187. /**
  153188. * Utility class for reading from a data buffer
  153189. */
  153190. export class DataReader {
  153191. /**
  153192. * The data buffer associated with this data reader.
  153193. */
  153194. readonly buffer: IDataBuffer;
  153195. /**
  153196. * The current byte offset from the beginning of the data buffer.
  153197. */
  153198. byteOffset: number;
  153199. private _dataView;
  153200. private _dataByteOffset;
  153201. /**
  153202. * Constructor
  153203. * @param buffer The buffer to read
  153204. */
  153205. constructor(buffer: IDataBuffer);
  153206. /**
  153207. * Loads the given byte length.
  153208. * @param byteLength The byte length to load
  153209. * @returns A promise that resolves when the load is complete
  153210. */
  153211. loadAsync(byteLength: number): Promise<void>;
  153212. /**
  153213. * Read a unsigned 32-bit integer from the currently loaded data range.
  153214. * @returns The 32-bit integer read
  153215. */
  153216. readUint32(): number;
  153217. /**
  153218. * Read a byte array from the currently loaded data range.
  153219. * @param byteLength The byte length to read
  153220. * @returns The byte array read
  153221. */
  153222. readUint8Array(byteLength: number): Uint8Array;
  153223. /**
  153224. * Read a string from the currently loaded data range.
  153225. * @param byteLength The byte length to read
  153226. * @returns The string read
  153227. */
  153228. readString(byteLength: number): string;
  153229. /**
  153230. * Skips the given byte length the currently loaded data range.
  153231. * @param byteLength The byte length to skip
  153232. */
  153233. skipBytes(byteLength: number): void;
  153234. }
  153235. }
  153236. declare module BABYLON {
  153237. /**
  153238. * Class for storing data to local storage if available or in-memory storage otherwise
  153239. */
  153240. export class DataStorage {
  153241. private static _Storage;
  153242. private static _GetStorage;
  153243. /**
  153244. * Reads a string from the data storage
  153245. * @param key The key to read
  153246. * @param defaultValue The value if the key doesn't exist
  153247. * @returns The string value
  153248. */
  153249. static ReadString(key: string, defaultValue: string): string;
  153250. /**
  153251. * Writes a string to the data storage
  153252. * @param key The key to write
  153253. * @param value The value to write
  153254. */
  153255. static WriteString(key: string, value: string): void;
  153256. /**
  153257. * Reads a boolean from the data storage
  153258. * @param key The key to read
  153259. * @param defaultValue The value if the key doesn't exist
  153260. * @returns The boolean value
  153261. */
  153262. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  153263. /**
  153264. * Writes a boolean to the data storage
  153265. * @param key The key to write
  153266. * @param value The value to write
  153267. */
  153268. static WriteBoolean(key: string, value: boolean): void;
  153269. /**
  153270. * Reads a number from the data storage
  153271. * @param key The key to read
  153272. * @param defaultValue The value if the key doesn't exist
  153273. * @returns The number value
  153274. */
  153275. static ReadNumber(key: string, defaultValue: number): number;
  153276. /**
  153277. * Writes a number to the data storage
  153278. * @param key The key to write
  153279. * @param value The value to write
  153280. */
  153281. static WriteNumber(key: string, value: number): void;
  153282. }
  153283. }
  153284. declare module BABYLON {
  153285. /**
  153286. * Class used to record delta files between 2 scene states
  153287. */
  153288. export class SceneRecorder {
  153289. private _trackedScene;
  153290. private _savedJSON;
  153291. /**
  153292. * Track a given scene. This means the current scene state will be considered the original state
  153293. * @param scene defines the scene to track
  153294. */
  153295. track(scene: Scene): void;
  153296. /**
  153297. * Get the delta between current state and original state
  153298. * @returns a string containing the delta
  153299. */
  153300. getDelta(): any;
  153301. private _compareArray;
  153302. private _compareObjects;
  153303. private _compareCollections;
  153304. private static GetShadowGeneratorById;
  153305. /**
  153306. * Apply a given delta to a given scene
  153307. * @param deltaJSON defines the JSON containing the delta
  153308. * @param scene defines the scene to apply the delta to
  153309. */
  153310. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  153311. private static _ApplyPropertiesToEntity;
  153312. private static _ApplyDeltaForEntity;
  153313. }
  153314. }
  153315. declare module BABYLON {
  153316. /**
  153317. * An interface for all Hit test features
  153318. */
  153319. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  153320. /**
  153321. * Triggered when new babylon (transformed) hit test results are available
  153322. */
  153323. onHitTestResultObservable: Observable<T[]>;
  153324. }
  153325. /**
  153326. * Options used for hit testing
  153327. */
  153328. export interface IWebXRLegacyHitTestOptions {
  153329. /**
  153330. * Only test when user interacted with the scene. Default - hit test every frame
  153331. */
  153332. testOnPointerDownOnly?: boolean;
  153333. /**
  153334. * The node to use to transform the local results to world coordinates
  153335. */
  153336. worldParentNode?: TransformNode;
  153337. }
  153338. /**
  153339. * Interface defining the babylon result of raycasting/hit-test
  153340. */
  153341. export interface IWebXRLegacyHitResult {
  153342. /**
  153343. * Transformation matrix that can be applied to a node that will put it in the hit point location
  153344. */
  153345. transformationMatrix: Matrix;
  153346. /**
  153347. * The native hit test result
  153348. */
  153349. xrHitResult: XRHitResult | XRHitTestResult;
  153350. }
  153351. /**
  153352. * The currently-working hit-test module.
  153353. * Hit test (or Ray-casting) is used to interact with the real world.
  153354. * For further information read here - https://github.com/immersive-web/hit-test
  153355. */
  153356. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  153357. /**
  153358. * options to use when constructing this feature
  153359. */
  153360. readonly options: IWebXRLegacyHitTestOptions;
  153361. private _direction;
  153362. private _mat;
  153363. private _onSelectEnabled;
  153364. private _origin;
  153365. /**
  153366. * The module's name
  153367. */
  153368. static readonly Name: string;
  153369. /**
  153370. * The (Babylon) version of this module.
  153371. * This is an integer representing the implementation version.
  153372. * This number does not correspond to the WebXR specs version
  153373. */
  153374. static readonly Version: number;
  153375. /**
  153376. * Populated with the last native XR Hit Results
  153377. */
  153378. lastNativeXRHitResults: XRHitResult[];
  153379. /**
  153380. * Triggered when new babylon (transformed) hit test results are available
  153381. */
  153382. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  153383. /**
  153384. * Creates a new instance of the (legacy version) hit test feature
  153385. * @param _xrSessionManager an instance of WebXRSessionManager
  153386. * @param options options to use when constructing this feature
  153387. */
  153388. constructor(_xrSessionManager: WebXRSessionManager,
  153389. /**
  153390. * options to use when constructing this feature
  153391. */
  153392. options?: IWebXRLegacyHitTestOptions);
  153393. /**
  153394. * execute a hit test with an XR Ray
  153395. *
  153396. * @param xrSession a native xrSession that will execute this hit test
  153397. * @param xrRay the ray (position and direction) to use for ray-casting
  153398. * @param referenceSpace native XR reference space to use for the hit-test
  153399. * @param filter filter function that will filter the results
  153400. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  153401. */
  153402. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  153403. /**
  153404. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  153405. * @param event the (select) event to use to select with
  153406. * @param referenceSpace the reference space to use for this hit test
  153407. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  153408. */
  153409. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  153410. /**
  153411. * attach this feature
  153412. * Will usually be called by the features manager
  153413. *
  153414. * @returns true if successful.
  153415. */
  153416. attach(): boolean;
  153417. /**
  153418. * detach this feature.
  153419. * Will usually be called by the features manager
  153420. *
  153421. * @returns true if successful.
  153422. */
  153423. detach(): boolean;
  153424. /**
  153425. * Dispose this feature and all of the resources attached
  153426. */
  153427. dispose(): void;
  153428. protected _onXRFrame(frame: XRFrame): void;
  153429. private _onHitTestResults;
  153430. private _onSelect;
  153431. }
  153432. }
  153433. declare module BABYLON {
  153434. /**
  153435. * Options used for hit testing (version 2)
  153436. */
  153437. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  153438. /**
  153439. * Do not create a permanent hit test. Will usually be used when only
  153440. * transient inputs are needed.
  153441. */
  153442. disablePermanentHitTest?: boolean;
  153443. /**
  153444. * Enable transient (for example touch-based) hit test inspections
  153445. */
  153446. enableTransientHitTest?: boolean;
  153447. /**
  153448. * Offset ray for the permanent hit test
  153449. */
  153450. offsetRay?: Vector3;
  153451. /**
  153452. * Offset ray for the transient hit test
  153453. */
  153454. transientOffsetRay?: Vector3;
  153455. /**
  153456. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  153457. */
  153458. useReferenceSpace?: boolean;
  153459. /**
  153460. * Override the default entity type(s) of the hit-test result
  153461. */
  153462. entityTypes?: XRHitTestTrackableType[];
  153463. }
  153464. /**
  153465. * Interface defining the babylon result of hit-test
  153466. */
  153467. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  153468. /**
  153469. * The input source that generated this hit test (if transient)
  153470. */
  153471. inputSource?: XRInputSource;
  153472. /**
  153473. * Is this a transient hit test
  153474. */
  153475. isTransient?: boolean;
  153476. /**
  153477. * Position of the hit test result
  153478. */
  153479. position: Vector3;
  153480. /**
  153481. * Rotation of the hit test result
  153482. */
  153483. rotationQuaternion: Quaternion;
  153484. /**
  153485. * The native hit test result
  153486. */
  153487. xrHitResult: XRHitTestResult;
  153488. }
  153489. /**
  153490. * The currently-working hit-test module.
  153491. * Hit test (or Ray-casting) is used to interact with the real world.
  153492. * For further information read here - https://github.com/immersive-web/hit-test
  153493. *
  153494. * Tested on chrome (mobile) 80.
  153495. */
  153496. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  153497. /**
  153498. * options to use when constructing this feature
  153499. */
  153500. readonly options: IWebXRHitTestOptions;
  153501. private _tmpMat;
  153502. private _tmpPos;
  153503. private _tmpQuat;
  153504. private _transientXrHitTestSource;
  153505. private _xrHitTestSource;
  153506. private initHitTestSource;
  153507. /**
  153508. * The module's name
  153509. */
  153510. static readonly Name: string;
  153511. /**
  153512. * The (Babylon) version of this module.
  153513. * This is an integer representing the implementation version.
  153514. * This number does not correspond to the WebXR specs version
  153515. */
  153516. static readonly Version: number;
  153517. /**
  153518. * When set to true, each hit test will have its own position/rotation objects
  153519. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  153520. * the developers will clone them or copy them as they see fit.
  153521. */
  153522. autoCloneTransformation: boolean;
  153523. /**
  153524. * Triggered when new babylon (transformed) hit test results are available
  153525. */
  153526. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  153527. /**
  153528. * Use this to temporarily pause hit test checks.
  153529. */
  153530. paused: boolean;
  153531. /**
  153532. * Creates a new instance of the hit test feature
  153533. * @param _xrSessionManager an instance of WebXRSessionManager
  153534. * @param options options to use when constructing this feature
  153535. */
  153536. constructor(_xrSessionManager: WebXRSessionManager,
  153537. /**
  153538. * options to use when constructing this feature
  153539. */
  153540. options?: IWebXRHitTestOptions);
  153541. /**
  153542. * attach this feature
  153543. * Will usually be called by the features manager
  153544. *
  153545. * @returns true if successful.
  153546. */
  153547. attach(): boolean;
  153548. /**
  153549. * detach this feature.
  153550. * Will usually be called by the features manager
  153551. *
  153552. * @returns true if successful.
  153553. */
  153554. detach(): boolean;
  153555. /**
  153556. * Dispose this feature and all of the resources attached
  153557. */
  153558. dispose(): void;
  153559. protected _onXRFrame(frame: XRFrame): void;
  153560. private _processWebXRHitTestResult;
  153561. }
  153562. }
  153563. declare module BABYLON {
  153564. /**
  153565. * Configuration options of the anchor system
  153566. */
  153567. export interface IWebXRAnchorSystemOptions {
  153568. /**
  153569. * a node that will be used to convert local to world coordinates
  153570. */
  153571. worldParentNode?: TransformNode;
  153572. /**
  153573. * If set to true a reference of the created anchors will be kept until the next session starts
  153574. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  153575. */
  153576. doNotRemoveAnchorsOnSessionEnded?: boolean;
  153577. }
  153578. /**
  153579. * A babylon container for an XR Anchor
  153580. */
  153581. export interface IWebXRAnchor {
  153582. /**
  153583. * A babylon-assigned ID for this anchor
  153584. */
  153585. id: number;
  153586. /**
  153587. * Transformation matrix to apply to an object attached to this anchor
  153588. */
  153589. transformationMatrix: Matrix;
  153590. /**
  153591. * The native anchor object
  153592. */
  153593. xrAnchor: XRAnchor;
  153594. /**
  153595. * if defined, this object will be constantly updated by the anchor's position and rotation
  153596. */
  153597. attachedNode?: TransformNode;
  153598. }
  153599. /**
  153600. * An implementation of the anchor system for WebXR.
  153601. * For further information see https://github.com/immersive-web/anchors/
  153602. */
  153603. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  153604. private _options;
  153605. private _lastFrameDetected;
  153606. private _trackedAnchors;
  153607. private _referenceSpaceForFrameAnchors;
  153608. private _futureAnchors;
  153609. /**
  153610. * The module's name
  153611. */
  153612. static readonly Name: string;
  153613. /**
  153614. * The (Babylon) version of this module.
  153615. * This is an integer representing the implementation version.
  153616. * This number does not correspond to the WebXR specs version
  153617. */
  153618. static readonly Version: number;
  153619. /**
  153620. * Observers registered here will be executed when a new anchor was added to the session
  153621. */
  153622. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  153623. /**
  153624. * Observers registered here will be executed when an anchor was removed from the session
  153625. */
  153626. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  153627. /**
  153628. * Observers registered here will be executed when an existing anchor updates
  153629. * This can execute N times every frame
  153630. */
  153631. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  153632. /**
  153633. * Set the reference space to use for anchor creation, when not using a hit test.
  153634. * Will default to the session's reference space if not defined
  153635. */
  153636. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  153637. /**
  153638. * constructs a new anchor system
  153639. * @param _xrSessionManager an instance of WebXRSessionManager
  153640. * @param _options configuration object for this feature
  153641. */
  153642. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  153643. private _tmpVector;
  153644. private _tmpQuaternion;
  153645. private _populateTmpTransformation;
  153646. /**
  153647. * Create a new anchor point using a hit test result at a specific point in the scene
  153648. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  153649. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  153650. *
  153651. * @param hitTestResult The hit test result to use for this anchor creation
  153652. * @param position an optional position offset for this anchor
  153653. * @param rotationQuaternion an optional rotation offset for this anchor
  153654. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  153655. */
  153656. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  153657. /**
  153658. * Add a new anchor at a specific position and rotation
  153659. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  153660. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  153661. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  153662. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  153663. *
  153664. * @param position the position in which to add an anchor
  153665. * @param rotationQuaternion an optional rotation for the anchor transformation
  153666. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  153667. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  153668. */
  153669. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  153670. /**
  153671. * detach this feature.
  153672. * Will usually be called by the features manager
  153673. *
  153674. * @returns true if successful.
  153675. */
  153676. detach(): boolean;
  153677. /**
  153678. * Dispose this feature and all of the resources attached
  153679. */
  153680. dispose(): void;
  153681. protected _onXRFrame(frame: XRFrame): void;
  153682. /**
  153683. * avoiding using Array.find for global support.
  153684. * @param xrAnchor the plane to find in the array
  153685. */
  153686. private _findIndexInAnchorArray;
  153687. private _updateAnchorWithXRFrame;
  153688. private _createAnchorAtTransformation;
  153689. }
  153690. }
  153691. declare module BABYLON {
  153692. /**
  153693. * Options used in the plane detector module
  153694. */
  153695. export interface IWebXRPlaneDetectorOptions {
  153696. /**
  153697. * The node to use to transform the local results to world coordinates
  153698. */
  153699. worldParentNode?: TransformNode;
  153700. /**
  153701. * If set to true a reference of the created planes will be kept until the next session starts
  153702. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  153703. */
  153704. doNotRemovePlanesOnSessionEnded?: boolean;
  153705. }
  153706. /**
  153707. * A babylon interface for a WebXR plane.
  153708. * A Plane is actually a polygon, built from N points in space
  153709. *
  153710. * Supported in chrome 79, not supported in canary 81 ATM
  153711. */
  153712. export interface IWebXRPlane {
  153713. /**
  153714. * a babylon-assigned ID for this polygon
  153715. */
  153716. id: number;
  153717. /**
  153718. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  153719. */
  153720. polygonDefinition: Array<Vector3>;
  153721. /**
  153722. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  153723. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  153724. */
  153725. transformationMatrix: Matrix;
  153726. /**
  153727. * the native xr-plane object
  153728. */
  153729. xrPlane: XRPlane;
  153730. }
  153731. /**
  153732. * The plane detector is used to detect planes in the real world when in AR
  153733. * For more information see https://github.com/immersive-web/real-world-geometry/
  153734. */
  153735. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  153736. private _options;
  153737. private _detectedPlanes;
  153738. private _enabled;
  153739. private _lastFrameDetected;
  153740. /**
  153741. * The module's name
  153742. */
  153743. static readonly Name: string;
  153744. /**
  153745. * The (Babylon) version of this module.
  153746. * This is an integer representing the implementation version.
  153747. * This number does not correspond to the WebXR specs version
  153748. */
  153749. static readonly Version: number;
  153750. /**
  153751. * Observers registered here will be executed when a new plane was added to the session
  153752. */
  153753. onPlaneAddedObservable: Observable<IWebXRPlane>;
  153754. /**
  153755. * Observers registered here will be executed when a plane is no longer detected in the session
  153756. */
  153757. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  153758. /**
  153759. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  153760. * This can execute N times every frame
  153761. */
  153762. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  153763. /**
  153764. * construct a new Plane Detector
  153765. * @param _xrSessionManager an instance of xr Session manager
  153766. * @param _options configuration to use when constructing this feature
  153767. */
  153768. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  153769. /**
  153770. * detach this feature.
  153771. * Will usually be called by the features manager
  153772. *
  153773. * @returns true if successful.
  153774. */
  153775. detach(): boolean;
  153776. /**
  153777. * Dispose this feature and all of the resources attached
  153778. */
  153779. dispose(): void;
  153780. protected _onXRFrame(frame: XRFrame): void;
  153781. private _init;
  153782. private _updatePlaneWithXRPlane;
  153783. /**
  153784. * avoiding using Array.find for global support.
  153785. * @param xrPlane the plane to find in the array
  153786. */
  153787. private findIndexInPlaneArray;
  153788. }
  153789. }
  153790. declare module BABYLON {
  153791. /**
  153792. * Options interface for the background remover plugin
  153793. */
  153794. export interface IWebXRBackgroundRemoverOptions {
  153795. /**
  153796. * Further background meshes to disable when entering AR
  153797. */
  153798. backgroundMeshes?: AbstractMesh[];
  153799. /**
  153800. * flags to configure the removal of the environment helper.
  153801. * If not set, the entire background will be removed. If set, flags should be set as well.
  153802. */
  153803. environmentHelperRemovalFlags?: {
  153804. /**
  153805. * Should the skybox be removed (default false)
  153806. */
  153807. skyBox?: boolean;
  153808. /**
  153809. * Should the ground be removed (default false)
  153810. */
  153811. ground?: boolean;
  153812. };
  153813. /**
  153814. * don't disable the environment helper
  153815. */
  153816. ignoreEnvironmentHelper?: boolean;
  153817. }
  153818. /**
  153819. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  153820. */
  153821. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  153822. /**
  153823. * read-only options to be used in this module
  153824. */
  153825. readonly options: IWebXRBackgroundRemoverOptions;
  153826. /**
  153827. * The module's name
  153828. */
  153829. static readonly Name: string;
  153830. /**
  153831. * The (Babylon) version of this module.
  153832. * This is an integer representing the implementation version.
  153833. * This number does not correspond to the WebXR specs version
  153834. */
  153835. static readonly Version: number;
  153836. /**
  153837. * registered observers will be triggered when the background state changes
  153838. */
  153839. onBackgroundStateChangedObservable: Observable<boolean>;
  153840. /**
  153841. * constructs a new background remover module
  153842. * @param _xrSessionManager the session manager for this module
  153843. * @param options read-only options to be used in this module
  153844. */
  153845. constructor(_xrSessionManager: WebXRSessionManager,
  153846. /**
  153847. * read-only options to be used in this module
  153848. */
  153849. options?: IWebXRBackgroundRemoverOptions);
  153850. /**
  153851. * attach this feature
  153852. * Will usually be called by the features manager
  153853. *
  153854. * @returns true if successful.
  153855. */
  153856. attach(): boolean;
  153857. /**
  153858. * detach this feature.
  153859. * Will usually be called by the features manager
  153860. *
  153861. * @returns true if successful.
  153862. */
  153863. detach(): boolean;
  153864. /**
  153865. * Dispose this feature and all of the resources attached
  153866. */
  153867. dispose(): void;
  153868. protected _onXRFrame(_xrFrame: XRFrame): void;
  153869. private _setBackgroundState;
  153870. }
  153871. }
  153872. declare module BABYLON {
  153873. /**
  153874. * Options for the controller physics feature
  153875. */
  153876. export class IWebXRControllerPhysicsOptions {
  153877. /**
  153878. * Should the headset get its own impostor
  153879. */
  153880. enableHeadsetImpostor?: boolean;
  153881. /**
  153882. * Optional parameters for the headset impostor
  153883. */
  153884. headsetImpostorParams?: {
  153885. /**
  153886. * The type of impostor to create. Default is sphere
  153887. */
  153888. impostorType: number;
  153889. /**
  153890. * the size of the impostor. Defaults to 10cm
  153891. */
  153892. impostorSize?: number | {
  153893. width: number;
  153894. height: number;
  153895. depth: number;
  153896. };
  153897. /**
  153898. * Friction definitions
  153899. */
  153900. friction?: number;
  153901. /**
  153902. * Restitution
  153903. */
  153904. restitution?: number;
  153905. };
  153906. /**
  153907. * The physics properties of the future impostors
  153908. */
  153909. physicsProperties?: {
  153910. /**
  153911. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  153912. * Note that this requires a physics engine that supports mesh impostors!
  153913. */
  153914. useControllerMesh?: boolean;
  153915. /**
  153916. * The type of impostor to create. Default is sphere
  153917. */
  153918. impostorType?: number;
  153919. /**
  153920. * the size of the impostor. Defaults to 10cm
  153921. */
  153922. impostorSize?: number | {
  153923. width: number;
  153924. height: number;
  153925. depth: number;
  153926. };
  153927. /**
  153928. * Friction definitions
  153929. */
  153930. friction?: number;
  153931. /**
  153932. * Restitution
  153933. */
  153934. restitution?: number;
  153935. };
  153936. /**
  153937. * the xr input to use with this pointer selection
  153938. */
  153939. xrInput: WebXRInput;
  153940. }
  153941. /**
  153942. * Add physics impostor to your webxr controllers,
  153943. * including naive calculation of their linear and angular velocity
  153944. */
  153945. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  153946. private readonly _options;
  153947. private _attachController;
  153948. private _controllers;
  153949. private _debugMode;
  153950. private _delta;
  153951. private _headsetImpostor?;
  153952. private _headsetMesh?;
  153953. private _lastTimestamp;
  153954. private _tmpQuaternion;
  153955. private _tmpVector;
  153956. /**
  153957. * The module's name
  153958. */
  153959. static readonly Name: string;
  153960. /**
  153961. * The (Babylon) version of this module.
  153962. * This is an integer representing the implementation version.
  153963. * This number does not correspond to the webxr specs version
  153964. */
  153965. static readonly Version: number;
  153966. /**
  153967. * Construct a new Controller Physics Feature
  153968. * @param _xrSessionManager the corresponding xr session manager
  153969. * @param _options options to create this feature with
  153970. */
  153971. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  153972. /**
  153973. * @hidden
  153974. * enable debugging - will show console outputs and the impostor mesh
  153975. */
  153976. _enablePhysicsDebug(): void;
  153977. /**
  153978. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  153979. * @param xrController the controller to add
  153980. */
  153981. addController(xrController: WebXRInputSource): void;
  153982. /**
  153983. * attach this feature
  153984. * Will usually be called by the features manager
  153985. *
  153986. * @returns true if successful.
  153987. */
  153988. attach(): boolean;
  153989. /**
  153990. * detach this feature.
  153991. * Will usually be called by the features manager
  153992. *
  153993. * @returns true if successful.
  153994. */
  153995. detach(): boolean;
  153996. /**
  153997. * Get the headset impostor, if enabled
  153998. * @returns the impostor
  153999. */
  154000. getHeadsetImpostor(): PhysicsImpostor | undefined;
  154001. /**
  154002. * Get the physics impostor of a specific controller.
  154003. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  154004. * @param controller the controller or the controller id of which to get the impostor
  154005. * @returns the impostor or null
  154006. */
  154007. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  154008. /**
  154009. * Update the physics properties provided in the constructor
  154010. * @param newProperties the new properties object
  154011. */
  154012. setPhysicsProperties(newProperties: {
  154013. impostorType?: number;
  154014. impostorSize?: number | {
  154015. width: number;
  154016. height: number;
  154017. depth: number;
  154018. };
  154019. friction?: number;
  154020. restitution?: number;
  154021. }): void;
  154022. protected _onXRFrame(_xrFrame: any): void;
  154023. private _detachController;
  154024. }
  154025. }
  154026. declare module BABYLON {
  154027. /**
  154028. * The motion controller class for all microsoft mixed reality controllers
  154029. */
  154030. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  154031. protected readonly _mapping: {
  154032. defaultButton: {
  154033. valueNodeName: string;
  154034. unpressedNodeName: string;
  154035. pressedNodeName: string;
  154036. };
  154037. defaultAxis: {
  154038. valueNodeName: string;
  154039. minNodeName: string;
  154040. maxNodeName: string;
  154041. };
  154042. buttons: {
  154043. "xr-standard-trigger": {
  154044. rootNodeName: string;
  154045. componentProperty: string;
  154046. states: string[];
  154047. };
  154048. "xr-standard-squeeze": {
  154049. rootNodeName: string;
  154050. componentProperty: string;
  154051. states: string[];
  154052. };
  154053. "xr-standard-touchpad": {
  154054. rootNodeName: string;
  154055. labelAnchorNodeName: string;
  154056. touchPointNodeName: string;
  154057. };
  154058. "xr-standard-thumbstick": {
  154059. rootNodeName: string;
  154060. componentProperty: string;
  154061. states: string[];
  154062. };
  154063. };
  154064. axes: {
  154065. "xr-standard-touchpad": {
  154066. "x-axis": {
  154067. rootNodeName: string;
  154068. };
  154069. "y-axis": {
  154070. rootNodeName: string;
  154071. };
  154072. };
  154073. "xr-standard-thumbstick": {
  154074. "x-axis": {
  154075. rootNodeName: string;
  154076. };
  154077. "y-axis": {
  154078. rootNodeName: string;
  154079. };
  154080. };
  154081. };
  154082. };
  154083. /**
  154084. * The base url used to load the left and right controller models
  154085. */
  154086. static MODEL_BASE_URL: string;
  154087. /**
  154088. * The name of the left controller model file
  154089. */
  154090. static MODEL_LEFT_FILENAME: string;
  154091. /**
  154092. * The name of the right controller model file
  154093. */
  154094. static MODEL_RIGHT_FILENAME: string;
  154095. profileId: string;
  154096. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  154097. protected _getFilenameAndPath(): {
  154098. filename: string;
  154099. path: string;
  154100. };
  154101. protected _getModelLoadingConstraints(): boolean;
  154102. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  154103. protected _setRootMesh(meshes: AbstractMesh[]): void;
  154104. protected _updateModel(): void;
  154105. }
  154106. }
  154107. declare module BABYLON {
  154108. /**
  154109. * The motion controller class for oculus touch (quest, rift).
  154110. * This class supports legacy mapping as well the standard xr mapping
  154111. */
  154112. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  154113. private _forceLegacyControllers;
  154114. private _modelRootNode;
  154115. /**
  154116. * The base url used to load the left and right controller models
  154117. */
  154118. static MODEL_BASE_URL: string;
  154119. /**
  154120. * The name of the left controller model file
  154121. */
  154122. static MODEL_LEFT_FILENAME: string;
  154123. /**
  154124. * The name of the right controller model file
  154125. */
  154126. static MODEL_RIGHT_FILENAME: string;
  154127. /**
  154128. * Base Url for the Quest controller model.
  154129. */
  154130. static QUEST_MODEL_BASE_URL: string;
  154131. profileId: string;
  154132. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  154133. protected _getFilenameAndPath(): {
  154134. filename: string;
  154135. path: string;
  154136. };
  154137. protected _getModelLoadingConstraints(): boolean;
  154138. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  154139. protected _setRootMesh(meshes: AbstractMesh[]): void;
  154140. protected _updateModel(): void;
  154141. /**
  154142. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  154143. * between the touch and touch 2.
  154144. */
  154145. private _isQuest;
  154146. }
  154147. }
  154148. declare module BABYLON {
  154149. /**
  154150. * The motion controller class for the standard HTC-Vive controllers
  154151. */
  154152. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  154153. private _modelRootNode;
  154154. /**
  154155. * The base url used to load the left and right controller models
  154156. */
  154157. static MODEL_BASE_URL: string;
  154158. /**
  154159. * File name for the controller model.
  154160. */
  154161. static MODEL_FILENAME: string;
  154162. profileId: string;
  154163. /**
  154164. * Create a new Vive motion controller object
  154165. * @param scene the scene to use to create this controller
  154166. * @param gamepadObject the corresponding gamepad object
  154167. * @param handedness the handedness of the controller
  154168. */
  154169. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  154170. protected _getFilenameAndPath(): {
  154171. filename: string;
  154172. path: string;
  154173. };
  154174. protected _getModelLoadingConstraints(): boolean;
  154175. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  154176. protected _setRootMesh(meshes: AbstractMesh[]): void;
  154177. protected _updateModel(): void;
  154178. }
  154179. }
  154180. declare module BABYLON {
  154181. /**
  154182. * A cursor which tracks a point on a path
  154183. */
  154184. export class PathCursor {
  154185. private path;
  154186. /**
  154187. * Stores path cursor callbacks for when an onchange event is triggered
  154188. */
  154189. private _onchange;
  154190. /**
  154191. * The value of the path cursor
  154192. */
  154193. value: number;
  154194. /**
  154195. * The animation array of the path cursor
  154196. */
  154197. animations: Animation[];
  154198. /**
  154199. * Initializes the path cursor
  154200. * @param path The path to track
  154201. */
  154202. constructor(path: Path2);
  154203. /**
  154204. * Gets the cursor point on the path
  154205. * @returns A point on the path cursor at the cursor location
  154206. */
  154207. getPoint(): Vector3;
  154208. /**
  154209. * Moves the cursor ahead by the step amount
  154210. * @param step The amount to move the cursor forward
  154211. * @returns This path cursor
  154212. */
  154213. moveAhead(step?: number): PathCursor;
  154214. /**
  154215. * Moves the cursor behind by the step amount
  154216. * @param step The amount to move the cursor back
  154217. * @returns This path cursor
  154218. */
  154219. moveBack(step?: number): PathCursor;
  154220. /**
  154221. * Moves the cursor by the step amount
  154222. * If the step amount is greater than one, an exception is thrown
  154223. * @param step The amount to move the cursor
  154224. * @returns This path cursor
  154225. */
  154226. move(step: number): PathCursor;
  154227. /**
  154228. * Ensures that the value is limited between zero and one
  154229. * @returns This path cursor
  154230. */
  154231. private ensureLimits;
  154232. /**
  154233. * Runs onchange callbacks on change (used by the animation engine)
  154234. * @returns This path cursor
  154235. */
  154236. private raiseOnChange;
  154237. /**
  154238. * Executes a function on change
  154239. * @param f A path cursor onchange callback
  154240. * @returns This path cursor
  154241. */
  154242. onchange(f: (cursor: PathCursor) => void): PathCursor;
  154243. }
  154244. }
  154245. declare module BABYLON {
  154246. /** @hidden */
  154247. export var blurPixelShader: {
  154248. name: string;
  154249. shader: string;
  154250. };
  154251. }
  154252. declare module BABYLON {
  154253. /** @hidden */
  154254. export var pointCloudVertexDeclaration: {
  154255. name: string;
  154256. shader: string;
  154257. };
  154258. }
  154259. // Mixins
  154260. interface Window {
  154261. mozIndexedDB: IDBFactory;
  154262. webkitIndexedDB: IDBFactory;
  154263. msIndexedDB: IDBFactory;
  154264. webkitURL: typeof URL;
  154265. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  154266. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  154267. WebGLRenderingContext: WebGLRenderingContext;
  154268. MSGesture: MSGesture;
  154269. CANNON: any;
  154270. AudioContext: AudioContext;
  154271. webkitAudioContext: AudioContext;
  154272. PointerEvent: any;
  154273. Math: Math;
  154274. Uint8Array: Uint8ArrayConstructor;
  154275. Float32Array: Float32ArrayConstructor;
  154276. mozURL: typeof URL;
  154277. msURL: typeof URL;
  154278. VRFrameData: any; // WebVR, from specs 1.1
  154279. DracoDecoderModule: any;
  154280. setImmediate(handler: (...args: any[]) => void): number;
  154281. }
  154282. interface HTMLCanvasElement {
  154283. requestPointerLock(): void;
  154284. msRequestPointerLock?(): void;
  154285. mozRequestPointerLock?(): void;
  154286. webkitRequestPointerLock?(): void;
  154287. /** Track wether a record is in progress */
  154288. isRecording: boolean;
  154289. /** Capture Stream method defined by some browsers */
  154290. captureStream(fps?: number): MediaStream;
  154291. }
  154292. interface CanvasRenderingContext2D {
  154293. msImageSmoothingEnabled: boolean;
  154294. }
  154295. interface MouseEvent {
  154296. mozMovementX: number;
  154297. mozMovementY: number;
  154298. webkitMovementX: number;
  154299. webkitMovementY: number;
  154300. msMovementX: number;
  154301. msMovementY: number;
  154302. }
  154303. interface Navigator {
  154304. mozGetVRDevices: (any: any) => any;
  154305. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  154306. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  154307. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  154308. webkitGetGamepads(): Gamepad[];
  154309. msGetGamepads(): Gamepad[];
  154310. webkitGamepads(): Gamepad[];
  154311. }
  154312. interface HTMLVideoElement {
  154313. mozSrcObject: any;
  154314. }
  154315. interface Math {
  154316. fround(x: number): number;
  154317. imul(a: number, b: number): number;
  154318. }
  154319. interface WebGLRenderingContext {
  154320. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  154321. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  154322. vertexAttribDivisor(index: number, divisor: number): void;
  154323. createVertexArray(): any;
  154324. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  154325. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  154326. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  154327. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  154328. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  154329. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  154330. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  154331. // Queries
  154332. createQuery(): WebGLQuery;
  154333. deleteQuery(query: WebGLQuery): void;
  154334. beginQuery(target: number, query: WebGLQuery): void;
  154335. endQuery(target: number): void;
  154336. getQueryParameter(query: WebGLQuery, pname: number): any;
  154337. getQuery(target: number, pname: number): any;
  154338. MAX_SAMPLES: number;
  154339. RGBA8: number;
  154340. READ_FRAMEBUFFER: number;
  154341. DRAW_FRAMEBUFFER: number;
  154342. UNIFORM_BUFFER: number;
  154343. HALF_FLOAT_OES: number;
  154344. RGBA16F: number;
  154345. RGBA32F: number;
  154346. R32F: number;
  154347. RG32F: number;
  154348. RGB32F: number;
  154349. R16F: number;
  154350. RG16F: number;
  154351. RGB16F: number;
  154352. RED: number;
  154353. RG: number;
  154354. R8: number;
  154355. RG8: number;
  154356. UNSIGNED_INT_24_8: number;
  154357. DEPTH24_STENCIL8: number;
  154358. MIN: number;
  154359. MAX: number;
  154360. /* Multiple Render Targets */
  154361. drawBuffers(buffers: number[]): void;
  154362. readBuffer(src: number): void;
  154363. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  154364. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  154365. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  154366. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  154367. // Occlusion Query
  154368. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  154369. ANY_SAMPLES_PASSED: number;
  154370. QUERY_RESULT_AVAILABLE: number;
  154371. QUERY_RESULT: number;
  154372. }
  154373. interface WebGLProgram {
  154374. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  154375. }
  154376. interface EXT_disjoint_timer_query {
  154377. QUERY_COUNTER_BITS_EXT: number;
  154378. TIME_ELAPSED_EXT: number;
  154379. TIMESTAMP_EXT: number;
  154380. GPU_DISJOINT_EXT: number;
  154381. QUERY_RESULT_EXT: number;
  154382. QUERY_RESULT_AVAILABLE_EXT: number;
  154383. queryCounterEXT(query: WebGLQuery, target: number): void;
  154384. createQueryEXT(): WebGLQuery;
  154385. beginQueryEXT(target: number, query: WebGLQuery): void;
  154386. endQueryEXT(target: number): void;
  154387. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  154388. deleteQueryEXT(query: WebGLQuery): void;
  154389. }
  154390. interface WebGLUniformLocation {
  154391. _currentState: any;
  154392. }
  154393. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  154394. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  154395. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  154396. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  154397. interface WebGLRenderingContext {
  154398. readonly RASTERIZER_DISCARD: number;
  154399. readonly DEPTH_COMPONENT24: number;
  154400. readonly TEXTURE_3D: number;
  154401. readonly TEXTURE_2D_ARRAY: number;
  154402. readonly TEXTURE_COMPARE_FUNC: number;
  154403. readonly TEXTURE_COMPARE_MODE: number;
  154404. readonly COMPARE_REF_TO_TEXTURE: number;
  154405. readonly TEXTURE_WRAP_R: number;
  154406. readonly HALF_FLOAT: number;
  154407. readonly RGB8: number;
  154408. readonly RED_INTEGER: number;
  154409. readonly RG_INTEGER: number;
  154410. readonly RGB_INTEGER: number;
  154411. readonly RGBA_INTEGER: number;
  154412. readonly R8_SNORM: number;
  154413. readonly RG8_SNORM: number;
  154414. readonly RGB8_SNORM: number;
  154415. readonly RGBA8_SNORM: number;
  154416. readonly R8I: number;
  154417. readonly RG8I: number;
  154418. readonly RGB8I: number;
  154419. readonly RGBA8I: number;
  154420. readonly R8UI: number;
  154421. readonly RG8UI: number;
  154422. readonly RGB8UI: number;
  154423. readonly RGBA8UI: number;
  154424. readonly R16I: number;
  154425. readonly RG16I: number;
  154426. readonly RGB16I: number;
  154427. readonly RGBA16I: number;
  154428. readonly R16UI: number;
  154429. readonly RG16UI: number;
  154430. readonly RGB16UI: number;
  154431. readonly RGBA16UI: number;
  154432. readonly R32I: number;
  154433. readonly RG32I: number;
  154434. readonly RGB32I: number;
  154435. readonly RGBA32I: number;
  154436. readonly R32UI: number;
  154437. readonly RG32UI: number;
  154438. readonly RGB32UI: number;
  154439. readonly RGBA32UI: number;
  154440. readonly RGB10_A2UI: number;
  154441. readonly R11F_G11F_B10F: number;
  154442. readonly RGB9_E5: number;
  154443. readonly RGB10_A2: number;
  154444. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  154445. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  154446. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  154447. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  154448. readonly DEPTH_COMPONENT32F: number;
  154449. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  154450. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  154451. 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;
  154452. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  154453. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  154454. readonly TRANSFORM_FEEDBACK: number;
  154455. readonly INTERLEAVED_ATTRIBS: number;
  154456. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  154457. createTransformFeedback(): WebGLTransformFeedback;
  154458. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  154459. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  154460. beginTransformFeedback(primitiveMode: number): void;
  154461. endTransformFeedback(): void;
  154462. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  154463. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  154464. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  154465. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  154466. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  154467. }
  154468. interface ImageBitmap {
  154469. readonly width: number;
  154470. readonly height: number;
  154471. close(): void;
  154472. }
  154473. interface WebGLQuery extends WebGLObject {
  154474. }
  154475. declare var WebGLQuery: {
  154476. prototype: WebGLQuery;
  154477. new(): WebGLQuery;
  154478. };
  154479. interface WebGLSampler extends WebGLObject {
  154480. }
  154481. declare var WebGLSampler: {
  154482. prototype: WebGLSampler;
  154483. new(): WebGLSampler;
  154484. };
  154485. interface WebGLSync extends WebGLObject {
  154486. }
  154487. declare var WebGLSync: {
  154488. prototype: WebGLSync;
  154489. new(): WebGLSync;
  154490. };
  154491. interface WebGLTransformFeedback extends WebGLObject {
  154492. }
  154493. declare var WebGLTransformFeedback: {
  154494. prototype: WebGLTransformFeedback;
  154495. new(): WebGLTransformFeedback;
  154496. };
  154497. interface WebGLVertexArrayObject extends WebGLObject {
  154498. }
  154499. declare var WebGLVertexArrayObject: {
  154500. prototype: WebGLVertexArrayObject;
  154501. new(): WebGLVertexArrayObject;
  154502. };
  154503. // Type definitions for WebVR API
  154504. // Project: https://w3c.github.io/webvr/
  154505. // Definitions by: six a <https://github.com/lostfictions>
  154506. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  154507. interface VRDisplay extends EventTarget {
  154508. /**
  154509. * Dictionary of capabilities describing the VRDisplay.
  154510. */
  154511. readonly capabilities: VRDisplayCapabilities;
  154512. /**
  154513. * z-depth defining the far plane of the eye view frustum
  154514. * enables mapping of values in the render target depth
  154515. * attachment to scene coordinates. Initially set to 10000.0.
  154516. */
  154517. depthFar: number;
  154518. /**
  154519. * z-depth defining the near plane of the eye view frustum
  154520. * enables mapping of values in the render target depth
  154521. * attachment to scene coordinates. Initially set to 0.01.
  154522. */
  154523. depthNear: number;
  154524. /**
  154525. * An identifier for this distinct VRDisplay. Used as an
  154526. * association point in the Gamepad API.
  154527. */
  154528. readonly displayId: number;
  154529. /**
  154530. * A display name, a user-readable name identifying it.
  154531. */
  154532. readonly displayName: string;
  154533. readonly isConnected: boolean;
  154534. readonly isPresenting: boolean;
  154535. /**
  154536. * If this VRDisplay supports room-scale experiences, the optional
  154537. * stage attribute contains details on the room-scale parameters.
  154538. */
  154539. readonly stageParameters: VRStageParameters | null;
  154540. /**
  154541. * Passing the value returned by `requestAnimationFrame` to
  154542. * `cancelAnimationFrame` will unregister the callback.
  154543. * @param handle Define the hanle of the request to cancel
  154544. */
  154545. cancelAnimationFrame(handle: number): void;
  154546. /**
  154547. * Stops presenting to the VRDisplay.
  154548. * @returns a promise to know when it stopped
  154549. */
  154550. exitPresent(): Promise<void>;
  154551. /**
  154552. * Return the current VREyeParameters for the given eye.
  154553. * @param whichEye Define the eye we want the parameter for
  154554. * @returns the eye parameters
  154555. */
  154556. getEyeParameters(whichEye: string): VREyeParameters;
  154557. /**
  154558. * Populates the passed VRFrameData with the information required to render
  154559. * the current frame.
  154560. * @param frameData Define the data structure to populate
  154561. * @returns true if ok otherwise false
  154562. */
  154563. getFrameData(frameData: VRFrameData): boolean;
  154564. /**
  154565. * Get the layers currently being presented.
  154566. * @returns the list of VR layers
  154567. */
  154568. getLayers(): VRLayer[];
  154569. /**
  154570. * Return a VRPose containing the future predicted pose of the VRDisplay
  154571. * when the current frame will be presented. The value returned will not
  154572. * change until JavaScript has returned control to the browser.
  154573. *
  154574. * The VRPose will contain the position, orientation, velocity,
  154575. * and acceleration of each of these properties.
  154576. * @returns the pose object
  154577. */
  154578. getPose(): VRPose;
  154579. /**
  154580. * Return the current instantaneous pose of the VRDisplay, with no
  154581. * prediction applied.
  154582. * @returns the current instantaneous pose
  154583. */
  154584. getImmediatePose(): VRPose;
  154585. /**
  154586. * The callback passed to `requestAnimationFrame` will be called
  154587. * any time a new frame should be rendered. When the VRDisplay is
  154588. * presenting the callback will be called at the native refresh
  154589. * rate of the HMD. When not presenting this function acts
  154590. * identically to how window.requestAnimationFrame acts. Content should
  154591. * make no assumptions of frame rate or vsync behavior as the HMD runs
  154592. * asynchronously from other displays and at differing refresh rates.
  154593. * @param callback Define the eaction to run next frame
  154594. * @returns the request handle it
  154595. */
  154596. requestAnimationFrame(callback: FrameRequestCallback): number;
  154597. /**
  154598. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  154599. * Repeat calls while already presenting will update the VRLayers being displayed.
  154600. * @param layers Define the list of layer to present
  154601. * @returns a promise to know when the request has been fulfilled
  154602. */
  154603. requestPresent(layers: VRLayer[]): Promise<void>;
  154604. /**
  154605. * Reset the pose for this display, treating its current position and
  154606. * orientation as the "origin/zero" values. VRPose.position,
  154607. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  154608. * updated when calling resetPose(). This should be called in only
  154609. * sitting-space experiences.
  154610. */
  154611. resetPose(): void;
  154612. /**
  154613. * The VRLayer provided to the VRDisplay will be captured and presented
  154614. * in the HMD. Calling this function has the same effect on the source
  154615. * canvas as any other operation that uses its source image, and canvases
  154616. * created without preserveDrawingBuffer set to true will be cleared.
  154617. * @param pose Define the pose to submit
  154618. */
  154619. submitFrame(pose?: VRPose): void;
  154620. }
  154621. declare var VRDisplay: {
  154622. prototype: VRDisplay;
  154623. new(): VRDisplay;
  154624. };
  154625. interface VRLayer {
  154626. leftBounds?: number[] | Float32Array | null;
  154627. rightBounds?: number[] | Float32Array | null;
  154628. source?: HTMLCanvasElement | null;
  154629. }
  154630. interface VRDisplayCapabilities {
  154631. readonly canPresent: boolean;
  154632. readonly hasExternalDisplay: boolean;
  154633. readonly hasOrientation: boolean;
  154634. readonly hasPosition: boolean;
  154635. readonly maxLayers: number;
  154636. }
  154637. interface VREyeParameters {
  154638. /** @deprecated */
  154639. readonly fieldOfView: VRFieldOfView;
  154640. readonly offset: Float32Array;
  154641. readonly renderHeight: number;
  154642. readonly renderWidth: number;
  154643. }
  154644. interface VRFieldOfView {
  154645. readonly downDegrees: number;
  154646. readonly leftDegrees: number;
  154647. readonly rightDegrees: number;
  154648. readonly upDegrees: number;
  154649. }
  154650. interface VRFrameData {
  154651. readonly leftProjectionMatrix: Float32Array;
  154652. readonly leftViewMatrix: Float32Array;
  154653. readonly pose: VRPose;
  154654. readonly rightProjectionMatrix: Float32Array;
  154655. readonly rightViewMatrix: Float32Array;
  154656. readonly timestamp: number;
  154657. }
  154658. interface VRPose {
  154659. readonly angularAcceleration: Float32Array | null;
  154660. readonly angularVelocity: Float32Array | null;
  154661. readonly linearAcceleration: Float32Array | null;
  154662. readonly linearVelocity: Float32Array | null;
  154663. readonly orientation: Float32Array | null;
  154664. readonly position: Float32Array | null;
  154665. readonly timestamp: number;
  154666. }
  154667. interface VRStageParameters {
  154668. sittingToStandingTransform?: Float32Array;
  154669. sizeX?: number;
  154670. sizeY?: number;
  154671. }
  154672. interface Navigator {
  154673. getVRDisplays(): Promise<VRDisplay[]>;
  154674. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  154675. }
  154676. interface Window {
  154677. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  154678. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  154679. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  154680. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  154681. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  154682. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  154683. }
  154684. interface Gamepad {
  154685. readonly displayId: number;
  154686. }
  154687. type XRSessionMode =
  154688. | "inline"
  154689. | "immersive-vr"
  154690. | "immersive-ar";
  154691. type XRReferenceSpaceType =
  154692. | "viewer"
  154693. | "local"
  154694. | "local-floor"
  154695. | "bounded-floor"
  154696. | "unbounded";
  154697. type XREnvironmentBlendMode =
  154698. | "opaque"
  154699. | "additive"
  154700. | "alpha-blend";
  154701. type XRVisibilityState =
  154702. | "visible"
  154703. | "visible-blurred"
  154704. | "hidden";
  154705. type XRHandedness =
  154706. | "none"
  154707. | "left"
  154708. | "right";
  154709. type XRTargetRayMode =
  154710. | "gaze"
  154711. | "tracked-pointer"
  154712. | "screen";
  154713. type XREye =
  154714. | "none"
  154715. | "left"
  154716. | "right";
  154717. type XREventType =
  154718. | "devicechange"
  154719. | "visibilitychange"
  154720. | "end"
  154721. | "inputsourceschange"
  154722. | "select"
  154723. | "selectstart"
  154724. | "selectend"
  154725. | "squeeze"
  154726. | "squeezestart"
  154727. | "squeezeend"
  154728. | "reset";
  154729. interface XRSpace extends EventTarget {
  154730. }
  154731. interface XRRenderState {
  154732. depthNear?: number;
  154733. depthFar?: number;
  154734. inlineVerticalFieldOfView?: number;
  154735. baseLayer?: XRWebGLLayer;
  154736. }
  154737. interface XRInputSource {
  154738. handedness: XRHandedness;
  154739. targetRayMode: XRTargetRayMode;
  154740. targetRaySpace: XRSpace;
  154741. gripSpace: XRSpace | undefined;
  154742. gamepad: Gamepad | undefined;
  154743. profiles: Array<string>;
  154744. }
  154745. interface XRSessionInit {
  154746. optionalFeatures?: string[];
  154747. requiredFeatures?: string[];
  154748. }
  154749. interface XRSession {
  154750. addEventListener: Function;
  154751. removeEventListener: Function;
  154752. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  154753. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  154754. requestAnimationFrame: Function;
  154755. end(): Promise<void>;
  154756. renderState: XRRenderState;
  154757. inputSources: Array<XRInputSource>;
  154758. // hit test
  154759. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  154760. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  154761. // legacy AR hit test
  154762. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  154763. // legacy plane detection
  154764. updateWorldTrackingState(options: {
  154765. planeDetectionState?: { enabled: boolean; }
  154766. }): void;
  154767. }
  154768. interface XRReferenceSpace extends XRSpace {
  154769. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  154770. onreset: any;
  154771. }
  154772. type XRPlaneSet = Set<XRPlane>;
  154773. type XRAnchorSet = Set<XRAnchor>;
  154774. interface XRFrame {
  154775. session: XRSession;
  154776. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  154777. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  154778. // AR
  154779. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  154780. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  154781. // Anchors
  154782. trackedAnchors?: XRAnchorSet;
  154783. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  154784. // Planes
  154785. worldInformation: {
  154786. detectedPlanes?: XRPlaneSet;
  154787. };
  154788. }
  154789. interface XRViewerPose extends XRPose {
  154790. views: Array<XRView>;
  154791. }
  154792. interface XRPose {
  154793. transform: XRRigidTransform;
  154794. emulatedPosition: boolean;
  154795. }
  154796. interface XRWebGLLayerOptions {
  154797. antialias?: boolean;
  154798. depth?: boolean;
  154799. stencil?: boolean;
  154800. alpha?: boolean;
  154801. multiview?: boolean;
  154802. framebufferScaleFactor?: number;
  154803. }
  154804. declare var XRWebGLLayer: {
  154805. prototype: XRWebGLLayer;
  154806. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  154807. };
  154808. interface XRWebGLLayer {
  154809. framebuffer: WebGLFramebuffer;
  154810. framebufferWidth: number;
  154811. framebufferHeight: number;
  154812. getViewport: Function;
  154813. }
  154814. declare class XRRigidTransform {
  154815. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  154816. position: DOMPointReadOnly;
  154817. orientation: DOMPointReadOnly;
  154818. matrix: Float32Array;
  154819. inverse: XRRigidTransform;
  154820. }
  154821. interface XRView {
  154822. eye: XREye;
  154823. projectionMatrix: Float32Array;
  154824. transform: XRRigidTransform;
  154825. }
  154826. interface XRInputSourceChangeEvent {
  154827. session: XRSession;
  154828. removed: Array<XRInputSource>;
  154829. added: Array<XRInputSource>;
  154830. }
  154831. interface XRInputSourceEvent extends Event {
  154832. readonly frame: XRFrame;
  154833. readonly inputSource: XRInputSource;
  154834. }
  154835. // Experimental(er) features
  154836. declare class XRRay {
  154837. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  154838. origin: DOMPointReadOnly;
  154839. direction: DOMPointReadOnly;
  154840. matrix: Float32Array;
  154841. }
  154842. declare enum XRHitTestTrackableType {
  154843. "point",
  154844. "plane",
  154845. "mesh"
  154846. }
  154847. interface XRHitResult {
  154848. hitMatrix: Float32Array;
  154849. }
  154850. interface XRTransientInputHitTestResult {
  154851. readonly inputSource: XRInputSource;
  154852. readonly results: Array<XRHitTestResult>;
  154853. }
  154854. interface XRHitTestResult {
  154855. getPose(baseSpace: XRSpace): XRPose | undefined;
  154856. // When anchor system is enabled
  154857. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  154858. }
  154859. interface XRHitTestSource {
  154860. cancel(): void;
  154861. }
  154862. interface XRTransientInputHitTestSource {
  154863. cancel(): void;
  154864. }
  154865. interface XRHitTestOptionsInit {
  154866. space: XRSpace;
  154867. entityTypes?: Array<XRHitTestTrackableType>;
  154868. offsetRay?: XRRay;
  154869. }
  154870. interface XRTransientInputHitTestOptionsInit {
  154871. profile: string;
  154872. entityTypes?: Array<XRHitTestTrackableType>;
  154873. offsetRay?: XRRay;
  154874. }
  154875. interface XRAnchor {
  154876. anchorSpace: XRSpace;
  154877. delete(): void;
  154878. }
  154879. interface XRPlane {
  154880. orientation: "Horizontal" | "Vertical";
  154881. planeSpace: XRSpace;
  154882. polygon: Array<DOMPointReadOnly>;
  154883. lastChangedTime: number;
  154884. }